[Feature Request] Add support for playhead tracking
czerpa-antdev opened this issue · comments
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.
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
?
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
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?
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.