QAudiorecorder limit recording file size
-
I'm recording audio in pcm encoding from input and output device (It doesn't matter input or output) and no problem saving in file.
The important thing is that i want to record only last minute or hour or ...
I searched it and according to the recommendations i came to the conclusion that the best way is limit the Buffer or file that data is writing into that.
but i don't know how do thatQAudioRecorder doesn't have any option to limit file or ...
i searched in all multimedia plugins files and classes to find a solution or best place to edit and add a function that i need.How do i do this?
-
since it's essentially raw data, I'd save it in fixed sized chunks to a ring buffer. That way older chunks age out of the ring as newer chunks are written:
It requires some real programming
high level pseudo-code:
ring_buffer ring; sample_reader reader; sample_buffer samples; while(!reader.done()) { samples=reader.read_samples(); if (ring.isFull() { ring.pop_oldest(); } ring.push(samples); } sample_buffer& last_minute=ring.concat(n); // where n represents the number of buffers in the ring // that represent the last minute of data
Actually, in hidsight, this could be simplified by using two buffers of size (n) and flipping back and forth between them as each one becomes full. You don't need a deque or ring. Just two work buffers and some flipping logic.
-
thanks
If during running app crashed all recorded buffers will be lost?
When should i save ringbuffer to file?
What i do to reduce file savings?
(i save it every 1 second now)