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

Re-work API #16

Open
AldaronLau opened this issue Feb 4, 2022 · 1 comment
Open

Re-work API #16

AldaronLau opened this issue Feb 4, 2022 · 1 comment
Labels
enhancement New feature or request

Comments

@AldaronLau
Copy link
Collaborator

Currently the API requires the user to pass a closure for synthesis.

I'd like to re-work this to be data-oriented (savable and loadable as a file), and synthesis constructable with the builder pattern. Users must be able to pass in their own variables, and still be able to get step events in custom closures for flexibility and backwards-compatibility.

@AldaronLau AldaronLau added the enhancement New feature or request label Feb 4, 2022
@AldaronLau
Copy link
Collaborator Author

Update

I have thought about the right way to do this probably too way much without writing code. I want to avoid writing a VM within Twang due to performance concerns. So how should a synthesis format work?

API

The new API will heavily use the type system.

use twang::Synth::{Sig, Mix};

let mut audio = Audio::<Ch16, 2>::with_silence(48_000, 48_000 * 5);
// Two sine oscillators, an octave apart
let oscs = [
    Sig(440.0).sine(),
    Sig(880.0).sine(),
];
// Mix the two together
let synth = Mix(&oscs);

synth.stream(audio.sink());

Format

For the format, twang will attempt to use postcard (as an optional feature). An intermediate MuON based format for human-readable/writeable will be able to be used with it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant