### Install QDax Dependencies Source: https://github.com/dbraun/dawdreamer/blob/main/docs/examples.md Install QDax for examples demonstrating integration with Quality Diversity algorithms in JAX. ```bash pip install qdax ``` -------------------------------- ### Complete Plugin Processing Example Source: https://github.com/dbraun/dawdreamer/blob/main/docs/user_guide/plugin_processor.md A comprehensive example demonstrating engine initialization, synth and reverb processor creation, state saving, automation setup, MIDI note addition, graph loading, rendering, audio saving, and MIDI saving. ```python import dawdreamer as daw import numpy as np from scipy.io import wavfile SAMPLE_RATE = 44100 BUFFER_SIZE = 128 PPQN = 960 SYNTH_PLUGIN = "/path/to/synth.dll" REVERB_PLUGIN = "/path/to/reverb.dll" engine = daw.RenderEngine(SAMPLE_RATE, BUFFER_SIZE) # Create synth synth = engine.make_plugin_processor("synth", SYNTH_PLUGIN) # Edit and save state synth.open_editor() synth.save_state('/path/to/state1') # Setup automation synth.record_automation = True duration = 10 automation = 0.5 + 0.5 * np.sin(np.linspace(0, 4*np.pi, int(duration * SAMPLE_RATE))) synth.set_automation(1, automation) # Add MIDI synth.add_midi_note(60, 100, 0.0, 2.0) synth.add_midi_note(64, 100, 2.0, 2.0) synth.add_midi_note(67, 100, 4.0, 2.0) # Create effect reverb = engine.make_plugin_processor("reverb", REVERB_PLUGIN) # Build graph graph = [ (synth, []), (reverb, ["synth"]) ] engine.load_graph(graph) engine.set_bpm(120.) engine.render(10.) # Save audio audio = engine.get_audio() wavfile.write('plugin_output.wav', SAMPLE_RATE, audio.transpose()) # Get automation data recorded_automation = synth.get_automation() # Save MIDI synth.save_midi('output.mid') ``` -------------------------------- ### Complete PlaybackWarpProcessor Example Source: https://github.com/dbraun/dawdreamer/blob/main/docs/user_guide/playback_warp.md A comprehensive example demonstrating the setup of the RenderEngine, loading audio, creating a PlaybackWarpProcessor, loading Ableton warp markers, and configuring loop properties. ```python import dawdreamer as daw import librosa from scipy.io import wavfile SAMPLE_RATE = 44100 BUFFER_SIZE = 512 engine = daw.RenderEngine(SAMPLE_RATE, BUFFER_SIZE) engine.set_bpm(130.) # Load audio audio, _ = librosa.load("drum_loop.wav", sr=SAMPLE_RATE, mono=False) # Create processor playback = engine.make_playbackwarp_processor("drums", audio) # Load Ableton warp markers playback.set_clip_file("drum_loop.wav.asd") # Adjust clip properties playback.loop_on = True playback.loop_start = 0.0 playback.loop_end = 4.0 ``` -------------------------------- ### Movie Generation Setup (Optional) Source: https://github.com/dbraun/dawdreamer/blob/main/examples/mashup_generator/mashup_generator.ipynb This section is for generating a movie from the audio. It requires ImageMagick to be installed and the 'magick.exe' environment variable to be set. ```python # This optional section is for making a movie. # You must install imagemagick and set an environment variable to magick.exe. See the MoviePy installation instructions. ``` -------------------------------- ### Install JAX/Flax Dependencies Source: https://github.com/dbraun/dawdreamer/blob/main/docs/examples.md Install JAX and Flax for examples involving differentiable audio processing and machine learning. ```bash pip install jax flax ``` -------------------------------- ### Launch Jupyter Notebook Source: https://github.com/dbraun/dawdreamer/blob/main/docs/examples.md Navigate to the examples directory and launch Jupyter Notebook to run the interactive examples. ```bash cd examples/ jupyter notebook ``` -------------------------------- ### Build VST3 Examples on Windows with CMake Source: https://github.com/dbraun/dawdreamer/blob/main/JuceLibraryCode/modules/juce_audio_processors/format_types/VST3_SDK/README.md Commands to generate Visual Studio projects and build VST3 examples on Windows using CMake. Includes options for specifying the generator, architecture, and VST3 installation path. ```bash mkdir build cd build ``` ```bash cmake.exe -G "Visual Studio 17 2022" -A x64 ..\vst3sdk ``` ```bash cmake.exe -G "Visual Studio 17 2022" -A x64 ..\vst3sdk -DSMTG_CREATE_PLUGIN_LINK=0 ``` ```bash cmake.exe -G "Visual Studio 17 2022" -A x64 -DSMTG_PLUGIN_TARGET_USER_PROGRAM_FILES_COMMON=1 ``` ```bash msbuild.exe vstsdk.sln ``` ```bash cmake --build . --config Release ``` -------------------------------- ### Complete Mixer Example Source: https://github.com/dbraun/dawdreamer/blob/main/docs/user_guide/other_processors.md A full example demonstrating loading audio, creating playback processors, instantiating an AddProcessor, building the audio graph, and rendering. ```python import dawdreamer as daw import librosa engine = daw.RenderEngine(44100, 512) # Load audio files vocals = engine.make_playback_processor("vocals", librosa.load("vocals.wav", sr=44100, mono=False)[0]) piano = engine.make_playback_processor("piano", librosa.load("piano.wav", sr=44100, mono=False)[0]) guitar = engine.make_playback_processor("guitar", librosa.load("guitar.wav", sr=44100, mono=False)[0]) # Create mixer mixer = engine.make_add_processor("mixer", [0.4, 0.4, 0.4]) # Build graph graph = [ (vocals, []), (piano, []), (guitar, []), (mixer, ["vocals", "piano", "guitar"]) ] engine.load_graph(graph) engine.render(10.0) mixed = engine.get_audio() ``` -------------------------------- ### Windows Installation Source: https://github.com/dbraun/dawdreamer/blob/main/CLAUDE.md Sets environment variables for Python version, builds the Visual Studio solution, and installs the package in develop mode. ```cmd set PYTHONMAJOR=3.11 && set pythonLocation=C:\Python311 msbuild Builds/VisualStudio2022/DawDreamer.sln /property:Configuration=Release python setup.py develop ``` -------------------------------- ### Run Standalone Python Script Example Source: https://github.com/dbraun/dawdreamer/blob/main/docs/examples.md Execute standalone Python script examples directly from their respective directories. ```bash cd examples/dj_mixing/ python dj_mixing.py ``` -------------------------------- ### Complete DawDreamer Audio Playback Example Source: https://github.com/dbraun/dawdreamer/blob/main/docs/user_guide/playback.md A comprehensive example showing how to load multiple audio files (vocals, drums, bass), create PlaybackProcessors for each, mix them using an AddProcessor, build the graph, render the audio, and save the final mix to a WAV file. ```python import dawdreamer as daw import librosa from scipy.io import wavfile SAMPLE_RATE = 44100 engine = daw.RenderEngine(SAMPLE_RATE, 512) # Load multiple audio files vocals, _ = librosa.load("vocals.wav", sr=SAMPLE_RATE, mono=False) drums, _ = librosa.load("drums.wav", sr=SAMPLE_RATE, mono=False) bass, _ = librosa.load("bass.wav", sr=SAMPLE_RATE, mono=False) # Create playback processors vocals_pb = engine.make_playback_processor("vocals", vocals) drums_pb = engine.make_playback_processor("drums", drums) bass_pb = engine.make_playback_processor("bass", bass) # Create mixer mixer = engine.make_add_processor("mixer", [0.4, 0.4, 0.4]) # Build graph graph = [ (vocals_pb, []), (drums_pb, []), (bass_pb, []), (mixer, ["vocals", "drums", "bass"]) ] engine.load_graph(graph) # Render duration = max(vocals.shape[1], drums.shape[1], bass.shape[1]) / SAMPLE_RATE engine.render(duration) # Save result audio = engine.get_audio() wavfile.write('mix.wav', SAMPLE_RATE, audio.transpose()) ``` -------------------------------- ### Install Dependencies Source: https://github.com/dbraun/dawdreamer/blob/main/examples/Box_API/Faust_Box_API.ipynb Installs necessary Python libraries for DawDreamer and audio processing if running in Google Colab. ```python if 'google.colab' in str(get_ipython()): !pip install numpy librosa scipy ipython ``` -------------------------------- ### Compressor Processor Setup Source: https://github.com/dbraun/dawdreamer/wiki/Other-Processors Details the creation and configuration of a compressor processor, including parameters for threshold, ratio, attack, and release times. ```python threshold = 0. # dB level of threshold ratio = 2. # greater than or equal to 1. attack = 2. # attack of compressor in milliseconds release = 50. # release of compressor in milliseconds compressor_processor = engine.make_compressor_processor("my_compressor", threshold, ratio, attack, release) # CompressorProcessor has getters/setters compressor_processor.threshold = threshold compressor_processor.ratio = ratio compressor_processor.attack = attack compressor_processor.release = release ``` -------------------------------- ### Verify DawDreamer Installation Source: https://github.com/dbraun/dawdreamer/blob/main/docs/installation.md Run a simple Python script to import DawDreamer and initialize the RenderEngine. A success message indicates the installation was successful. ```python import dawdreamer as daw engine = daw.RenderEngine(44100, 512) print("DawDreamer installed successfully!") ``` -------------------------------- ### Install Brax and Jumanji Source: https://github.com/dbraun/dawdreamer/blob/main/examples/Faust_to_QDax/Faust_to_QDax.ipynb Installs the Brax and Jumanji libraries. The `|tail -n 1` is used to display only the last line of the pip installation output. ```python try: pass except: !pip install brax==0.9.2 |tail -n 1 try: pass except: !pip install jumanji==0.3.1 ``` -------------------------------- ### Stereo Reverb Example with Faust Processor Source: https://github.com/dbraun/dawdreamer/blob/main/docs/user_guide/faust_processor.md A complete example demonstrating loading a Faust DSP reverb, setting parameters, loading an input audio file, and rendering the processed audio to a WAV file. ```python import dawdreamer as daw from scipy.io import wavfile import librosa DSP_PATH = "/absolute/path/to/faust_reverb.dsp" INPUT_AUDIO_PATH = "/path/to/piano.wav" DURATION = 10. SAMPLE_RATE = 44100 engine = daw.RenderEngine(SAMPLE_RATE, 512) faust_processor = engine.make_faust_processor("faust") faust_processor.set_dsp(DSP_PATH) # Compile early to catch errors faust_processor.compile() print(faust_processor.get_parameters_description()) # Set parameters faust_processor.set_parameter("/Zita_Light/Dry/Wet_Mix", 1.) # Load input audio audio, _ = librosa.load(INPUT_AUDIO_PATH, sr=SAMPLE_RATE, mono=False) playback = engine.make_playback_processor("piano", audio) # Build graph graph = [ (playback, []), (faust_processor, ["piano"]) ] engine.load_graph(graph) engine.render(DURATION) output_audio = engine.get_audio() wavfile.write('reverb_output.wav', SAMPLE_RATE, output_audio.transpose()) ``` -------------------------------- ### Basic Faust Sine Wave Example Source: https://github.com/dbraun/dawdreamer/blob/main/docs/index.md A basic example demonstrating how to create a Faust processor for a sine wave, load it into the render engine, and render audio. Requires numpy. ```python import dawdreamer as daw import numpy as np # Create engine engine = daw.RenderEngine(44100, 512) # Add a Faust processor faust = engine.make_faust_processor("synth") faust.set_dsp_string("process = os.osc(440) * 0.1;") # Load graph and render engine.load_graph([(faust, [])]) engine.render(2.0) # 2 seconds # Get audio audio = engine.get_audio() # shape: (channels, samples) ``` -------------------------------- ### Build VST3 Examples on macOS with CMake Source: https://github.com/dbraun/dawdreamer/blob/main/JuceLibraryCode/modules/juce_audio_processors/format_types/VST3_SDK/README.md Commands to generate Xcode projects and build VST3 examples on macOS using CMake. Includes options for specifying the build type. ```bash mkdir build cd build ``` ```bash cmake -GXcode ../vst3sdk ``` ```bash cmake -DCMAKE_BUILD_TYPE=Debug ../ ``` ```bash xcodebuild ``` ```bash cmake --build . --config Release ``` -------------------------------- ### Install QDax from GitHub Source: https://github.com/dbraun/dawdreamer/blob/main/examples/Faust_to_QDax/Faust_to_QDax.ipynb Installs the QDax library directly from its development branch on GitHub. The `--no-deps` flag prevents reinstallation of dependencies, and `|tail -n 1` filters the output. ```python try: pass except: !pip install --no-deps git+https://github.com/adaptive-intelligent-robotics/QDax@develop |tail -n 1 ``` -------------------------------- ### Install Build and Wheel Modules Source: https://github.com/dbraun/dawdreamer/wiki/Developer's-Guide Install the 'build' and 'wheel' Python packages using pip. These are necessary for creating Python distribution packages. ```bash python -m pip install build wheel ``` -------------------------------- ### Basic Faust Sine Tone Example Source: https://github.com/dbraun/dawdreamer/blob/main/README.md This example demonstrates how to create a stereo sine tone using Faust within DawDreamer. It covers initializing the render engine, defining a Faust DSP string, setting parameters, rendering audio, and saving it to a WAV file. The example also shows how to change parameters and re-render. ```python import dawdreamer as daw from scipy.io import wavfile SAMPLE_RATE = 44100 engine = daw.RenderEngine(SAMPLE_RATE, 512) # 512 block size faust_processor = engine.make_faust_processor("faust") faust_processor.set_dsp_string( """ declare name "MySine"; freq = hslider("freq", 440, 0, 20000, 0); gain = hslider("vol[unit:dB]", 0, -120, 20, 0) : ba.db2linear; process = freq : os.osc : _*gain <: si.bus(2); """ ) print(faust_processor.get_parameters_description()) engine.load_graph([ (faust_processor, []) ]) faust_processor.set_parameter("/MySine/freq", 440.) # 440 Hz faust_processor.set_parameter("/MySine/vol", -6.) # -6 dB volume engine.set_bpm(120.) engine.render(4., beats=True) # render 4 beats. audio = engine.get_audio() # shaped (2, N samples) wavfile.write("sine_demo.wav", SAMPLE_RATE, audio.T) # Change settings and re-render faust_processor.set_parameter("/MySine/freq", 880.) # 880 Hz engine.render(4., beats=True) ``` -------------------------------- ### macOS Installation Source: https://github.com/dbraun/dawdreamer/blob/main/CLAUDE.md Sets environment variables for Python version and architecture, builds the project using a macOS specific script, and installs in develop mode. ```bash export PYTHONMAJOR=3.11 ARCHS=arm64 export pythonLocation=/Library/Frameworks/Python.framework/Versions/3.11 ./build_macos.sh && ARCHS=$ARCHS python3.11 setup.py develop ``` -------------------------------- ### Print Initial Model Parameters Source: https://github.com/dbraun/dawdreamer/blob/main/examples/Faust_to_JAX/Faust_to_JAX.ipynb Prints the initial parameters for both the hidden model and the training model to observe their starting states. ```python print("hidden params:", hidden_params) print("train params:", train_params) ``` -------------------------------- ### Install DawDreamer and Dependencies Source: https://github.com/dbraun/dawdreamer/blob/main/docs/examples.md Install DawDreamer and common dependencies using pip. Some examples may require additional libraries like JAX, Flax, or QDax. ```bash pip install dawdreamer pip install librosa scipy numpy matplotlib jupyter ``` -------------------------------- ### Audio-Rate and PPQN-Rate Automation Source: https://context7.com/dbraun/dawdreamer/llms.txt This example demonstrates advanced parameter automation using `processor.set_automation`. It shows how to automate parameters at audio-rate (per sample) and PPQN-rate (musically synced) for dynamic synth control. It also covers recording automation during rendering and retrieving it afterwards. ```python import dawdreamer as daw import numpy as np from scipy.io import wavfile SAMPLE_RATE = 44100 PPQN = 960 engine = daw.RenderEngine(SAMPLE_RATE, 128) # small buffer for smooth automation faust = engine.make_faust_processor("synth") faust.set_dsp_string(""" declare name "MySynth"; freq = hslider("freq", 440, 20, 20000, 1); cutoff = hslider("cutoff", 5000, 20, 20000, 1); process = freq : os.osc : fi.lowpass(4, cutoff) <: _, _; """) duration = 8.0 num_samples = int(duration * SAMPLE_RATE) # Audio-rate: glide freq from 220 to 880 Hz freq_glide = np.linspace(220.0, 880.0, num_samples, dtype=np.float32) faust.set_automation("/MySynth/freq", freq_glide) # PPQN-rate: cutoff filter opens on the beat (4 beats) beats = 4 pulses = beats * PPQN cutoff_values = np.linspace(500.0, 12000.0, pulses, dtype=np.float32) faust.set_automation("/MySynth/cutoff", cutoff_values, ppqn=PPQN) # Record all parameter automation after render faust.record_automation = True engine.load_graph([(faust, [])]) engine.set_bpm(120.0) engine.render(beats, beats=True) audio = engine.get_audio() wavfile.write("automated_synth.wav", SAMPLE_RATE, audio.T) # Retrieve recorded parameter automation as dict of arrays all_automation = faust.get_automation() # e.g. {'/MySynth/freq': np.array([...]), '/MySynth/cutoff': np.array([...])} print({k: v.shape for k, v in all_automation.items()}) ``` -------------------------------- ### Initialize Dawdreamer Engine and Load Plugins Source: https://github.com/dbraun/dawdreamer/wiki/Plugin-Processor Sets up the audio engine and creates instances of VST/AU plugins. Ensure plugin paths are correct and supported extensions are used. ```python BUFFER_SIZE = 128 PPQN = 960 SYNTH_PLUGIN = "C:/path/to/synth.dll" REVERB_PLUGIN = "C:/path/to/reverb.dll" MIDI_PATH = "C:/path/to/song.mid" engine = daw.RenderEngine(SAMPLE_RATE, BUFFER_SIZE) synth = engine.make_plugin_processor("my_synth", SYNTH_PLUGIN) assert synth.get_name() == "my_synth" ``` -------------------------------- ### Install DawDreamer with PyPI Source: https://github.com/dbraun/dawdreamer/blob/main/README.md Install the DawDreamer library using pip. Ensure you have a compatible Python version installed. ```bash pip install dawdreamer ``` -------------------------------- ### Install and Verify DawDreamer Source: https://github.com/dbraun/dawdreamer/blob/main/CLAUDE.md Install the DawDreamer package in editable mode and verify the installation by creating a RenderEngine instance. ```bash pip install -e . # Verify python3 -c "import dawdreamer; dawdreamer.RenderEngine(44100, 512)" ``` -------------------------------- ### Linux Prerequisites and Installation Source: https://github.com/dbraun/dawdreamer/blob/main/CLAUDE.md Installs necessary dependencies for DawDreamer on Linux, updates submodules, downloads Faust libraries, and then installs the package. ```bash # Install dependencies sudo apt-get install -yq build-essential clang cmake git python3-dev \ libboost-all-dev libfreetype6-dev libncurses-dev \ libx11-dev libxrandr-dev libasound2-dev libxcomposite-dev # Submodules and Faust git submodule update --init --recursive cd thirdparty/libfaust && python3 download_libfaust.py && cd ../.. # Build and install (builds C++, copies .so, installs package) pip install -e . ``` -------------------------------- ### Complete Audio Rendering Workflow in Python Source: https://github.com/dbraun/dawdreamer/blob/main/docs/user_guide/render_engine.md Demonstrates setting up a render engine, creating Faust processors, loading a graph, and rendering audio with both static and dynamic BPM. Ensure necessary libraries like dawdreamer and numpy are installed. ```python import dawdreamer as daw import numpy as np from scipy.io import wavfile # Setup SAMPLE_RATE = 44100 BUFFER_SIZE = 512 engine = daw.RenderEngine(SAMPLE_RATE, BUFFER_SIZE) # Create processors synth = engine.make_faust_processor("synth") synth.set_dsp_string("process = os.osc(440) * 0.1;") # Load graph engine.load_graph([(synth, [])]) # Render with static BPM engine.set_bpm(120.) engine.render(4., beats=True) audio1 = engine.get_audio() # Render with dynamic BPM ppqn = 960 bpm_ramp = np.linspace(120, 180, 4 * ppqn) engine.set_bpm(bpm_ramp, ppqn=ppqn) engine.render(4., beats=True) audio2 = engine.get_audio() # Save outputs wavfile.write('static_bpm.wav', SAMPLE_RATE, audio1.transpose()) wavfile.write('dynamic_bpm.wav', SAMPLE_RATE, audio2.transpose()) ``` -------------------------------- ### Install DawDreamer Wheel Source: https://github.com/dbraun/dawdreamer/blob/main/docs/installation.md Install the generated DawDreamer wheel package using pip. This command installs the package from the local 'dist' directory. ```bash python -m pip install dist/dawdreamer-*.whl ``` -------------------------------- ### Query and Set Plugin Parameters Source: https://context7.com/dbraun/dawdreamer/llms.txt Demonstrates how to query parameter ranges, set parameters by index, and load/save plugin states. Use `open_editor()` for interactive tweaking. ```python par_range = synth.get_parameter_range(10, search_steps=1000, convert=False) print(par_range) synth.set_parameter(7, 0.1234) ``` ```python synth.load_state("/path/to/my_synth_state") synth.load_preset("/path/to/preset.fxp") # VST2 FXP synth.load_vst3_preset("/path/to/p.vstpreset") # VST3 ``` -------------------------------- ### Install DawDreamer Source: https://github.com/dbraun/dawdreamer/blob/main/examples/Box_API/Faust_Box_API.ipynb Installs the DawDreamer library if it's not already found. ```python try: import dawdreamer except ModuleNotFoundError: !pip install dawdreamer ``` -------------------------------- ### JAX Model Inference Setup Source: https://github.com/dbraun/dawdreamer/blob/main/examples/Faust_to_QDax/Faust_to_QDax.ipynb This code prepares a JAX model for inference by JIT-compiling the `apply` method and setting up input tensors for frequency, gain, and gate. ```python jit_inference_fn = jax.jit(model.apply, static_argnums=[2]) # 2 seconds T = int(SAMPLE_RATE * 2.0) # Hold for 1 second hold_length = int(SAMPLE_RATE * 1.0) # Play the synth as 440 Hz. freq = jnp.full((T,), 440.0) ``` -------------------------------- ### Initialize RenderEngine Source: https://github.com/dbraun/dawdreamer/blob/main/docs/quickstart.md Create an instance of the RenderEngine with the desired sample rate and block size. ```python engine = daw.RenderEngine(sample_rate=44100, block_size=512) ``` -------------------------------- ### Install DawDreamer Wheel Source: https://github.com/dbraun/dawdreamer/wiki/Developer's-Guide Install the built DawDreamer Python wheel. Replace 'dist/dawdreamer.whl' with the correct path to your wheel file. ```bash python -m pip install dist/dawdreamer.whl ``` -------------------------------- ### Verify DawDreamer Installation Source: https://github.com/dbraun/dawdreamer/blob/main/docs/installation.md Verify that DawDreamer is installed correctly by importing the library and creating a RenderEngine instance. This confirms the build was successful. ```python python3 -c "import dawdreamer as daw; engine = daw.RenderEngine(44100, 512); print('Success!')" ``` -------------------------------- ### Initialize RenderEngine and Set BPM Source: https://context7.com/dbraun/dawdreamer/llms.txt Demonstrates initializing the RenderEngine with sample rate and block size, and setting static or dynamic BPM values. Dynamic BPM can be set using a NumPy array for tempo automation. ```python import dawdreamer as daw import numpy as np from scipy.io import wavfile SAMPLE_RATE = 44100 BUFFER_SIZE = 512 # smaller = finer automation, higher CPU engine = daw.RenderEngine(SAMPLE_RATE, BUFFER_SIZE) # Static BPM (default 120) engine.set_bpm(130.0) # Dynamic BPM via PPQN-rate NumPy array (tempo automation) PPQN = 960 duration = 8.0 # seconds bpm_array = np.linspace(120.0, 160.0, int(duration * PPQN / 60), dtype=np.float32) # Note: array length = beats * PPQN; each element is one BPM value per pulse engine.set_bpm(bpm_array, ppqn=PPQN) # Render by seconds engine.render(4.0) # 4 seconds audio = engine.get_audio() # shape: (channels, num_samples), dtype: float32 # Render by beats (uses current BPM) engine.set_bpm(120.0) engine.render(8.0, beats=True) # 8 beats = 4 seconds at 120 BPM audio = engine.get_audio() # shape: (2, 176400) # Retrieve audio from a specific processor by name (requires processor.record = True) intermediate = engine.get_audio("my_processor_name") # Save to WAV wavfile.write("output.wav", SAMPLE_RATE, audio.T) ``` -------------------------------- ### Reverb Processor Initialization Source: https://github.com/dbraun/dawdreamer/wiki/Other-Processors Explains how to instantiate a basic reverb processor from JUCE, setting parameters such as room size, damping, wet/dry levels, and width. ```python # Basic reverb processor from JUCE. room_size = 0.5 damping = 0.5 wet_level = 0.33 dry_level = 0.4 width = 1. reverb_processor = engine.make_reverb_processor("my_reverb", room_size, damping, wet_level, dry_level, width) # ReverbProcessor has getters/setters reverb_processor.room_size = room_size reverb_processor.damping = damping reverb_processor.wet_level = wet_level reverb_processor.dry_level = dry_level reverb_processor.width = width ``` -------------------------------- ### Run CLI Example for Parallel Sound Generation Source: https://github.com/dbraun/dawdreamer/blob/main/examples/xml_synth_sound_rendering/README.md Use this command to generate many sounds in parallel with the TAL-U-NO-LX VST plugin using multiprocessing. Adjust the plugin and preset directory paths as needed. ```bash python main.py --plugin "path/to/TAL-U-NO-LX-V2.vst3" --preset-dir "path/to/TAL-U-NO-LX_presets" ``` -------------------------------- ### Install DawDreamer on macOS using setup.py Source: https://github.com/dbraun/dawdreamer/blob/main/DEVELOPER.md Installs the DawDreamer Python package in editable mode on macOS, using the specified Python version. ```bash ARCHS=$ARCHS python3.11 setup.py develop ``` -------------------------------- ### Prepare for Loss Landscape Analysis Source: https://github.com/dbraun/dawdreamer/blob/main/examples/Faust_to_JAX/Faust_to_JAX.ipynb Selects a single input example and its corresponding ground truth output to prepare for analyzing the loss landscape. This involves holding all parameters constant except for one that will be varied. ```python # Pick a single example x = noises[0:1] y = hidden_model.apply({"params": hidden_params}, x, T) # Pick the first param to be the varying parameter. ``` -------------------------------- ### Delay Processor Setup Source: https://github.com/dbraun/dawdreamer/wiki/Other-Processors Illustrates the creation of a delay processor, specifying delay time in milliseconds and the wet/dry mix. Currently, only the linear delay rule is supported. ```python delay_rule = "linear" # only linear is supported right now delay_ms = 200. # delay in milliseconds delay_wet = .3 # 0 means use all of original signal and none of the "wet" delayed signal. 1. is the opposite. delay_processor = engine.make_delay_processor("my_delay", delay_rule, delay_ms, delay_wet) # delay_processor.rule = "linear" # modifying the rule is not supported yet. delay_processor.delay = delay_ms delay_processor.wet = delay_wet ``` -------------------------------- ### Add and Playback Processors Source: https://github.com/dbraun/dawdreamer/wiki/Other-Processors Demonstrates creating and configuring add and playback processors, loading audio files, setting up a Faust effect, defining an audio graph, and rendering audio. Playback processors can have their data updated between renders. ```python add_processor = engine.make_add_processor("added") # or start with gain values add_processor = engine.make_add_processor("added", [0.25, 0.42, 0.30]) add_processor.gain_levels = [0.26, 0.41, 0.31] # Adjust gain levels whenever you want. import librosa def load_audio_file(file_path, duration=None): sig, rate = librosa.load(file_path, duration=duration, mono=False, sr=SAMPLE_RATE) assert(rate == SAMPLE_RATE) return sig # load stereo wav files into playback vocals = engine.make_playback_processor("vocals", load_audio_file("vocals.wav")) piano = engine.make_playback_processor("piano", load_audio_file("piano.wav")) guitar = engine.make_playback_processor("guitar", load_audio_file("guitar.wav")) faust_effect = engine.make_faust_processor("faust") faust_effect.set_dsp_string("process = sp.stereoize( fi.lowpass(2, 5000.) );") faust_effect.record = True # A graph is a meaningfully ordered list of tuples. # In each tuple, the first item is an audio processor. # The second item is this audio processor's list of input processors by their unique names. # Note that you can use either hard-coded strings or `get_name()` to make this list. # The audio from the last tuple's processor will be accessed automatically later by engine.get_audio() graph = [ (vocals, []), # Playback has no inputs. (piano, []), # Playback has no inputs. (guitar, []), # Playback has no inputs (faust_effect, ["guitar"]) (add_processor, ["vocals", "piano", "faust"]) ] engine.load_graph(graph) engine.render(5.) # You can get the audio of any processor whose recording was enabled. filtered_guitar = faust_effect.get_audio() # Or get audio according to the processor's unique name filtered_guitar = engine.get_audio("faust") # You can set playback data in between rendering. vocals.set_data(load_audio_file("other_vocals.wav")) ``` -------------------------------- ### Install Linux Dependencies Source: https://github.com/dbraun/dawdreamer/wiki/Developer's-Guide Install essential development packages on Ubuntu systems. This includes build tools, compilers, and libraries required for DawDreamer. ```bash apt-get install -yq --no-install-recommends \ ca-certificates \ build-essential \ clang \ pkg-config \ libboost-all-dev \ libboost-python-dev \ libfreetype6-dev \ libx11-dev \ libxinerama-dev \ libxrandr-dev \ libxcursor-dev \ mesa-common-dev \ libasound2-dev \ freeglut3-dev \ libxcomposite-dev \ libcurl4-gnutls-dev \ git \ cmake \ python3 \ python3.10-dev ``` -------------------------------- ### Install Matplotlib and IPyMPL for Colab Source: https://github.com/dbraun/dawdreamer/blob/main/examples/Faust_to_QDax/Faust_to_QDax.ipynb Installs `ipympl`, `librosa`, and `matplotlib` if running in a Google Colab environment. Otherwise, it sets up matplotlib for inline plotting. ```python if "google.colab" in str(get_ipython()): !pip install ipympl librosa matplotlib |tail -n 1 else: %matplotlib inline ``` -------------------------------- ### Streamlined DawDreamer Installation for Automation Source: https://github.com/dbraun/dawdreamer/blob/main/docs/installation.md A streamlined command for installing DawDreamer with minimal output, suitable for automated builds or LLM interactions. Includes verification. ```bash # Quick install if C++ library already exists (minimal output) python3 setup.py develop --quiet 2>&1 | grep -E '(Successfully|ERROR|Failed)' || \ (echo "Installing (1-2 min on WSL2)..." && \ python3 setup.py develop --quiet && \ echo "✓ Installed successfully") # Verify silently python3 -c "import dawdreamer; dawdreamer.RenderEngine(44100, 512)" && \ echo "✓ Working" || echo "✗ Failed" ``` -------------------------------- ### Argument Parser Setup Source: https://github.com/dbraun/dawdreamer/blob/main/examples/Faust_to_JAX/Faust_to_JAX.ipynb Configures command-line arguments for the DSP model testing script, including sample rate, duration, input/output files, and random seed. ```python if __name__ == '__main__': import argparse parser = argparse.ArgumentParser(description='Run a JAX/Flax model converted from Faust code') parser.add_argument('-sr', '--sample-rate', type=int, default=44100, help='Sample rate (such as 44100)') parser.add_argument('-d', '--duration', type=float, default=None, help='Output duration in seconds') parser.add_argument('--random', action='store_true', help="Whether the default audio is random. By default it's an impulse.") parser.add_argument('--seed', default=0, type=int, help="Seed for random number generator (default: 0)") parser.add_argument('-i', '--input', type=str, default=None, help='Filepath for input audio WAV') ``` -------------------------------- ### Install Linux Dependencies Source: https://github.com/dbraun/dawdreamer/blob/main/DEVELOPER.md Installs all necessary packages for building DawDreamer on Ubuntu/Debian systems. Ensure you have sufficient disk space and a stable internet connection. ```bash apt-get install -yq --no-install-recommends \ ca-certificates build-essential clang pkg-config \ libboost-all-dev libboost-python-dev libfreetype6-dev \ libx11-dev libxinerama-dev libxrandr-dev libxcursor-dev \ mesa-common-dev libasound2-dev freeglut3-dev \ libxcomposite-dev libcurl4-gnutls-dev libncurses-dev \ git cmake python3 python3-dev ``` -------------------------------- ### Create and Load Audio Processing Graph Source: https://github.com/dbraun/dawdreamer/blob/main/DEVELOPER.md Demonstrates creating Faust and plugin processors, defining their connections in a graph, loading the graph into the engine, and rendering audio. Ensure processor names are unique for graph connectivity. ```python synth = engine.make_faust_processor("synth") synth.set_dsp_string("process = os.osc(440) : *(0.1);") effect = engine.make_plugin_processor("reverb", "path/to/plugin.dll") # Build graph graph = [ (synth, []), # synth takes no input (effect, ["synth"]) ] engine.load_graph(graph) # Render engine.set_bpm(120) engine.render(4., beats=True) # 4 beats # Get audio audio = engine.get_audio() # shape (channels, samples) ``` -------------------------------- ### Create RenderEngine in Python Source: https://github.com/dbraun/dawdreamer/blob/main/docs/user_guide/index.md Initializes the audio rendering engine with a specified sample rate and buffer size. ```python import dawdreamer as daw engine = daw.RenderEngine(44100, 512) ``` -------------------------------- ### Install Dependencies Source: https://github.com/dbraun/dawdreamer/blob/main/examples/Faust_to_JAX/Faust_to_JAX.ipynb Installs necessary Python packages including numpy, scipy, librosa, jax, flax, and optax. This is typically run in a Google Colab environment. ```python if "google.colab" in str(get_ipython()): !pip install numpy scipy librosa jax flax optax ``` -------------------------------- ### Install Pre-commit Hooks Source: https://github.com/dbraun/dawdreamer/blob/main/DEVELOPER.md Installs and enables pre-commit hooks for code quality checks. These hooks automatically format code and check for common issues before commits. ```bash pip install pre-commit pre-commit install ``` -------------------------------- ### Create RenderEngine Instance Source: https://github.com/dbraun/dawdreamer/blob/main/docs/user_guide/render_engine.md Instantiate the RenderEngine with a specified sample rate and block size. The block size affects parameter automation granularity. ```python import dawdreamer as daw SAMPLE_RATE = 44100 BUFFER_SIZE = 128 # Parameters will undergo automation at this block size # Make an engine. We typically only need one. engine = daw.RenderEngine(SAMPLE_RATE, BUFFER_SIZE) ``` -------------------------------- ### Set Up JAX Training State and Step Function Source: https://github.com/dbraun/dawdreamer/blob/main/examples/Faust_to_JAX/Faust_to_JAX.ipynb This snippet configures the Optax optimizer, creates a 'TrainState' for managing model parameters and optimizer state, and defines a JAX-jitted 'train_step' function for a single training iteration, including loss calculation and gradient application. ```python learning_rate = 2e-1 # @param {type: 'number'} momentum = 0.95 # @param {type: 'number'} # Create Train state tx = optax.sgd(learning_rate, momentum) state = train_state.TrainState.create(apply_fn=train_model.apply, params=train_params, tx=tx) @jax.jit def train_step(state, x, y): """Train for a single step.""" def loss_fn(params): pred = train_model.apply({"params": params}, x, T) # L1 time-domain loss loss = (jnp.abs(pred - y)).mean() return loss, pred grad_fn = jax.value_and_grad(loss_fn, has_aux=True) (loss, pred), grads = grad_fn(state.params) state = state.apply_gradients(grads=grads) return state, loss losses = [] cutoffs = [] train_steps = 600 steps_per_eval = 40 pbar = tqdm(range(train_steps)) jit_hidden_model = jax.jit(hidden_model.apply, static_argnums=[2]) ``` -------------------------------- ### Install DawDreamer Python Package Source: https://github.com/dbraun/dawdreamer/blob/main/DEVELOPER.md Installs the DawDreamer Python package in editable mode. This command also handles the C++ build process via setup.py. ```bash pip install -e . ``` -------------------------------- ### Install DawDreamer Python Package (Editable Mode) Source: https://github.com/dbraun/dawdreamer/blob/main/docs/installation.md Install the DawDreamer Python package in editable mode using setup.py. This is typically done after building from source. ```bash python3 setup.py develop ``` -------------------------------- ### Add and Render MIDI Notes Source: https://context7.com/dbraun/dawdreamer/llms.txt Illustrates how to add individual MIDI notes with velocity, start time, and duration, and then render the audio. MIDI can also be loaded from files. ```python synth.add_midi_note(60, 100, 0.0, 2.0) synth.add_midi_note(64, 100, 2.0, 2.0) synth.add_midi_note(67, 100, 4.0, 2.0) ``` ```python # synth.load_midi("/path/to/song.mid", clear_previous=True, beats=False, all_events=True) ``` -------------------------------- ### Install Linux Dependencies Source: https://github.com/dbraun/dawdreamer/blob/main/docs/installation.md Install the required system dependencies for building DawDreamer on Debian/Ubuntu-based Linux distributions. This includes build tools, libraries, and Python development headers. ```bash apt-get install -yq --no-install-recommends \ ca-certificates \ build-essential \ clang \ pkg-config \ libboost-all-dev \ libboost-python-dev \ libfreetype6-dev \ libx11-dev \ libxinerama-dev \ libxrandr-dev \ libxcursor-dev \ mesa-common-dev \ libasound2-dev \ freeglut3-dev \ libxcomposite-dev \ libcurl4-gnutls-dev \ libncurses-dev \ git \ cmake \ python3 \ python3-dev ``` -------------------------------- ### Place Clip Twice and Render Source: https://github.com/dbraun/dawdreamer/blob/main/docs/user_guide/playback_warp.md Demonstrates how to set clip positions for repeated patterns, configure Rubber Band options for time-stretching quality, and render the audio. Ensure the engine BPM is set to the target tempo for accurate beat-matching. ```python playback.set_clip_positions([ [0., 4., 0.], # First loop [4., 8., 0.] # Second loop ]) # Set Rubber Band options playback.set_options( daw.PlaybackWarpProcessor.option.OptionTransientsCrisp | daw.PlaybackWarpProcessor.option.OptionPitchHighQuality ) # Render engine.load_graph([(playback, [])]) engine.render(8., beats=True) # Save audio_out = engine.get_audio() wavfile.write('warped_drums.wav', SAMPLE_RATE, audio_out.transpose()) ``` -------------------------------- ### Get Plugin Parameters Description Source: https://github.com/dbraun/dawdreamer/blob/main/docs/user_guide/plugin_processor.md Retrieves a list of dictionaries, where each dictionary describes an available parameter of the plugin. You can also get a specific parameter's name by its index. ```python # Returns a list of dictionaries params = synth.get_parameters_description() print(params) # Get specific parameter name by index param_name = synth.get_parameter_name(1) print(param_name) # Example: "A Pan" for Serum oscillator A panning ``` -------------------------------- ### Initialize Render Engine Source: https://github.com/dbraun/dawdreamer/wiki/Render-Engine-and-BPM Create an instance of the RenderEngine with specified sample rate and buffer size. This is the primary object for audio rendering. ```python import dawdreamer as daw SAMPLE_RATE = 44100 BUFFER_SIZE = 128 # Parameters will undergo automation at this buffer/block size. # Make an engine. We typically only need one. engine = daw.RenderEngine(SAMPLE_RATE, BUFFER_SIZE) ```