How to use Eric Lyon's "kbuffer" object - or record buffers at low samplerates?

Erin's icon

Hello -

I'm trying to record up to 8 streams of sensor data into audio buffers. I'm using various sensors attached to an Arduino, reading data over Serial. Reading and displaying the data in realtime is no problem, but recording and playing the data back is.

It doesn't need to be sample accurate (as a delay that is smaller than a ms is nothing I will lose sleep over) but I am having problems just playing the sensordata back at something that looks like the same speed that I recorded it at.

I noticed that Eric Lyon developed something called kbuffer~ to solve this problem, but for the life of me I can't figure out the help file.

Does anyone either have experience with how kbuffer~ works, or alternatively, can give me tips on how to record incoming data (being changed into floats between 0.0 and 1.0) as audio into buffers?

Ideally the buffer needs to be able to handle 30mins of recording, but I can deal with 20.

Also I'm not sure if my playback speed might be affected because playing 8 channels of audio might be "expensive" on my system, but I'm on a newer Mac with 8GB of RAM so I slightly doubt that's the issue.

In short: how to record data at a really low samplerate and play it back at the correct samplerate...something as low as 250 would be great.

Peter McCulloch's icon

I'd recommend checking out seq~ for recording and playing back control rate information in an accurate fashion. I haven't tried it on as long of a time scale, but it should be able to do it.

Do you need it to play while recording? If not, you could also just use sfrecord~ 8 to write an 8 channel sound file. (And use sfplay~ 8 to read it back in)

There is a way to do down sampling within poly~ (e.g. "down 8" will downsample by a factor of 8), but I'd avoid doing it if you don't have to. (For your use case you'd also want to make sure you turn the resampling off for poly~; check the attributes of poly~ for the correct way to do this)