Actually I spent quite some time trying to get the wave memblocks a week or so ago, trying to make a synthesizer-like application.
It didn't go very well, but I learned some usefull things anyways (oh yeah, and I managed to make a really nice knob control!
)
The wave header is 28 bytes, divided into 7 longwords:
♦ format
♦ channels (1 = mono, 2 = stereo)
♦ samples per second (per channel, that is)
♦ bytes per second (with the PCM format, which is the only one I know, this is simply samples per second * channels * 2, since each sample consists of 2 bytes)
♦ block align (I never quite got this one; always seems to be 2)
♦ bits per sample (I suppose this differs between various formats. DBPro seems only to be able to read 16 bit samples though. Also, should this change, each sample would of course not be 2 bytes, but
bits per sample / 8 bytes in size).
♦ offsetSize (this seems to be how many bytes after the final header byte (28) the actual wave data starts. For homebrewed PCM waves, this is 0).
Anyways, we have a set amount of samples per second,
a.
We also have the channels,
b, which means that the true amount of samples per second is
ab.
As well, we have the size of each sample,
c (which is
bits per second / 8).
We can find the size of the memblock using
get memblock size(). From this value, we subtract 28 (the header) as well as the size of the possible offset to the audio data. The result, we call
d
Now, to find out the duration, we simply enough carry out the following division:
duration = d / (abc)
You'd think it should be easy to get a visual repressentation out of this then, but alas, it seems not to be.
I might look into that further today.
A nice knob, made using sprites
"I kören hörs de brummande busarna Björnligan och Gondolen"