Created
September 11, 2017 21:40
-
-
Save Sciss/0faff609a7c5b07fef577959ea1a9365 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class HasRange[U](val lo: Float, val hi: Float) | |
object HasRange { | |
implicit def SinOscHasRange = new HasRange[SinOsc ](-1, +1) | |
implicit def ImpulseHasRange = new HasRange[Impulse]( 0, +1) | |
} | |
implicit class GERangeOps[U <: GE](in: U) { | |
def range(lo: GE = 0f, hi: GE = 1f)(implicit r: HasRange[U]): GE = | |
in.linlin(r.lo, r.hi, lo, hi) | |
def exprange(lo: GE = 0.01f, hi: GE = 1f)(implicit r: HasRange[U]): GE = | |
in.linexp(r.lo, r.hi, lo, hi) | |
} | |
play { | |
SinOsc.ar(SinOsc.ar(0.3).exprange(440, 6600)) * 0.1 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment