I like the music in Discworld II, and I have been trying to figure out how to open the mus files. I downloaded awave, even tried opening them with audacity, and goldwave, but all I get is garbage, and tried all raw formats I can think of. Is there something I am missing?
I would really like to convert the mus files so that I can just listen to them as mp3s or ogg files. Can it actually be done? If so how?
Discworld II Mus files
Moderator: ScummVM Team
The audio in Discworld 2 uses a customized ADPCM encoding. Voices and SFX are encoded using 6-bit ADPCM and music is encoded using 8-bit ADPCM (both @ 22050Hz). The music files themselves got an index at their beginning, with information on the beginning offset of each track, as well as the track length.
Perhaps you could find some program that can handle such audio, or you could modify ScummVM's source to dump music as it plays it.
Perhaps you could find some program that can handle such audio, or you could modify ScummVM's source to dump music as it plays it.
The topic have been already discussed here.
Here's simple code that I used, to do the task (based on valuable info from DrMcCoy - thanks!):
Here's simple code that I used, to do the task (based on valuable info from DrMcCoy - thanks!):
Code: Select all
#include <iostream>
#include <fstream>
using namespace std;
static const double TinselFilterTable[4][2] = {
{0, 0 },
{0.9375, 0},
{1.796875, -0.8125},
{1.53125, -0.859375}
};
void decode(char* buffer, fstream& output)
{
const double eVal = 1.007843258;
static double d0 = 0, d1 = 0;
double k0, k1, predictor, sample;
unsigned char start = buffer[0], filterVal = (start & 0xC0) >> 6;
int i, code;
short result;
if ((start & 0x20) != 0)
{ //Lower 6 bit are negative - Negate
start = ~(start | 0xC0) + 1;
predictor = 1 << start;
}
else
{ // Lower 6 bit are positive - Truncate
start &= 0x1F;
predictor = ((double) 1.0) / (1 << start);
}
k0 = TinselFilterTable[filterVal][0];
k1 = TinselFilterTable[filterVal][1];
for (i=1;i<=32;i++)
{
code = buffer[i] << 8;
sample = (double) code;
sample *= eVal * predictor;
sample += (d0 * k0) + (d1 * k1);
d1 = d0;
d0 = sample;
if (sample < -32768.0) sample = 32768.0;
if (sample > 32767.0) sample = 32767.0;
result = sample;
output.put(result & 0xFF);
output.put((result >> 8) & 0xFF);
}
}
int main (int argc, char *argv[])
{
char buffer[33];
long samples, i;
if (argc != 3)
{
cout << "Usage: D2_decode IN_FILENAME OUT_FILENAME" << endl;
return 1;
}
fstream infile (argv[1], ios::in | ios::binary | ios::ate);
fstream outfile (argv[2], ios::out | ios::binary);
if (!infile.is_open())
{
cout << "I can't open input file" << endl;
return 1;
}
if (!outfile.is_open())
{
cout << "I can't create output file" << endl;
return 1;
}
samples = infile.tellg() / 33;
infile.seekg (0, ios::beg);
for (i=0;i < samples;i++)
{
infile.read (buffer, 33);
decode(buffer, outfile);
}
infile.close();
outfile.close();
return 0;
}
Thanks for the reply, I have looked at the info provided, but as far as the source is concerned, I really have no clue. I have no programming aptitude and I wouldn't understand what I'm looking at, even though the code is right in front of my face.
So I tried the info provided with goldwave, and got 'some' kind of 'wave' with barely any audible results, but with still mostly noise. I guess I'm just stuck. Sorry for my lack of knowledge
So I tried the info provided with goldwave, and got 'some' kind of 'wave' with barely any audible results, but with still mostly noise. I guess I'm just stuck. Sorry for my lack of knowledge
I you use Windows, then here is compiled program, according with a batch file that will convert all the files. Just unpack these two files into a folder, where *.MUS files are, and run convert.bat. As a result you will get a bunch of *.RAW files, that can be handled by Goldwave for example, and saved in more handy format like ogg.Jeebizz wrote:Thanks for the reply, I have looked at the info provided, but as far as the source is concerned, I really have no clue. I have no programming aptitude and I wouldn't understand what I'm looking at, even though the code is right in front of my face.
So I tried the info provided with goldwave, and got 'some' kind of 'wave' with barely any audible results, but with still mostly noise. I guess I'm just stuck. Sorry for my lack of knowledge
EDIT:
To properly open files in sound editor you will need this info: the files are saved as raw PCM, 22050 kHz, mono with 16-bit big endian samples.
I tried that, and many other combos of pcm with no endian, little, and big endian, and still nothing. However I will try out this program that was mentioned, I hope it works, and thanks again for the patient replies.Originally posted by Seldon
To properly open files in sound editor you will need this info: the files are saved as raw PCM, 22050 kHz, mono with 16-bit big endian samples.
Don't want to really start another thread just to supply this info but:
Out of curiosity I tried opening the english.smp files from both discworld I and II. I couldn't get the .smp files from discworld II to open, and the decode to raw program didn't help any.
However, with Discworld I's english.smp, I was able to open it with goldwave as raw as PCM 8-bit mono (no endian), at 22050khz, and it works. I can at least listen to the file all at once. Too bad can't do the same with the files in Discworld II.
Out of curiosity I tried opening the english.smp files from both discworld I and II. I couldn't get the .smp files from discworld II to open, and the decode to raw program didn't help any.
However, with Discworld I's english.smp, I was able to open it with goldwave as raw as PCM 8-bit mono (no endian), at 22050khz, and it works. I can at least listen to the file all at once. Too bad can't do the same with the files in Discworld II.