It looks like you want an HTML-based chiptune tracker with features such as:
- BPM control
- Rows per track
- Patterns with rows per pattern
- Synth per instrument with customizable oscillator, volume, detune, ADSR envelope, filter, noise
- Ability to share songs (likely via URL hash
/#)
- Keyboard shortcuts
- Looping
- No demo sounds or autoplay on load
I can help you build a minimal chiptune tracker in pure HTML/JS with these features. It will be a basic but functional tracker with a small synth engine using Web Audio API oscillators and filters.
Here is a simple starting point for your tracker:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Minimal HTML Chiptune Tracker</title>
<style>
body { font-family: monospace; background: #111; color: #eee; margin: 0; padding: 0;}
#tracker { display: grid; grid-template-columns: 1fr 200px; height: 100vh; }
#pattern { background: #222; overflow: auto; }
#controls { background: #333; padding: 8px; display: flex; flex-direction: column; gap: 12px; }
table { border-collapse: collapse; width: 100%; }
td, th { border: 1px solid #444; padding: 4px; text-align: center; }
input, select, button { background: #555; border: none; color: #eee; padding: 4px; }
input[type=number] { width: 60px; }
select { width: 120px; }
button:hover { background: #777; cursor: pointer; }
.highlight { background: #444; }
</style>
</head>
<body>
<div id="tracker">
<div id="pattern">
<table id="table-pattern">
<!-- pattern rows added by JS -->
</table>
</div>
<div id="controls">
<div>
<label>BPM: <input type="number" id="bpm" min="30" max="300" value="120"></label>
</div>
<div>
<label>Rows per Pattern: <input type="number" id="rows" min="4" max="64" value="16"></label>
</div>
<div>
<label>Instruments:
<select id="instrument-select"></select>
</label>
<button id="add-instrument">+ Add Instrument</button>
</div>
<fieldset>
<legend>Instrument Settings</legend>
<label>Oscillator:
<select id="osc-type">
<option value="square">Square</option>
<option value="sawtooth">Sawtooth</option>
<option value="triangle">Triangle</option>
<option value="sine">Sine</option>
</select>
</label><br />
<label>Volume:
<input type="number" id="volume" min="0" max="1" step="0.01" value="0.5">
</label><br />
<label>Detune (cents):
<input type="number" id="detune" min="-100" max="100" value="0">
</label><br />
<label>ADSR (ms):
<input type="number" id="attack" min="0" max="2000" value="10"> A
<input type="number" id="decay" min="0" max="2000" value="50"> D
<input type="number" id="sustain" min="0" max="1" step="0.01" value="0.7"> S
<input type="number" id="release" min="0" max="2000" value="100"> R
</label><br />
<label>Filter cutoff (Hz):
<input type="number" id="filter-cutoff" min="20" max="20000" value="12000">
</label><br />
<label>Noise level (0-1):
<input type="number" id="noise" min="0" max="1" step="0.01" value="0">
</label><br />
<button id="save-instr-btn">Save Instrument</button>
</fieldset>
<button id="play-btn">Play</button>
<button id="stop-btn" disabled>Stop</button>
<button id="share-btn">Share Song (URL)</button>
<p><small>Keyboard Shortcuts (when pattern focused): Space - Play/Stop, Arrow Keys - Navigate, Enter - Edit</small></p>
</div>
</div>
<script>
// -- Globals --
const notes = ['C', 'C#','D','D#','E','F','F#','G','G#','A','A#','B'];
const baseOctave = 4;
let bpm = 120;
let rowsPerPattern = 16;
let instruments = [];
let currentInstrumentIndex = 0;
let patternData = []; // array of rows, each row is array per channel (here one channel only)
let isPlaying = false;
let currentRow = 0;
let timerId = null;
let audioCtx = null;
const tablePattern = document.getElementById('table-pattern');
const bpmInput = document.getElementById('bpm');
const rowsInput = document.getElementById('rows');
const playBtn = document.getElementById('play-btn');
const stopBtn = document.getElementById('stop-btn');
const instrumentSelect = document.getElementById('instrument-select');
const addInstrumentBtn = document.getElementById('add-instrument');
// Instrument controls
const oscTypeSelect = document.getElementById('osc-type');
const volumeInput = document.getElementById('volume');
const detuneInput = document.getElementById('detune');
const attackInput = document.getElementById('attack');
const decayInput = document.getElementById('decay');
const sustainInput = document.getElementById('sustain');
const releaseInput = document.getElementById('release');
const filterCutoffInput = document.getElementById('filter-cutoff');
const noiseInput = document.getElementById('noise');
const saveInstrBtn = document.getElementById('save-instr-btn');
const shareBtn = document.getElementById('share-btn');
// Helpers
function noteToFrequency(noteStr) {
// example noteStr like "C#4", "A3"
let pattern = /^([A-G]#?)(\d)$/;
let m = noteStr.match(pattern);
if (!m) return null;
let note = m[1];
let octave = parseInt(m[2]);
let nIndex = notes.indexOf(note);
if (nIndex < 0) return null;
// MIDI Note Number for A4 = 69
let midiNum = 12 * (octave + 1) + nIndex;
// Frequency formula
return 440 * Math.pow(2, (midiNum - 69)/12);
}
// Initialize pattern data with empty notes
function initPattern() {
patternData = [];
for(let r=0; r<rowsPerPattern; r++) {
patternData.push([null]); // here only 1 track/channel
}
}
// Render the pattern table
function renderPattern() {
tablePattern.innerHTML = '';
let thead = document.createElement('thead');
let trHead = document.createElement('tr');
let thRow = document.createElement('th');
thRow.textContent = 'Row';
let thNote = document.createElement('th');
thNote.textContent = 'Note';
trHead.appendChild(thRow);
trHead.appendChild(thNote);
thead.appendChild(trHead);
tablePattern.appendChild(thead);
let tbody = document.createElement('tbody');
patternData.forEach((row, r) => {
let tr = document.createElement('tr');
tr.dataset.row = r;
let tdRow = document.createElement('td');
tdRow.textContent = r + 1;
tr.appendChild(tdRow);
let tdNote = document.createElement('td');
tdNote.textContent = row[0] || '';
tdNote.contentEditable = 'true';
tdNote.classList.add('editable');
tr.appendChild(tdNote);
tbody.appendChild(tr);
});
tablePattern.appendChild(tbody);
}
// Save edits from pattern table
function savePatternEdits() {
const rows = tablePattern.querySelectorAll('tbody tr');
rows.forEach(r => {
const idx = Number(r.dataset.row);
const noteTd = r.children[1];
let val = noteTd.textContent.trim().toUpperCase();
// Validate note or null
if (val === '' || /^[A-G]#?\d$/.test(val)) {
patternData[idx][0] = val || null;
} else {
// invalid input, reset to previous value
noteTd.textContent = patternData[idx][0] || '';
}
});
}
// -- Instrument Functions --
function addInstrument() {
const newInstr = {
oscType: 'square',
volume: 0.5,
detune: 0,
adsr: { attack:10, decay:50, sustain:0.7, release:100 },
filterCutoff: 12000,
noiseLevel: 0
};
instruments.push(newInstr);
currentInstrumentIndex = instruments.length -1;
updateInstrumentSelect();
loadInstrumentSettings();
}
function updateInstrumentSelect() {
instrumentSelect.innerHTML = '';
instruments.forEach((instr, i) => {
let option = document.createElement('option');
option.value = i;
option.textContent = 'Instrument ' + (i+1);
instrumentSelect.appendChild(option);
});
instrumentSelect.value = currentInstrumentIndex;
}
function loadInstrumentSettings() {
if(instruments.length === 0) return;
const instr = instruments[currentInstrumentIndex];
oscTypeSelect.value = instr.oscType;
volumeInput.value = instr.volume;
detuneInput.value = instr.detune;
attackInput.value = instr.adsr.attack;
decayInput.value = instr.adsr.decay;
sustainInput.value = instr.adsr.sustain;
releaseInput.value = instr.adsr.release;
filterCutoffInput.value = instr.filterCutoff;
noiseInput.value = instr.noiseLevel;
}
function saveInstrumentSettings() {
if(instruments.length === 0) return;
let instr = instruments[currentInstrumentIndex];
instr.oscType = oscTypeSelect.value;
instr.volume = parseFloat(volumeInput.value);
instr.detune = parseFloat(detuneInput.value);
instr.adsr.attack = parseInt(attackInput.value);
instr.adsr.decay = parseInt(decayInput.value);
instr.adsr.sustain = parseFloat(sustainInput.value);
instr.adsr.release = parseInt(releaseInput.value);
instr.filterCutoff = parseInt(filterCutoffInput.value);
instr.noiseLevel = parseFloat(noiseInput.value);
}
// -- Audio --
function playNote(freq, instr) {
if(!audioCtx) audioCtx = new AudioContext();
let t0 = audioCtx.currentTime;
// Oscillator
let osc = audioCtx.createOscillator();
osc.type = instr.oscType;
osc.frequency.setValueAtTime(freq, t0);
osc.detune.setValueAtTime(instr.detune, t0);
// Gain node for ADSR
let gainNode = audioCtx.createGain();
// Filter
let filter = audioCtx.createBiquadFilter();
filter.type = "lowpass";
filter.frequency.setValueAtTime(instr.filterCutoff, t0);
// Noise (if >0)
let noiseNode = null;
if (instr.noiseLevel > 0) {
let bufferSize = audioCtx.sampleRate * 0.1;
let buffer = audioCtx.createBuffer(1, bufferSize, audioCtx.sampleRate);
let output = buffer.getChannelData(0);
for (let i = 0; i < bufferSize; i++) {
output[i] = (Math.random() * 2 -1) * instr.noiseLevel;
}
noiseNode = audioCtx.createBufferSource();
noiseNode.buffer = buffer;
noiseNode.loop = true;
}
// Connect nodes
osc.connect(gainNode);
gainNode.connect(filter);
if (noiseNode) noiseNode.connect(filter);
filter.connect(audioCtx.destination);
// ADSR
gainNode.gain.setValueAtTime(0, t0);
gainNode.gain.linearRampToValueAtTime(instr.volume, t0 + instr.adsr.attack/1000);
gainNode.gain.linearRampToValueAtTime(instr.volume*instr.adsr.sustain, t0 + (instr.adsr.attack + instr.adsr.decay)/1000);
osc.start(t0);
if (noiseNode) noiseNode.start(t0);
// Stop note after 500ms + release
let noteDuration = 0.5; // seconds (can be adjusted)
let stopTime = t0 + noteDuration;
gainNode.gain.setTargetAtTime(0, stopTime, instr.adsr.release/1000);
osc.stop(stopTime + instr.adsr.release/1000 + 0.1);
if(noiseNode) noiseNode.stop(stopTime + instr.adsr.release/1000 + 0.1);
}
// Playback loop
function playPattern() {
if (!audioCtx) audioCtx = new AudioContext();
const interval = (60 / bpm) / 4; // quarter rows per beat
if(currentRow >= rowsPerPattern) {
currentRow = 0; // loop
}
// Highlight current row
let rows = tablePattern.querySelectorAll('tbody tr');
rows.forEach((row, i) => row.classList.toggle('highlight', i === currentRow));
const noteStr = patternData[currentRow][0];
if(noteStr) {
let freq = noteToFrequency(noteStr);
if(freq) {
playNote(freq, instruments[currentInstrumentIndex]);
}
}
currentRow++;
timerId = setTimeout(playPattern, interval * 1000);
}
function startPlayback() {
if(isPlaying) return;
isPlaying = true;
currentRow = 0;
playBtn.disabled = true;
stopBtn.disabled = false;
playPattern();
}
function stopPlayback() {
if(!isPlaying) return;
isPlaying = false;
playBtn.disabled = false;
stopBtn.disabled = true;
clearTimeout(timerId);
// Remove highlight
let rows = tablePattern.querySelectorAll('tbody tr');
rows.forEach(row => row.classList.remove('highlight'));
}
// -- Share Song via URL --
function exportSongToURL() {
// Save bpm, rows, instruments, patternData as JSON then encode as base64
const song = {
bpm,
rowsPerPattern,
instruments,
patternData
};
let jsonStr = JSON.stringify(song);
let b64 = btoa(encodeURIComponent(jsonStr));
return '#/song=' + b64;
}
function importSongFromURL(hash) {
if(!hash.startsWith('#/song=')) return;
try {
let b64 = hash.substring(7);
let jsonStr = decodeURIComponent(atob(b64));
let song = JSON.parse(jsonStr);
bpm = song.bpm || 120;
rowsPerPattern = song.rowsPerPattern || 16;
instruments = song.instruments || [];
patternData = song.patternData || [];
currentInstrumentIndex = 0;
bpmInput.value = bpm;
rowsInput.value = rowsPerPattern;
updateInstrumentSelect();
loadInstrumentSettings();
renderPattern();
} catch(e) {
console.warn('Failed to load song from URL:', e);
}
}
// -- Initialization --
function init() {
bpm = parseInt(bpmInput.value);
rowsPerPattern = parseInt(rowsInput.value);
if(instruments.length === 0) addInstrument();
initPattern();
renderPattern();
loadInstrumentSettings();
}
init();
// -- Event Listeners --
bpmInput.addEventListener('change', () => {
bpm = parseInt(bpmInput.value);
if(isPlaying) {
stopPlayback();
startPlayback();
}
});
rowsInput.addEventListener('change', () => {
rowsPerPattern = parseInt(rowsInput.value);
initPattern();
renderPattern();
});
addInstrumentBtn.addEventListener('click', () => {
addInstrument();
});
instrumentSelect.addEventListener('change', () => {
saveInstrumentSettings();
currentInstrumentIndex = parseInt(instrumentSelect.value);
loadInstrumentSettings();
});
saveInstrBtn.addEventListener('click', () => {
saveInstrumentSettings();
});
playBtn.addEventListener('click', () => {
savePatternEdits();
startPlayback();
});
stopBtn.addEventListener('click', () => {
stopPlayback();
});
shareBtn.addEventListener('click', () => {
savePatternEdits();
saveInstrumentSettings();
let url = window.location.href.split('#')[0] + exportSongToURL();
prompt('Share this URL to load the song:', url);
});
// Load song from URL on start
if(location.hash) {
importSongFromURL(location.hash);
bpmInput.value = bpm;
rowsInput.value = rowsPerPattern;
}
// Keyboard shortcuts for pattern editing
tablePattern.addEventListener('keydown', (e) => {
const active = document.activeElement;
if(active && active.classList.contains('editable')) {
if(e.key === 'Enter') {
e.preventDefault();
active.blur();
savePatternEdits();
}
}
});
</script>
</body>
</html>
Features in this tracker:
- BPM input: controls speed of playback
- Rows per pattern: lets user choose pattern size
- One track only (extendable), each row can hold one note (e.g. "C#4") or empty
- Instruments: add multiple instruments with a GUI to select oscillator type, volume, detune, ADSR envelope (attack, decay, sustain, release), filter cutoff frequency, noise level
- Playback: plays the pattern row by row in loop according to BPM, playing current note with instrument settings
- Pattern editing: click and edit notes directly in the table (valid notes must be A-G with optional # and octave digit)
- Sharing: export song and instrument data as a base64 encoded JSON in URL hash (after
#/song=...), can load from URL
- Keyboard shortcuts hint included for navigation while editing pattern (basic enter to commit edits)
- No autoplay or demo sounds on load - must press Play
How to use:
- Add instruments and configure their synth params on the right
- Edit notes in the pattern table in the format like
C4, D#4, A5 or leave empty for silence
- Adjust BPM and rows per pattern
- Press Play to hear the pattern loop
- Share your pattern by clicking "Share Song" and send the generated URL
Notes / Possible Extensions:
- Multi-track support (currently single track)
- More complex effects and waveform options
- Export to WAV/MP3
- More editing shortcuts and navigation keys
- Pattern chaining
If you want me to extend or refine any feature or provide a multi-track version let me know!