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

[Question] What is the Rusty way to make an additive synth with dasp? #165

Open
gcentauri opened this issue Oct 24, 2021 · 2 comments
Open

Comments

@gcentauri
Copy link

Hello all!

This is a question for anyone who may have some suggestions. I have a decent understanding of DSP, but I'm very new to Rust. I'm probably getting ahead of myself trying to learn it with digital audio, but its what is inspiring me to learn Rust so here i am.

I'd like to build an example additive synth, with as many Sine oscillators as I can handle. Ideally, I'd like to have a function to call where I could have a base frequency and N partials as some multiple of the base.

So far I can do this in a naive way by hard coding in each sine wave and then using add_amp to sum them all together like so:

sine_0.add_amp(sine_1).add_amp(sine_2). ... .add_amp(sine_N)

but this isn't very nice and it isn't flexible. I'm looking for a way to do something like

sines.reduce(|acc, sine| acc.add_amp(sine))

but I can't seem to figure out how to manage the types.

Perhaps I'm going about this the wrong way?

Any input would be welcome, and if there's a better forum than an issue on this repo I'm happy to move the discussion elsewhere.

Thank you!

@chaosprint
Copy link

chaosprint commented Oct 24, 2021

I would suggest you check the dasp graph module in this repo.
Build a sine node, put two of the sine nodes in a graph. Then you are ready to go.
Both OOP or FP either do not work well or hard to implement.
You can check on my project Glicol to see how dasp graph is used:
https://github.com/chaosprint/glicol

@gcentauri
Copy link
Author

@chaosprint - thanks for the feedback. i was aiming to learn a bit by digging as low-level as I dared, but I see what you're saying. Glicol looks cool!

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

No branches or pull requests

2 participants