jack0088 wrote: ↑
Sat Nov 11, 2017 7:17 pm
@zorg I'm not sure I understand your response completely - so let's have an example:
My app has a button "record voice"
The user tap on it and can now speak for unlimited time
When the user taps button "stop recording" the app should play the whole recoded snippet.
Issue: when start recording I have to give it a buffer size (first parameter "samples") but I do no know at this moment how long the user will be recording for.
> From what you're saying it looks like I should monitor the recorder:getSampleCount() and when its filled create another one. Is that correct?
> Lets say the user spoke for 1 minute and stopped. Based on this I would breal the recording into 4 independent buffers (each 15 seconds @44kHz = 661500 samples). Now I could use the QSource to play back all of them, right? Is the QSource something like a playlist? I thought it would be a buffer of flexible length which you can rewind, play, stop, or seek..
Yeah, i didn't understand you completely myself, that's why i came up with answers to two different things; your follow-up cleared things up though!
So, technically, you will sooner or later find yourself hitting memory limitations, but for the time being, let's not care about that.
You only need to give a size parameter to SoundDatas (and recording devices), QSources don't require such a parameter.
Indeed, you should monitor if the recorded sample count is greater or equal to one (SoundData) buffer's length, which you defined; if it is, then you need to put the SoundData object you got with recorder:getData into a table; i am assuming that that creates new SoundData objects with time, so there shouldn't be an issue with all returned SD object being the same, and having your data overwritten.
QSources are indeed like playlists, except they behave like a queue; you push data onto them, and the data you pushed last will be played last, so it plays enqueued data sequentially.
You don't need to create buffers that long though, 15 seconds is a ton; 1 second buffers should suffice, i'd say.