Hey
This might be a newbie question, but here it goes anyway.
I want to record into an array, but I want to have a bang end the recording into the array. For the most part, you have to set the length of the sample that you are about to record. How can I make this sample length variable according to when I bang it to end?
-
Recording audio in Tables
-
As far as i know you can not. However there's a trick: before recording starts you should resize the table to the max number of samples you're about to record (with some extra margin just in case). Then time the recording timespan with a [timer] object (one bang for the start, one for the end). With this time you can calculate the samplelength and resize the table again.
Keep in mind that - when you read the table with a [tabread4~] - you don't need to resize anything, because you can build/send messages to that object to do playback.
If you just want to do simple looped playback of a recording you can also use a delayline to write into ([delwrite~] creates a delayline). Then with a [vd~] you can loop the length you want. But this is less flexible in terms of manipulation once recorded (no slicing, stuttering, chopping things up).
Hope this helps,
D.
|] [] |.| ][|-| -- http://soundcloud.com/domxh
-
I tried getting this to work by dynamically resizing the table while recording, but this causes clicks in the audio. I think Domien's idea is the best. You could even use resize messages to shrink the table at the end of recording in order to save memory.
Anyhow, I've attached the patch. Even though it doesn't work well some parts of the might be useful. I've used this method before for resizing tables that I'm storing non-audio data in, and it works just fine for that.
Best of luck!