TonicAudio / Tonic

Easy and efficient audio synthesis in C++
The Unlicense
524 stars 63 forks source link

Provide default mGen's for Generator and ControlGenerator Objects #6

Closed morganpackard closed 11 years ago

morganpackard commented 11 years ago

PassThroughGenerator_ shouldn't be necessary. Generator and ControlGenerator should be non-abstract, and work on their own, just with no effect.

Any parameter which takes one of these should not be required to be set. The automatically-instantiated Generator and ControlGenerator should be able to work just fine as-is, rather than crashing, which is what happens now.

morganpackard commented 11 years ago

It may not be necessary to actually create the object. Could be more efficient to just have the base class not rely on the core object in any way.

ndonald2 commented 11 years ago

I think there are advantages to both approaches. Leaving Generator_ and ControlGenerator_ as abstract makes it very clear that tick() (and other required methods) MUST be overridden in subclasses, whereas if they have default empty implementations it might be easier to forget.

The default Generator and ControlGenerator smart pointer template classes using a "passthrough" object as their default mGen should allow them to be used as-is for parameters to other Generators without crashing, and the "passthrough" classes are very lightweight, so I don't know if efficiency is that big of a concern.

All in all, I'm pretty indifferent on this, so if you feel like it's more convenient for the base classes to be concrete, that's fine with me too.

ndonald2 commented 11 years ago

What do you think about this issue now that we've made some strides? I think Generator subclasses should always provide reasonable default values for their inputs, and having this explode when you fail to do so is a good way to identify the source of error. Otherwise you could be tracking down why the hell your thing's not working, when it all comes down to the fact that the default "Passthrough" control generator is spitting out zeros.

morganpackard commented 11 years ago

I haven't come across a need for the default pass-through mgens. I'd be fine with the base class blowing up if you try to tick it.

Sent from my iPhone

On Apr 14, 2013, at 1:58 PM, "Nick D." notifications@github.com wrote:

What do you think about this issue now that we've made some strides? I think Generator subclasses should always provide reasonable default values for their inputs, and having this explode when you fail to do so is a good way to identify the source of error. Otherwise you could be tracking down why the hell your thing's not working, when it all comes down to the fact that the default "Passthrough" control generator is spitting out zeros.

— Reply to this email directly or view it on GitHubhttps://github.com/TonicAudio/Tonic/issues/6#issuecomment-16355983 .

ndonald2 commented 11 years ago

Cool, marking as closed then.