I’m working on an application in which I receive asynchronous commands to process and record sounds from various channels (I have multiple soundcards connected).
A typical usage example would then be as follows:
– start recording from channel 3, record the next five seconds (a)
– start recording from channel 1
…some time passes…
– start recording from channel 2
– stop recording on channel 1 (b)
– stop recording from channel 2
…and so on.
I am not sure after reading the help file on the FMOD threading model whether this can be done with FMOD. The only way I see to implement this would be to create a thread for each recording command and either let it finish itself after the period given in the command (like in (a) above), or set an event that signals to a thread to finish (like in (b) above). But this doesn’t seem to be possible in FMOD since all FMOD commands have to be in the same thread, or so I understand.
Is my understanding of this problem good? Any comments/suggestions are appreciated!
Thank you in advance,
- acgrama asked 7 years ago
Starting and stopping recording with FMOD are not blocking operations. You could start recording on different sound cards and stop when you need to. Just as long as you handle all FMOD calls from the same thread. If you have async calls coming from multiple threads you should probably put them into a queue that services FMOD calls on one thread.
Depending on what you want to do with the recorded data, you may need to copy the data from the looping record sound regularly to another location, disk perhaps?
Thank you, Mathew! This is the kind of information I was missing.
You are right — I want to copy the contents of the buffer to a dedicated location in order to do various processing on it.
Since we are on this topic: how do I know when the current sound buffer is "full", in order to copy its contents? From some of the FMOD examples I understand a comparison between the current and the previous result of System->getRecordPosition() can be done and, thus, determine if the buffer if full. But is this the only way to do it?
- acgrama answered 7 years ago
If you only require a few seconds of recording, i.e. a fixed amount of time, you can simply create the FMOD::Sound large enough for that recording. When the buffer is full the recording will stop.
If you want to record a lot of sound, or do not know how much sound you will need when you start recording, you set the FMOD::Sound as looping. This means when the recording buffer is full it starts overwriting from the start. As you say, you will need to monitor the record position (System::getRecordPosition) to do this, when "enough" data is in the buffer (you decide how much that is) you copy it out and remember where you are up to.
If you are using a looping buffer you probably don’t want to ever let the buffer get full as it will overwrite existing data, you want to copy the data out ahead of time.
Please login first to submit.