In my app I have a countdown timer to let the user know when to start talking.
Right now it counts down from 3. (3….2….1….START)
When recording starts, i’d also like to play a BEEP to let the user know. The thing is, when I call my record method, it doesn’t actually start recording right away.
When my timer hits 0, I call my record method, but it hangs for about 2 seconds before any recording starts.
Also, if I have a BEEP play when recording begins, it always catches the beep in the recording, which is what I don’t want. Would there be a way to prevent that?
If you need to see any code just let me know.
- RyanG asked 7 years ago
The delay you are seeing is the OS switching the audio session to "record and play". To avoid this delay you need to start FMOD with that audio session. You can do this via System::init extradriverdata using the FMOD_IPHONE_EXTRADRIVERDATA struct in fmodiphone.h
[quote="mathew":29z4ocxl]The delay you are seeing is the OS switching the audio session to "record and play". To avoid this delay you need to start FMOD with that audio session. You can do this via System::init extradriverdata using the FMOD_IPHONE_EXTRADRIVERDATA struct in fmodiphone.h[/quote:29z4ocxl]
Thanks! I implemented what you said:
[code:29z4ocxl] FMOD_IPHONE_EXTRADRIVERDATA edd;
edd.sessionCategory = FMOD_IPHONE_SESSIONCATEGORY_PLAYANDRECORD;
result = system->init(2, FMOD_INIT_NORMAL | FMOD_INIT_ENABLE_PROFILE, &edd); ERRCHECK(result);[/code:29z4ocxl]
It seems to help the delay a little but the very first time the app is launched and you hit record, there is still more than a second delay only the first time. After the first the timing is perfect. We are initializing FMOD before you begin recording so it’s not doing that then, any other suggestions?
Also I’m sure this is just a matter of changing a number but how would I increase the quality of my recordings?
[quote="mathew":1yfj8qc7]You can control the sample rate of the recording when you create the sound it records into, this will be the main factor controlling quality.[/quote:1yfj8qc7]
I figured it was just something I had to increase, but I have tried everything I could find and I can’t seem to increase the quality, heres my code:
[code:1yfj8qc7] memset(&exinfo, 0, sizeof(FMOD_CREATESOUNDEXINFO));
exinfo.cbsize = sizeof(FMOD_CREATESOUNDEXINFO); exinfo.numchannels = 2; exinfo.format = FMOD_SOUND_FORMAT_PCM16; exinfo.defaultfrequency = 8000; exinfo.length = exinfo.defaultfrequency * sizeof(short) * exinfo.numchannels * RECORD_LENGTH_SECS; bytesPerSample = sizeof(short) * exinfo.numchannels; bytesPerSecond = exinfo.defaultfrequency * bytesPerSample; //bytesPerSecond *= 2; result = system->createSound(NULL, FMOD_2D | FMOD_SOFTWARE | FMOD_OPENUSER, &exinfo, &sound); ERRCHECK(result);[/code:1yfj8qc7]
I tried messing with bytesPerSample & bytesPerSecond but I did not hear an increase in sound quality. I also looked at all of the properties I could set for exinfo, and I saw nothing like sample rate. What would I be changing in the above code?
So I am still not getting the desired behavior when playing a beep RIGHT when the recording stops. I have 2 different situations when trying to resolve this:
I get the beep to play perfectly when recording starts, BUT when I playback my recording the beep is in the recording, which is not desired.
If I sleep the thread to prevent the beep from catching in the recording, there is a delay from when the beep plays and recording actually starts.
I have tried a few things to try to start the recording after the beep has finished, but no matter what I am doing it is still getting caught in the recording.
Would my best bet be to stick with #1 and somehow delete the first like 0.5 seconds of the recording? If so is that possible? How would that be done?
Thanks for any help!
You have full access to the data inside the FMOD::Sound, if you wanted to silence out some of it just use Sound::lock and memset some of the buffer to 0. Just keep an eye on the record position so you aren’t touching part of the buffer that is being recorded to.
Please login first to submit.