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

class library: UGen - provide bilin #781

Merged
merged 1 commit into from
Mar 28, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions HelpSource/Classes/UGen.schelp
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,30 @@ code::
{ Line.ar(-1, 5, 0.1).curvelin(0, 3, -1, 1, curve: -4) }.plot(0.1);
::


method:: bilin
Map the receiver from two assumed linear input ranges (inMin..inCenter) and (inCenter..inMax) to two linear output ranges (outMin..outCenter) and (outCenter..outMax). If the input exceeds the input range, the following behaviours are specified by the clip argument.
argument::inCenter
argument::inMin
assumed input minimum
argument::inMax
assumed input maximum
argument::outCenter
argument::outMin
output minimum
argument::outMax
output maximum
argument::clip
nil (don't clip)
\max (clip ceiling)
\min (clip floor)
\minmax (clip both - this is default).
discussion::
code::
{Line.kr(0, 10, 0.1).bilin(1, 0, 10, 0.6, 0, 1)}.plot(0.1)
::


method:: prune
Limits the receiver range to one of the four clip modes, see code::linlin:: above.

Expand Down
9 changes: 9 additions & 0 deletions SCClassLibrary/Common/Audio/UGen.sc
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,15 @@ UGen : AbstractFunction {
^log((b - scaled) / a) / curve
}

bilin { arg inCenter, inMin, inMax, outCenter, outMin, outMax, clip=\minmax;
^Select.perform(this.methodSelectorForRate, this < inCenter,
[
this.linlin(inCenter, inMax, outCenter, outMax, clip),
this.linlin(inMin, inCenter, outMin, outCenter, clip)
]
)
}

signalRange { ^\bipolar }
@ { arg y; ^Point.new(this, y) } // dynamic geometry support

Expand Down