Git Product home page Git Product logo

Comments (6)

mgeier avatar mgeier commented on July 28, 2024 7

I've created an example showing how to record for an arbitrary amount of time: rec_unlimited.py.

Does this help?

from python-sounddevice.

mgeier avatar mgeier commented on July 28, 2024

This is certainly possible but you'll have to implement it yourself using the callback API.

The reason why sounddevice.rec() uses a pre-defined duration, is to be able to allocate all necessary memory in one big NumPy array beforehand.

You could extend that to arbitrary durations by appending to a list of audio blocks in each callback.
Once you have enough, you can stop() (or abort()) the stream and afterwards join your list of audio blocks into a big NumPy array (if needed).

Note that allocating memory within the time-constrained callback may take too long, which may lead to drop-outs in your recording. You should be able to detect those with the status argument of your callback function. As long as status doesn't contain any error bits, you should be fine.

from python-sounddevice.

rodrimaia avatar rodrimaia commented on July 28, 2024

Helps A LOT! thank you so much. I will experiment a little bit and try to do my 'loop pedal emulator'. this is extremely helpful. This module is awesome.

from python-sounddevice.

 avatar commented on July 28, 2024

Dude you gave me the exact thing which i needed, thanks

from python-sounddevice.

egzon-korenica avatar egzon-korenica commented on July 28, 2024

I've created an example showing how to record for an arbitrary amount of time: rec_unlimited.py.

Does this help?

This code is amazing, I was wondering though, is it possible to do multiple recordings in one session? I mean when you click ctrl+c the whole program shuts down.

from python-sounddevice.

HaHeho avatar HaHeho commented on July 28, 2024

This code is amazing, I was wondering though, is it possible to do multiple recordings in one session? I mean when you click ctrl+c the whole program shuts down.

I mean, that is what the code does. There is nothing happening after catching the KeyboardInterrupt. You can modify that of course, like adding similar code afterwards or putting it inside a loop.

from python-sounddevice.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.