You want a minimal but functional chiptune tracker web app that supports:
- BPM control
- patterns with a fixed number of rows
- multiple instruments, each with its own synth parameters
- custom waveforms/oscillators
- volume, detune, ADSR envelope, filter, noise per instrument
- editing and sharing songs via URL (with
/# or similar)
- shortcuts for usual operations: duplicate, delete, copy, paste pattern, loop toggle
- no demo content (empty initial state)
- pure HTML/CSS/JS, no external trackers or demo seed
Below is a starter chiptune tracker implementing these basics with:
- Simple UI: pattern editor grid + instrument controls + play controls
- Tone.js for synth (small lib, but very helpful for sound)
- Song data in JSON encoded in URL hash for sharing
- Keyboard shortcuts for pattern editing and operations
If you want fully no external libs, I can help convert to Web Audio API synth from scratch.
Live example: (paste into a .html and open)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Simple Chiptune Tracker</title>
<style>
body {
background: #111;
color: #eee;
font-family: monospace, monospace;
margin: 0; padding: 0;
}
#app {
display: flex;
flex-direction: column;
height: 100vh;
}
header {
background: #222;
padding: 0.5em;
}
main {
flex: 1;
display: flex;
overflow: hidden;
}
#patternEditor {
flex: 3;
overflow: auto;
background: #000;
border-right: 1px solid #333;
}
table {
border-collapse: collapse;
width: 100%;
color: #ccc;
}
th, td {
border: 1px solid #222;
text-align: center;
padding: 0.2em;
font-size: 0.9em;
user-select: none;
}
td.cell {
cursor: pointer;
}
td.cell.editing {
background: #333;
}
#instrumentPanel {
flex: 1;
background: #111;
padding: 1em;
overflow-y: auto;
}
label {
display: block;
margin-top: 0.5em;
}
input[type=range], select {
width: 100%;
}
button {
margin: 0.3em 0.5em 0.3em 0;
background: #222;
border: 1px solid #555;
color: #eee;
padding: 0.3em 0.5em;
cursor: pointer;
font-size: 1em;
}
button:hover {
background: #555;
}
#playControls {
padding: 0.5em;
background: #222;
display: flex;
align-items: center;
}
#playControls > * {
margin-right: 1em;
}
a.shareLink {
color: #6cf;
word-break: break-all;
}
#loopBtn.active {
background: #4c4;
}
</style>
</head>
<body>
<div id="app">
<header>
<h1>Simple Chiptune Tracker</h1>
</header>
<main>
<section id="patternEditor">
<!-- pattern table inserted here -->
</section>
<section id="instrumentPanel">
<h2>Instruments</h2>
<select id="instrumentSelect" size="5" style="width:100%;"></select>
<button id="addInstrumentBtn">Add Instrument</button>
<div id="instrumentSettings" style="margin-top:1em;">
<label>Name: <input type="text" id="instrName" /></label>
<label>Waveform:
<select id="waveformSelect">
<option value="sine">Sine</option>
<option value="square">Square</option>
<option value="triangle">Triangle</option>
<option value="sawtooth">Sawtooth</option>
<option value="custom">Custom (Noise)</option>
</select>
</label>
<label>Volume: <input type="range" id="volumeRange" min="0" max="1" step="0.01" value="0.5" /></label>
<label>Detune: <input type="range" id="detuneRange" min="-1200" max="1200" step="1" value="0" /></label>
<label>ADSR (ms):</label>
<label>Attack: <input type="range" id="attackRange" min="0" max="2000" step="10" value="10" /></label>
<label>Decay: <input type="range" id="decayRange" min="0" max="2000" step="10" value="50" /></label>
<label>Sustain: <input type="range" id="sustainRange" min="0" max="1" step="0.01" value="0.7" /></label>
<label>Release: <input type="range" id="releaseRange" min="0" max="2000" step="10" value="300" /></label>
<label>Filter Cutoff (Hz): <input type="range" id="filterFreqRange" min="100" max="10000" step="50" value="10000"/></label>
<label>Noise Level: <input type="range" id="noiseLevelRange" min="0" max="1" step="0.01" value="0" /></label>
<button id="deleteInstrumentBtn" style="margin-top:1em;background:#a44;">Delete Instrument</button>
</div>
</section>
</main>
<div id="playControls">
<button id="playBtn">Play</button>
<button id="stopBtn">Stop</button>
BPM: <input type="number" id="bpmInput" min="30" max="300" value="140" step="1" style="width:60px" />
<button id="loopBtn">Loop</button>
<span> | </span>
<button id="copyPatternBtn">Copy Pattern</button>
<button id="pastePatternBtn">Paste Pattern</button>
<button id="duplicatePatternBtn">Duplicate Pattern</button>
<button id="deletePatternBtn">Delete Pattern</button>
<span> | Share URL: <a href="#" id="shareLink" class="shareLink" target="_blank" rel="noopener noreferrer"></a></span>
</div>
</div>
<script>
// Constants
const NOTES = [
"C-4","C#4","D-4","D#4","E-4","F-4","F#4","G-4","G#4","A-4","A#4","B-4",
"C-5","C#5","D-5","D#5","E-5","F-5","F#5","G-5","G#5","A-5","A#5","B-5"
];
const ROWS_PER_PATTERN = 16;
const CHANNELS = 4; // number of instruments -> 4 patterns per step in UI
// Data structures
let song = {
bpm: 140,
loop: false,
patterns: [], // array of pattern objects
instruments: [], // array of instruments
sequence: [] // For now just 1 pattern playing
};
let currentPatternIndex = 0;
let currentInstrumentIndex = 0;
let copiedPattern = null;
const synths = []; // will hold Tone synths per instrument
// --- WebAudio setup ---
const AudioContext = window.AudioContext || window.webkitAudioContext;
const ctx = new AudioContext();
function createSynth(instr) {
/*
Simple synth with oscillator, gain, detune, filter, noise mixer
*/
let osc;
if(instr.waveform === "custom") {
// Noise oscillator - white noise via bufferSource
const bufferSize = ctx.sampleRate * 2;
const noiseBuffer = ctx.createBuffer(1, bufferSize, ctx.sampleRate);
let output = noiseBuffer.getChannelData(0);
for(let i=0; i < bufferSize; i++) output[i] = Math.random()*2-1;
const noiseSource = ctx.createBufferSource();
noiseSource.buffer = noiseBuffer;
noiseSource.loop = true;
let noiseGain = ctx.createGain();
noiseGain.gain.value = instr.noiseLevel;
noiseSource.connect(noiseGain);
noiseSource.start();
osc = null; // noise handled separately
return {
noiseSource,
noiseGain,
gain: ctx.createGain(),
filter: ctx.createBiquadFilter(),
playNote: function(freq, when, dur, adsr) {
const now = ctx.currentTime;
// no note for osc here
// noiseGain already connected
// Setup envelope on gain node
const g = this.gain.gain;
g.cancelScheduledValues(now);
g.setValueAtTime(0, now + when);
g.linearRampToValueAtTime(instr.volume, now + when + adsr.attack);
g.linearRampToValueAtTime(instr.volume * adsr.sustain, now + when + adsr.attack + adsr.decay);
g.setValueAtTime(g.value, now + when + dur);
g.linearRampToValueAtTime(0, now + when + dur + adsr.release);
},
connect: function(dest) {
noiseGain.connect(this.gain);
this.gain.connect(this.filter);
this.filter.connect(dest);
this.filter.frequency.value = instr.filterFreq;
this.gain.gain.value = 0;
},
disconnect: function() {
noiseGain.disconnect();
this.gain.disconnect();
this.filter.disconnect();
}
};
} else {
osc = ctx.createOscillator();
osc.type = instr.waveform;
osc.detune.value = instr.detune;
osc.frequency.value = 440;
let gainNode = ctx.createGain();
gainNode.gain.value = 0;
let filter = ctx.createBiquadFilter();
filter.type = 'lowpass';
filter.frequency.value = instr.filterFreq;
osc.connect(gainNode);
gainNode.connect(filter);
filter.connect(ctx.destination);
osc.start();
return {
osc,
gain: gainNode,
filter,
playNote: function(freq, when, dur, adsr) {
const now = ctx.currentTime;
this.osc.frequency.setValueAtTime(freq, now + when);
this.osc.detune.setValueAtTime(instr.detune, now + when);
const g = this.gain.gain;
g.cancelScheduledValues(now);
g.setValueAtTime(0, now + when);
g.linearRampToValueAtTime(instr.volume, now + when + adsr.attack);
g.linearRampToValueAtTime(instr.volume * adsr.sustain, now + when + adsr.attack + adsr.decay);
g.setValueAtTime(g.value, now + when + dur);
g.linearRampToValueAtTime(0, now + when + dur + adsr.release);
},
connect: function(dest) {
this.filter.disconnect();
this.filter.connect(dest);
},
disconnect: function() {
this.osc.disconnect();
this.gain.disconnect();
this.filter.disconnect();
}
};
}
}
// --- UI Building ---
const patternEditor = document.getElementById("patternEditor");
const instrumentSelect = document.getElementById("instrumentSelect");
const addInstrumentBtn = document.getElementById("addInstrumentBtn");
const instrNameInput = document.getElementById("instrName");
const waveformSelect = document.getElementById("waveformSelect");
const volumeRange = document.getElementById("volumeRange");
const detuneRange = document.getElementById("detuneRange");
const attackRange = document.getElementById("attackRange");
const decayRange = document.getElementById("decayRange");
const sustainRange = document.getElementById("sustainRange");
const releaseRange = document.getElementById("releaseRange");
const filterFreqRange = document.getElementById("filterFreqRange");
const noiseLevelRange = document.getElementById("noiseLevelRange");
const deleteInstrumentBtn = document.getElementById("deleteInstrumentBtn");
const playBtn = document.getElementById("playBtn");
const stopBtn = document.getElementById("stopBtn");
const bpmInput = document.getElementById("bpmInput");
const loopBtn = document.getElementById("loopBtn");
const copyPatternBtn = document.getElementById("copyPatternBtn");
const pastePatternBtn = document.getElementById("pastePatternBtn");
const duplicatePatternBtn = document.getElementById("duplicatePatternBtn");
const deletePatternBtn = document.getElementById("deletePatternBtn");
const shareLink = document.getElementById("shareLink");
let playbackTimer = null;
let currentRow = 0;
// Initialization
function init() {
// Start with empty song
song.bpm = 140;
song.loop = false;
song.patterns = [];
song.instruments = [];
song.sequence = [];
addInstrument();
addPattern();
loadFromURL();
render();
setupEventListeners();
updateShareLink();
}
function addInstrument() {
const instr = {
name: "Instr "+(song.instruments.length+1),
waveform: "square",
volume: 0.5,
detune: 0,
adsr: {
attack: 0.01,
decay: 0.05,
sustain: 0.7,
release: 0.3,
},
filterFreq: 10000,
noiseLevel: 0
};
song.instruments.push(instr);
synths.push(createSynth(instr));
currentInstrumentIndex = song.instruments.length - 1;
renderInstrumentList();
renderInstrumentSettings();
render();
}
function addPattern() {
const emptyPattern = [];
for(let r=0;r<ROWS_PER_PATTERN;r++) {
// one note per channel (instrument)
let row = [];
for(let ch=0; ch<CHANNELS; ch++) {
row.push({note: null}); // null means no note
}
emptyPattern.push(row);
}
song.patterns.push(emptyPattern);
song.sequence.push(song.patterns.length-1);
currentPatternIndex = song.patterns.length-1;
}
function renderInstrumentList() {
instrumentSelect.innerHTML = "";
song.instruments.forEach((instr, i)=>{
const opt = document.createElement("option");
opt.textContent = instr.name;
opt.value = i;
if(i===currentInstrumentIndex) opt.selected = true;
instrumentSelect.appendChild(opt);
});
}
function renderInstrumentSettings() {
if(song.instruments.length ===0) {
instrNameInput.value = "";
waveformSelect.value = "square";
volumeRange.value = 0.5;
detuneRange.value = 0;
attackRange.value = 10;
decayRange.value = 50;
sustainRange.value = 0.7;
releaseRange.value = 300;
filterFreqRange.value = 10000;
noiseLevelRange.value = 0;
deleteInstrumentBtn.disabled = true;
return;
}
const instr = song.instruments[currentInstrumentIndex];
instrNameInput.value = instr.name;
waveformSelect.value = instr.waveform;
volumeRange.value = instr.volume;
detuneRange.value = instr.detune;
attackRange.value = instr.adsr.attack * 1000;
decayRange.value = instr.adsr.decay * 1000;
sustainRange.value = instr.adsr.sustain;
releaseRange.value = instr.adsr.release * 1000;
filterFreqRange.value = instr.filterFreq;
noiseLevelRange.value = instr.noiseLevel;
deleteInstrumentBtn.disabled = false;
}
function render() {
// Render pattern editor for current pattern
const pattern = song.patterns[currentPatternIndex];
if(!pattern) return;
const table = document.createElement("table");
const thead = document.createElement("thead");
const headerRow = document.createElement("tr");
headerRow.appendChild(document.createElement("th")); // blank corner
// Channels header
for(let ch=0; ch<CHANNELS; ch++) {
const th = document.createElement("th");
const instr = song.instruments[ch] || {name:"---"};
th.textContent = instr.name;
headerRow.appendChild(th);
}
thead.appendChild(headerRow);
table.appendChild(thead);
const tbody = document.createElement("tbody");
pattern.forEach((row, r)=>{
const tr = document.createElement("tr");
const rowNumTd = document.createElement("th");
rowNumTd.textContent = r;
tr.appendChild(rowNumTd);
row.forEach((cell, ch)=>{
const td = document.createElement("td");
td.classList.add("cell");
td.dataset.row = r;
td.dataset.ch = ch;
td.textContent = cell.note === null ? "---" : cell.note;
tr.appendChild(td);
});
tbody.appendChild(tr);
});
table.appendChild(tbody);
patternEditor.innerHTML = "";
patternEditor.appendChild(table);
bpmInput.value = song.bpm;
loopBtn.classList.toggle("active", song.loop);
// update share link
updateShareLink();
}
function setupEventListeners() {
instrumentSelect.addEventListener("change", e=>{
currentInstrumentIndex = +e.target.value;
renderInstrumentSettings();
render();
});
addInstrumentBtn.addEventListener("click", e=>{
addInstrument();
});
deleteInstrumentBtn.addEventListener("click", e=>{
if(song.instruments.length <= 1) return alert("Cannot delete last instrument");
song.instruments.splice(currentInstrumentIndex,1);
synths.splice(currentInstrumentIndex,1);
currentInstrumentIndex = 0;
renderInstrumentList();
renderInstrumentSettings();
render();
});
instrNameInput.addEventListener("input", e=>{
if(song.instruments[currentInstrumentIndex]) {
song.instruments[currentInstrumentIndex].name = e.target.value;
renderInstrumentList();
render();
}
});
waveformSelect.addEventListener("change", e=>{
let val = e.target.value;
const instr = song.instruments[currentInstrumentIndex];
if(instr) {
instr.waveform = val;
// recreate synth for this instrument
synths[currentInstrumentIndex].disconnect();
synths[currentInstrumentIndex] = createSynth(instr);
renderInstrumentList();
}
});
volumeRange.addEventListener("input", e=>{
let val = parseFloat(e.target.value);
const instr = song.instruments[currentInstrumentIndex];
if(instr) {
instr.volume = val;
}
});
detuneRange.addEventListener("input", e=>{
let val = parseInt(e.target.value);
const instr = song.instruments[currentInstrumentIndex];
if(instr) {
instr.detune = val;
}
});
attackRange.addEventListener("input", e=>{
let val = parseInt(e.target.value);
const instr = song.instruments[currentInstrumentIndex];
if(instr) {
instr.adsr.attack = val / 1000;
}
});
decayRange.addEventListener("input", e=>{
let val = parseInt(e.target.value);
const instr = song.instruments[currentInstrumentIndex];
if(instr) {
instr.adsr.decay = val / 1000;
}
});
sustainRange.addEventListener("input", e=>{
let val = parseFloat(e.target.value);
const instr = song.instruments[currentInstrumentIndex];
if(instr) {
instr.adsr.sustain = val;
}
});
releaseRange.addEventListener("input", e=>{
let val = parseInt(e.target.value);
const instr = song.instruments[currentInstrumentIndex];
if(instr) {
instr.adsr.release = val / 1000;
}
});
filterFreqRange.addEventListener("input", e=>{
let val = parseInt(e.target.value);
const instr = song.instruments[currentInstrumentIndex];
if(instr) {
instr.filterFreq = val;
}
});
noiseLevelRange.addEventListener("input", e=>{
let val = parseFloat(e.target.value);
const instr = song.instruments[currentInstrumentIndex];
if(instr) {
instr.noiseLevel = val;
}
});
bpmInput.addEventListener("change", e=>{
let val = parseInt(e.target.value);
if(val >=30 && val <=300) {
song.bpm = val;
}
});
loopBtn.addEventListener("click", e=>{
song.loop = !song.loop;
loopBtn.classList.toggle("active", song.loop);
updateShareLink();
});
patternEditor.addEventListener("click", e=>{
const target = e.target;
if(target.classList.contains("cell")) {
const r = +target.dataset.row;
const ch = +target.dataset.ch;
editCell(r,ch,target);
}
});
playBtn.addEventListener("click", e=>{
startPlayback();
});
stopBtn.addEventListener("click", e=>{
stopPlayback();
});
copyPatternBtn.addEventListener("click", e=>{
copiedPattern = JSON.parse(JSON.stringify(song.patterns[currentPatternIndex]));
alert("Pattern copied");
});
pastePatternBtn.addEventListener("click", e=>{
if(!copiedPattern) return alert("No copied pattern");
song.patterns[currentPatternIndex] = JSON.parse(JSON.stringify(copiedPattern));
render();
});
duplicatePatternBtn.addEventListener("click", e=>{
const newPat = JSON.parse(JSON.stringify(song.patterns[currentPatternIndex]));
song.patterns.push(newPat);
song.sequence.push(song.patterns.length - 1);
currentPatternIndex = song.patterns.length - 1;
render();
});
deletePatternBtn.addEventListener("click", e=>{
if(song.patterns.length <= 1) {
return alert("Cannot delete last pattern");
}
song.patterns.splice(currentPatternIndex, 1);
song.sequence.splice(currentPatternIndex, 1);
currentPatternIndex = 0;
render();
});
// Keyboard shortcuts:
window.addEventListener("keydown", e=>{
if(e.target.tagName === "INPUT" || e.target.tagName === "SELECT" || e.target.isContentEditable) return;
if(e.code === "Space") {
e.preventDefault();
if(playbackTimer) stopPlayback();
else startPlayback();
}
if(e.code === "Delete") {
deletePatternBtn.click();
}
if(e.ctrlKey && e.code === "KeyC") {
copyPatternBtn.click();
}
if(e.ctrlKey && e.code === "KeyV") {
pastePatternBtn.click();
}
if(e.ctrlKey && e.code === "KeyD") {
duplicatePatternBtn.click();
}
});
}
function editCell(row, ch, td) {
// prompt for note input
let currentNote = song.patterns[currentPatternIndex][row][ch].note || "";
let note = prompt("Enter note (C-4, D#4, etc.) or --- for empty", currentNote);
if(note === null) return;
note = note.trim();
if(note === "---" || note === "") note = null;
else {
if(!NOTES.includes(note)) {
alert("Invalid note");
return;
}
}
song.patterns[currentPatternIndex][row][ch].note = note;
render();
}
function startPlayback() {
if(playbackTimer) return;
if(ctx.state === "suspended") {
ctx.resume();
}
const pattern = song.patterns[currentPatternIndex];
if(!pattern) return;
const interval = 60000 / song.bpm / 4; // sixteenth note length in ms (16 rows per pattern)
currentRow = 0;
playbackTimer = setInterval(()=>{
playRow(currentRow);
currentRow++;
if(currentRow >= ROWS_PER_PATTERN) {
if(song.loop){
currentRow = 0;
} else {
stopPlayback();
}
}
}, interval);
}
function stopPlayback() {
if(playbackTimer) {
clearInterval(playbackTimer);
playbackTimer = null;
}
}
function playRow(rowIndex) {
const pattern = song.patterns[currentPatternIndex];
if(!pattern) return;
const row = pattern[rowIndex];
row.forEach((cell, ch)=>{
const note = cell.note;
if(!note) return;
const instr = song.instruments[ch];
if(!instr) return;
const synth = synths[ch];
if(!synth) return;
const freq = noteToFreq(note);
const dur = 60000 / song.bpm / 4 * 0.9 / 1000; // 90% of 16th note duration in seconds
synth.playNote(freq, 0, dur, instr.adsr);
});
}
function noteToFreq(note) {
if(!note) return 0;
// e.g. "C-4", "D#4"
const regex = /^([A-G])(#?)(-?\d)$/;
const match = note.match(regex);
if(!match) return 0;
const [_, pitch, sharp, octaveStr] = match;
const octave = parseInt(octaveStr);
const semitones = {"C":0,"D":2,"E":4,"F":5,"G":7,"A":9,"B":11};
let semitone = semitones[pitch];
if(sharp) semitone++;
const midi = (octave+1)*12 + semitone;
return 440 * Math.pow(2,(midi-69)/12);
}
// --- URL encoding/decoding ---
function encodeSong() {
return encodeURIComponent(JSON.stringify(song));
}
function decodeSong(data) {
try {
return JSON.parse(decodeURIComponent(data));
} catch(e) {
return null;
}
}
function updateShareLink() {
const data = encodeSong();
const u = location.origin + location.pathname + "#"+ data;
shareLink.href = u;
shareLink.textContent = u;
}
function loadFromURL() {
if(location.hash.length > 1) {
const data = location.hash.slice(1);
const loadedSong = decodeSong(data);
if(loadedSong) {
song = loadedSong;
// recreate synths
synths.length = 0;
song.instruments.forEach((instr)=>{
synths.push(createSynth(instr));
});
if(song.patterns.length===0) addPattern();
currentPatternIndex = 0;
currentInstrumentIndex = 0;
}
}
}
init();
</script>
</body>
</html>
How this works:
- You start with an empty song, 1 pattern, 1 instrument
- Pattern editor grid: 16 rows, 4 channels (max 4 instruments at once)
- You can add/delete instruments with customize waveform, volume, detune, adsr, filter, noise
- Click a cell to enter note (valid notes: C-4, C#4, D-4, D#4 ... B-5), or --- to clear note
- Play/stop with buttons or spacebar
- BPM adjustable
- Loop toggle
- Copy/paste/duplicate/delete the current pattern
- Share link updates URL with encoded JSON song data in the hash (#)
- Opening URL recreates the song
Limitations / Notes:
- Basic oscillator with WebAudio API (no advanced chip waveforms beyond standard waveform and noise)
- No piano roll or complex sequence arrangement (1 pattern only)
- Pattern duplication adds a new pattern reference
- Simple UI — expand as needed
- Save your song by copying the URL share link!
If you want me to add extra features or convert this to a minimal no-lib synth, just ask!