Dynamically Record Audio

61 views
Skip to first unread message

Marcel Ochs

unread,
Apr 20, 2017, 8:52:13 AM4/20/17
to pyo-discuss
Hey Guys,

is there a way to dynamically record an undefined length of audio and save it to ram? I've already tried several ways but it didn't get a working result. I'm trying to build a kind of looper which is taking the first "record" as the default loop length.

Greetings
Marcel O.

Olivier Bélanger

unread,
Apr 20, 2017, 9:28:54 AM4/20/17
to pyo-discuss
Well, you just made me found (and fixed) a bug!

If you can compile pyo from source this script will work as expected, otherwise I'm planning a new bug fixes release very soon, so you won't have to wait very long!

from pyo import *

s = Server().boot()

THE_MAX_LENGTH_YOU_MAY_WANT = 60 * 60 # 1 hour memory

def start():
    "Start the recording."
    rec.play()

def stop():
    "Stop the recording, adjust looper ending point and start the playback."
    duration = rec["time"].get() / s.getSamplingRate()
    rec.stop()
    lop.dur =  duration
    lop.out()

tab = NewTable(length=THE_MAX_LENGTH_YOU_MAY_WANT)
inp = Input()
rec = TableRec(inp, tab)

lop = Looper(tab, mul=0.5).stop()

s.gui(locals())

Olivier


--
You received this message because you are subscribed to the Google Groups "pyo-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyo-discuss+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Marcel Ochs

unread,
Apr 25, 2017, 5:03:14 AM4/25/17
to pyo-discuss
That's convienient. :)
Also thank you for helping me this fast! I already took your example as guideline for my little looper project. Pyo ist just an awesome DSP Library.

Marcel O.
To unsubscribe from this group and stop receiving emails from it, send an email to pyo-discuss...@googlegroups.com.

p.s...@outlook.com

unread,
Apr 26, 2017, 11:06:37 AM4/26/17
to pyo-discuss
Hi Marcel and Olivier,

Strange to see that there was a bug! I have not encountered any issues with this. This is essentially the same process I used as well for the same purpose - set the NewTable to be a long length I wouldn't reach (for me that's just 60 seconds), record into it, use a timer (I think from threading) to time the difference between start and stop, then set the Looper to loop for that duration.

To get around any clicks you may find while maintaining a precise loop length, I ended up getting it to record for 100ms or so past my second timer trigger and setting Looper to crossfade outside of its duration. I found that (which makes sense) if you set the filled duration of the NewTable to be exactly the length of time you recorded for, the external crossfade still has audio shooting from loud to nothing instantly, resulting in a click a lot of the time. I hope that makes sense. I'd be happy to send you some lumps of my code that I've developed from Olivier's looping components, and to address any other questions you have about it. Some of my fixes are probably not ideal but I've found pyo to be incredibly flexible for looping dozens of tracks of precise lengths and relationships.

Best,
Paul

Olivier Bélanger

unread,
Apr 26, 2017, 11:16:16 AM4/26/17
to pyo-d...@googlegroups.com
The bug was just with the ["time"] streams that was not started
anymore (I broke it not so long ago). It's fixed now with pyo 0.8.6.

Olivier


On 4/26/17, p.s...@outlook.com <p.s...@outlook.com> wrote:
> Hi Marcel and Olivier,
>
> Strange to see that there was a bug! I have not encountered any issues with
>
> this. This is essentially the same process I used as well for the same
> purpose - set the NewTable to be a long length I wouldn't reach (for me
> that's just 60 seconds), record into it, use a timer (I think from*
> threading*) to time the difference between start and stop, then set the

Darren Sholes

unread,
Sep 16, 2021, 1:39:08 PM9/16/21
to pyo-discuss
One question related to "THE_MAX_LENGTH_YOU_MAY_WANT = 60 * 60 # 1 hour memory". Will the Table that's being recorded always take up 1 hour memory, or will it automatically reduce the size to however long the recording is?

If it doesn't automatically reduce the size, would it make sense to write the recorded portion to a new Table of the appropriate length, and delete the first 1 hour Table? Especially if I want to have a number of these Tables and save the recorded portion to WAV files?

Cheers,
Darren

To unsubscribe from this group and stop receiving emails from it, send an email to pyo-discuss...@googlegroups.com.

Darren Sholes

unread,
Sep 24, 2021, 1:41:06 PM9/24/21
to pyo-discuss
A follow up question to the one above:

In my program, users can create NewTable objects to record to after the Server is already started. If the Tables are large enough (1 hr memory from above), there is an audible drop/pop in the input monitoring. I can't pre-allocate tables before starting the server because I have no idea how many the user will create. And if they're all 1hr, for "dynamic" recording, then I'd quickly run out of memory.

Has anyone used multiprocessing/multithreading/asyncio to create large tables after the Server has started? Or to save large Tables to disk (using ``savefileFromTable``)?
Reply all
Reply to author
Forward
0 new messages