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

[Feature Request] Add support for playhead tracking #295

Open
czerpa-antdev opened this issue Feb 29, 2024 · 4 comments · May be fixed by #301
Open

[Feature Request] Add support for playhead tracking #295

czerpa-antdev opened this issue Feb 29, 2024 · 4 comments · May be fixed by #301

Comments

@czerpa-antdev
Copy link

czerpa-antdev commented Feb 29, 2024

Some plugins leverage playhead information to perform audio processing tasks.

Right now the only Python tool with this capability that I am aware of is DawDreamer: https://github.com/DBraun/DawDreamer

Playhead code: https://github.com/search?q=repo%3ADBraun%2FDawDreamer+AudioPlayHead&type=code&

However, the tool is not as friendly to use as Pedalboard and one requires to add significant amount of code to do simple tasks.

@psobot
Copy link
Member

psobot commented Feb 29, 2024

Hi @czerpa-antdev!

What kind of playhead integration would you be looking for? Pedalboard doesn't really have the notion of a playhead on purpose (nor tempo, nor time signature, etc; it's not meant to be a DAW). Are you just looking for the capability to set the playhead position and speed with each call to process?

@czerpa-antdev
Copy link
Author

czerpa-antdev commented Feb 29, 2024

hi @psobot!
thanks for reaching out so quickly. Really appreciate it. I see your point, it does sound like a fundamental design question with Pedalboard, thanks for clarifying that.

Mainly, what I was hoping to request is the ability to have a playhead. The playhead to update its sample position as incoming audio buffers are being passed to the plugin under usage. Some of the plugins I am currently working on require that information in order to properly process the incoming audio.

Ultimately, to do some thing like this (not needed in this exact format of course):

from pedalboard.io import AudioFile
import pedalboard as pb

plugin = pb.load_plugin("path_to_plugin")
plugin.parameter_that_needs_playhead = "some_value"

with AudioFile("input.wav") as f:
    with AudioFile("output.wav", 'w', f.samplerate, f.num_channels) as o:
        while f.tell() < f.frames:
            # as buffers are fed, the playhead information would update.
            chunk = f.read(f.samplerate)
            effected = plugin(chunk, f.samplerate, reset=False)
            o.write(effected)

let me know your thoughts

@psobot
Copy link
Member

psobot commented Feb 29, 2024

That seems entirely reasonable (and fairly simple to add) - but my understanding is that most plugins would expect a playhead to include musical context information, like a tempo, time signature, and similar (see JUCE's AudioPlayHead::PositionInfo). Pedalboard currently has no notion of these musical concepts. Do you know if the plugins you're working on would require all of the fields in PositionInfo to be set?

@czerpa-antdev
Copy link
Author

that's an excellent question.

I talked with the devs of the plugin, in an ideal situation, we would need musical context information to unblock us from exercising ALL aspects of the plugin. However, for a set of critical parameters, all we would need is having the playhead information with this set: positionInfo.timeInSamples and positionInfo.isPlaying

Hopefully this allows for some flexibility should adding musical context info (e.g. BPM) is not feasible.

let me know how would either impact the work, feasibility, etc. Happy to continue discussing.

@psobot psobot linked a pull request Mar 7, 2024 that will close this issue
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.

2 participants