I am a rookie when it comes to using the FMOD soundsystem, but I am in the process of studying it for a decision if we can use it for our software.
I’ve seen the record example that records a sample of 5 seconds using FSOUND_Record_StartSample.
That’s not that difficult to understand, but what if i want to record a sound of an undetermined length? In other words, when I push a button, the recording starts, when I push the button again, the recording stops.
How can I implement this, or is there a useful example somewhere?
Thanks in advance!
- Ronnie asked 14 years ago
Thanx for your help. Maybe I can help you out too if I know how
What I want (to begin with) is to save the recorder sample as a wav file (or whatever other format). Saving to wav isn’t the problem, but how to save a ‘dynamically growing’ sample structure.
I understand the record sample that saves 5 seconds of recorded sound to file, but what if I want to save 6 seconds or 1 minute or an hour and a half?
I understand what you are saying. And I want to do almost the same thing. Instead of saving the stream to file, I want to encode it and send it over the internet.
Look at my code (http://18.104.22.168/forum/viewtopic.php?t=2834.) to see what I’m trying out right now. I don’t know if it is a good way to handle the recorded data but I’m just giving it a shot.
So I’m recording in a loop. Then I made a streamcallback and I pass it the recorded sample. So in your case, I suppose you could write the samples to file in the streamcallback. In [url=http://www.fmod.org/forum/viewtopic.php?t=2635:2myglfpv]this[/url:2myglfpv] thread, davide posted a link to some code that does some encoding. direct link = http://web.rossoalice.it/davidemania/QtFMOD_test.zip
But as I said before, I don’t know if this is the right way to do the job. I hope Brett or somebody else can help us out with this 😉
Thanks for your reply. I understand a little bit better what way to go, but not yet completely :). If I know where the record cursor is, how do I know what the size is of the chunk of data that has to be copied?
I presume that the first chunk can be copied by calling FSOUND_Record_GetPosition for the end and FSOUND_Sample_Lock for the start of the chunk of data. But how to read the following chucks when the cursor has wrapped?
To cut a long story short, is there somewhere an example of how to do this kind of thing?
[quote:24arpa42]If I know where the record cursor is, how do I know what the size is of the chunk of data that has to be copied?
You can just keep the previous position of the record cursor in an other variable and this way you know which data has been added since the last time.
About my previous answer(s): I’m sorry if I caused confusion but it seems you don’t need (or better not use) a custom stream to process the captured data 😳
I’m a rookie too 😉
I am playing around with FMOD for two days now and I’m trying to do exactly the same thing as you.
To record for an undetermined time, I guess you can set the recording on loop:
Or at least, that’s what I tried and it seems to work. The only thing you need to take care of, is that the reading can’t pass the recording when you are playing the sample while you are recording. This is explained well in the same recording example and the documentation:
cited from the docs:
The recording/playback rates are slightly innacurate and are not identical (ie 44100.0 for playback, 44100.1 for recording), so one could possibly be faster or slower than the other. In this case the recording and the playback cursor could overlap, and the output will sound corrupted.
To counter this you might adjust the playback frequency of the channel you are playing the record sample on while it plays, using FSOUND_GetCurrentPosition and FSOUND_Record_GetPosition as calibration points.
In the recording sample there is an example of trying to play back sound as it records, and the mechanism to try and keep the 2 cursors a safe distance from each other is employed.
So this part isn’t too difficult I guess.
But with manipulating the captured data, I can’t really help. I’m trying to figure that out myself right now.
I suggest you take a look at the thread where I posted my question: http://22.214.171.124/forum/viewtopic.php?t=2834. Maybe it can help you too.
Please login first to submit.