Hi there, I’m trying to create some sounds to use in my game, have downloaded some sample wav files which this program by frostgiant accepts and outputs, but I don’t understand how to interpret the results:
static const unsigned char sample_dead[] =
{
0x19, 0x18, 0x1D, 0x18, 0x12, 0x0F, 0x00, 0x00, 0x20, 0x32, 0x32,
0x32, 0x32, 0x32, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x32, 0x32,
0x32, 0x32, 0x32, 0x32, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x20, 0x32,
0x32, 0x32, 0x32, 0x32, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x32,
0x32, 0x32, 0x32, 0x32, 0x32, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E,
0x32, 0x32, 0x32, 0x32, 0x32, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E,
0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E,
.
.
.
};
I’ve tried to reproduce each array’s entry as a note, but that doesn’t work (I suppose that each entry by it’s own does not fall into the human audible range) so does someone knows how to interpret the array element’s?
Regards
Jorgeche
Jorgeche: I already emailed this to you, but I figured I’d copy it here too in case anyone else is interested or comes to look for info in the future, or has any other info to add to the conversation.
—–
I’m not totally sure that the vbwav program actually works. I don’t think I was ever able to sucessfully get it working, and if I understand it correctly I don’t really think it would work. I’ll try to explain it the way I think it works.
As you see the data is PCM, which is just a bunch of samples of the waveform, sampled at around 44KHz. The original wav file is played by outputting each sample at a constant speed (44KHz). When those samples are output to the speaker you get a waveform that actually sounds like something. The VB works by using waveform RAM, which is 32 samples, but then the frequency registers adjust the frequency that those samples are played at.
AFAIK there’s no good way to play PCM on the VB… the only real way to do it would be to use the waveform RAM to hold 32 samples at a time and play that back, refreshing the waveform RAM after every set is played. But that would sound really choppy, so you’d probably have to buffer ahead to other waveform RAM banks, and then switch and fill up the previously used one. I still don’t think that’d sound smooth.
Basically PCM isn’t meant for the VB and you should really set the waveform RAM as an “instrument” (whether it’s sine, square, sawtooth, etc). Then control the frequency, envelope, etc registers to make the music/sound. VB sounds are more similar to midi than wav… midi uses instruments and frequencies instead of just streaming samples.
If you have a wav file that you want played on the VB, the best way would be to look at the typical waveform (what one cycle looks like), set the waveform RAM to that type, then break the wav into individual notes and figure out the frequency. You could use an FFT to get the frequency components and piece together the song in frequencies (which is what the VB wants), but that’d be pretty time consuming unless you made an app to do it for you. I believe something like a wav to midi converter would do that for you though.
I’m sure there’s a bunch out there, but the first free one I came across was AmazingMIDI: http://www.pluto.dti.ne.jp/~araki/amazingmidi/ … so you may want to try that out. Of course it’s not gonna work well for speech, but for music it should split it up into notes for you. You just gotta remember you’ve only got 6 channels that can play at a time (and really only 5 normal ones), so you may need to merge notes similar in frequency together into a single note for the VB.
DogP