It sounds like you want to build (or get help with) a web-based HTML chiptune tracker featuring:
- BPM control
- Rows per track
- Patterns with rows per pattern
- Multiple instruments, each with synth settings (custom oscillators, volume, detune, ADSR envelope, filter, noise)
- Ability to share songs (maybe via URL hash "/#")
- Keyboard shortcuts
- Loop playback
- No demo included (minimal or no preload content)
I can help outline how to make such a tracker or provide a starter code example. A full tracker is a complex project but I can suggest the architecture, libraries, and a minimal baseline implementation in HTML/JS.
Basic architecture
-
Data model:
- Song: Contains BPM, tracks
- Track: Contains patterns (pattern sequences)
- Pattern: Contains rows
- Row: Contains notes, instrument triggers
- Instrument: Synth engine params (oscillator type, volume, detune, ADSR, filter, noise)
-
Audio synth:
Use Web Audio API to build a chiptune-style synth with custom oscillator waveforms and apply volume, detune, ADSR, filter and noise modulation.
-
UI:
- Tracker grid: pattern rows for each track
- Controls: BPM, rows per pattern
- Instrument editor: waveform selection, ADSR sliders, volume, etc.
- Playback controls: play, stop, loop toggle
- Share: encode song state into URL hash (e.g.
/#songDataBase64) and decode on load
- Keyboard shortcuts: navigation, play/stop, note entry
Minimal example partial code snippet for a synth instrument with oscillator + ADSR + filter + noise
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Simple HTML Chiptune Tracker</title>
<style>
body { font-family: monospace; background: #222; color: #eee; }
.tracker { display: grid; grid-template-columns: repeat(4, 50px); grid-gap: 2px; }
.cell { padding: 3px; border: 1px solid #444; text-align: center; }
.instrument-editor { margin-top: 20px; }
</style>
</head>
<body>
<h1>Chiptune Tracker (minimal)</h1>
BPM: <input type="number" id="bpm" value="120" min="30" max="300" />
<button id="playBtn">Play</button>
<div class="tracker" id="tracker"></div>
<div class="instrument-editor">
<h2>Instrument 1 Settings</h2>
Oscillator:
<select id="oscType">
<option value="square">Square</option>
<option value="sawtooth">Sawtooth</option>
<option value="triangle">Triangle</option>
<option value="custom">Custom (noise)</option>
</select><br/>
Volume: <input type="range" id="volume" min="0" max="1" step="0.01" value="0.5" /><br/>
Detune (cents): <input type="number" id="detune" min="-100" max="100" value="0" /><br/>
ADSR (ms): A <input type="number" id="attack" value="10" min="0" max="1000" step="1" />
D <input type="number" id="decay" value="50" min="0" max="1000" step="1" />
S <input type="range" id="sustain" min="0" max="1" step="0.01" value="0.8" />
R <input type="number" id="release" value="300" min="0" max="2000" step="1" /><br/>
</div>
<script>
const AudioCtx = window.AudioContext || window.webkitAudioContext;
const audioCtx = new AudioCtx();
// Simple instrument settings
let instrument = {
oscType: 'square',
volume: 0.5,
detune: 0,
adsr: {attack:0.01, decay:0.05, sustain:0.8, release:0.3},
};
// Update instrument on UI change
document.getElementById('oscType').addEventListener('change', e => instrument.oscType = e.target.value);
document.getElementById('volume').addEventListener('input', e => instrument.volume = parseFloat(e.target.value));
document.getElementById('detune').addEventListener('input', e => instrument.detune = parseInt(e.target.value));
document.getElementById('attack').addEventListener('input', e => instrument.adsr.attack = e.target.value/1000);
document.getElementById('decay').addEventListener('input', e => instrument.adsr.decay = e.target.value/1000);
document.getElementById('sustain').addEventListener('input', e => instrument.adsr.sustain = e.target.value);
document.getElementById('release').addEventListener('input', e => instrument.adsr.release = e.target.value/1000);
// Play a note helper function
function playNote(freq, time=audioCtx.currentTime, duration=0.5) {
let osc;
if(instrument.oscType === 'custom'){
// White noise example as custom oscillator
let bufferSize = audioCtx.sampleRate * duration;
let buffer = audioCtx.createBuffer(1, bufferSize, audioCtx.sampleRate);
let data = buffer.getChannelData(0);
for(let i=0; i<bufferSize; i++) data[i] = (Math.random()*2 -1)*0.3;
const noise = audioCtx.createBufferSource();
noise.buffer = buffer;
noise.loop = false;
const gainNode = audioCtx.createGain();
gainNode.gain.setValueAtTime(0, time);
gainNode.gain.linearRampToValueAtTime(instrument.volume, time + instrument.adsr.attack);
gainNode.gain.linearRampToValueAtTime(instrument.volume * instrument.adsr.sustain, time + instrument.adsr.attack + instrument.adsr.decay);
gainNode.gain.setValueAtTime(instrument.volume * instrument.adsr.sustain, time + duration);
gainNode.gain.linearRampToValueAtTime(0, time + duration + instrument.adsr.release);
noise.connect(gainNode).connect(audioCtx.destination);
noise.start(time);
noise.stop(time + duration + instrument.adsr.release);
return;
}
osc = audioCtx.createOscillator();
osc.type = instrument.oscType;
osc.frequency.setValueAtTime(freq, time);
osc.detune.setValueAtTime(instrument.detune, time);
const gainNode = audioCtx.createGain();
gainNode.gain.setValueAtTime(0, time);
gainNode.gain.linearRampToValueAtTime(instrument.volume, time + instrument.adsr.attack);
gainNode.gain.linearRampToValueAtTime(instrument.volume * instrument.adsr.sustain, time + instrument.adsr.attack + instrument.adsr.decay);
gainNode.gain.setValueAtTime(instrument.volume * instrument.adsr.sustain, time + duration);
gainNode.gain.linearRampToValueAtTime(0, time + duration + instrument.adsr.release);
osc.connect(gainNode);
gainNode.connect(audioCtx.destination);
osc.start(time);
osc.stop(time + duration + instrument.adsr.release);
}
// Testing playback
document.getElementById('playBtn').addEventListener('click', () => {
let baseFreq = 440; // A4
// Play major scale as an example
let notes = [0, 2, 4, 5, 7, 9, 11, 12];
let now = audioCtx.currentTime;
notes.forEach((note, i) => {
playNote(baseFreq * Math.pow(2, note/12), now + i * 0.5, 0.4);
});
});
</script>
</body>
</html>
Next steps / extending
- Add a tracker grid UI for multiple tracks and patterns with rows with note input.
- Implement a pattern data structure and song playback scheduler (timing based on BPM and rows per pattern).
- Add logic to encode the song data (notes, pattern order, instruments) into a sharable string (e.g., base64 JSON) in URL hash for sharing.
- Implement keyboard shortcuts (e.g. space to play/stop, arrow keys to move cursor).
- Add looping playback toggle.
- Add filter (e.g.
BiquadFilterNode) per instrument in the synth chain.
- Add noise oscillator for percussive/noise instruments.
- Support rows per track and rows per pattern configuration UI.
If you want, I can help build out any section specifically: UI grid, playback engine, sharing system, keyboard input, or synth engine.
Also, you can check for open source chiptune trackers written in JS for inspiration, e.g.:
Let me know how you'd like to proceed or which area you want me to focus on!