0
0

hi

I would like to draw the waveform of the left and right channel.
My problem is I don’t understand the description of Sound::lock
[code:1cf3fjy3]FMOD_RESULT Sound::lock(
unsigned int offset,
unsigned int length,
void ** ptr1,
void ** ptr2,
unsigned int * len1,
unsigned int * len2
);[/code:1cf3fjy3]

The description for the parameters ptr1 and ptr2 says "first" and "second part of the locked data".
Why is there a second pointer and what does first/second part mean?
Would not ptr1 and len1 be enough to signal … "fmod locked [len1] bytes at [ptr1]."?
Can the sound be played while its locked?

If its raw pcm-data I image it like this:

[code:1cf3fjy3]
ptr1
V
samples 0 |1 |2 |3
bytes 0 |4 |8 |12
L/R|L/R|L/R|L/R
[/code:1cf3fjy3]

Or does it work like this?
[code:1cf3fjy3]
left channel:
ptr1
V
samples 0|1|2|3
bytes 0|2|4|6
L|L|L|L

right channel:
ptr2
V
samples 0|1|2|3
bytes 0|2|4|6
R|R|R|R
[/code:1cf3fjy3]

-deadcode, germany

  • You must to post comments
0
0

Hi,
Your first example is the correct one. Remember FMOD’s data is not just stereo, it could be 5.1, so a pointer for left and pointer for right wouldnt really make sense there.

The second pointer is for if your offset+length goes past the end of the sound. In this case the 2nd pointer will be valid for ‘wraparound’.
if your offset = 0 and length = length of sample, ptr2 will always be null and you can ignore it.

If the length of the sound was 1024, and you specified offset = 768 and len = 512, then ptr1 would be at 768 with len1 being 256.
Next ptr2 would be at offset 0 and len2 would be 256 as well.

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.