0
0

Is there anything I can do to get an audio level while recording on the iPhone? I’d like to make a visualization of the users voice while they are recording but I can’t find anything in the documentation. I have done it using apples core audio services and its fairly simple but I can’t seem to get the data I need from FMOD.

Thanks a lot, any help appreciated!

  • You must to post comments
0
0

You can access the data inside the FMOD::Sound object that you are recording into via Sound::lock and Sound::unlock.
You can then scan the data to calculate levels.

  • You must to post comments
0
0

In my timerUpdate method I am locking the sound:

[code:2pok547l]
result = sound->lock(lastRecordPos * bytesPerSample, blockLength * bytesPerSample, &ptr1, &ptr2, &len1, &len2);
[/code:2pok547l]

I am just under what data I would be scanning? I tried looking at len1, len2, and everything given above. I also tried

[code:2pok547l]sound->getVariations(&frequency, &volume, &pan);[/code:2pok547l]
and
[code:2pok547l]sound->readData(buffer, lenbytes, &read);[/code:2pok547l]

And a few other methods under sound, but none of the numbers I am getting back reflect my audio input in the mic. Ive checked these forums and look at others post about a similar problem but I have yet to find a solution.

I have also looked into the pitch detection example. That example is recording then playing, then getting the spectrum data, is that what I should be doing? I have attempted that as well but am getting nowhere.

Thanks!

  • You must to post comments
0
0

ptr1 and ptr2 contain the sound data. You can loop over the sound data and determine the peak/RMS.

  • You must to post comments
0
0

[quote="peter":t1fem02t]ptr1 and ptr2 contain the sound data. You can loop over the sound data and determine the peak/RMS.[/quote:t1fem02t]

I see; but what is the type of sound data will I be getting from ptr1 & ptr2? I guess this part is confusing me a little. I have read from other topics here what exactly ptr1 & ptr2 are, but I couldn’t find anything on what type of data I will be getting (i.e. unsigned int? float?) are there some methods I should be applying to the pointers to get that data while looping?

Thanks so much, I’m no audio expert but I am understanding more and more using FMOD.

  • You must to post comments
0
0

If I remember correctly, it depends on the bits per sample.
so if it is 16bit, ptr1 & ptr2 are shorts, if 8 bit you should cast it to a char, etc…
you can get the bits by using getFormat()
also note that it might be interleaved if it isn’t a mono file 😉

  • You must to post comments
0
0

Yes, mind breaker is correct. Don’t worry about interleaving since the source is a microphone it should be a mono.

  • You must to post comments
0
0

[quote="mindbreaker":j4o0kqcq]If I remember correctly, it depends on the bits per sample.
so if it is 16bit, ptr1 & ptr2 are shorts, if 8 bit you should cast it to a char, etc…
you can get the bits by using getFormat()
also note that it might be interleaved if it isn’t a mono file ;)[/quote:j4o0kqcq]

Ok I actually have to cast them as longs, I get a 2 different numbers from ptr1 & ptr2 but they are constant throughout the timer while recording. I tried doing some things with the ptrs and lengths, but I couldn’t get a number that changed while I spoke. I can only seem to get constant numbers.

  • You must to post comments
0
0

Does anyone else have any suggestions? I have tried outputting every number I could get out of the ptrs and I still cannot get what I need. Any help greatly appreciated!

  • You must to post comments
0
0

When you start recording you setup an FMOD::Sound object via FMOD_CREATESOUNDEXINFO, you define the format of the data, i.e. PCM16 == short, channels = 1, length = x
So when you call Sound::lock you will get two pointers into that buffer, this is because when you record into a buffer the data is written in a ring, so if the locked region wraps you will get two ptr values and two lengths. All you should have to do is cast ptr1 and ptr2 to (short *) and divide len1 and len2 by sizeof(short), then iterate over the array.

  • You must to post comments
0
0

[quote="mathew":2u9elaxj]When you start recording you setup an FMOD::Sound object via FMOD_CREATESOUNDEXINFO, you define the format of the data, i.e. PCM16 == short, channels = 1, length = x
So when you call Sound::lock you will get two pointers into that buffer, this is because when you record into a buffer the data is written in a ring, so if the locked region wraps you will get two ptr values and two lengths. All you should have to do is cast ptr1 and ptr2 to (short *) and divide len1 and len2 by sizeof(short), then iterate over the array.[/quote:2u9elaxj]

I was able to get what I needed from the ptrs, it seems so easy now! :roll:

Thanks once again for the help!

  • You must to post comments
Showing 10 results
Your Answer

Please first to submit.