Bringing in and outputting audio streams from/to numpy arrays #316
-
|
I am working on a program that uses pyo as the main audio processing library, but i want to be able to have audio generation and modification from other libraries in the pyo chain - for instance, I would like to use FluidSynth as an audio generator, and at some point i hope to implement VST plugins (wrapped into a pyo object somehow). For input, im thinking passing the data into a table and using TableRead or similar could work, but not sure how to ensure its written while pyo is processing the buffer, or if this would be the most efficient way to do this. For output, i think there is a way to get the audio streams from objects, but again, i dont know how to syncronize this with the buffer. If anyone can offer some advice, thank you in advance |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 8 replies
-
|
To get the audio to a NumPy array you can use About synchronizing, since you convert audio streams to NumPy arrays and back, there will be at least one sample block latency and I don't think you can avoid this. |
Beta Was this translation helpful? Give feedback.
-
|
been trying to get this working with the getBuffer() function. it actually works on the array directly, but it only works on every other buffer (sound rapidly shifts back and forth between full volume and half volume), not sure whats going on there, but if i can modify the buffer at just the right point in time, i think that method should work very efficiently. if i try a less direct approach by uncommenting out those lines of code and passing self._data_output to the TableScan, the signal looks about right in my scope, but sounds like its being played through a ringmod (i think its dropping a few samples each buffer?) |
Beta Was this translation helpful? Give feedback.
To get the audio to a NumPy array you can use
getBuffer(). I'm not sure if all classes share this, probably, since all classes inherit from the PyoObject class. What I've done in my book is this:About synchronizing, since you convert audio streams to NumPy arrays and back, there will be at least one sample block latency and I don't think you can avoid this.
For example, to write data to a NewTable() that you can then read with TableRead(), you will need a whole sample block to write that data to NewTable().
I don't think though that one sample block latency is all that bad.