jamoma / jamoma2

A header-only C++ library for building dynamic and reflexive systems with an emphasis on audio and media.
MIT License
30 stars 6 forks source link

Implement Gain type with user-defined literals for db etc. #22

Closed tap closed 9 years ago

tap commented 9 years ago

Not sure what to call this type since Gain is used already for a Ugen -- or maybe the Gain Ugen can be renamed something else like Scale or Fader or something?

tap commented 9 years ago

Or the new type could be called GainValue, which might make more sense...

tap commented 9 years ago

Bailing on this initiative.

The following code won't work because you can't pass a negative number into the literal code, e.g.

    my_gain.gain = -12_db;          // should assign roughly 0.25

Instead it strips the negative sign. What you can do is create a class then assign, then do the unary- operator overload, but by then we've already done the assignment the wrong way.

As an additional point of punishment it then makes accessing parameters of a GainValue class more complicated because you have a couple of classes to hop through when trying to fetch the linear value e.g. in the process method.