Hi everyone 8)
Ok, so I’ve set myself the task of writing an [offline] waveform display tool. It’s actually part of a bigger tool but that’s inconsequential. After trawling this forum and the FMOD docs, I’m faced with a few questions.
The two preferred methods appear to be…
I’m moving more toward the latter, as I understand getWaveData won’t provide me with wave data for the entire file.
Right, so, I’ve loaded the file in…
[code:caovm657]fsystem->createSound(filename, FMOD_SOFTWARE, 0, &fsound);[/code:caovm657]
…and looking at some examples on here, I’ve got…
// Here we go...
fsound->lock(0, wLength*2, (void)&wsPtr1, (void)&wsPtr2, &wPtrLen1, &wPtrLen2);
My PCM16 .wav file is returning [i:caovm657]wLength[/i:caovm657] as [b:caovm657]38098948[/b:caovm657] after the ‘getLength()’ function. Rather oddly, [b:caovm657]both[/b:caovm657] [i:caovm657]wsPtr1[/i:caovm657] and [i:caovm657]wsPtr2[/i:caovm657] (after being locked) are pointing to the same memory address, and [i:caovm657]wPtrLen1[/i:caovm657] and [i:caovm657]wPtrLen2[/i:caovm657] are [b:caovm657]both also 38098948[/b:caovm657], the same size as [i:caovm657]wLength[/i:caovm657].
So firstly, I figure I must be doing something wrong… :s
I’m not sure I’m getting the length with the right time unit, and I’m only multiplying it by 2 because that’s what the example code did.
Could some one point me in the right direction?
- acron^ asked 9 years ago
pcmbytes is the number of BYTES (taking into consideration channels and bitdepth). Multiplying it by 2 is pointless.
You would multiply it if you use justed FMOD_TIMEUNIT_PCM.
What is has given you is the whole of the sample in ptr1 and len1, then because you asked for twice as much, it wrapped around, and gave it to you again.
OK, so now I’ve got an array of 38,098,948 PCM bytes. That makes sense, as my .wav is 38,099,178 bytes. A discrepancy for header information, I’m assuming.
So now how can I extract peak data from this?
Do I deconstruct each byte as per the diagram in the documentation? (‘TERMINOLOGY / BASIC CONCEPTS.’)
Forgive my newbieness, but I’ve never approached audio file formats before 😳
Hopefully a final query…
Iterating through the wsPtr1 as an array breaks on iteration ‘19050464’. This is exactly half the size of the .wav, plus 990…
Any reason for this?
EDIT: I’m guessing that as it’s 16bit, each element represents two bytes, but why the 990?
Please login first to submit.