Skip to content

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

Open

Description

@gcentauri

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!

Activity

  1. chaosprint commented on Oct 24, 2021

    @chaosprint

    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

  2. gcentauri commented on Oct 25, 2021

    @gcentauri
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions