diff --git a/docs/library/envelope/asrenvelope/index.md b/docs/library/envelope/asrenvelope/index.md index 09f945c2..3d41207c 100644 --- a/docs/library/envelope/asrenvelope/index.md +++ b/docs/library/envelope/asrenvelope/index.md @@ -25,3 +25,32 @@ output.play() ``` +```python + +#------------------------------------------------------------------------------- +# Using ASREnvelope to shape the sound of an oscillator over time. +# The Line node generates a continuously-changing value which we use as the +# release time. +#------------------------------------------------------------------------------- +clock = Impulse(8.0) +CMaj7 = [ 60, 64, 67, 71, 74, 76 ] * 8 +FMaj9 = [ 65, 69, 72, 76, 77, 81 ] * 8 +arpeggios = CMaj7 + FMaj9 +sequence = Sequence(arpeggios, clock) +frequency = MidiNoteToFrequency(sequence) + +oscillator = TriangleOscillator(frequency) +release = Line(0.1, 0.5, 6, True) +envelope = ASREnvelope(attack=0.0, + sustain=0.0, + release=release, + curve=1.0, + clock=clock) +voice = oscillator * envelope + +pan = SineLFO(0.1667, -1.0, 1.0) +output = StereoPanner(voice, pan) +output.play() + +``` + diff --git a/docs/library/envelope/index.md b/docs/library/envelope/index.md index df1f991a..84c22470 100644 --- a/docs/library/envelope/index.md +++ b/docs/library/envelope/index.md @@ -6,5 +6,5 @@ - **[ASREnvelope](asrenvelope/index.md)**: Attack-sustain-release envelope. - **[DetectSilence](detectsilence/index.md)**: Detects blocks of silence below the threshold value. Used as an auto-free node to terminate a Patch after processing is complete. - **[Envelope](envelope/index.md)**: Generic envelope constructor, given an array of levels, times and curves. -- **[Line](line/index.md)**: Line segment with the given start/end values and duration. If loop is true, repeats indefinitely. Retriggers on a clock signal. +- **[Line](line/index.md)**: Line segment with the given start/end values, and duration (in seconds). If loop is true, repeats indefinitely. Retriggers on a clock signal. - **[RectangularEnvelope](rectangularenvelope/index.md)**: Rectangular envelope with the given sustain duration. diff --git a/docs/library/envelope/line/index.md b/docs/library/envelope/line/index.md index 40d0235d..9ed93604 100644 --- a/docs/library/envelope/line/index.md +++ b/docs/library/envelope/line/index.md @@ -1,5 +1,5 @@ title: Line node documentation -description: Line: Line segment with the given start/end values and duration. If loop is true, repeats indefinitely. Retriggers on a clock signal. +description: Line: Line segment with the given start/end values, and duration (in seconds). If loop is true, repeats indefinitely. Retriggers on a clock signal. [Reference library](../../index.md) > [Envelope](../index.md) > [Line](index.md) @@ -9,7 +9,7 @@ description: Line: Line segment with the given start/end values and duration. If Line(start=0.0, end=1.0, time=1.0, loop=0, clock=None) ``` -Line segment with the given start/end values and duration. If loop is true, repeats indefinitely. Retriggers on a clock signal. +Line segment with the given start/end values, and duration (in seconds). If loop is true, repeats indefinitely. Retriggers on a clock signal. ### Examples @@ -22,7 +22,31 @@ Line segment with the given start/end values and duration. If loop is true, repe clock = Impulse(frequency=1.0) line = Line(0.0, 0.5, 0.5, False, clock) osc = SawOscillator(200) -output = osc * line +output = StereoPanner(osc * line) +output.play() + +``` + +```python + +#------------------------------------------------------------------------------- +# Using Line to repeatedly alter the release value of an envelope applied to the +# main synth voice, in time with the music. +#------------------------------------------------------------------------------- +clock = Impulse(8.0) +CMaj7 = [ 60, 64, 67, 71, 74, 76 ] * 8 +FMaj9 = [ 65, 69, 72, 76, 77, 81 ] * 8 +arpeggios = CMaj7 + FMaj9 +sequence = Sequence(arpeggios, clock) +frequency = MidiNoteToFrequency(sequence) + +oscillator = TriangleOscillator(frequency) +release = Line(0.1, 0.5, 6, True) +envelope = ASREnvelope(0.0, 0.0, release, 1.0, clock) +voice = oscillator * envelope + +pan = SineLFO(0.1667, -1.0, 1.0) +output = StereoPanner(voice, pan) output.play() ``` diff --git a/docs/library/fft/index.md b/docs/library/fft/index.md index d502a67e..59109ff5 100644 --- a/docs/library/fft/index.md +++ b/docs/library/fft/index.md @@ -6,6 +6,8 @@ - **[FFTConvolve](fftconvolve/index.md)**: Frequency-domain convolution, using overlap-add. Useful for convolution reverb, with the input buffer containing an impulse response. Requires an FFT* input. - **[FFTContrast](fftcontrast/index.md)**: FFT Contrast. Requires an FFT* input. - **[FFTFlipSpectrum](fftflipspectrum/index.md)**: Flips the FFT magnitude spectrum in the X axis. Requires an FFT* input. +- **[FFTMagnitudePhaseArray](fftmagnitudephasearray/index.md)**: Fixed mag/phase array. +- **[FFTRandomPhase](fftrandomphase/index.md)**: Randomise phase values. - **[FFT](fft/index.md)**: Fast Fourier Transform. Takes a time-domain input, and generates a frequency-domain (FFT) output. - **[FFTFindPeaks](fftfindpeaks/index.md)**: Find peaks in the FFT magnitude spectrum. Requires an FFT* input. - **[IFFT](ifft/index.md)**: Inverse Fast Fourier Transform. Requires an FFT* input, generates a time-domain output. diff --git a/docs/library/index.md b/docs/library/index.md index 71543fad..8959796c 100644 --- a/docs/library/index.md +++ b/docs/library/index.md @@ -45,7 +45,7 @@ - **[ASREnvelope](envelope/asrenvelope/index.md)**: Attack-sustain-release envelope. - **[DetectSilence](envelope/detectsilence/index.md)**: Detects blocks of silence below the threshold value. Used as an auto-free node to terminate a Patch after processing is complete. - **[Envelope](envelope/envelope/index.md)**: Generic envelope constructor, given an array of levels, times and curves. -- **[Line](envelope/line/index.md)**: Line segment with the given start/end values and duration. If loop is true, repeats indefinitely. Retriggers on a clock signal. +- **[Line](envelope/line/index.md)**: Line segment with the given start/end values, and duration (in seconds). If loop is true, repeats indefinitely. Retriggers on a clock signal. - **[RectangularEnvelope](envelope/rectangularenvelope/index.md)**: Rectangular envelope with the given sustain duration. --- @@ -56,6 +56,8 @@ - **[FFTConvolve](fft/fftconvolve/index.md)**: Frequency-domain convolution, using overlap-add. Useful for convolution reverb, with the input buffer containing an impulse response. Requires an FFT* input. - **[FFTContrast](fft/fftcontrast/index.md)**: FFT Contrast. Requires an FFT* input. - **[FFTFlipSpectrum](fft/fftflipspectrum/index.md)**: Flips the FFT magnitude spectrum in the X axis. Requires an FFT* input. +- **[FFTMagnitudePhaseArray](fft/fftmagnitudephasearray/index.md)**: Fixed mag/phase array. +- **[FFTRandomPhase](fft/fftrandomphase/index.md)**: Randomise phase values. - **[FFT](fft/fft/index.md)**: Fast Fourier Transform. Takes a time-domain input, and generates a frequency-domain (FFT) output. - **[FFTFindPeaks](fft/fftfindpeaks/index.md)**: Find peaks in the FFT magnitude spectrum. Requires an FFT* input. - **[IFFT](fft/ifft/index.md)**: Inverse Fast Fourier Transform. Requires an FFT* input, generates a time-domain output. @@ -96,6 +98,7 @@ - **[ScaleLinLin](operators/scalelinlin/index.md)**: Scales the input from a linear range (between a and b) to a linear range (between c and d). - **[Subtract](operators/subtract/index.md)**: Subtract each sample of b from each sample of a. Can also be written as a - b - **[Sum](operators/sum/index.md)**: Sums the output of all of the input nodes, by sample. +- **[TimeShift](operators/timeshift/index.md)**: TimeShift - **[Sin](operators/sin/index.md)**: Outputs sin(a), per sample. - **[Cos](operators/cos/index.md)**: Outputs cos(a), per sample. - **[Tan](operators/tan/index.md)**: Outputs tan(a), per sample. diff --git a/docs/library/operators/channelarray/index.md b/docs/library/operators/channelarray/index.md index 74c96842..eeaafc40 100644 --- a/docs/library/operators/channelarray/index.md +++ b/docs/library/operators/channelarray/index.md @@ -11,3 +11,17 @@ ChannelArray() Takes an array of inputs and spreads them across multiple channels of output. +### Examples + +```python + +#------------------------------------------------------------------------------- +# Using ChannelArray to pan a low tone to the left and a high tone to the right. +#------------------------------------------------------------------------------- +low = TriangleOscillator(220) +high = TriangleOscillator(660) +panned = ChannelArray([low, high]) * 0.3 +panned.play() + +``` + diff --git a/docs/library/operators/index.md b/docs/library/operators/index.md index 7ca4f26f..820715eb 100644 --- a/docs/library/operators/index.md +++ b/docs/library/operators/index.md @@ -29,6 +29,7 @@ - **[ScaleLinLin](scalelinlin/index.md)**: Scales the input from a linear range (between a and b) to a linear range (between c and d). - **[Subtract](subtract/index.md)**: Subtract each sample of b from each sample of a. Can also be written as a - b - **[Sum](sum/index.md)**: Sums the output of all of the input nodes, by sample. +- **[TimeShift](timeshift/index.md)**: TimeShift - **[Sin](sin/index.md)**: Outputs sin(a), per sample. - **[Cos](cos/index.md)**: Outputs cos(a), per sample. - **[Tan](tan/index.md)**: Outputs tan(a), per sample. diff --git a/docs/library/oscillators/impulse/index.md b/docs/library/oscillators/impulse/index.md index 09377c3c..fd9da691 100644 --- a/docs/library/oscillators/impulse/index.md +++ b/docs/library/oscillators/impulse/index.md @@ -21,7 +21,7 @@ Produces a value of 1 at the given `frequency`, with output of 0 at all other ti clock = Impulse(1.0) osc = TriangleOscillator(250) envelope = ASREnvelope(0.01, 0.0, 0.5, 1.0, clock) -output = osc * envelope +output = StereoPanner(osc * envelope) output.play() ``` diff --git a/docs/library/oscillators/sawlfo/index.md b/docs/library/oscillators/sawlfo/index.md index 97e34ada..fb67d5c7 100644 --- a/docs/library/oscillators/sawlfo/index.md +++ b/docs/library/oscillators/sawlfo/index.md @@ -20,7 +20,8 @@ Produces a sawtooth LFO at the given `frequency` and `phase` offset, with output #------------------------------------------------------------------------------- lfo = SawLFO(1, 200, 1000) sine = SineOscillator(lfo) -sine.play() +output = StereoPanner(sine) * 0.5 +output.play() ``` diff --git a/docs/library/oscillators/sawoscillator/index.md b/docs/library/oscillators/sawoscillator/index.md index ab9370c5..7effa1a1 100644 --- a/docs/library/oscillators/sawoscillator/index.md +++ b/docs/library/oscillators/sawoscillator/index.md @@ -20,7 +20,7 @@ Produces a (non-band-limited) sawtooth wave, with the given `frequency` and `pha #------------------------------------------------------------------------------- saw = SawOscillator(440) envelope = ASREnvelope(0.05, 0.1, 0.5) -output = saw * envelope +output = StereoPanner(saw * envelope) * 0.5 output.play() ``` diff --git a/docs/library/oscillators/sinelfo/index.md b/docs/library/oscillators/sinelfo/index.md index 46c74cb8..732ace53 100644 --- a/docs/library/oscillators/sinelfo/index.md +++ b/docs/library/oscillators/sinelfo/index.md @@ -20,7 +20,8 @@ Produces a sinusoidal LFO at the given `frequency` and `phase` offset, with outp #------------------------------------------------------------------------------- lfo = SineLFO(1, 200, 1000) saw = SawOscillator(lfo) -saw.play() +output = StereoPanner(saw) * 0.3 +output.play() ``` diff --git a/docs/library/oscillators/sineoscillator/index.md b/docs/library/oscillators/sineoscillator/index.md index b39a3677..e6938abc 100644 --- a/docs/library/oscillators/sineoscillator/index.md +++ b/docs/library/oscillators/sineoscillator/index.md @@ -20,7 +20,7 @@ Produces a sine wave at the given `frequency`. #------------------------------------------------------------------------------- sine = SineOscillator(440) envelope = ASREnvelope(0.1, 0.1, 0.5) -output = sine * envelope +output = StereoPanner(sine * envelope) * 0.5 output.play() ``` diff --git a/docs/library/oscillators/squarelfo/index.md b/docs/library/oscillators/squarelfo/index.md index d5d523b8..69a2ac12 100644 --- a/docs/library/oscillators/squarelfo/index.md +++ b/docs/library/oscillators/squarelfo/index.md @@ -20,7 +20,8 @@ Produces a pulse wave LFO with the given `frequency` and pulse `width`, ranging #------------------------------------------------------------------------------- lfo = SquareLFO(1, 200, 400) sine = SineOscillator(lfo) -sine.play() +output = StereoPanner(sine) * 0.5 +output.play() ``` diff --git a/docs/library/oscillators/squareoscillator/index.md b/docs/library/oscillators/squareoscillator/index.md index 43d8076c..bc4d0275 100644 --- a/docs/library/oscillators/squareoscillator/index.md +++ b/docs/library/oscillators/squareoscillator/index.md @@ -20,7 +20,7 @@ Produces a pulse wave with the given `frequency` and pulse `width`, where `widt #------------------------------------------------------------------------------- square = SquareOscillator(440) envelope = ASREnvelope(0, 0.1, 0.5) -output = square * envelope +output = StereoPanner(square * envelope) * 0.5 output.play() ``` diff --git a/docs/library/oscillators/trianglelfo/index.md b/docs/library/oscillators/trianglelfo/index.md index b6f19469..db9d36d7 100644 --- a/docs/library/oscillators/trianglelfo/index.md +++ b/docs/library/oscillators/trianglelfo/index.md @@ -20,7 +20,8 @@ Produces a triangle LFO with the given `frequency` and `phase` offset, ranging f #----------------------------------------------------------------------------------- lfo = TriangleLFO(3, 200, 900) sine = SineOscillator(lfo) -sine.play() +output = StereoPanner(sine) * 0.5 +output.play() ``` diff --git a/docs/library/oscillators/triangleoscillator/index.md b/docs/library/oscillators/triangleoscillator/index.md index 90c914d6..f86b8ccd 100644 --- a/docs/library/oscillators/triangleoscillator/index.md +++ b/docs/library/oscillators/triangleoscillator/index.md @@ -20,7 +20,7 @@ Produces a triangle wave with the given `frequency`. #------------------------------------------------------------------------------- tri = TriangleOscillator(440) envelope = ASREnvelope(0.1, 0.1, 0.5) -output = tri * envelope +output = StereoPanner(tri * envelope) * 0.5 output.play() ``` diff --git a/docs/library/processors/delays/allpassdelay/index.md b/docs/library/processors/delays/allpassdelay/index.md index ac4ee275..1943eec3 100644 --- a/docs/library/processors/delays/allpassdelay/index.md +++ b/docs/library/processors/delays/allpassdelay/index.md @@ -11,3 +11,54 @@ AllpassDelay(input=0.0, delay_time=0.1, feedback=0.5, max_delay_time=0.5) All-pass delay, with `feedback` between 0 and 1. `delay_time` must be less than or equal to `max_delay_time`. +### Examples + +```python + +#------------------------------------------------------------------------------- +# Using AllpassDelay to add a delay effect to a simple melodic sequence. +# The original oscillator can be heard in the left channel. +# The delay effect can be heard in the right channel. +#------------------------------------------------------------------------------- +clock = Impulse(1.0) +sequence = Sequence([ 60, 62, 64, 65, 67, 69, 71, 72 ], clock) +frequency = MidiNoteToFrequency(sequence) + +oscillator = TriangleOscillator(frequency) +envelope = ASREnvelope(0, 0.2, 0.3, 1.0, clock) +voice = oscillator * envelope +delayed = AllpassDelay(input=voice, + delay_time=0.4, + feedback=0.8) + +output = ChannelArray([ voice, delayed ]) * 0.75 +output.play() + +``` + +```python + +#------------------------------------------------------------------------------- +# Using AllpassDelay to add a dreamy atmosphere to synth arpeggios +#------------------------------------------------------------------------------- +clock = Impulse(3.5) +Am7 = [ 67, 64, 60, 57 ] * 4 +D7 = [ 62, 66, 69, 72] * 4 +arpeggios = Am7 + D7 +sequence = Sequence(arpeggios, clock) +frequency = MidiNoteToFrequency(sequence) + +oscillator = SquareOscillator(frequency) +envelope = ASREnvelope(0.1, 0, 0.2, 1.0, clock) +voice = oscillator * envelope +filtered = SVFilter(voice, "low_pass", 4000, 0.3) +delayed = AllpassDelay(input=filtered, + delay_time=0.15, + feedback=0.8) + +pan = TriangleLFO(0.1, -1.0, 1.0) +output = StereoPanner(delayed, pan) * 0.5 +output.play() + +``` + diff --git a/docs/library/processors/delays/combdelay/index.md b/docs/library/processors/delays/combdelay/index.md index c15580ae..ef13f4f7 100644 --- a/docs/library/processors/delays/combdelay/index.md +++ b/docs/library/processors/delays/combdelay/index.md @@ -11,3 +11,29 @@ CombDelay(input=0.0, delay_time=0.1, feedback=0.5, max_delay_time=0.5) Comb delay, with `feedback` between 0 and 1. `delay_time` must be less than or equal to `max_delay_time`. +### Examples + +```python + +#------------------------------------------------------------------------------- +# Using CombDelay to change the character of a saw wave oscillator. +#------------------------------------------------------------------------------- +clock = Impulse(4) +arpeggio = [60, 62, 64, 66, 68, 70, + 72, 70, 68, 66, 64, 62] +sequence = Sequence(arpeggio, clock) +frequency = MidiNoteToFrequency(sequence) + +oscillator = SawOscillator(frequency) +envelope = ASREnvelope(0.1, 0, 0.2, 1.0, clock) +voice = oscillator * envelope +comb = CombDelay(input=voice, + delay_time=0.09, + feedback=0.6, + max_delay_time=0.9) + +output = StereoPanner(comb) * 0.5 +output.play() + +``` + diff --git a/docs/library/processors/delays/onetapdelay/index.md b/docs/library/processors/delays/onetapdelay/index.md index 9b917b2f..90803347 100644 --- a/docs/library/processors/delays/onetapdelay/index.md +++ b/docs/library/processors/delays/onetapdelay/index.md @@ -11,3 +11,49 @@ OneTapDelay(input=0.0, delay_time=0.1, max_delay_time=0.5) Single-tap delay line. `delay_time` must be less than or equal to `max_delay_time`. +### Examples + +```python + +#------------------------------------------------------------------------------- +# Using OneTapDelay to create a delay effect with no feedback. +# The original sound is heard in the left channel, and the delayed sound in the +# right channel. +#------------------------------------------------------------------------------- +clock = Impulse(1) +oscillator = TriangleOscillator(440) +envelope = ASREnvelope(0.001, 0, 0.3, 1.0, clock) +voice = oscillator * envelope +delayed = OneTapDelay(voice, 0.25) * 0.5 +output = ChannelArray([voice, delayed]) * 0.5 +output.play() + +``` + +```python + +#------------------------------------------------------------------------------- +# Using OneTapDelay to bring controlled rhythmic interest to a melodic sequence +#------------------------------------------------------------------------------- +clock = Impulse(3.5) +Dm = [ 62, 65, 69 ] * 2 +Bdim = [ 59, 62, 65 ] * 2 +Gm = [55, 58, 62 ] * 2 +Bb = [77, 74, 70 ] +A = [ 76, 73, 69 ] + +arpeggios = Dm + Bdim + Gm + Bb + A +sequence = Sequence(arpeggios, clock) +frequency = MidiNoteToFrequency(sequence) + +oscillator = SquareOscillator(frequency) +envelope = ASREnvelope(0.1, 0, 0.2, 1.0, clock) +voice = oscillator * envelope +filtered = SVFilter(voice, "low_pass", 4000, 0.3) +delayed = filtered + OneTapDelay(filtered, 0.4) * 0.5 + +output = StereoPanner(delayed) * 0.3 +output.play() + +``` + diff --git a/docs/library/processors/distortion/resample/index.md b/docs/library/processors/distortion/resample/index.md index 74798faf..14d02bd4 100644 --- a/docs/library/processors/distortion/resample/index.md +++ b/docs/library/processors/distortion/resample/index.md @@ -11,3 +11,17 @@ Resample(input=0, sample_rate=44100, bit_rate=16) Resampler and bit crusher. `sample_rate` is in Hz, `bit_rate` is an integer between 0 and 16. +### Examples + +```python + +#------------------------------------------------------------------------------- +# Using Resample to distort a sine wave. +#------------------------------------------------------------------------------- +sine = SineOscillator(440) +crushed = Resample(sine, 11025, 4) +output = StereoPanner(crushed) * 0.3 +output.play() + +``` + diff --git a/docs/library/processors/filters/eq/index.md b/docs/library/processors/filters/eq/index.md index cf687ea1..a0987654 100644 --- a/docs/library/processors/filters/eq/index.md +++ b/docs/library/processors/filters/eq/index.md @@ -11,3 +11,23 @@ EQ(input=0.0, low_gain=1.0, mid_gain=1.0, high_gain=1.0, low_freq=500, high_freq Three-band EQ. +### Examples + +```python + +#------------------------------------------------------------------------------- +# Using EQ to shape white noise. The low band (below 500Hz) is reduced. The mid +# band is boosted. The high band (above 2000Hz) is reduced drastically. +#------------------------------------------------------------------------------- +noise = WhiteNoise() +eq = EQ(input=noise, + low_gain=0.0, + mid_gain=1.5, + high_gain=0.2, + low_freq=1000, + high_freq=2000) +output = StereoPanner(eq) * 0.5 +output.play() + +``` + diff --git a/docs/library/processors/filters/svfilter/index.md b/docs/library/processors/filters/svfilter/index.md index 1f221196..d9a1fa43 100644 --- a/docs/library/processors/filters/svfilter/index.md +++ b/docs/library/processors/filters/svfilter/index.md @@ -11,3 +11,48 @@ SVFilter(input=0.0, filter_type=SIGNALFLOW_FILTER_TYPE_LOW_PASS, cutoff=440, res State variable filter. `filter_type` can be 'low_pass', 'band_pass', 'high_pass', 'notch', 'peak', 'low_shelf', 'high_shelf'. `resonance` should be between `[0..1]`. +### Examples + +```python + +#------------------------------------------------------------------------------- +# Using SVFilter as a low-pass filter on white noise. +#------------------------------------------------------------------------------- +noise = WhiteNoise() +filtered = SVFilter(input=noise, + filter_type="low_pass", + cutoff=1000, + resonance=0.6) +output = StereoPanner(filtered) +output.play() + +``` + +```python + +#------------------------------------------------------------------------------- +# Using SVFilter as a low-pass filter to reduce the harshness of a square wave +# oscillator. +#------------------------------------------------------------------------------- +clock = Impulse(3.5) +Am7 = [ 67, 64, 60, 57 ] * 4 +D7 = [ 62, 66, 69, 72] * 4 +arpeggios = Am7 + D7 +sequence = Sequence(arpeggios, clock) +frequency = MidiNoteToFrequency(sequence) + +oscillator = SquareOscillator(frequency) +envelope = ASREnvelope(0.1, 0, 0.2, 1.0, clock) +voice = oscillator * envelope +filtered = SVFilter(input=voice, + filter_type= "low_pass", + cutoff=4000, + resonance=0.3) +delayed = AllpassDelay(filtered, 0.15, 0.8, 0.5) + +pan = TriangleLFO(0.1, -1.0, 1.0) +output = StereoPanner(delayed, pan) * 0.3 +output.play() + +``` + diff --git a/docs/library/processors/panning/stereobalance/index.md b/docs/library/processors/panning/stereobalance/index.md index babb85bf..9e5e4c3a 100644 --- a/docs/library/processors/panning/stereobalance/index.md +++ b/docs/library/processors/panning/stereobalance/index.md @@ -11,3 +11,23 @@ StereoBalance(input=0, balance=0) Takes a stereo input and rebalances it, where `balance` of `0` is unchanged, `-1` is hard left, and `1` is hard right. +### Examples + +```python + +#------------------------------------------------------------------------------- +# Demonstrating the effects of StereoBalance. First a low tone is assigned to +# the left channel and a high tone is assigned to the right channel. +# Setting StereoBalance's balance value to 0.0 will mean both tones are heard +# equally. A value of -1.0 will result in only the left channel being heard. +# A value of 1.0 will result in only the right channel being heard. +# In this example, an LFO is modulating the balance value between -1.0 and 1.0. +#------------------------------------------------------------------------------- +low = TriangleOscillator(220) +high = TriangleOscillator(660) +panned = ChannelArray([low, high]) +balanced = StereoBalance(panned, TriangleLFO(0.2, -1, 1)) * 0.5 +balanced.play() + +``` + diff --git a/docs/library/processors/panning/stereopanner/index.md b/docs/library/processors/panning/stereopanner/index.md index cb30a219..e649d73b 100644 --- a/docs/library/processors/panning/stereopanner/index.md +++ b/docs/library/processors/panning/stereopanner/index.md @@ -11,3 +11,46 @@ StereoPanner(input=0, pan=0.0) Pans a mono input to a stereo output. `pan` should be between -1 (hard left) to +1 (hard right), with 0 = centre. +### Examples + +```python + +#------------------------------------------------------------------------------- +# Using StereoPanner to pan a low pitch to the left and a high pitch to the +# right. +#------------------------------------------------------------------------------- +low = TriangleOscillator(220) +high = TriangleOscillator(660) + +left = StereoPanner(low, -0.8) +right = StereoPanner(high, 0.8) + +output = (left + right) * 0.5 +output.play() + +``` + +```python + +#------------------------------------------------------------------------------- +# Using StereoPanner to repeatedly pan an arpeggiating oscillator between the +# left and right channels. +#------------------------------------------------------------------------------- +clock = Impulse(8.0) +CMaj7 = [ 60, 64, 67, 71, 74, 76 ] * 8 +FMaj9 = [ 65, 69, 72, 76, 77, 81 ] * 8 +arpeggios = CMaj7 + FMaj9 +sequence = Sequence(arpeggios, clock) +frequency = MidiNoteToFrequency(sequence) + +oscillator = TriangleOscillator(frequency) +release = Line(0.1, 0.5, 12, True) +envelope = ASREnvelope(0.0, 0.0, release, 1.0, clock) +voice = oscillator * envelope + +pan = SineLFO(0.1667, -1.0, 1.0) +output = StereoPanner(voice, pan) +output.play() + +``` + diff --git a/docs/library/processors/panning/stereowidth/index.md b/docs/library/processors/panning/stereowidth/index.md index cb3be16c..18f07a59 100644 --- a/docs/library/processors/panning/stereowidth/index.md +++ b/docs/library/processors/panning/stereowidth/index.md @@ -11,3 +11,18 @@ StereoWidth(input=0, width=1) Reduces the width of a stereo signal. When `width` = 1, input is unchanged. When `width` = 0, outputs a pair of identical channels both containing L+R. +### Examples + +```python + +#------------------------------------------------------------------------------- +# Using StereoWidth to continuously alter the width of a stereo signal. +#------------------------------------------------------------------------------- +low = TriangleOscillator(220) +high = TriangleOscillator(660) +panned = ChannelArray([low, high]) +width = StereoWidth(panned, TriangleLFO(0.5, 0, 1)) * 0.3 +width.play() + +``` + diff --git a/docs/library/stochastic/whitenoise/index.md b/docs/library/stochastic/whitenoise/index.md index 879008ac..0758cdd8 100644 --- a/docs/library/stochastic/whitenoise/index.md +++ b/docs/library/stochastic/whitenoise/index.md @@ -11,3 +11,44 @@ WhiteNoise(frequency=0.0, min=-1.0, max=1.0, interpolate=true, random_interval=t Generates whitenoise between min/max. If frequency is zero, generates at audio rate. For frequencies lower than audio rate, interpolate applies linear interpolation between values, and random_interval specifies whether new random values should be equally-spaced or randomly-spaced. +### Examples + +```python + +#------------------------------------------------------------------------------- +# Using white noise to control the pitch of an oscillator. +# A new pitch is determined once every second. Interpolation is turned off so +# that the oscillator jumps to the new pitch instead of smoothly moving to it. +# Random interval is turned off so that pitch changes occur at a regular rate. +#------------------------------------------------------------------------------- +frequency = WhiteNoise( frequency=1, + min=100, + max=1000, + interpolate=False, + random_interval=False) +oscillator = SineOscillator(frequency) +output = StereoPanner(oscillator) * 0.5 +output.play() + +``` + +```python + +#------------------------------------------------------------------------------- +# Using white noise to simulate the sound of wind. +# White noise is generated at audio rate and passed into a band-pass filter. +# The cutoff of the filter is controlled by another white noise generator, which +# generates a new value between 100 and 300 at randomly-spaced intervals every +# second, and smoothly interpolates between these values. +#------------------------------------------------------------------------------- +noise = WhiteNoise() +cutoff = WhiteNoise(1, 100, 300, True, True) +filtered = SVFilter(input=noise, + filter_type= "band_pass", + cutoff=cutoff, + resonance=0.8) +output = StereoPanner(filtered) * 0.5 +output.play() + +``` +