pedalboard
pedalboard copied to clipboard
AudioFile in input of AudioStream
Hello guys,
I want to have the global latency of an audio stream (pedalbaord & VB-Cable). Is it possible to give a wav file in input of AudioStream instead of microphone ? Since i know the duration of the input wav file and i can hear the output Virtual Microphone , i want to calculate the theorical & real end time.
Is it possible to do something like this with pedalbaord ?
Thanks !
@psobot Maybe this could be done with the use of JUCE’s AudioFormatReader?
Hi @adrienpl and @Dohg678!
Pedalboard doesn’t have a mechanism for this at the moment. I haven’t thought about a good API design for this just yet, but it should be possible to either put audio playback into the AudioStream class or to add a new class or function just to play a single buffer.
However, I’m not sure if this would solve your problem - what do you mean when you say that you want to measure the “global latency” of an audio stream?
Hi again @adrienpl and @Dohg678,
The ability to write to (i.e.: playback) and read from (i.e.: record) audio devices has been added to the AudioStream class in v0.9.12. See the documentation for more details, but in a nutshell:
from pedalboard.io import AudioStream
# Play a chunk of audio to the default audio device:
with AudioFile("my_file.mp3") as f:
ten_second_chunk = f.read(f.samplerate * 10)
AudioStream.play(ten_second_chunk, f.samplerate)
...or something like:
# Play an audio file by looping through it in chunks:
with AudioStream(output_device=AudioStream.default_output_device_name) as stream:
with AudioFile("my_audio_file.mp3") as f:
while f.tell() < f.frames:
# Decode and play 512 samples at a time:
stream.write(f.read(512))
Great thanks 👍
Thanks 👍 That is exactly what i needed for one of my upcoming projects!