Skip to content
TheChatArchiveThe Chat Archive
gpt-4.1-mini-2025-04-14· OpenAIAi2 WildChat-4.8M (AI2)

html chiptune tracker bpm piano rows per tracks patterns rows per pattern custom osc…

  1. User

    html chiptune tracker bpm piano rows per tracks patterns rows per pattern custom osc volume detune adsr filter noise share shortcuts loop "/#" no demo

  2. Assistant

    It looks like you're interested in creating or finding an HTML-based chiptune tracker with the following features and characteristics:

    • BPM control
    • Piano note input
    • Customizable rows per track
    • Patterns with rows per pattern
    • Support for custom oscillators
    • Controls for volume, detune, ADSR envelope, filter, noise
    • Ability to share compositions (maybe via URL hash or similar)
    • Keyboard shortcuts
    • Looping support
    • Use of the URL fragment (/#) to manage state or sharing
    • And notably, no demo (perhaps you prefer a minimal starting template or just the tool itself without example projects)

    What You Might Be Looking For

    There are a few existing HTML/JS chiptune trackers which might cover some of these features:

    • FamiTracker (Windows native, not HTML)
    • BeepBox (https://www.beepbox.co/) — online chiptune tracker with pattern editing, piano roll, custom waveforms, ADSR, filters, sharing via URL, looping, keyboard shortcuts.
    • WebAudio Tracker projects on GitHub, some with advanced synthesis options.

    Since you require no demo and feature-rich controls, if you're building your own or want an example codebase, here is an outline and advice.


    Building Your Own Minimal HTML Chiptune Tracker Skeleton

    You can create a simplified chiptune tracker in the browser with Web Audio API. Here's a high-level overview:

    1. UI components:

      • BPM input box
      • Piano keyboard UI or keyboard bindings
      • Pattern editor grid (rows x tracks)
      • Controls per track and per note for volume, detune, ADSR, filter, noise enable
      • Pattern navigation
      • Loop toggle
      • Share button (encoding pattern as JSON base64 in URL fragment)
    2. Audio engine:

      • Use OscillatorNode with selectable waveforms (sine, square, sawtooth, custom periodic wave)
      • GainNode for volume control and ADSR envelope shaping
      • BiquadFilterNode for filters (lowpass/highpass/etc.)
      • White noise source via AudioBufferSourceNode for noise
      • detune property on oscillators
    3. Playback engine:

      • Schedule notes per BPM and ticks using setTimeout or, preferably, AudioContext time scheduling
      • Looping over patterns
      • Real time changes to parameters
    4. Sharing:

      • Serialize current tracker state (patterns, BPM, instrument params) into a JSON string
      • Encode as base64 and put in the URL fragment /#state
      • Parse from URL to load state on page load

    Example Minimal Code Outline (no demo data):

    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8" />
    <title>Minimal HTML Chiptune Tracker</title>
    <style>
      body { font-family: monospace; background:#111; color:#eee; }
      #piano { margin: 10px; }
      .key { display: inline-block; width: 20px; height: 80px; margin: 1px; background: #333; }
      .key.white { background: white; height: 120px; width: 40px; margin: 1px; }
      .key.active { background: yellow; }
      #pattern { white-space: pre; font-size: 12px; line-height:1.2em; }
      input, button { margin: 4px; }
    </style>
    </head>
    <body>
    
    <h1>Minimal Chiptune Tracker</h1>
    
    <label for="bpm">BPM:</label>
    <input id="bpm" type="number" min="30" max="300" value="120" />
    
    <button id="playPause">Play</button>
    <button id="loopToggle">Loop: On</button>
    
    <div id="piano"></div>
    
    <pre id="pattern"></pre>
    
    <script>
    const AudioContext = window.AudioContext || window.webkitAudioContext;
    const ctx = new AudioContext();
    
    const bpmInput = document.getElementById('bpm');
    const playPauseBtn = document.getElementById('playPause');
    const loopToggleBtn = document.getElementById('loopToggle');
    const pianoDiv = document.getElementById('piano');
    const patternPre = document.getElementById('pattern');
    
    let isPlaying = false;
    let isLoop = true;
    let currentRow = 0;
    let timerId = null;
    
    const rowsPerPattern = 16;
    const tracks = 4;
    
    const notes = ['C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#', 'A', 'A#', 'B'];
    const baseOctave = 4;
    
    // Simple pattern data: rows * tracks with note names or null
    // Initialize empty pattern:
    let pattern = [];
    for(let r=0; r<rowsPerPattern; r++){
      pattern[r] = [];
      for(let t=0; t<tracks; t++){
        pattern[r][t] = null; // no note
      }
    }
    
    // Helper: map note name + octave to frequency
    function noteToFrequency(note, octave){
      let n = notes.indexOf(note);
      if(n<0) return 440;
      let keyNum = n + (octave+1)*12;
      return 440 * Math.pow(2,(keyNum-69)/12);
    }
    
    // Build piano UI for one octave + C5
    function buildPiano(){
      for(let i=0; i<notes.length; i++){
        let key = document.createElement('div');
        key.textContent = notes[i];
        key.className = 'key ' + (notes[i].includes('#') ? '' : 'white');
        pianoDiv.appendChild(key);
      }
    }
    buildPiano();
    
    // Play a note with oscillator + gain + ADSR (simplified)
    function playNote(freq, duration=0.5){
      if(ctx.state === 'suspended') ctx.resume();
      let osc = ctx.createOscillator();
      osc.type = 'square'; // chiptune style
      osc.frequency.setValueAtTime(freq, ctx.currentTime);
    
      let gainNode = ctx.createGain();
      gainNode.gain.setValueAtTime(0, ctx.currentTime);
      gainNode.gain.linearRampToValueAtTime(0.2, ctx.currentTime + 0.01); // attack
      gainNode.gain.linearRampToValueAtTime(0.1, ctx.currentTime + 0.1); // decay/sustain
    
      osc.connect(gainNode).connect(ctx.destination);
      osc.start();
    
      gainNode.gain.exponentialRampToValueAtTime(0.001, ctx.currentTime + duration);
      osc.stop(ctx.currentTime + duration + 0.05);
    }
    
    // Render pattern as ascii table
    function renderPattern(){
      let lines = [];
      for(let r=0; r<rowsPerPattern; r++){
        let line = r.toString().padStart(2,'0') + ' | ';
        for(let t=0; t<tracks; t++){
          line += (pattern[r][t] || '---') + ' ';
        }
        lines.push(line);
      }
      patternPre.textContent = lines.join('\n');
    }
    renderPattern();
    
    // Playback loop
    function playSequence(){
      let msPerRow = 60000/(bpmInput.value*4); // assuming 4 rows per beat
    
      function step(){
        // play notes on currentRow
        for(let t=0; t<tracks; t++){
          let note = pattern[currentRow][t];
          if(note){
            let [noteName, octave] = note.match(/[A-G]#?/)?.[0], parseInt(note.slice(-1));
            let freq = noteToFrequency(noteName, octave);
            playNote(freq, msPerRow/1000*0.8);
          }
        }
    
        currentRow++;
        if(currentRow >= rowsPerPattern){
          if(isLoop) currentRow = 0;
          else {
            stop();
            return;
          }
        }
        timerId = setTimeout(step, msPerRow);
      }
      step();
    }
    
    function stop(){
      isPlaying = false;
      playPauseBtn.textContent = "Play";
      clearTimeout(timerId);
      currentRow = 0;
    }
    
    playPauseBtn.onclick = () => {
      if(isPlaying){
        stop();
      } else{
        isPlaying = true;
        playPauseBtn.textContent = "Pause";
        playSequence();
      }
    };
    
    loopToggleBtn.onclick = () => {
      isLoop = !isLoop;
      loopToggleBtn.textContent = "Loop: " + (isLoop ? "On" : "Off");
    };
    
    // Keyboard shortcuts for toggling note on first track on current row (just demo)
    window.addEventListener('keydown', e => {
      if(e.key === 'a'){
        // toggle C4 note on track 0, currentRow
        let note = 'C4';
        if(pattern[currentRow][0] === note) pattern[currentRow][0] = null;
        else pattern[currentRow][0] = note;
        renderPattern();
      }
    });
    
    // Sharing (serialize pattern + bpm to base64 in URL hash)
    function exportState(){
      let state = {
        bpm: Number(bpmInput.value),
        pattern,
        loop: isLoop,
      };
      return btoa(JSON.stringify(state));
    }
    
    function importState(str){
      try {
        let state = JSON.parse(atob(str));
        bpmInput.value = state.bpm || 120;
        pattern = state.pattern || pattern;
        isLoop = state.loop !== undefined ? state.loop : true;
        loopToggleBtn.textContent = "Loop: " + (isLoop ? "On" : "Off");
        renderPattern();
      } catch(e){
        console.error('Invalid state in URL hash');
      }
    }
    
    if(location.hash.startsWith('#')){
      importState(location.hash.substring(1));
    }
    
    // Update URL hash on state change (debounced)
    function updateURL(){
      history.replaceState(null, '', '#'+exportState());
    }
    setInterval(updateURL, 1000);
    
    </script>
    </body>
    </html>
    

    What This Example Does:

    • Simple 4-track 16-row pattern editor (only visually displayed, no full UI editing)
    • Shows a piano keyboard (no interaction besides display)
    • Play/Pause and looping toggle buttons
    • Play sequence with 4 rows per beat and adjustable BPM
    • Keyboard shortcut a toggles C4 note on track 0, current row
    • Shares state via URL hash using base64-encoded JSON
    • Basic square wave oscillator with gain envelope for chiptune sound
    • No demo patterns included, fully blank on load unless hash present

    How to extend this:

    • Add full pattern editing UI (click cells to set notes)
    • Add custom oscillator types (triangle, sawtooth, custom periodic waves)
    • Add controls for detune, ADSR per track or instrument
    • Add noise channel using noise buffer + gain node
    • Add filters per track (BiquadFilterNode)
    • Add piano keyboard interaction (mouse and keyboard input)
    • Add undo/redo shortcuts
    • Save/load as JSON files

    Existing Alternatives You May Like:

    • BeepBox.co: Feature-rich, supports custom oscillators, ADSR, filters, piano keyboard, sharing via URL, looping, keyboard shortcuts. No installation needed.
    • jsfxr or chipmusic.js frameworks
    • Searching GitHub for "web audio chiptune tracker" will give sample projects.

    If you want me to help build a specific feature or refine the above example toward your exact requirements, just ask!

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.