Welcome to the Kretz Multi-Track Drum Machine v2.16 beta! This is a browser-based, 8-track drum synthesizer and sequencer built using the Web Audio API. It allows you to:
* Synthesize a wide variety of drum and percussion sounds from scratch using oscillators, envelopes, filters, and effects.
* Sequence these sounds across 8 independent tracks using a 32-step grid.
* Apply track-specific effects (Distortion) and sends to master effects (Reverb, Delay, Flanger).
* Control master effects and dynamics processing (Compressor).
* Adjust step velocity and pitch offset for dynamic and varied sequences.
* Visualize the final audio output with an oscilloscope.
* Save and load the entire state of the machine (all track parameters, sequences, and global settings) to a `.krtz` file.
**Target Audience:** Musicians, sound designers, hobbyists interested in electronic music production, sound synthesis, and browser-based audio tools. Some familiarity with synthesis concepts (oscillators, envelopes, filters) is helpful but not strictly required to start experimenting.
1. **Load the Machine:** Save the complete HTML code (provided previously) as a file named `kretz_drum_machine_v2.16.html` (or similar). Open this file in a modern web browser (like Chrome, Firefox, Edge, Safari).
2. **Activate Audio:** Due to browser security policies, audio playback often requires user interaction. **Click anywhere on the page** (e.g., a button or even empty space) after loading to activate the Web Audio API. You might see a message in the browser's developer console confirming the `AudioContext` has resumed if it was initially suspended.
3. **Explore:** You'll see the interface load with default sounds and an empty sequencer grid.
The interface is divided into several main sections:
1. **Top Button Bar:** Quick access to Play/Generate Selected Track, Play/Stop/Export Sequence, and Save/Load State functions.
2. **Instructions & Track Selector:** Displays the version information and provides buttons (`T1` to `T8`) to select the track you are currently editing. Each track also has Mute (`M`) and Solo (`S`) buttons.
3. **Controls (Main Synthesis Area):** This large grid contains multiple control groups for shaping the sound of the *currently selected track*.
* Oscillator
* Amplitude Envelope
* Filters (Lowpass & Highpass)
* Pitch Envelope
* Track Effects & Sends
4. **Master Effects:** Controls for effects applied to the overall mix (Compressor, Reverb, Delay, Flanger) and the final Master Volume.
5. **Sequencer:** The 32-step grid for programming patterns for all 8 tracks, plus controls for Tempo, Sequence Length, and sequence manipulation buttons.
6. **Visualization & Scope Zoom:** An Oscilloscope displaying the final output waveform and a control to zoom its horizontal scale.
7. **Bottom Button Bar:** Duplicate Play/Generate buttons for the selected track.
8. **Footer:** Copyright and version information.
* **Track:** The drum machine has 8 independent tracks. Each track holds its own unique set of synthesis parameters and its own 32-step sequence pattern. You edit one track at a time.
* **Parameters:** These are the settings within the `Controls` section (like Waveform, Attack, Cutoff, Distortion) that define the sound of the selected track.
* **Steps:** The sequencer grid consists of steps (up to 32 per track). An active step triggers the sound of its corresponding track at that point in the sequence. Each step also stores Velocity and Pitch Offset values.
* **Sends:** Instead of inserting an effect directly onto a track (which would require 8 separate reverbs, delays, etc.), tracks *send* a portion of their signal to shared Master Effects. The "Send" sliders control how much of that track's signal goes to the respective master effect.
* **Master Effects:** These effects (Reverb, Delay, Flanger) process the combined signals sent from the individual tracks. They affect the overall mix. The Compressor also acts on the master bus *before* the final volume control.
### 5.1. Track Selection & Mute/Solo (In Instructions section)
* **Track Select Buttons (`T1`-`T8`):** Click a button to select the track you want to edit. The controls in the main grid section will update to reflect that track's parameters. The active track button is highlighted.
* **Mute Button (`M`):** Click the `M` next to a track button to Mute that track. Muted tracks will not play during sequence playback (unless Soloed). The button turns red when muted. Click again to unmute.
* **Solo Button (`S`):** Click the `S` next to a track button to Solo that track. When any track is soloed, only soloed tracks will play during sequence playback. Mute buttons are ignored when solo is active. The button turns green when soloed. Click again to unsolo. If multiple tracks are soloed, they will all play.
### 5.2. Oscillator Section
This section defines the basic sound source for the selected track.
* **Waveform:** Select the fundamental oscillator shape:
* `Sine`: Pure, fundamental tone. Good for clean sub-basses, kick body.
* `Square`: Bright, hollow sound with only odd harmonics. Good for retro sounds, clicks, or filtered basses.
* `Sawtooth`: Harsh, buzzy sound with all harmonics. Good for basses, leads, or filtered percussion.
* `Noise`: White noise (random frequencies). Essential for snares, hi-hats, shakers, claps.
* `Random`: *Experimental.* Generates a sine wave with a random frequency each time it's triggered. Less predictable for standard drums.
* **Punch Amt:** Acts like a transient shaper. Increases the initial "click" or impact of the sound (0% to 100%). Very useful for adding attack to kicks and snares. *Disabled for Noise/Random waveforms.*
* **Pitch - Octave:** Sets the base octave range for the oscillator (C-3 to C5). *Disabled for Noise/Random waveforms.*
* **Pitch - Pitch (Fine):** Fine-tunes the oscillator frequency *added* to the base Octave frequency (0 Hz to 15000 Hz). Allows precise tuning. `0 Hz` effectively silences the oscillator if no pitch envelope is used. *Disabled for Noise/Random waveforms.*
* **Oscillator LFO (Vibrato):** A Low-Frequency Oscillator that modulates the main oscillator's pitch, creating vibrato. *Disabled for Noise/Random waveforms.*
* `Shape`: Waveform of the LFO (Sine, Square, Sawtooth, Triangle).
* `Rate (Hz)`: Speed of the vibrato (0.1 Hz to 30 Hz).
* `Amount (%)`: Intensity of the vibrato (0% to 100%).
### 5.3. Amplitude Envelope
Controls the volume shape of the sound over time (ADSR).
* **Attack (ms):** How long it takes for the sound to reach full volume (0-1000 ms). Very short attacks are typical for percussion.
* **Decay (ms):** How long it takes for the sound to decrease from full volume to the Sustain Level (0-1000 ms). Crucial for shaping the body/tail of drum sounds.
* **Sustain Lvl (%):** The volume level the sound holds at after the Decay phase, *if* the note was held (0-100%). For most percussion, this is set to 0. If set higher, the sound will continue until the Release phase starts.
* **Release (ms):** How long it takes for the sound to fade out from the Sustain Level to silence *after* the note trigger ends (0-2000 ms). For typical triggered drums where Sustain is 0, the Release effectively starts immediately after the Decay finishes. Defines the tail length.
### 5.4. Filters
Shape the frequency content of the sound. Each track has a Lowpass and a Highpass filter in series.
* **Lowpass (LP):** Cuts frequencies *above* the cutoff frequency.
* `LP Cutoff (Hz)`: The frequency above which sounds are attenuated (20-10000 Hz). Lower values make the sound darker/muffled.
* `LP Res (Resonance)`: Emphasizes frequencies *at* the cutoff point (0.0-20.0). Higher values create a "peaky" or whistling sound. Can self-oscillate at extreme settings.
* `LP Env Amt (%)`: How much the Amplitude Envelope affects the LP Cutoff frequency (0-100%). Positive values make the filter "open up" (cutoff increases) during the Attack/Decay phases.
* **Highpass (HP):** Cuts frequencies *below* the cutoff frequency.
* `HP Cutoff (Hz)`: The frequency below which sounds are attenuated (20-10000 Hz). Useful for removing low-end rumble or thinning out sounds.
* `HP Res (Resonance)`: Emphasizes frequencies *at* the cutoff point (0.0-20.0). Less commonly used aggressively on HP filters than LP.
* `HP Env Amt (%)`: How much the Amplitude Envelope affects the HP Cutoff frequency (0-100%). Positive values make the filter sweep upwards during the Attack/Decay.
### 5.5. Pitch Envelope
Modulates the oscillator's pitch over time. *Disabled for Noise/Random waveforms.*
* **Amount (%):** How much the envelope affects the pitch (0-100%). 100% represents a significant pitch sweep.
* **Speed (%):** Modifies the speed of the Pitch Envelope's Attack, Decay, and Release times. Negative values slow it down, positive values speed it up (-100% to +100%). 0% means the Attack/Decay/Release sliders use their exact millisecond values.
* **Attack (ms):** Time for the pitch sweep to reach its peak (defined by Amount).
* **Decay (ms):** Time for the pitch sweep to fall from the peak to the Pitch Sustain Level.
* **Sustain Lvl (%):** The pitch offset level held after the Pitch Decay phase. 0% means pitch returns towards the oscillator's base frequency.
* **Release (ms):** Time for the pitch to return to the oscillator's base frequency after the note trigger ends (or after Sustain, if Sustain Lvl > 0).
**Example:** A classic kick drum uses a fast Pitch Attack and Decay with a moderate Amount to create the initial "thump" as the pitch drops quickly.
### 5.6. Track Effects & Sends
Controls specific to the track's output stage.
* **Distortion (%):** Adds harmonic distortion/saturation to the track's sound (0-100%). Makes sounds grittier or more aggressive.
* **Volume (%):** Individual volume control for the selected track (0-100%). Affects the signal *before* sends and the master output.
* **Pan:** Controls the stereo position (-100 = Full Left, 0 = Center, +100 = Full Right).
* **Sends:**
* `Reverb Send (%)`: Amount of this track's signal sent to the Master Reverb.
* `Delay Send (%)`: Amount of this track's signal sent to the Master Delay.
* `Flanger Send (%)`: Amount of this track's signal sent to the Master Flanger.
### 5.7. Master Effects
Global effects applied to the mix of signals received from the track sends, plus master bus processing.
* **Compressor:** Reduces the dynamic range of the overall mix, making quieter parts louder and louder parts potentially quieter. Helps "glue" the mix together.
* `Comp Thresh (dB)`: The volume level above which compression starts (-60dB to 0dB). Lower values mean more signal gets compressed.
* `Comp Ratio`: How much the signal is reduced once it exceeds the threshold (e.g., 4:1 means for every 4dB over the threshold, the output only increases by 1dB).
* **Reverb:** Simulates acoustic space.
* `Pre-Delay (ms)`: Time before the reverb effect starts after the initial sound (0-200 ms).
* `Tone (LPF Hz)`: A lowpass filter on the reverb signal itself (100-15000 Hz). Lower values make the reverb darker.
* `Reverb Wet (%)`: Overall mix level of the reverb effect (0-100%).
* **Delay:** Creates echoes.
* `Delay Time`: Sets the delay time based on musical subdivisions of the current `Tempo` (1/16th note to whole note, including triplet 't' and dotted 'd' variations). The calculated time in seconds is shown in parentheses.
* `Delay Fbk (%)`: Amount of the delayed signal fed back into the delay input, creating multiple echoes (0-95%). High values can lead to runaway feedback.
* `Delay Wet (%)`: Overall mix level of the delay effect (0-100%).
* **Flanger:** Creates a swirling, metallic, "jet plane" sound by mixing the signal with a slightly delayed and modulated copy.
* `Rate (Hz)`: Speed of the LFO that modulates the flanger's delay time (0.05-5 Hz).
* `Depth (ms)`: Amount the LFO modulates the delay time (0.1-10 ms). Higher values create a wider sweep.
* `Delay (ms)`: Base delay time for the flanger effect (1-20 ms). This sets the center point around which the LFO modulates.
* `Feedback (%)`: Amount of the flanged signal fed back into its input (-90% to +90%). Positive feedback reinforces the effect, negative feedback creates a different, often hollower character.
* `Flanger Wet (%)`: Overall mix level of the flanger effect (0-100%).
* **Master Output:**
* `Master Vol (%)`: Final volume control for the entire drum machine output (0-100%).
* `Normalize Export`: Checkbox. If checked, exported WAV files (single track or sequence) will be normalized to peak at 0dBFS. If unchecked, they retain their original level relative to the Master Volume.
### 5.8. Sequencer
The heart of the rhythm programming.
* **Tempo (BPM):** Sets the playback speed (Beats Per Minute) from 40 to 240. Also affects tempo-synced Delay times.
* **Length:** Sets the number of steps in the sequence loop (1 to 32). Steps beyond this length are disabled visually and won't play.
* **Sequencer Grid:**
* Each row represents a track (T1-T8).
* Each column represents a step (1-32).
* **Left-Click:** Toggles a step On (active, purple) or Off (inactive, dark grey).
* **Right-Click:** Clears a step (sets inactive, resets velocity/pitch offset).
* **Vertical Drag (Left Mouse Button):** Adjusts the `Velocity` of the step (0-127). Velocity affects the loudness of the triggered note. The value is displayed within the step.
* **Shift + Vertical Drag (Left Mouse Button):** Adjusts the `Pitch Offset` of the step (-48 to +48 semitones). This overrides the track's base pitch for that specific step only. Useful for melodic variations or tonal percussion. The value is displayed with a +/- sign.
* **Playing Indicator:** Steps currently playing flash with a white outline.
* **Disabled Steps:** Steps beyond the set `Length` appear faded and cannot be activated.
* **Sequencer Controls:**
* `Play Seq`: Starts sequence playback.
* `Stop Seq`: Stops sequence playback and resets the playhead to the beginning.
* `Random Steps`: Randomly activates/deactivates steps and sets random velocities for the *currently selected track*.
* `Random Tones`: Sets random Pitch Offset values for all steps on the *currently selected track*.
* `Clear Steps`: Clears all steps (sets inactive, resets velocity/pitch) for the *currently selected track*.
* `Clear All Tracks`: Clears all steps for *all 8 tracks*.
* `Export Seq WAV`: Renders the current sequence (respecting Mute/Solo states and sequence Length) to a WAV file and initiates download (honors the Normalize checkbox).
### 5.9. Visualization
* **Master Oscilloscope:** Displays the waveform of the final stereo output *after* all master effects and master volume. Useful for seeing the overall shape and level of your mix.
* **Scope Zoom:** Adjusts the horizontal magnification of the oscilloscope display (0.1x to 10.0x). Useful for examining waveform details or seeing more of the overall shape.
### 5.10. Save/Load State
* **Save State (.krtz):** Click to save the *entire* current state of the drum machine – all track parameters, sequences (including step active state, velocity, pitch offset), mute/solo states, tempo, sequence length, all master effect settings, and scope zoom – into a single `.krtz` file (JSON format). The filename includes a timestamp.
* **Load State (.krtz):** Click this button, then select a previously saved `.krtz` file. This will completely restore the machine to the state saved in that file. **Warning:** Loading will overwrite your current session.
### Example 1: Creating a Basic Kick Drum (Track 1)
1. **Select Track:** Click `T1`.
2. **Oscillator:**
* Set `Waveform` to `Sine`.
* Set `Octave` to `C0` or `C-1` for a low fundamental.
* Adjust `Pitch (Fine)` slightly if needed (e.g., 50-150 Hz).
* Increase `Punch Amt` significantly (e.g., 70-90%) for attack.
3. **Amplitude Envelope:**
* `Attack`: Keep very low (1-5 ms).
* `Decay`: Short to medium (80-200 ms). This defines the kick's length.
* `Sustain Lvl`: 0%.
* `Release`: Short (50-100 ms).
4. **Pitch Envelope:**
* `Amount`: Medium to high (50-80%).
* `Speed`: 0% or slightly positive.
* `Attack`: Very short (1-5 ms).
* `Decay`: Very short (20-60 ms). This creates the pitch drop.
* `Sustain Lvl`: 0%.
* `Release`: Short (50 ms).
5. **Filters:** Maybe use `LP Cutoff` to remove high frequencies if needed, or `HP Cutoff` slightly (e.g., 30Hz) to remove sub-rumble.
6. **Play:** Click the `Play Selected Track` button (top or bottom bar) to hear the sound. Tweak parameters until satisfied.
### Example 2: Creating a Basic Snare Drum (Track 2)
1. **Select Track:** Click `T2`.
2. **Oscillator:**
* Set `Waveform` to `Noise`. (Pitch controls become disabled).
3. **Amplitude Envelope:**
* `Attack`: Very short (1-5 ms).
* `Decay`: Short (80-150 ms).
* `Sustain Lvl`: 0%.
* `Release`: Short (50-100 ms).
4. **Filters:** Crucial for snare shaping.
* `LP Cutoff`: Adjust to control brightness (e.g., 4000-8000 Hz).
* `HP Cutoff`: Adjust to control body/thinness (e.g., 200-1000 Hz).
* `LP Res / HP Res`: Experiment with small amounts for character.
5. **Track Effects:** Add some `Distortion` (e.g., 10-30%) for grit.
6. **Sends:** Add some `Reverb Send` for space.
7. **Play:** Click `Play Selected Track` and adjust filters/decay.
* *Optional:* Layer a pitched element. Select another track (e.g., T3), create a short sine/square sound with a quick decay, and trigger it on the same steps as the snare in the sequencer.
### Example 3: Creating Basic Hi-Hats (Track 4)
1. **Select Track:** Click `T4`.
2. **Oscillator:** Set `Waveform` to `Noise`.
3. **Amplitude Envelope:**
* `Attack`: 1 ms.
* `Decay`: Very short (10-50 ms for closed hat, 100-200 ms for open hat).
* `Sustain Lvl`: 0%.
* `Release`: Very short (10-50 ms).
4. **Filters:**
* `HP Cutoff`: Set high (e.g., 5000-9000 Hz) to make it sound thin and "hissy".
* `LP Cutoff`: Keep high or fully open (10000 Hz).
5. **Play:** Adjust `Decay`/`Release` and `HP Cutoff` for desired sound. Use separate tracks for closed and open hats if needed.
### Example 4: Sequencing a Simple Beat
1. Create sounds for Kick (T1), Snare (T2), Closed Hat (T4) using the methods above.
2. **Set Tempo:** Adjust the `Tempo` slider (e.g., 120 BPM).
3. **Set Length:** Ensure `Length` is set (e.g., 16 or 32 steps).
4. **Program Kick (T1):** Left-click steps 1, 5, 9, 13 (a basic four-on-the-floor pattern).
5. **Program Snare (T2):** Left-click steps 5, 13 (on the 2nd and 4th beat).
6. **Program Hi-Hat (T4):** Left-click steps 1, 3, 5, 7, 9, 11, 13, 15 (straight eighth notes).
7. **Play:** Click `Play Sequence` (or `Seq Play Top Btn`).
8. **Adjust:** Use Mute/Solo. Tweak track `Volume`/`Pan`. Add `Delay Send` to the snare. Adjust step `Velocity` by dragging vertically on steps. Add a pitch offset (`Shift+Drag`) to one of the snare hits.
* **Experiment:** Don't be afraid to turn knobs randomly! Synthesis is about exploration.
* **Subtlety is Key:** Often, small amounts of distortion, filtering, or effects can make a big difference without overwhelming the sound.
* **Layering:** Use multiple tracks triggered simultaneously to create more complex sounds (e.g., Noise + Sine for a snare body).
* **Velocity & Pitch Offset:** Use these step parameters extensively to make sequences less robotic and more dynamic.
* **Filters are Powerful:** Learn how LP/HP filters and resonance shape sounds – they are fundamental to drum synthesis.
* **Envelopes Define Shape:** The Amp and Pitch envelopes are critical for defining the attack, body, and tail of your drum sounds. Master them!
* **Sends vs. Volume:** Use sends for shared spatial effects (Reverb, Delay). Use track `Volume` for individual track levels in the mix.
* **Save Often:** Use the `Save State` button frequently during your session to avoid losing work. Give files descriptive names.
* **Use the Oscilloscope:** Get a visual feel for how your sounds and the overall mix are behaving dynamically.
* **No Sound:**
* Did you click the page after loading to activate the AudioContext? Check the browser console for errors.
* Is the Master Volume slider up?
* Is the Track Volume slider up for the selected track?
* Are tracks muted or is solo active inappropriately?
* Is the oscillator `Pitch (Fine)` set to 0 Hz for a pitched waveform (Sine, Square, Saw)?
* Are filter cutoffs set extremely low (LP) or high (HP), filtering out all sound?
* Is the Amplitude Envelope Attack extremely long or Decay/Release extremely short?
* **Sequencer Not Playing:**
* Did you click `Play Sequence`?
* Are there active steps programmed on unmuted/soloed tracks within the current `Length`?
* **Save/Load Issues:**
* Ensure you are using `.krtz` files generated by this version or a compatible one. Loading states from significantly different versions might fail or produce unexpected results.
* If saving fails repeatedly, check the browser's developer console for `JSON.stringify` errors. This might indicate a rare corruption in the internal state (try refreshing or loading a known good state).
* **CPU Overload (Glitches/Stuttering):**
* Complex sounds on many tracks playing simultaneously, especially with heavy effects (like Reverb or many distortion instances), can tax the CPU.
* Try simplifying sounds, reducing the number of simultaneous notes, or using sends more efficiently instead of heavy effects on every track.
* Close other demanding browser tabs or applications.
## 9. Conclusion
The Kretz Multi-Track Drum Machine offers a powerful platform for creating unique electronic drum sounds and sequences directly in your browser. Explore the synthesis options, program intricate rhythms, and utilize the effects to shape your final sound. Happy drumming!