diff --git a/CMakeLists.txt b/CMakeLists.txt index d1aef9d5..419c58d9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -217,11 +217,6 @@ if (CMAKE_BUILD_PYTHON) if (CMAKE_SYSTEM_NAME STREQUAL "Windows") target_link_libraries(signalflow ${Python3_LIBRARIES}) endif() -else() - #------------------------------------------------------------------------------- - # Build examples - #------------------------------------------------------------------------------- - add_subdirectory("examples/cpp") endif() #------------------------------------------------------------------------------- diff --git a/examples/cpp/CMakeLists.txt b/examples/cpp/CMakeLists.txt deleted file mode 100644 index a1f0d48f..00000000 --- a/examples/cpp/CMakeLists.txt +++ /dev/null @@ -1,48 +0,0 @@ -set(EXAMPLES ${EXAMPLES} - audio-in-example.cpp - buffer-save-example.cpp - granulator-example.cpp - hello-world.cpp - index-example.cpp - json-load-example.cpp - sine-field-example.cpp - spooky-wobble.cpp - supersaw-example.cpp - patch-example.cpp - trigger-example.cpp - wavetable-2d-example.cpp - wavetable-example.cpp -) - -if (CMAKE_SYSTEM_NAME STREQUAL "Darwin") - set(EXAMPLES ${EXAMPLES} - mouse-control-example.cpp - ) -endif() - -if (VAMP) - set(EXAMPLES ${EXAMPLES} - vamp-input-example.cpp - ) -endif() - -foreach (EXAMPLE ${EXAMPLES}) - get_filename_component(EXAMPLE_NAME ${EXAMPLE} NAME_WE) - add_executable(${EXAMPLE_NAME} ${EXAMPLE}) - - #------------------------------------------------------------------------ - # Don't build examples in an examples subdirectory of build - #------------------------------------------------------------------------ - set_target_properties(${EXAMPLE_NAME} - PROPERTIES - RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR} - ) - target_link_libraries(${EXAMPLE_NAME} signalflow) -endforeach() - -if (WIN32 AND FFTW_BUILD_DIR) - file(COPY "${FFTW_BUILD_DIR}/libfftw3-3.dll" DESTINATION ${CMAKE_BINARY_DIR}) - file(COPY "${FFTW_BUILD_DIR}/libfftw3f-3.dll" DESTINATION ${CMAKE_BINARY_DIR}) - file(COPY "${FFTW_BUILD_DIR}/libfftw3l-3.dll" DESTINATION ${CMAKE_BINARY_DIR}) -endif() - diff --git a/examples/cpp/README.md b/examples/cpp/README.md deleted file mode 100644 index 8b813280..00000000 --- a/examples/cpp/README.md +++ /dev/null @@ -1,62 +0,0 @@ -# SignalFlow Examples - -**[audio-in-example.cpp](audio-in-example.cpp)** -Takes audio input from the default input device, records it to -a short buffer, and plays it back at variable rates. - -**[audio-write-example.cpp](audio-write-example.cpp)** -Demonstrates recording audio input (or any other synthesis node) -to a buffer, and saving the output to disk as a .wav file. - -**[fft-lpf-example.cpp](fft-lpf-example.cpp)** -Performs an FFT on an incoming signal, then passes it through -a frequency-domain brick wall filter, zeroing any bins beyond -the specified cutoff frequency. - -**[granulator-example.cpp](granulator-example.cpp)** -Demonstrates granular synthesis upon an audio buffer, with randomly -modulated position and length, and a user-specified grain envelope. - -**[hello-world.cpp](hello-world.cpp)** -The canonical 440hz sine wave example. - -**[index-example.cpp](index-example.cpp)** -Demonstrates using the `Index` node to retrieve indexed items -from a `std::vector`. Note that the first argument to Index is a -static property, not a node. - -**[json-load-example.cpp](json-load-example.cpp)** -Demonstrates loading a patch spec from a JSON graph description. -Optional pathname to a JSON file can be passed in argv. - -**[mouse-control-example.cpp](mouse-control-example.cpp)** -Demonstrates mapping the mouse cursor position to synthesis -parameters. Only available on macOS for now. - -**[sine-field-example.cpp](sine-field-example.cpp)** -An array of delayed sine pings. - -**[spooky-wobble.cpp](spooky-wobble.cpp)** -Tape-wobble effect with crackle. - -**[supersaw-example.cpp](supersaw-example.cpp)** -Demonstrates using Signal's multichannel expansion and mixdown -to create complex harmonics. - -**[patch-template-example.cpp](patch-template-example.cpp)** -Demonstrates the creation of a reusable graph of nodes, that can -be subsequently replicated for polyphonic output. - -**[trigger-example.cpp](trigger-example.cpp)** -Node triggers are discrete events that trigger a given behaviour -within a node. This example demonstrates using a trigger to -periodically reset the position of an envelope node. - -**[waveshaper-example.cpp](waveshaper-example.cpp)** -Demonstrates constructing a waveshaper buffer from a lambda function, -used to dynamically alter the timbre of an oscillator. - -**[wavetable-example.cpp](wavetable-example.cpp)** -Demonstrates using the `Wavetable` oscillator to generate periodic -waveforms from a fixed audio buffer. - diff --git a/examples/cpp/audio-in-example.cpp b/examples/cpp/audio-in-example.cpp deleted file mode 100644 index 02c5647b..00000000 --- a/examples/cpp/audio-in-example.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/*------------------------------------------------------------------------ - * Audio input example - * - * Takes audio input from the default input device, records it to - * a short buffer, and plays it back at variable rates. - * - * Make some noise when starting the patch. - *-----------------------------------------------------------------------*/ - -#include - -using namespace signalflow; - -int main() -{ - /*------------------------------------------------------------------------ - * Instantiate a global processing graph. - *-----------------------------------------------------------------------*/ - AudioGraphRef graph = new AudioGraph(); - - /*------------------------------------------------------------------------ - * Take a two-channel input from the default input device. - *-----------------------------------------------------------------------*/ - NodeRef input = new AudioIn(); - - /*------------------------------------------------------------------------ - * Create a one-second stereo buffer. - *-----------------------------------------------------------------------*/ - BufferRef buffer = new Buffer(2, graph->get_sample_rate() * 1.0); - - /*------------------------------------------------------------------------ - * Create a BufferRecorder to perform a one-shot recording of the input. - *-----------------------------------------------------------------------*/ - NodeRef recorder = new BufferRecorder(buffer, input); - graph->play(recorder); - - /*------------------------------------------------------------------------ - * Create a parallel series of BufferPlayers to play back the recording. - * Add a varispeed effect with interpolated WhiteNoise objects assigned to - * the sampler's rate input. - *-----------------------------------------------------------------------*/ - for (int i = 0; i < 5; i++) - { - NodeRef rate = new WhiteNoise(0.5, 0.3, 1.8, true); - NodeRef sampler = new BufferPlayer(buffer, rate, true); - - /*------------------------------------------------------------------------ - * Attenuate the output level so we don't distort. - *-----------------------------------------------------------------------*/ - graph->play(sampler * 0.2); - } - - graph->wait(); -} diff --git a/examples/cpp/buffer-save-example.cpp b/examples/cpp/buffer-save-example.cpp deleted file mode 100644 index 3b859f96..00000000 --- a/examples/cpp/buffer-save-example.cpp +++ /dev/null @@ -1,53 +0,0 @@ -/*------------------------------------------------------------------------ - * Buffer save example - * - * Demonstrates recording audio input (or any other synthesis node) - * to a buffer, and saving the output to disk as a .wav file. - *-----------------------------------------------------------------------*/ - -#include -#include -#include -#include - -using namespace signalflow; - -int main() -{ - /*------------------------------------------------------------------------ - * Instantiate the global processing graph. - *-----------------------------------------------------------------------*/ - AudioGraphRef graph = new AudioGraph(); - - /*------------------------------------------------------------------------ - * Take a two-channel input from the default input device. - *-----------------------------------------------------------------------*/ - NodeRef input = new AudioIn(); - - /*------------------------------------------------------------------------ - * Create a five-second stereo buffer. - *-----------------------------------------------------------------------*/ - BufferRef buffer = new Buffer(2, graph->get_sample_rate() * 5.0); - - /*------------------------------------------------------------------------ - * Create a BufferRecorder to perform a one-shot recording of the input. - * It must be connected to the graph's output to trigger processing. - *-----------------------------------------------------------------------*/ - NodeRef recorder = new BufferRecorder(buffer, input); - graph->add_node(recorder); - - NodeRef rms = new RMS(input); - graph->play(rms * 0.0); - rms->poll(5); - graph->start(); - - /*------------------------------------------------------------------------ - * Wait until our recording is complete (happening in the audio I/O - * thread), then save to disk. - *-----------------------------------------------------------------------*/ - std::cout << "Starting recording..." << std::endl; - std::this_thread::sleep_for(std::chrono::milliseconds(5000)); - std::cout << "Finished recording." << std::endl; - - buffer->save("out.wav"); -} diff --git a/examples/cpp/fft-lpf-example.cpp b/examples/cpp/fft-lpf-example.cpp deleted file mode 100644 index 308366ac..00000000 --- a/examples/cpp/fft-lpf-example.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/*------------------------------------------------------------------------ - * FFT brick-wall filter example. - * - * Performs an FFT on an incoming signal, then passes it through - * a frequency-domain brick wall filter, zeroing any bins beyond - * the specified cutoff frequency. - *-----------------------------------------------------------------------*/ -#include - -using namespace signalflow; - -int main() -{ - /*------------------------------------------------------------------------ - * Create the global signal processing graph. - *-----------------------------------------------------------------------*/ - AudioGraphRef graph = new AudioGraph(); - - /*------------------------------------------------------------------------ - * Load and play a sample. - *-----------------------------------------------------------------------*/ - BufferRef buffer = new Buffer("audio/gliss.aif"); - NodeRef sampler = new BufferPlayer(buffer, 1.0, true); - - /*------------------------------------------------------------------------ - * Perform FFT -> filter -> inverse FFT - *-----------------------------------------------------------------------*/ - NodeRef fft = new FFT(sampler); - NodeRef lpf = new FFTLPF(fft, 400); - NodeRef output = new IFFT(lpf); - - /*------------------------------------------------------------------------ - * Pan the output to centre of stereo field. - *-----------------------------------------------------------------------*/ - NodeRef pan = new StereoPanner(output); - - /*------------------------------------------------------------------------ - * Send to output. - *-----------------------------------------------------------------------*/ - graph->add_output(pan); - graph->start(); - graph->wait(); -} diff --git a/examples/cpp/granulator-example.cpp b/examples/cpp/granulator-example.cpp deleted file mode 100644 index e3ec5725..00000000 --- a/examples/cpp/granulator-example.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/*------------------------------------------------------------------------ - * Granulator example - * - * Demonstrates granular synthesis upon an audio buffer, with randomly - * modulated position and length, and a user-specified grain envelope. - *-----------------------------------------------------------------------*/ -#include - -/*------------------------------------------------------------------------ - * All objects are in the signal:: namespace. - * Import this namespace for code brevity. - *-----------------------------------------------------------------------*/ -using namespace signalflow; - -int main() -{ - /*------------------------------------------------------------------------ - * Instantiate a single AudioGraph object for all global audio processing. - *-----------------------------------------------------------------------*/ - AudioGraphRef graph = new AudioGraph(); - - /*------------------------------------------------------------------------ - * Load audio buffer - *-----------------------------------------------------------------------*/ - BufferRef buffer = new Buffer("audio/gliss.aif"); - - /*------------------------------------------------------------------------ - * RandomImpulse creates an impulse train with randomised interval, at a - * given mean frequency. This is used to trigger grains. - *-----------------------------------------------------------------------*/ - NodeRef dust = new RandomImpulse(100.0); - - /*------------------------------------------------------------------------ - * Set position, length and pan to oscillating randomised values. - *-----------------------------------------------------------------------*/ - NodeRef pos = new WhiteNoise(0.3, 0, buffer->get_duration(), false); - NodeRef len = new WhiteNoise(100, 0.1, 0.5, false); - NodeRef pan = new WhiteNoise(100, -1, 1, false); - - /*------------------------------------------------------------------------ - * Create a granulator object with Hanning envelope applies to grains. - *-----------------------------------------------------------------------*/ - NodeRef granulator = new Granulator(buffer, dust, pos, len); - BufferRef env_buf = new EnvelopeBuffer(SIGNALFLOW_BUFFER_HANNING); - - granulator->set_input("pan", pan); - granulator->set_buffer("envelope", env_buf); - granulator = granulator * 0.25; - - /*------------------------------------------------------------------------ - * The AudioGraph can have multiple inputs, summed to output. - * Add the granulator as its only output. - *-----------------------------------------------------------------------*/ - graph->play(granulator); - - /*------------------------------------------------------------------------ - * Loop forever. - *-----------------------------------------------------------------------*/ - graph->wait(); -} diff --git a/examples/cpp/hello-world.cpp b/examples/cpp/hello-world.cpp deleted file mode 100644 index c222202f..00000000 --- a/examples/cpp/hello-world.cpp +++ /dev/null @@ -1,36 +0,0 @@ -/*------------------------------------------------------------------------ - * Hello, world. - * - * The canonical 440hz sine wave example. - *-----------------------------------------------------------------------*/ - -#include - -/*------------------------------------------------------------------------ - * All objects are in the signalflow:: namespace. - * Import this namespace for code brevity. - *-----------------------------------------------------------------------*/ -using namespace signalflow; - -int main() -{ - /*------------------------------------------------------------------------ - * Instantiate a single AudioGraph object for global audio processing. - *-----------------------------------------------------------------------*/ - AudioGraphRef graph = new AudioGraph(); - - /*------------------------------------------------------------------------ - * Create a sine wave oscillator at 440Hz. - *-----------------------------------------------------------------------*/ - NodeRef sine = new SineOscillator(440); - - /*------------------------------------------------------------------------ - * Begin playing the oscillator. - *-----------------------------------------------------------------------*/ - graph->play(sine); - - /*------------------------------------------------------------------------ - * Run indefinitely. - *-----------------------------------------------------------------------*/ - graph->wait(); -} diff --git a/examples/cpp/index-example.cpp b/examples/cpp/index-example.cpp deleted file mode 100644 index 2fa5a562..00000000 --- a/examples/cpp/index-example.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/*------------------------------------------------------------------------ - * Index example - * - * Demonstrates using the `Index` node to retrieve indexed items - * from a `std::vector`. Note that the first argument to Index is a - * static property, not a node. - *-----------------------------------------------------------------------*/ - -#include - -#include - -using namespace signalflow; - -int main() -{ - AudioGraphRef graph = new AudioGraph(); - - /*------------------------------------------------------------------------ - * Create a list of frequencies to iterate over - *-----------------------------------------------------------------------*/ - std::vector freqs = { 60, 120, 180, 240, 300, 360, 420, 480 }; - - /*------------------------------------------------------------------------ - * Create a pair of sawtooth waves, scaled between 0..8, used to index - * over the array. The SawOscillator nodes are output over consecutive channels. - * - * Index casts the `index` inputs to an integer, used to select the - * output frequency. Via automatic channel upmixing, this creates - * two parallel counters, phasing gradually against each other. - *-----------------------------------------------------------------------*/ - NodeRef saw = new SawLFO({ 1, 0.97 }, 0, 8); - NodeRef index = new Index(freqs, saw); - - /*------------------------------------------------------------------------ - * Use the resultant values as frequency parameters of a SineOscillator node, - * with a time-synced pair of TriangleOscillator waves to act as envelopes. - *-----------------------------------------------------------------------*/ - NodeRef sine = new SineOscillator(index); - NodeRef envelope = new TriangleLFO({ 8.0, 7.76 }, 0, 1); - sine = sine * envelope; - - /*------------------------------------------------------------------------ - * Reduce the stereo width slightly to increase the interaction between - * L / R channels. - *-----------------------------------------------------------------------*/ - NodeRef width = new StereoWidth(sine, 0.5); - - graph->play(width); - graph->wait(); -} diff --git a/examples/cpp/json-load-example.cpp b/examples/cpp/json-load-example.cpp deleted file mode 100644 index d1d6ceac..00000000 --- a/examples/cpp/json-load-example.cpp +++ /dev/null @@ -1,41 +0,0 @@ -/*------------------------------------------------------------------------ - * JSON load example - * - * Demonstrates loading a patch spec from a JSON graph description. - * Optional pathname to a JSON file can be passed in argv. - *-----------------------------------------------------------------------*/ - -#include - -using namespace signalflow; - -int main(int argc, char **argv) -{ - AudioGraphRef graph = new AudioGraph(); - graph->poll(1); - - /*------------------------------------------------------------------------ - * A PatchSpec contains a description of a synthesis graph. - * It takes a short human-readable name, drawn from [0-9a-zA-Z_-] - *-----------------------------------------------------------------------*/ - PatchSpecRef spec = new PatchSpec(); - - /*------------------------------------------------------------------------ - * ->load() parses the specified JSON file and creates a graph - * definition from it. - *-----------------------------------------------------------------------*/ - if (argc > 1) - spec->load(argv[1]); - else - spec->load("synths/sine-env-delay.json"); - - /*------------------------------------------------------------------------ - * Instantiate a patch using this spec. - * TODO: Instantiate two synths with different frequencies/pans. - *-----------------------------------------------------------------------*/ - PatchRef patch = new Patch(spec); - graph->play(patch); - graph->wait(); - - return 0; -} diff --git a/examples/cpp/mouse-control-example.cpp b/examples/cpp/mouse-control-example.cpp deleted file mode 100644 index 20703ec1..00000000 --- a/examples/cpp/mouse-control-example.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/*------------------------------------------------------------------------ - * Mouse control example - * - * Demonstrates mapping the mouse cursor position to synthesis - * parameters. Only available on macOS for now. - *-----------------------------------------------------------------------*/ -#include - -/*------------------------------------------------------------------------ - * All objects are in the signal:: namespace. - * Import this namespace for code brevity. - *-----------------------------------------------------------------------*/ -using namespace signalflow; - -int main() -{ - /*------------------------------------------------------------------------ - * Instantiate a global processing graph. - *-----------------------------------------------------------------------*/ - AudioGraphRef graph = new AudioGraph(); - - /*------------------------------------------------------------------------ - * Read an audio sample. - *-----------------------------------------------------------------------*/ - BufferRef buffer = new Buffer("audio/jurassic-park-mono.wav"); - - /*------------------------------------------------------------------------ - * The MouseX and MouseY objects give live mouse position data, - * normalised to [0, 1]. - *-----------------------------------------------------------------------*/ - NodeRef mousex = new MouseX(); - NodeRef mousey = new MouseY(); - mousex->poll(2); - mousey->poll(2); - - /*------------------------------------------------------------------------ - * Use the MouseX to determine the position within a sample for - * granulation, plus noise to prevent the machine-gun effect. - *-----------------------------------------------------------------------*/ - NodeRef noise = new WhiteNoise(); - NodeRef pos = (mousex * buffer->get_duration()) + noise.scale(-1.0, 1.0); - - /*------------------------------------------------------------------------ - * Create Granulator object, with 50 grains per second. - * MouseY determines the playback rate. - *-----------------------------------------------------------------------*/ - NodeRef granulator = new Granulator(buffer, new Impulse(50), pos, 0.2, mousey * 2.0); - granulator->set_input("max_grains", 50); - graph->play(granulator * 0.2); - graph->wait(); -} diff --git a/examples/cpp/patch-example.cpp b/examples/cpp/patch-example.cpp deleted file mode 100644 index 629b7175..00000000 --- a/examples/cpp/patch-example.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/*------------------------------------------------------------------------ - * Patch template example - * - * Demonstrates the creation of a reusable graph of nodes, that can - * be subsequently replicated for polyphonic output. - *-----------------------------------------------------------------------*/ - -#include - -#include -#include - -using namespace signalflow; - -PatchSpecRef create_synth() -{ - /*------------------------------------------------------------------------ - * Create a new PatchTemplate - *-----------------------------------------------------------------------*/ - PatchRef patch = new Patch(); - - /*------------------------------------------------------------------------ - * Create a named input that can be used to modulate parameters of - * the patch. - *-----------------------------------------------------------------------*/ - NodeRef freq = patch->add_input("freq", 440.0); - NodeRef width = patch->add_input("width", 0.5); - NodeRef pan = patch->add_input("pan", 0.0); - NodeRef square = patch->add_node(new SquareOscillator(freq, width)); - NodeRef asr = patch->add_node(new ASREnvelope(0.0, 0.0, 1.3)); - NodeRef shaped = patch->add_node(square * asr * 0.05); - NodeRef stereo = patch->add_node(new StereoPanner(shaped, pan)); - NodeRef delay = new CombDelay(stereo, 0.1, 0.9, 0.5); - NodeRef output = stereo + delay * 0.3; - patch->set_output(output); - - PatchSpecRef ref = patch->to_spec(); - return ref; -} - -int main() -{ - AudioGraphRef graph = new AudioGraph(); - - PatchSpecRef spec = create_synth(); - spec->print(); - - graph->start(); - graph->poll(2); - - std::set synths; - - while (true) - { - float freq = 100 * int(powf(8, random_uniform(0, 1))); - PatchRef patch = new Patch(spec, { { "freq", freq }, { "width", random_uniform(0.3, 0.7) } }); - synths.insert(patch); - patch->set_auto_free(true); - graph->play(patch); - std::this_thread::sleep_for(std::chrono::milliseconds(1000)); - } - - return 0; -} diff --git a/examples/cpp/sine-field-example.cpp b/examples/cpp/sine-field-example.cpp deleted file mode 100644 index 80239751..00000000 --- a/examples/cpp/sine-field-example.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/*------------------------------------------------------------------------ - * SineOscillator field example - * - * An array of delayed sine pings. - *-----------------------------------------------------------------------*/ - -#include - -using namespace signalflow; - -int main() -{ - /*------------------------------------------------------------------------ - * Create the global processing graph and begin playback. - *-----------------------------------------------------------------------*/ - AudioGraphRef graph = new AudioGraph(); - - /*------------------------------------------------------------------------ - * Create a bank of sine bleeps. - *-----------------------------------------------------------------------*/ - for (int x = 0; x < 32; x++) - { - NodeRef sine = new SineOscillator(random_uniform(220, 1660)); - NodeRef resample = new Resample(sine, 11025, 12); - NodeRef noise = new WhiteNoise(0.3, 1.0, 2); - NodeRef dust = new RandomImpulse(noise); - NodeRef env = new ASREnvelope(0.005, 0.01, 0.05); - env->set_input("clock", dust); - - NodeRef sum = resample * env; - NodeRef pan = new StereoPanner(sum * 0.1, random_uniform(-1, 1)); - NodeRef delay = new CombDelay(pan, 0.2, 0.4); - graph->play(delay); - } - - /*------------------------------------------------------------------------ - * Run forever. - *-----------------------------------------------------------------------*/ - graph->wait(); -} diff --git a/examples/cpp/spooky-wobble.cpp b/examples/cpp/spooky-wobble.cpp deleted file mode 100644 index 49cf49a1..00000000 --- a/examples/cpp/spooky-wobble.cpp +++ /dev/null @@ -1,41 +0,0 @@ -/*------------------------------------------------------------------------ - * Spooky Wobble - * - * Tape-wobble effect with crackle. - *-----------------------------------------------------------------------*/ - -#include - -using namespace signalflow; - -int main() -{ - AudioGraphRef graph = new AudioGraph(); - - /*------------------------------------------------------------------------ - * Load in a sample and play it back at a varying rate. - *-----------------------------------------------------------------------*/ - BufferRef buffer = new Buffer("audio/gliss.aif"); - NodeRef sampler = new BufferPlayer(buffer, new WhiteNoise(0.3, true), true); - NodeRef sampler_pan = new StereoPanner(sampler, -0.5); - graph->play(sampler_pan); - - /*------------------------------------------------------------------------ - * Add some gentle crackle. - *-----------------------------------------------------------------------*/ - NodeRef noise = new WhiteNoise(50, true); - NodeRef noise_pan = new StereoPanner(noise, 0.5); - graph->play(noise_pan); - - /*------------------------------------------------------------------------ - * Add some occasional pops. - *-----------------------------------------------------------------------*/ - NodeRef dust = new RandomImpulse(1); - NodeRef dust_pan = new StereoPanner(dust, 0.0); - graph->play(dust_pan); - - /*------------------------------------------------------------------------ - * Loop indefinitely. - *-----------------------------------------------------------------------*/ - graph->wait(); -} diff --git a/examples/cpp/supersaw-example.cpp b/examples/cpp/supersaw-example.cpp deleted file mode 100644 index 492e74de..00000000 --- a/examples/cpp/supersaw-example.cpp +++ /dev/null @@ -1,44 +0,0 @@ -/*------------------------------------------------------------------------ - * Supersaw example: - * - * Demonstrates using Signal's multichannel expansion and mixdown - * to create complex harmonics. - *-----------------------------------------------------------------------*/ - -#include - -using namespace signalflow; - -int main() -{ - /*------------------------------------------------------------------------ - * Create a global AudioGraph object - *-----------------------------------------------------------------------*/ - AudioGraphRef graph = new AudioGraph(); - - /*------------------------------------------------------------------------ - * Create 6 mono channels of sawtooth with varying frequencies. - * This is shorthand for: - * - * NodeRef multiplex = new ChannelArray({ 58.3, 59.1, 60.0, 60.3, 60.5 }); - * NodeRef saw = new SawOscillator(multiplex); - *-----------------------------------------------------------------------*/ - NodeRef saw = new SawOscillator({ 58.3, 59.1, 60.0, 60.3, 60.5 }); - - /*------------------------------------------------------------------------ - * ChannelMixer up-mixes or down-mixes between different numbers of channels. - * Downmixing 6 channels to 2 creates a stereo spread of six sawtooths - * between the L and R speaker. - *-----------------------------------------------------------------------*/ - NodeRef mix = new ChannelMixer(2, saw); - - /*------------------------------------------------------------------------ - * To add some life, add a resonant filter with wandering cutoff - *-----------------------------------------------------------------------*/ - NodeRef sine = new SineOscillator(0.1); - NodeRef cutoff = sine.scale(200, 8000); - NodeRef moog = new MoogVCF(mix, cutoff, 2); - - graph->play(moog); - graph->wait(); -} diff --git a/examples/cpp/trigger-example.cpp b/examples/cpp/trigger-example.cpp deleted file mode 100644 index a23e6cb9..00000000 --- a/examples/cpp/trigger-example.cpp +++ /dev/null @@ -1,44 +0,0 @@ -/*------------------------------------------------------------------------ - * Trigger example - * - * Node triggers are discrete events that trigger a given behaviour - * within a node. This example demonstrates using a trigger to - * periodically reset the position of an envelope node. - *-----------------------------------------------------------------------*/ - -#include - -#include -#include -#include - -using namespace signalflow; - -int main() -{ - AudioGraphRef graph = new AudioGraph(); - - /*------------------------------------------------------------------------ - * Create a simple envelope-modulated triangle wave. - *-----------------------------------------------------------------------*/ - NodeRef triangle = new TriangleOscillator(1000); - NodeRef envelope = new ASREnvelope(0.01, 0.0, 0.1); - NodeRef output = triangle * envelope; - - /*------------------------------------------------------------------------ - * Pan the output across the stereo field. - *-----------------------------------------------------------------------*/ - NodeRef panned = new StereoPanner(output); - - graph->play(panned); - - while (true) - { - /*------------------------------------------------------------------------ - * Periodically, retrigger the envelope, panned to a random location. - *-----------------------------------------------------------------------*/ - std::this_thread::sleep_for(std::chrono::milliseconds(random_integer(10, 1000))); - panned->set_input("pan", random_uniform(-1, 1)); - envelope->trigger(); - } -} diff --git a/examples/cpp/vamp-input-example.cpp b/examples/cpp/vamp-input-example.cpp deleted file mode 100644 index 1c278054..00000000 --- a/examples/cpp/vamp-input-example.cpp +++ /dev/null @@ -1,29 +0,0 @@ -/*------------------------------------------------------------------------ - * Vamp example - * - * Uses the Vamp audio analysis framework to extract features from - * the audio input. - * - * SignalFlow must be compiled with Vamp support. - * - * Docs: - * https://www.vamp-plugins.org/plugin-doc/vamp-example-plugins.html - *-----------------------------------------------------------------------*/ - -#include - -using namespace signalflow; - -int main() -{ - AudioGraphRef graph = new AudioGraph(); - NodeRef input = new AudioIn(); - NodeRef centroid = new VampAnalysis(input, "vamp:vamp-example-plugins:spectralcentroid:linearcentroid"); - - centroid->poll(10, "centroid"); - - NodeRef sine = new SineOscillator(centroid); - - graph->play(sine); - graph->wait(); -} diff --git a/examples/cpp/waveshaper-example.cpp b/examples/cpp/waveshaper-example.cpp deleted file mode 100644 index 9886d88e..00000000 --- a/examples/cpp/waveshaper-example.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/*------------------------------------------------------------------------ - * Waveshaper example - * - * Demonstrates constructing a waveshaper buffer from a lambda function, - * used to dynamically alter the timbre of an oscillator. - *-----------------------------------------------------------------------*/ -#include - -using namespace signalflow; - -int main() -{ - /*------------------------------------------------------------------------ - * Create the global signal processing graph. - *-----------------------------------------------------------------------*/ - AudioGraphRef graph = new AudioGraph(); - - /*------------------------------------------------------------------------ - * Create a stereo pair of oscillating sine waves, an octave apart. - *-----------------------------------------------------------------------*/ - NodeRef sine = new SineOscillator({ 40, 80 }); - - /*------------------------------------------------------------------------ - * Create a WaveShaperBuffer and populate it with a cubic function. - * WaveShaperBuffer is a subclass of Buffer that is optimised for - * mapping a sample value [-1, 1] to a new sample value [-1, 1]. - *-----------------------------------------------------------------------*/ - BufferRef buffer = new WaveShaperBuffer(); - buffer->fill([](float input) { return input * input * input; }); - - /*------------------------------------------------------------------------ - * The WaveShaper node takes an input audio node and a WaveShaperBuffer. - * Distort the input by multiplying it to exceed [-1, 1]. - * WaveShaper will clip this to [-1, 1] (as well as mapping the samples - * based on the buffer's cubic function). - *-----------------------------------------------------------------------*/ - NodeRef overdriven = sine * new WhiteNoise(0.2, 1, 3, true); - NodeRef shaper = new WaveShaper(overdriven, buffer); - - /*------------------------------------------------------------------------ - * Add some delay and stereo width modulation. - *-----------------------------------------------------------------------*/ - NodeRef delay = new CombDelay(shaper, 0.5, 0.5, 0.5); - NodeRef width = new SineOscillator(0.2); - NodeRef throb = new StereoWidth(delay, width.scale(0.5, 1)); - - /*------------------------------------------------------------------------ - * Send to output and start processing. - *-----------------------------------------------------------------------*/ - graph->play(throb); - graph->wait(); -} diff --git a/examples/cpp/wavetable-2d-example.cpp b/examples/cpp/wavetable-2d-example.cpp deleted file mode 100644 index c6088c55..00000000 --- a/examples/cpp/wavetable-2d-example.cpp +++ /dev/null @@ -1,50 +0,0 @@ -/*------------------------------------------------------------------------ - * Wavetable example - * - * Demonstrates using the `Wavetable` oscillator to generate periodic - * waveforms from a fixed audio buffer. - *-----------------------------------------------------------------------*/ -#include -#include - -using namespace signalflow; - -int main() -{ - AudioGraphRef graph = new AudioGraph(); - - int wavetable_size = 4096; - - std::vector> wt(1); - wt[0] = std::vector(wavetable_size); - for (int i = 0; i < wavetable_size; i++) - { - wt[0][i] = sin(i * M_PI * 2 / wavetable_size); - } - BufferRef bufferA = new Buffer(1, wavetable_size, wt); - - std::vector> wt2(1); - wt2[0] = std::vector(wavetable_size); - for (int i = 0; i < wavetable_size; i++) - { - if (i < wavetable_size / 2) - wt2[0][i] = -1; - else - wt2[0][i] = 1; - } - BufferRef bufferB = new Buffer(1, wavetable_size, wt2); - - std::vector buffers({ bufferA, bufferB }); - BufferRef2D buffer2D = new Buffer2D(buffers); - NodeRef morph = new SawOscillator(2.0); - morph = morph * 0.5 + 0.5; - - float freq = 50.0; - NodeRef wavetable2D = new Wavetable2D(buffer2D, freq, 1.0); - NodeRef delay = new CombDelay(wavetable2D, 0.1, 0.3); - - NodeRef pan = new StereoPanner(delay); - - graph->play(pan); - graph->wait(); -} diff --git a/examples/cpp/wavetable-example.cpp b/examples/cpp/wavetable-example.cpp deleted file mode 100644 index 5bccd636..00000000 --- a/examples/cpp/wavetable-example.cpp +++ /dev/null @@ -1,36 +0,0 @@ -/*------------------------------------------------------------------------ - * Wavetable example - * - * Demonstrates using the `Wavetable` oscillator to generate periodic - * waveforms from a fixed audio buffer. - *-----------------------------------------------------------------------*/ -#include -#include - -using namespace signalflow; - -int main() -{ - AudioGraphRef graph = new AudioGraph(); - - NodeRef freq = new WhiteNoise(2.0, 140, 800, true); - freq = new RoundToScale(freq); - - int wavetable_size = 4096; - std::vector> wt(1); - wt[0] = std::vector(wavetable_size); - for (int i = 0; i < wavetable_size; i++) - { - wt[0][i] = sin(i * M_PI * 2 / wavetable_size); - } - BufferRef buffer = new Buffer(1, wavetable_size, wt); - NodeRef wavetable = new Wavetable(buffer, freq * 2.0); - NodeRef delay = new CombDelay(wavetable, 0.1, 0.3); - - NodeRef pan = new StereoPanner(delay); - - NodeRef attenuated = pan * 0.2; - graph->play(attenuated); - - graph->wait(); -}