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

Can we author Surge oscillators or FX in Faust? #3669

Open
baconpaul opened this issue Jan 19, 2021 · 18 comments
Open

Can we author Surge oscillators or FX in Faust? #3669

baconpaul opened this issue Jan 19, 2021 · 18 comments
Labels
DSP Issues and feature requests related to sound generation in the synth Experimental Issues related to experimental features that may or may not see the light of day Oscillator Features or additions to the oscillator section

Comments

@baconpaul
Copy link
Collaborator

Filters are super hard because of the SSE architecture, but oscillators and fx may be less so. the faust architecture is basically a templating model. The sliders are basically params. Can I take this simple oscillator and make it show up in surge?

https://github.com/magnetophon/faustOscillators/blob/master/example.dsp

declare author "Bart Brouns";
declare license "GPLv3";
declare name "osc-example";
import("stdfaust.lib");

process = sineSquarePulse~_;

sineSquarePulse(FB) =
  it.interpolate_linear(sinSquare,sine,square):clip
with {
  sine = os.osc(f);
  square = os.pulsetrain(f,width);
  clip = _*drive:max(-1):min(1);
  f = freq+(FM*FB);
};

freq      = hslider ("[0]freq", 440, 27.5, 3520, 0.1) :si.smoo;
sinSquare = hslider ("[1]sinSquare", 0.5, 0, 1, 0.1)  :si.smoo;
width     = hslider ("[2]width", 0.5, 0, 1, 0.1)      :si.smoo;
drive     = hslider ("[3]drive", 1, 1, 100, 0.1)       :si.smoo;
FM        = hslider ("[4]FM", 0, 0, 100, 0.1)         :si.smoo;
@mkruselj mkruselj added DSP Issues and feature requests related to sound generation in the synth Experimental Issues related to experimental features that may or may not see the light of day Oscillator Features or additions to the oscillator section labels Jan 19, 2021
@mkruselj mkruselj added this to the 1.9.0 milestone Jan 19, 2021
@magnetophon
Copy link
Contributor

Awesome! I hope this gets in! :D

Filters are super hard because of the SSE architecture

Would you mind explaining like i'm an audio-engineer, not a coder?

@baconpaul
Copy link
Collaborator Author

Would you mind explaining like i'm an audio-engineer, not a coder?

There is no non-coder explanation really. The filters use a particular style of coding to do voice-level parallelism which isn’t how Faust outputs C++. It’s described here https://github.com/surge-synthesizer/surge/blob/main/src/common/dsp/QuadFilterChain.h

@magnetophon
Copy link
Contributor

So you think faust filters will be too CPU intensive?

@baconpaul
Copy link
Collaborator Author

I think implementing a voice filter in Faust (like another one int he filter bank next to obxd) would not have the right code structure; and unrolling that code structure would yes increase cpu at least 4x over coding them in parallel

@magnetophon
Copy link
Contributor

OK, thanks for the explanation!

@baconpaul
Copy link
Collaborator Author

That said: prototyping a filter in Faust is easy to do. And then we just have to re-code it as parallel stuff. But the idea of “you write a Faust function and have production ready oscillator or fx with no c++” is not one available for our filter architecture as easily.

I’m also looking at libfaust.... man it is tempting for the scripting language rather than LuaJIT. I really need to understand what the full set of dependencies would be. Is there a Faust dev forum where I can hang out which is friendly and responsive?

@magnetophon
Copy link
Contributor

I’m also looking at libfaust.... man it is tempting for the scripting language rather than LuaJIT.

Woohooo!!!!!!!!!!!!!!!!!!!! Very exiting!!! :D

I really need to understand what the full set of dependencies would be.

Going by the package I wrote for a faust JIT lv2, it can't be much, as far as I can tell, just faust.

BTW: personally I like the approach they take to get an editor: they include libvterm and run $EDITOR inside that in the plugin.
Probably not compatible with windows though.
Just a side-note...

Is there a Faust dev forum where I can hang out which is friendly and responsive?

I recommend the faustaudio slack channel
You usually get an answer from one of the main faust devs: @sletz (Hi Stephan! Hope you don't mind the ping!)

@mkruselj
Copy link
Collaborator

mkruselj commented Jan 19, 2021

I’m also looking at libfaust.... man it is tempting for the scripting language rather than LuaJIT.

What do we gain by using Faust for function modulator/waveform generator, instead of Lua? I know the con to using it already - Lua is a lot more established.

@sletz
Copy link

sletz commented Jan 19, 2021

I’m also looking at libfaust.... man it is tempting for the scripting language rather than LuaJIT.

What do we gain by using Faust for function modulator/waveform generator, instead of Lua? I know the con to using it already - Lua is a lot more established.

@magnetophon
Copy link
Contributor

magnetophon commented Jan 19, 2021

Familiarity is indeed an advantage of LuaJIT.

Faust OTOH has advantages in this use case too, appart from the ones Paul mentioned:

  • Made for audio and real time:
    Everything has a very low, but more importantly constant cpu usage.
    AFAIK, in a general purpose language like LuaJIT, that is the responsibility of the person writing the code.
  • Produces a nice block diagram svg of your code, with clickable hierarchy, that can be shown in the plugin.
    Very handy for debugging and understanding others peoples code.
  • Everything is a stream, reducing boilerplate code
  • The synthax and features lend themselves very well to audio. For example pattern matching is very handy.
  • Quite well established in the audio community.

EDIT:

  • if one of the users comes up with a cool LFO or something, it's usually trivial to turn into production ready C++ fro inclusion in Surge.

@baconpaul
Copy link
Collaborator Author

So now don’t get all excited. JUCe has to come first.

But short answer to @mkruselj question is exactly as @magnetophon said: Faust is a language for signal manipulation Lua is for general purpose scripting. We want signal manipulation....

But both require careful consideration and nothing is decided yet. Anything including nothing at all may be what we do in the short term :)

@baconpaul
Copy link
Collaborator Author

Ha well the real trick is I have to not get excited. We can’t have surge 1.9 be an unrunnable pile of semi finished ideas. Gotta wrap things up in order.

@magnetophon
Copy link
Contributor

Hmm, github is messing with me: my excited comment was displayed twice, so I deleted it, and now both are gone.
In order to make Paul not sound like a lunatic, I'll add it here:

I know all that, but I'm still exCited!

@sletz
Copy link

sletz commented Jan 19, 2021

Note that libfaust even contains an interpreter, much simpler to deploy compared to the LLVM backend. It has been used in the Faust support for VCV Prototype here: https://github.com/VCVRack/VCV-Prototype/tree/faust, https://github.com/VCVRack/VCV-Prototype/blob/faust/Faust.md, https://github.com/VCVRack/VCV-Prototype/blob/faust/src/FaustEngine.cpp

@surge-synthesizer surge-synthesizer deleted a comment from magnetophon Jan 19, 2021
@mkruselj mkruselj modified the milestones: 1.9.0, Surge XT Jan 24, 2021
@baconpaul
Copy link
Collaborator Author

https://faustdoc.grame.fr/manual/architectures/

and pushing this (compile time only) into 1.9

@baconpaul baconpaul modified the milestones: Surge XT, 1.9.0 Feb 6, 2021
@mkruselj mkruselj changed the title Can we author surge Oscillators or FX in faust? Can we author Surge oscillators or FX in faust? Feb 8, 2021
@mkruselj mkruselj changed the title Can we author Surge oscillators or FX in faust? Can we author Surge oscillators or FX in Faust? Feb 13, 2021
@mkruselj
Copy link
Collaborator

mkruselj commented Mar 5, 2021

@baconpaul Move to XT?

@baconpaul
Copy link
Collaborator Author

I have still not given up on doing this one this cycle!

@mkruselj mkruselj removed this from the 1.9.0 milestone Mar 10, 2021
@mkruselj mkruselj added this to the Surge XT 1.0 milestone Mar 10, 2021
@baconpaul
Copy link
Collaborator Author

baconpaul commented Nov 12, 2021

from eyal on tap discord (to be clear he's working with JOS not me)

Hey, so I started working on a hobby project with Julius Smith lately.
https://github.com/eyalamirmusic/FaustCPPConverter

This is a project that as a part of the cmake build runs the Faust compiler and generates C++ files you can use directly in your project - I also wrote a C++ wrapper to make that part slightly easier.

Unlike the faust native JUCE exporters and all that, this doesn't give you a ready to go plugin, but it will give you all your .dsp files as classes that are more flexible to use in a "regular" JUCE plugin.

It's in very early stages so we'd appreciate any ideas/feedbacks!
Our next project would probably be to write JUCE module wrappers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DSP Issues and feature requests related to sound generation in the synth Experimental Issues related to experimental features that may or may not see the light of day Oscillator Features or additions to the oscillator section
Projects
None yet
Development

No branches or pull requests

4 participants