### Example Graph Source: https://docs.rs/crate/fundsp/0.20.0 An example of a fundsp audio graph. ```rust noise() & constant(440.0) >> sine() ``` -------------------------------- ### Build Log - Docker Start and Output Source: https://docs.rs/crate/fundsp/0.20.0/builds/1379849/i686-unknown-linux-gnu.txt The output from starting the docker container and the build process, including warnings about unscraped examples and target filters. ```text [INFO] running `Command { std: "docker" "start" "-a" "b89039557fe1b3560ab78c648fc82d9b6fc6bfb6982518b6760f730cde7b8f1b", kill_on_drop: false }` [INFO] [stderr] warning: Rustdoc did not scrape the following examples because they require dev-dependencies: beep, file, grain, grain2, keys, live_adsr, network, optimize, peek, plot, sequence, type [INFO] [stderr] If you want Rustdoc to scrape these examples, then add `doc-scrape-examples = true` [INFO] [stderr] to the [[example]] target configuration of at least one example. [INFO] [stderr] warning: target filter specified, but no targets matched; this is a no-op [INFO] [stderr] Documenting fundsp v0.20.0 (/opt/rustwide/workdir) [INFO] [stderr] Finished `dev` profile [unoptimized + debuginfo] target(s) in 2.00s [INFO] [stderr] Generated /opt/rustwide/target/i686-unknown-linux-gnu/doc/fundsp/index.html ``` -------------------------------- ### Sequencer component example Source: https://docs.rs/crate/fundsp/0.20.0 Creating a stereo sequencer. ```rust use fundsp::hacker::*; // Create stereo sequencer. // The first argument should be set true if we want to replay events after `reset`. let mut sequencer = Sequencer::new(false, 2); ``` -------------------------------- ### Build Log - Docker Start and Output Source: https://docs.rs/crate/fundsp/0.20.0/builds/1920853/x86_64-unknown-linux-gnu.txt Information about starting the docker container and its standard output. ```text [INFO] running `Command { std: "docker" "start" "-a" "ff22f8475628bb5eec5b72c1c88c3cb68620e01328899e3aa268eeaeb8f035ae", kill_on_drop: false }` [INFO] [stderr] warning: Rustdoc did not scrape the following examples because they require dev-dependencies: beep, file, grain, grain2, keys, live_adsr, network, optimize, peek, plot, sequence, type [INFO] [stderr] If you want Rustdoc to scrape these examples, then add `doc-scrape-examples = true` [INFO] [stderr] to the [[example]] target configuration of at least one example. [INFO] [stderr] warning: target filter specified, but no targets matched; this is a no-op [INFO] [stderr] Documenting fundsp v0.20.0 (/opt/rustwide/workdir) [INFO] [stderr] Finished `dev` profile [unoptimized + debuginfo] target(s) in 1.76s [INFO] [stderr] Generated /opt/rustwide/target/x86_64-unknown-linux-gnu/doc/fundsp/index.html ``` -------------------------------- ### Build Log - Docker Start Command Source: https://docs.rs/crate/fundsp/0.20.0/builds/1379849/i686-pc-windows-msvc.txt The command to start the docker container for the build process. ```text [INFO] running `Command { std: "docker" "start" "-a" "81411a5f284ac3b1290c26cc79ac9e4fae15e16bdc5726c52d35ccac7357565d", kill_on_drop: false } ``` -------------------------------- ### Sequencer component example with events Source: https://docs.rs/crate/fundsp/0.20.0 Adding new events to the sequencer with specified start and stop times, fade-in, and fade-out envelopes. ```rust // Add a new event with start time 1.0 seconds and end time 2.0 seconds. // Fade-in time is 0.1 seconds, while the fade-out time is 0.2 seconds. // This returns an `EventId`. let id1 = sequencer.push(1.0, 2.0, Fade::Smooth, 0.1, 0.2, Box::new(noise() | noise())); // Add a new event that starts immediately and plays indefinitely. let id2 = sequencer.push_relative(0.0, f64::INFINITY, Fade::Smooth, 0.1, 0.2, Box::new(pink() | pink())); ``` -------------------------------- ### Net component example Source: https://docs.rs/crate/fundsp/0.20.0 Dynamically building `dc(220.0) >> sine()` using `Net`. ```rust use fundsp::hacker::*; // Instantiate network with 0 inputs and 1 output. let mut net = Net::new(0, 1); // Add nodes, obtaining their IDs. let dc_id = net.push(Box::new(dc(220.0))); let sine_id = net.push(Box::new(sine())); // Connect nodes. net.pipe_all(dc_id, sine_id); net.pipe_output(sine_id); ``` -------------------------------- ### Build Log - Docker Start Command Source: https://docs.rs/crate/fundsp/0.20.0/builds/1920853/i686-pc-windows-msvc.txt The docker command used to start the build container. ```text [INFO] running `Command { std: "docker" "start" "-a" "464b740379491a55cce08c0a767ff10a9745b63bc83283cd4823c7bb2d13b52e", kill_on_drop: false } ``` -------------------------------- ### Net component example with wrap Source: https://docs.rs/crate/fundsp/0.20.0 Wrapping a saw wave in a network and conditionally adding filters. ```rust use fundsp::hacker::*; // Wrap saw wave in a network. let mut net = Net::wrap(Box::new(saw())); // Now we can add filters conditionally. let add_filter = true; if add_filter { net = net >> lowpass_hz(1000.0, 1.0); } ``` -------------------------------- ### Bus Operator Example (Mono Signal) Source: https://docs.rs/crate/fundsp/0.20.0 Shows the bus operator (&) for creating an inline audio bus. This example adds 20% chorus to a mono signal. ```Rust pass() & 0.2 * chorus(0, 0.0, 0.01, 0.3) ``` -------------------------------- ### Build Log - Docker Start and Output Source: https://docs.rs/crate/fundsp/0.20.0/builds/1379849/x86_64-apple-darwin.txt The output from starting the docker container and the warnings/information generated during the documentation build process. ```text [INFO] running `Command { std: "docker" "start" "-a" "ff317d02f03e40b276303f8753d4ae6cefffb31402ec23f3224b872c90564825", kill_on_drop: false }` [INFO] [stderr] warning: Rustdoc did not scrape the following examples because they require dev-dependencies: beep, file, grain, grain2, keys, live_adsr, network, optimize, peek, plot, sequence, type [INFO] [stderr] If you want Rustdoc to scrape these examples, then add `doc-scrape-examples = true` [INFO] [stderr] to the [[example]] target configuration of at least one example. [INFO] [stderr] warning: target filter specified, but no targets matched; this is a no-op [INFO] [stderr] Documenting fundsp v0.20.0 (/opt/rustwide/workdir) [INFO] [stderr] Finished `dev` profile [unoptimized + debuginfo] target(s) in 1.62s [INFO] [stderr] Generated /opt/rustwide/target/x86_64-apple-darwin/doc/fundsp/index.html ``` -------------------------------- ### Load a WAV file Source: https://docs.rs/crate/fundsp/0.20.0/source/README.md Example of loading a WAV file named 'test.wav' into a Wave object. ```rust let wave3 = Wave::load("test.wav").expect("Could not load wave."); ``` -------------------------------- ### Setting Listener Example Source: https://docs.rs/crate/fundsp/0.20.0/source/README.md Shows how to wrap a node in a setting listener to adjust settings from other threads and use addressing. ```rust use fundsp::hacker::*; let (sender, node) = listen(dc(0.5) >> resample(pink())); sender.try_send(Setting::value(0.6).left()).expect("Cannot send setting."); ``` -------------------------------- ### Stack Operator Example Source: https://docs.rs/crate/fundsp/0.20.0 Illustrates the stack operator (|) for building composite components. This example concatenates frequency and Q signals to the input signal for a lowpass filter. ```Rust (pass() | constant((440.0, 1.0))) >> lowpass() ``` -------------------------------- ### Block Processing Example Source: https://docs.rs/crate/fundsp/0.20.0 Demonstrates creating and processing audio blocks using BufferArray and BufferVec, including noise generation and filtering. ```rust use fundsp::hacker::*; // Create a stereo buffer on the stack. let mut buffer = BufferArray::::new(); // Declare stereo noise. let mut node = noise() | noise(); // Process 50 samples into the buffer. There are no inputs, so we can borrow an empty buffer. node.process(50, &BufferRef::empty(), &mut buffer.buffer_mut()); // Create another stereo buffer, this one on the heap. let mut filtered = BufferVec::new(2); // Declare stereo filter. let mut filter = lowpole_hz(3000.0) | lowpole_hz(3000.0); // Filter the 50 noise samples. filter.process(50, &buffer.buffer_ref(), &mut filtered.buffer_mut()); ``` -------------------------------- ### Net component example with frontend and backend Source: https://docs.rs/crate/fundsp/0.20.0 Dividing a `Net` into a frontend and a backend for real-time situations, allowing frontend changes to be committed to the backend. ```rust use fundsp::hacker::*; let mut net = Net::new(0, 1); let noise_id = net.chain(Box::new(pink())); // Create the backend. let mut backend = net.backend(); // The backend is now ready to be sent into an audio thread. // We can make changes to the frontend and then commit them to the backend. net.replace(noise_id, Box::new(brown())); net.commit(); // We can also use the graph syntax to make changes, as long as connectivity // is maintained at commit time. net = net >> peak_hz(1000.0, 1.0); net.commit(); /// Nodes can be replaced smoothly with a crossfade to avoid clicks. net.crossfade(noise_id, Fade::Smooth, 1.0, Box::new(white())); net.commit(); ``` -------------------------------- ### FM Oscillator Example Source: https://docs.rs/crate/fundsp/0.20.0 An example of an FM oscillator expressed in FunDSP graph notation. ```Rust sine_hz(f) * f * m + f >> sine() ``` -------------------------------- ### Graph Expression Example Source: https://docs.rs/crate/fundsp/0.20.0 An example of a signal processing graph defined using FunDSP operators. ```Rust A >> (B ^ C ^ D) ``` -------------------------------- ### Applying settings to a node Source: https://docs.rs/crate/fundsp/0.20.0 Demonstrates how to apply settings to a node using the `set` method. ```rust use fundsp::hacker::*; let mut node = afollow(0.1, 1.0); node.set(Setting::attack_release(0.2, 2.0)); ``` -------------------------------- ### Basic Setting Usage Source: https://docs.rs/crate/fundsp/0.20.0/source/README.md Demonstrates how to apply settings to a node using the `set` method. ```rust use fundsp::hacker::*; let mut node = afollow(0.1, 1.0); node.set(Setting::attack_release(0.2, 2.0)); ``` -------------------------------- ### Examine frequency responses interactively with evcxr Source: https://docs.rs/crate/fundsp/0.20.0 This example shows how to use evcxr to load the fundsp crate, define a bell filter, and print its frequency response as an ASCII chart. ```shell C:\rust>evcxr Welcome to evcxr. For help, type :help >> :dep fundsp >> use fundsp::hacker::*; >> print!("{}", bell_hz(1000.0, 1.0, db_amp(50.0)).display()) 60 dB ------------------------------------------------ 60 dB 50 dB -------------------------.---------------------- 50 dB * 40 dB -------------------------*---------------------- 40 dB ** 30 dB -----------------------.***--------------------- ******. 20 dB -------------------..*********.----------------- ..**************. 10 dB -------------..********************..----------- ..*****************************... 0 dB ....***************************************..... 0 dB | | | | | | | | | | 10 50 100 200 500 1k 2k 5k 10k 20k Hz Peak Magnitude : 50.00 dB (1000 Hz) Inputs : 1 Outputs : 1 Latency : 0.0 samples Footprint : 96 bytes >> ``` -------------------------------- ### Indexed Generator Function Example (busi) Source: https://docs.rs/crate/fundsp/0.20.0 Example demonstrating the use of `busi` to create 20 noise bands within a specified frequency range using an indexed generator function. ```rust use fundsp::hacker::*; let partials = busi::(|i| noise() >> resonator_hz(xerp(1_000.0, 2_000.0, rnd1(i) as f32), 20.0)); ``` -------------------------------- ### Fractional Generator Function Example (busf) Source: https://docs.rs/crate/fundsp/0.20.0 Example demonstrating the use of `busf` to distribute 20 noise bands evenly within a specified frequency range using a fractional generator function. ```rust use fundsp::hacker::*; let partials = busf::(|f| noise() >> resonator_hz(xerp(1_000.0, 2_000.0, f), 20.0)); ``` -------------------------------- ### evcxr Source: https://docs.rs/crate/fundsp/0.20.0/source/README.md Example of using evcxr to examine frequency responses interactively. ```rust C:\rust>evcxr Welcome to evcxr. For help, type :help >> :dep fundsp >> use fundsp::hacker::* >> print!("{}", bell_hz(1000.0, 1.0, db_amp(50.0)).display()) 60 dB ------------------------------------------------ 60 dB 50 dB -------------------------.---------------------- 50 dB * 40 dB -------------------------*---------------------- 40 dB ** 30 dB -----------------------.***--------------------- ******. 20 dB -------------------..*********.----------------- ..**************. 10 dB -------------..********************..----------- ..*****************************... 0 dB ....***************************************..... 0 dB | | | | | | | | | | 10 50 100 200 500 1k 2k 5k 10k 20k Hz Peak Magnitude : 50.00 dB (1000 Hz) Inputs : 1 Outputs : 1 Latency : 0.0 samples Footprint : 96 bytes >> ```