grame-cncm / faust

Functional programming language for signal processing and sound synthesis
http://faust.grame.fr
Other
2.57k stars 322 forks source link

Host Tempo into generated Plugins #357

Open alcomposer opened 5 years ago

alcomposer commented 5 years ago

Having read the Faust documentation, it is unclear what is the best way to get host tempo (BPM, speed etc) into a plugin DSP.

I am referring to DSP code that is compiled with the faust2/plugin/ scripts.

Can this be made clearer in the documentation?

sletz commented 5 years ago

This example code shows how Faust audio DSP can indeed be synchronized using MIDI clock based synchro (so start/stop/sync MIDI messages). To correctly work, it supposes that the MIDI receiving wrapping code handles MIDI events timestamps. This is not the case in all faust2xx scripts.

sletz commented 5 years ago

So right now MIDI clock based synchro (with start/stop/clock messages) is handled in some of the faust2xx scripts. What kind of other synchro system would be usefull ?

JeremyKeenan commented 4 years ago

Ableton Link support would be very useful.

sletz commented 4 years ago

What kind of use-case do you have in mind?

JeremyKeenan commented 4 years ago

Using Link synchronisation in Faust generated plugins within SuperCollider for example, which will have Link support in the next release.

sletz commented 4 years ago

Well I actually started to implement something in 2019. The idea was to define some new meta-data to be added in controllers (like sliders, nentry..) and to be linked to Ableton Link start/stop/tempo parameters. This is coded in an AbletonLinkUI class that is not part of GitHub yet, and has never been finished and tested. @JeremyKeenan are you willing to help in some C++ programming ?

JeremyKeenan commented 4 years ago

Good to know a start has been made. Unfortunately my C++ dev skills are not up to par, I'm more on the openFrameworks tinkering level. I would be glad to help with testing.

I guess the specific use case I'd imagined was syncing triggers and LFOs to tempo, for example in SuperCollider externals.

sletz commented 4 years ago

Du you mean SuperCollider externals written in Faust ?

JeremyKeenan commented 4 years ago

Yes, exactly that.

On Mon, Feb 3, 2020 at 12:23 PM Stéphane Letz notifications@github.com wrote:

Du you mean SuperCollider externals written in Faust ?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/grame-cncm/faust/issues/357?email_source=notifications&email_token=ABGYLF5DIJCQU7BJDUI3FH3RBAEDLA5CNFSM4JJCBAS2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEKTU2VY#issuecomment-581389655, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABGYLF2XUY6DKWYBUJNOIFLRBAEDLANCNFSM4JJCBASQ .

-- www.jeremykeenan.info www.callandresponse.org.uk

sletz commented 4 years ago

Which means probably being able to "connect" to the SuperCollider global Ableton Link context ? Or imagine each Faust UGEn has its own Ableton Link context ? (which is probably easier to set up, but would mean several Faust UGEn would open several Ableton Link context..) Is this a problem ?

JeremyKeenan commented 4 years ago

I think the idea would be to connect to the SuperCollider Link context. I don't think it would be a problem though to have individual contexts, as I understand the idea of link is to Sync multiple applications and contexts to a single source.

On Mon, Feb 3, 2020 at 12:44 PM Stéphane Letz notifications@github.com wrote:

Which means probably being able to "connect" to the SuperCollider global Ableton Link context ? Or imagine each Faust UGEn has its own Ableton Link context ? (which is probably easier to set up, but would mean several Faust UGEn would open several Ableton Link context..) Is this a problem ?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/grame-cncm/faust/issues/357?email_source=notifications&email_token=ABGYLFZXIRRXFFXS6UAN7ZTRBAGUDA5CNFSM4JJCBAS2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEKTWTOI#issuecomment-581396921, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABGYLF72OIRLTXYNKQI35GDRBAGUDANCNFSM4JJCBASQ .

-- www.jeremykeenan.info www.callandresponse.org.uk

magnetophon commented 4 years ago

@sletz

This is not the case in all faust2xx scripts.

Which ones do have host tempo abilities?

DBraun commented 2 years ago

We could take some inspiration from how VSTs get the playhead context from the DAW including the tempo, time signature, etc.

https://github.com/juce-framework/JUCE/blob/2f980209cc4091a4490bb1bafc5d530f16834e58/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp#L250

Maybe we could have a new faust libraries named pl (playhead). Then we could write pl.bpm. BPM would not become an hslider or anything UI related. It would be up to the DAW to tell Faust the playhead context for each block.

m_dsp = m_factory->createDSPInstance();
m_dsp->setPlayhead(somethingFromDAW);

// then later in process loop:

// compute would be modified to get the playhead and make private calls to update private variables:
// pl.bpm, pl.timeSigNumerator etc.
// Then compute would proceed as usual.
m_dsp->compute(128, inPtrs, outPtrs);