html chiptune tracker piano bpm rows per tracks patterns rows per pattern synth per…
- User
html chiptune tracker piano bpm rows per tracks patterns rows per pattern synth per instrument custom osc volume detune adsr filter noise share song shortcuts loop "/#" no demo
- Assistant
It sounds like you want to create (or find) an HTML-based chiptune tracker with features like:
- Piano keyboard interface
- BPM (tempo) control
- Rows per track and patterns
- Patterns and rows per pattern
- Synth per instrument with custom oscillators
- Volume, detune, ADSR envelope, filter, noise controls
- Ability to share songs (via URLs or hash
/#!) - Keyboard shortcuts for better UX
- Looping functionality
- No demo/autoplay on load
What you want sounds like a minimal but feature-rich browser chiptune tracker.
While there might be existing projects similar to this, I can help you with pointers or a minimal template. First, I'll list some existing projects, then outline how you would implement the core features with Web Audio API, then provide a basic code example scaffolding.
Existing Projects / Inspirations
-
BeepBox − https://beepbox.co/
Fully featured, supports patterns, oscillator selection, envelope, filters, sharing with URL, keyboard shortcuts, looping. -
FamiTracker (native app) − not browser-based but a chiptune tracker.
-
JSChiptune − https://github.com/jscynth/jscynth (usually playback focused)
-
Tone.js − A great Web Audio framework simplifying synth and effects.
Key Feature Breakdown
Feature How to do it in Web Audio / HTML/JS Piano keyboard HTML keyboard UI with click and keyboard event support BPM Control of tempo, controlling interval or requestAnimationFrameto play rowsRows per track, Patterns Use JS arrays to store sequences of notes per pattern and per track Synth per instrument Use Web Audio OscillatorNodes, create a synth for each instrument Custom oscillator oscillators of type 'sine', 'square', 'triangle', 'sawtooth' or custom waveforms Volume, detune, ADSR GainNode for volume, detune property on OscillatorNode, GainNodes with time-automations for ADSR envelopes Filter BiquadFilterNode with cutoff frequency and type Noise White noise generated with AudioBufferSourceNode and filtered Share song via URL Serialize tracker data to JSON encode it into URL hash (e.g. /#!datahere)Shortcuts Add event listeners for keydown to implement transport controls, note input, etc. Loop Repeat playback by cycling thru patterns No demo Start with blank song or pause playback initially
Minimal example skeleton
Here's a very simplified minimal example outline you can expand:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width" /> <title>Minimal Chiptune Tracker</title> <style> body { font-family: monospace; background: #222; color: #eee; } #piano { user-select:none; } .key { display: inline-block; width: 24px; height: 120px; margin: 1px; border: 1px solid #444; background: #ccc; cursor: pointer; } .key.black { background: #333; width: 16px; height: 80px; position: relative; left: -8px; margin-right: -8px; } #tracker { margin-top: 1em; } table { border-collapse: collapse; } td { border: 1px solid #555; width: 40px; height: 24px; text-align: center; cursor: pointer; } td.note { background: #444; } td.note.active { background: #6cf; } </style> </head> <body> <h1>Minimal Chiptune Tracker</h1> <div id="controls"> BPM: <input type="number" id="bpm" min="60" max="240" value="120" /> <button id="playpause">Play</button> Loop: <input type="checkbox" id="loop" checked /> </div> <div id="piano"></div> <div id="tracker"> <table id="pattern"></table> </div> <script> const AudioContext = window.AudioContext || window.webkitAudioContext; const audioCtx = new AudioContext(); // Basic piano keys: C4 to B4 const notes = ['C4','C#4','D4','D#4','E4','F4','F#4','G4','G#4','A4','A#4','B4']; const frequencies = { 'C4':261.63,'C#4':277.18,'D4':293.66,'D#4':311.13,'E4':329.63,'F4':349.23, 'F#4':369.99,'G4':392,'G#4':415.3,'A4':440,'A#4':466.16,'B4':493.88 }; // Build piano const pianoDiv = document.getElementById('piano'); notes.forEach(note=>{ const key = document.createElement('div'); key.classList.add('key'); if(note.includes('#')) key.classList.add('black'); key.textContent = note.replace('4',''); key.dataset.note = note; key.addEventListener('mousedown', ()=>playNote(note)); pianoDiv.appendChild(key); }); function playNote(note, duration=0.5) { const osc = audioCtx.createOscillator(); const gain = audioCtx.createGain(); osc.frequency.value = frequencies[note]; osc.type = 'square'; // chiptune style gain.gain.setValueAtTime(0.3, audioCtx.currentTime); // Simple ADSR gain.gain.exponentialRampToValueAtTime(0.0001, audioCtx.currentTime + duration); osc.connect(gain).connect(audioCtx.destination); osc.start(); osc.stop(audioCtx.currentTime + duration); } // Tracker data model: Let's say one track, one pattern 16 rows let patternLength = 16; let bpm = 120; let interval = 60000/bpm/4; // 4 rows per beat let patternData = new Array(patternLength).fill(null); // each row can store {note: 'C4', instrument: 0} // Build pattern table in DOM const table = document.getElementById('pattern'); for (let i=0; i<patternLength; i++) { const tr = document.createElement('tr'); const tdNum = document.createElement('td'); tdNum.textContent = i+1; tr.appendChild(tdNum); const tdNote = document.createElement('td'); tdNote.classList.add('note'); tdNote.textContent = '-'; tdNote.dataset.row = i; tdNote.addEventListener('click', e=>{ // Cycle through notes as example let row = e.target.dataset.row; let current = patternData[row]; if(current === null) { patternData[row] = {note:'C4'}; } else { // cycle notes let idx = notes.indexOf(current.note); idx = (idx + 1) % notes.length; patternData[row] = {note: notes[idx]}; } updateTable(); }); tr.appendChild(tdNote); table.appendChild(tr); } function updateTable() { // update pattern display for(let i=0; i<patternLength; i++) { const td = table.rows[i].cells[1]; td.textContent = patternData[i] ? patternData[i].note : '-'; } } updateTable(); // Playback control let playing = false; let currentRow = 0; let timerId; const playPauseBtn = document.getElementById('playpause'); function playRow(row) { const noteData = patternData[row]; if(noteData) playNote(noteData.note, interval/1000*0.9); highlightRow(row); } function highlightRow(row) { for(let i=0; i<patternLength; i++) { table.rows[i].cells[1].style.backgroundColor = (i===row) ? '#3af' : '#444'; } } function scheduler() { if(!playing) return; playRow(currentRow); currentRow++; if(currentRow >= patternLength) { if(document.getElementById('loop').checked) currentRow = 0; else { playing = false; playPauseBtn.textContent = 'Play'; return; } } timerId = setTimeout(scheduler, interval); } playPauseBtn.onclick = () => { if(!playing) { if(audioCtx.state === 'suspended') audioCtx.resume(); playing = true; playPauseBtn.textContent = 'Pause'; scheduler(); } else { playing = false; playPauseBtn.textContent = 'Play'; clearTimeout(timerId); } }; document.getElementById('bpm').addEventListener('change', e=>{ bpm = Number(e.target.value); interval = 60000/bpm/4; }); // Keyboard shortcuts (space to play/pause) window.addEventListener('keydown', e=>{ if(e.code === 'Space') { e.preventDefault(); playPauseBtn.click(); } }); </script> </body> </html>
What you get here:
- Simple piano keyboard with notes C4-B4, square wave synth played on mouse click
- A single-pattern tracker grid to input notes by clicking the table cells cycling through notes
- Play/pause button and BPM control
- Playback rows at correct timing with loop option
- Spacebar shortcut to toggle play/pause
- No demo audio on page load (must click play)
How to extend this?
- Add multiple tracks
- Add multiple patterns and pattern switching
- Custom oscillator shapes (via
audioCtx.createPeriodicWave()) - ADSR envelope with Attack, Decay, Sustain, Release sliders controlling GainNode automation curves
- Filter effects with BiquadFilterNode controlled per instrument
- Noise channel with AudioBufferSourceNode playing buffer of random samples
- Save and load song state to/from URL hash (base64 or URI encoded JSON string)
- Keyboard piano input with computer keyboard (e.g. Z,S,X,D,C,V... for chromatic)
Summary
- You can build a custom chiptune tracker in HTML + JS using Web Audio API with oscillator nodes and gain envelopes
- The above minimal example is a starting point showing core concepts
- For full trackers, consider libraries like Tone.js to simplify synth and scheduling
- For sharing, implement JSON serialization of your song data and embed in URL hash after encoding
If you want, I can help you build any specific feature or work on a more complete tracker. Let me know!
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.