Skip to content

Commit

Permalink
Documentation: Requested changes and QOL improvements
Browse files Browse the repository at this point in the history
* Improving QOL for oscillator examples by making them stereo and reducing volume -- let me know if this should be done differently?
* Making formatting more consistent across examples
* For node classes with more arguments, explicitly typing them out to help the reader understand
  • Loading branch information
gregwht committed Feb 9, 2024
1 parent 27356fe commit e0b61be
Show file tree
Hide file tree
Showing 23 changed files with 70 additions and 63 deletions.
9 changes: 5 additions & 4 deletions docs/library/envelope/asrenvelope/example-1.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
# 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
Expand All @@ -16,12 +15,14 @@

oscillator = TriangleOscillator(frequency)
release = Line(0.1, 0.5, 6, True)
envelope= ASREnvelope(0.0, 0.0, release, 1.0, clock)
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()

graph.wait()
2 changes: 1 addition & 1 deletion docs/library/envelope/line/example-0.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
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()
graph.wait()
5 changes: 1 addition & 4 deletions docs/library/envelope/line/example-1.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
# 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
Expand All @@ -15,12 +14,10 @@

oscillator = TriangleOscillator(frequency)
release = Line(0.1, 0.5, 6, True)
envelope= ASREnvelope(0.0, 0.0, release, 1.0, clock)
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()

graph.wait()
2 changes: 1 addition & 1 deletion docs/library/oscillators/impulse/example-0.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
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()
graph.wait()
3 changes: 2 additions & 1 deletion docs/library/oscillators/sawlfo/example-0.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
#-------------------------------------------------------------------------------
lfo = SawLFO(1, 200, 1000)
sine = SineOscillator(lfo)
sine.play()
output = StereoPanner(sine) * 0.5
output.play()
graph.wait()
2 changes: 1 addition & 1 deletion docs/library/oscillators/sawoscillator/example-0.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
#-------------------------------------------------------------------------------
saw = SawOscillator(440)
envelope = ASREnvelope(0.05, 0.1, 0.5)
output = saw * envelope
output = StereoPanner(saw * envelope) * 0.5
output.play()
graph.wait()
3 changes: 2 additions & 1 deletion docs/library/oscillators/sinelfo/example-0.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
#-------------------------------------------------------------------------------
lfo = SineLFO(1, 200, 1000)
saw = SawOscillator(lfo)
saw.play()
output = StereoPanner(saw) * 0.3
output.play()
graph.wait()
2 changes: 1 addition & 1 deletion docs/library/oscillators/sineoscillator/example-0.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
#-------------------------------------------------------------------------------
sine = SineOscillator(440)
envelope = ASREnvelope(0.1, 0.1, 0.5)
output = sine * envelope
output = StereoPanner(sine * envelope) * 0.5
output.play()
graph.wait()
3 changes: 2 additions & 1 deletion docs/library/oscillators/squarelfo/example-0.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
#-------------------------------------------------------------------------------
lfo = SquareLFO(1, 200, 400)
sine = SineOscillator(lfo)
sine.play()
output = StereoPanner(sine) * 0.5
output.play()
graph.wait()
2 changes: 1 addition & 1 deletion docs/library/oscillators/squareoscillator/example-0.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
#-------------------------------------------------------------------------------
square = SquareOscillator(440)
envelope = ASREnvelope(0, 0.1, 0.5)
output = square * envelope
output = StereoPanner(square * envelope) * 0.5
output.play()
graph.wait()
3 changes: 2 additions & 1 deletion docs/library/oscillators/trianglelfo/example-0.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
#-----------------------------------------------------------------------------------
lfo = TriangleLFO(3, 200, 900)
sine = SineOscillator(lfo)
sine.play()
output = StereoPanner(sine) * 0.5
output.play()
graph.wait()
2 changes: 1 addition & 1 deletion docs/library/oscillators/triangleoscillator/example-0.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
#-------------------------------------------------------------------------------
tri = TriangleOscillator(440)
envelope = ASREnvelope(0.1, 0.1, 0.5)
output = tri * envelope
output = StereoPanner(tri * envelope) * 0.5
output.play()
graph.wait()
8 changes: 5 additions & 3 deletions docs/library/processors/delays/allpassdelay/example-0.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@
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)
envelope = ASREnvelope(0, 0.2, 0.3, 1.0, clock)
voice = oscillator * envelope

delayed = AllpassDelay(voice, 0.4, 0.8, 0.5)
delayed = AllpassDelay(input=voice,
delay_time=0.4,
feedback=0.8)

output = ChannelArray([ voice, delayed ]) * 0.75
output.play()
Expand Down
15 changes: 7 additions & 8 deletions docs/library/processors/delays/allpassdelay/example-1.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,21 @@
# 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 * 0.3
filtered = SVFilter(voice, SIGNALFLOW_FILTER_TYPE_LOW_PASS, 4000, 0.3)
delayed = AllpassDelay(filtered, 0.15, 0.8, 0.5)
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)
output = StereoPanner(delayed, pan) * 0.5
output.play()

graph.wait()
8 changes: 5 additions & 3 deletions docs/library/processors/delays/combdelay/example-0.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@
frequency = MidiNoteToFrequency(sequence)

oscillator = SawOscillator(frequency)
envelope= ASREnvelope(0.1, 0, 0.2, 1.0, clock)
envelope = ASREnvelope(0.1, 0, 0.2, 1.0, clock)
voice = oscillator * envelope

comb = CombDelay(voice, 0.09, 0.6, 0.9)
comb = CombDelay(input=voice,
delay_time=0.09,
feedback=0.6,
max_delay_time=0.9)

output = StereoPanner(comb) * 0.5
output.play()
Expand Down
9 changes: 6 additions & 3 deletions docs/library/processors/filters/eq/example-0.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@
# band is boosted. The high band (above 2000Hz) is reduced drastically.
#-------------------------------------------------------------------------------
noise = WhiteNoise()

eq = EQ(noise, 0.6, 1.5, 0.1, 500, 2000)

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()
graph.wait()
5 changes: 4 additions & 1 deletion docs/library/processors/filters/svfilter/example-0.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
# Using SVFilter as a low-pass filter on white noise.
#-------------------------------------------------------------------------------
noise = WhiteNoise()
filtered = SVFilter(noise, SIGNALFLOW_FILTER_TYPE_LOW_PASS, 1000, 0.6)
filtered = SVFilter(input=noise,
filter_type="low_pass",
cutoff=1000,
resonance=0.6)
output = StereoPanner(filtered)
output.play()
graph.wait()
12 changes: 6 additions & 6 deletions docs/library/processors/filters/svfilter/example-1.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,22 @@
# 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)
envelope = ASREnvelope(0.1, 0, 0.2, 1.0, clock)
voice = oscillator * envelope
filtered = SVFilter(voice, SIGNALFLOW_FILTER_TYPE_LOW_PASS, 4000, 0.3)
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)
output = StereoPanner(delayed, pan) * 0.3
output.play()

graph.wait()
15 changes: 5 additions & 10 deletions docs/library/processors/panning/stereobalance/example-0.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,16 @@
graph = AudioGraph()

#-------------------------------------------------------------------------------
# Demonstrating the effects of StereoBalance. Two tones are first panned hard
# left and hard right with StereoPanner.
# 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)

left = StereoPanner(low, -1.0)
right = StereoPanner(high, 1.0)
panned = (left + right)

balanced = StereoBalance(panned, -1.0)

panned = ChannelArray([low, high])
balanced = StereoBalance(panned, TriangleLFO(0.2, -1, 1)) * 0.5
balanced.play()
graph.wait()
2 changes: 0 additions & 2 deletions docs/library/processors/panning/stereopanner/example-0.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
# Using StereoPanner to pan a low pitch to the left and a high pitch to the
# right.
#-------------------------------------------------------------------------------

low = TriangleOscillator(220)
high = TriangleOscillator(660)

Expand All @@ -14,5 +13,4 @@

output = (left + right) * 0.5
output.play()

graph.wait()
5 changes: 1 addition & 4 deletions docs/library/processors/panning/stereopanner/example-1.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
# 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
Expand All @@ -15,12 +14,10 @@

oscillator = TriangleOscillator(frequency)
release = Line(0.1, 0.5, 12, True)
envelope= ASREnvelope(0.0, 0.0, release, 1.0, clock)
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()

graph.wait()
8 changes: 6 additions & 2 deletions docs/library/stochastic/whitenoise/example-0.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@
# 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(1, 100, 1000, False, False)
frequency = WhiteNoise( frequency=1,
min=100,
max=1000,
interpolate=False,
random_interval=False)
oscillator = SineOscillator(frequency)
output = StereoPanner(oscillator)
output = StereoPanner(oscillator) * 0.5
output.play()
graph.wait()
8 changes: 5 additions & 3 deletions docs/library/stochastic/whitenoise/example-1.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@
#-------------------------------------------------------------------------------
noise = WhiteNoise()
cutoff = WhiteNoise(1, 100, 300, True, True)

filtered = SVFilter(noise, SIGNALFLOW_FILTER_TYPE_BAND_PASS, cutoff, 0.8)
output = StereoPanner(filtered)
filtered = SVFilter(input=noise,
filter_type= "band_pass",
cutoff=cutoff,
resonance=0.8)
output = StereoPanner(filtered) * 0.5
output.play()
graph.wait()

0 comments on commit e0b61be

Please sign in to comment.