diff --git a/docs/library/control/mousedown/example-0.py b/docs/library/control/mousedown/example-0.py new file mode 100644 index 00000000..8675b485 --- /dev/null +++ b/docs/library/control/mousedown/example-0.py @@ -0,0 +1,11 @@ +from signalflow import * +graph = AudioGraph() + +#------------------------------------------------------------------------------- +# When the left mouse button is clicked, as detected by MouseDown(), an LFO is applied to the oscillator's frequency. +#------------------------------------------------------------------------------- +lfo = SineLFO(5, 100, 600) +frequency = If(MouseDown(), lfo, 100) +osc = TriangleOscillator(frequency) +osc.play() +graph.wait() \ No newline at end of file diff --git a/docs/library/control/mousedown/example-1.py b/docs/library/control/mousedown/example-1.py new file mode 100644 index 00000000..4da74c2c --- /dev/null +++ b/docs/library/control/mousedown/example-1.py @@ -0,0 +1,13 @@ +from signalflow import * +graph = AudioGraph() + +#------------------------------------------------------------------------------- +# A simple wobbling synthesiser controlled using the mouse. When the mouse is clicked, as detected by MouseDown(), an LFO is activated and affects the oscillator's frequency. MouseX position changes the rate of the LFO. MouseY position changes the upper frequency limit, affecting pitch. +#------------------------------------------------------------------------------- +rate = MouseX() * 10 +upper_limit = MouseY() * 1500 +lfo = SineLFO(rate, 100, upper_limit) +frequency = If(MouseDown(), lfo, 100) +osc = TriangleOscillator(frequency) +osc.play() +graph.wait() \ No newline at end of file diff --git a/docs/library/control/mousex/example-0.py b/docs/library/control/mousex/example-0.py new file mode 100644 index 00000000..f1ec1572 --- /dev/null +++ b/docs/library/control/mousex/example-0.py @@ -0,0 +1,11 @@ +from signalflow import * +graph = AudioGraph() + +#------------------------------------------------------------------------------- +# Using the MouseX position to change the rate of an LFO, which is modulating an oscillator's frequency +#------------------------------------------------------------------------------- +lfo_rate = MouseX() * 10 +frequency = SineLFO(lfo_rate, 100, 600) +osc = TriangleOscillator(frequency) +osc.play() +graph.wait() \ No newline at end of file diff --git a/docs/library/control/mousex/example-1.py b/docs/library/control/mousex/example-1.py new file mode 100644 index 00000000..4da74c2c --- /dev/null +++ b/docs/library/control/mousex/example-1.py @@ -0,0 +1,13 @@ +from signalflow import * +graph = AudioGraph() + +#------------------------------------------------------------------------------- +# A simple wobbling synthesiser controlled using the mouse. When the mouse is clicked, as detected by MouseDown(), an LFO is activated and affects the oscillator's frequency. MouseX position changes the rate of the LFO. MouseY position changes the upper frequency limit, affecting pitch. +#------------------------------------------------------------------------------- +rate = MouseX() * 10 +upper_limit = MouseY() * 1500 +lfo = SineLFO(rate, 100, upper_limit) +frequency = If(MouseDown(), lfo, 100) +osc = TriangleOscillator(frequency) +osc.play() +graph.wait() \ No newline at end of file diff --git a/docs/library/control/mousey/example-0.py b/docs/library/control/mousey/example-0.py new file mode 100644 index 00000000..031548d0 --- /dev/null +++ b/docs/library/control/mousey/example-0.py @@ -0,0 +1,10 @@ +from signalflow import * +graph = AudioGraph() + +#------------------------------------------------------------------------------- +# Using the MouseY position to change the frequency of an oscillator. +#------------------------------------------------------------------------------- +frequency = MouseY() * 1000 +osc = TriangleOscillator(frequency) +osc.play() +graph.wait() \ No newline at end of file diff --git a/docs/library/control/mousey/example-1.py b/docs/library/control/mousey/example-1.py new file mode 100644 index 00000000..4da74c2c --- /dev/null +++ b/docs/library/control/mousey/example-1.py @@ -0,0 +1,13 @@ +from signalflow import * +graph = AudioGraph() + +#------------------------------------------------------------------------------- +# A simple wobbling synthesiser controlled using the mouse. When the mouse is clicked, as detected by MouseDown(), an LFO is activated and affects the oscillator's frequency. MouseX position changes the rate of the LFO. MouseY position changes the upper frequency limit, affecting pitch. +#------------------------------------------------------------------------------- +rate = MouseX() * 10 +upper_limit = MouseY() * 1500 +lfo = SineLFO(rate, 100, upper_limit) +frequency = If(MouseDown(), lfo, 100) +osc = TriangleOscillator(frequency) +osc.play() +graph.wait() \ No newline at end of file diff --git a/docs/library/envelope/asrenvelope/example-0.py b/docs/library/envelope/asrenvelope/example-0.py new file mode 100644 index 00000000..179af9f9 --- /dev/null +++ b/docs/library/envelope/asrenvelope/example-0.py @@ -0,0 +1,11 @@ +from signalflow import * +graph = AudioGraph() + +#------------------------------------------------------------------------------- +# Using an ASR Envelope to shape a square wave oscillator +#------------------------------------------------------------------------------- +osc = SquareOscillator(500) +envelope = ASREnvelope(0.1, 0.0, 0.5) +output = osc * envelope +output.play() +graph.wait() diff --git a/docs/library/envelope/line/example-0.py b/docs/library/envelope/line/example-0.py new file mode 100644 index 00000000..55423b2e --- /dev/null +++ b/docs/library/envelope/line/example-0.py @@ -0,0 +1,12 @@ +from signalflow import * +graph = AudioGraph() + +#------------------------------------------------------------------------------- +# Using a line to control the gain of an oscillator, emulating a sidechain ducking effect. +#------------------------------------------------------------------------------- +clock = Impulse(frequency=1.0) +line = Line(0.0, 0.5, 1.0, 0, clock) +osc = SawOscillator(200) +output = osc * line +output.play() +graph.wait() \ No newline at end of file diff --git a/docs/library/oscillators/impulse/example-0.py b/docs/library/oscillators/impulse/example-0.py index 4a84be9e..c326cb2d 100644 --- a/docs/library/oscillators/impulse/example-0.py +++ b/docs/library/oscillators/impulse/example-0.py @@ -2,9 +2,11 @@ graph = AudioGraph() #------------------------------------------------------------------------------- -# Impulse generator producing an impulse every second (60bpm) +# Using an Impulse node as a clock to trigger an envelope once per second. #------------------------------------------------------------------------------- -impulse = Impulse(frequency=1.0) -output = impulse * 0.5 +clock = Impulse(1.0) +osc = TriangleOscillator(250) +envelope = ASREnvelope(0.01, 0.0, 0.5, 1.0, clock) +output = osc * envelope output.play() graph.wait() \ No newline at end of file diff --git a/docs/library/sequencing/clockdivider/example-0.py b/docs/library/sequencing/clockdivider/example-0.py new file mode 100644 index 00000000..fc1e0642 --- /dev/null +++ b/docs/library/sequencing/clockdivider/example-0.py @@ -0,0 +1,23 @@ +from signalflow import * +graph = AudioGraph() + +#------------------------------------------------------------------------------- +# Using a ClockDivider to create rhythms related to the main clock. Here the oscillator in the left channel is heard on every tick of the clock. The oscillator in the right channel is heard every 3 ticks of the clock. +#------------------------------------------------------------------------------- +clock = Impulse(2.0) +divided_clock = ClockDivider(clock, 3) + +oscillator_a = TriangleOscillator(220) +oscillator_b = TriangleOscillator(440) + +envelope_a = ASREnvelope(0.01, 0.0, 0.25, 1.0, clock) +envelope_b = ASREnvelope(0.01, 0.0, 0.5, 1.0, divided_clock) + +voice_a = oscillator_a * envelope_a +voice_b = oscillator_b * envelope_b + +left = StereoPanner(voice_a, -1.0) +right = StereoPanner(voice_b, 1.0) + +left.play() +right.play() \ No newline at end of file diff --git a/docs/library/sequencing/sequence/example-0.py b/docs/library/sequencing/sequence/example-0.py new file mode 100644 index 00000000..76d3af36 --- /dev/null +++ b/docs/library/sequencing/sequence/example-0.py @@ -0,0 +1,12 @@ +from signalflow import * +graph = AudioGraph() + +#------------------------------------------------------------------------------- +# Creating a sequence using the MIDI note values of a C Major scale, starting on middle C. +#------------------------------------------------------------------------------- +clock = Impulse(2.0) +sequence = Sequence([ 60, 62, 64, 65, 67, 69, 71, 72 ], clock) +frequency = MidiNoteToFrequency(sequence) +oscillator = TriangleOscillator(frequency) +oscillator.play() +graph.wait() \ No newline at end of file diff --git a/source/include/signalflow/node/buffer/buffer-player.h b/source/include/signalflow/node/buffer/buffer-player.h index 51ac9e94..3142993b 100644 --- a/source/include/signalflow/node/buffer/buffer-player.h +++ b/source/include/signalflow/node/buffer/buffer-player.h @@ -7,7 +7,7 @@ namespace signalflow /**--------------------------------------------------------------------------------* * Plays the contents of the given buffer. start_time/end_time are in seconds. - * When a clock signal is receives, rewinds to the start_time. + * When a clock signal is received, rewinds to the start_time. *---------------------------------------------------------------------------------*/ class BufferPlayer : public Node {