| 1 |
// Listing 5.5 Function to cut gain (or any float) in half |
| 2 |
|
| 3 |
SinOsc s => dac; // (1) Oscillator to test halfGain function |
| 4 |
|
| 5 |
// our function |
| 6 |
fun float halfGain( float originalGain ) // (2) Defines the halfGain function |
| 7 |
{ |
| 8 |
return (originalGain*0.5); |
| 9 |
} |
| 10 |
|
| 11 |
// remember that .gain is a function built into SinOsc |
| 12 |
<<< "Full Gain: ", s.gain() >>>; // (3) Prints initial gain of SinOsc |
| 13 |
second => now; |
| 14 |
|
| 15 |
// call halfGain() |
| 16 |
halfGain(s.gain()) => s.gain; // (4) Prints new SinOsc gain |
| 17 |
<<< "Gain is now half: ", s.gain() >>>; // after cutting it in half |
| 18 |
second => now; |