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

Get rid of panics in Rate methods #11

Open
briansorahan opened this issue Jul 29, 2017 · 0 comments
Open

Get rid of panics in Rate methods #11

briansorahan opened this issue Jul 29, 2017 · 0 comments

Comments

@briansorahan
Copy link
Contributor

briansorahan commented Jul 29, 2017

This is a rough sketch of an idea to avoid all the panic'ing in the ugen Rate methods.
The idea is to cache an error on the ugen that will get returned when NewSynthdef is called.

sinosc.go:

type SinOsc struct {
    Freq  Input
    Phase Input
}

func (s SinOsc) Rate(rate int8) Input {
    var err error
    if !supported(rate) {
        err = errors.Errorf("unsupported rate: %d", rate)
    }
    return NewInput("SinOsc", err, ...)
}

...

input.go:

type Input interface {
    ...
    err() error
}

synthdef.go:

func NewSynthdef(name string, f UgenFunc) (*Synthdef, error) {
    // Flatten the ugen graph.
    // If any ugens return an input that returns a non-nil error from
    // the private err() method then return the error.
}
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

1 participant