Skip to content

Conversation

nshaheed
Copy link
Contributor

@nshaheed nshaheed commented Sep 3, 2025

No more linear scaling!

// set a Gain with a deciBel value now
SinOsc s => GainDB g(-6.0) => dac;

<<< g.gain(), Std.dbtolin(g.gain()) >>>;

3::second => now;

outputs:

-6.000000 0.501187

@nshaheed
Copy link
Contributor Author

nshaheed commented Sep 3, 2025

an alternative implementation of this could be a Gain.db function, i.e.:

SinOsc s => Gain g => dac; // use a gain as normal

-6 => g.db; // set inside gain
<<< g.db() >>>; // prints out "-6"

However, this means that constructors always have to be in linear scaling.

@nshaheed
Copy link
Contributor Author

@gewang as discussed in pr-lab I've made the following changes:

  • GainDB now inheirits from Gain, the only difference between the two is that the GainDB constructor uses dB scaling rather than linear scaling
  • Added Gain.db getters and setters so that any Gain object can bet set with db values

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

Successfully merging this pull request may close these issues.

1 participant