Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AudioFile in input of AudioStream #294

Closed
adrienpl opened this issue Feb 29, 2024 · 5 comments
Closed

AudioFile in input of AudioStream #294

adrienpl opened this issue Feb 29, 2024 · 5 comments

Comments

@adrienpl
Copy link

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 !

@Abyz08
Copy link

Abyz08 commented Mar 1, 2024

@psobot Maybe this could be done with the use of JUCE’s AudioFormatReader?

@psobot
Copy link
Member

psobot commented Mar 4, 2024

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?

@psobot
Copy link
Member

psobot commented Jul 30, 2024

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))

@psobot psobot closed this as completed Jul 30, 2024
@adrienpl
Copy link
Author

Great thanks 👍

@Abyz08
Copy link

Abyz08 commented Sep 11, 2024

Thanks 👍
That is exactly what i needed for one of my upcoming projects!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants