It sounds like you want to build or find an HTML-based chiptune tracker with the following features:
- BPM control
- Track (channel) system
- Patterns per track
- Rows per pattern
- Synth per instrument
- Custom oscillators
- Volume, detune, ADSR
- Filter and noise options
- Ability to share songs (URL shorteners or hash links)
- Shortcuts for editing
- Loop playback
- No demo required (maybe you want just the source or a minimal player/editor)
Here’s a rundown to help you:
1. Existing Projects to Consider or Fork
Since you’re asking about a chiptune tracker in HTML, here are some well-known JS-based chiptune trackers and libraries that cover much of this:
- FamiTracker Online (famistudio.github.io)
- Advanced, but maybe heavy since it’s a port of desktop tool.
- Has patterns, tracks, synths, ADSR, etc.
- BeepBox (https://www.beepbox.co/)
- Open source, web-based tracker.
- Supports patterns, channels, synths, volume, ADSR envelopes, filters.
- Uses URL hashes for sharing songs.
- Keyboard shortcuts and loop playback.
- Custom waveforms (oscillators).
- JSFX and Tone.js
- JavaScript audio frameworks to build your own tracker.
- Tone.js supports oscillators, envelopes, filters.
- You’d have to build pattern/track abstraction yourself.
2. What Does a Simple Chiptune Tracker Architecture Look Like?
- Tempo / BPM: Controls playback speed (rows per minute).
- Tracks (Channels): each track handles an instrument/voice.
- Patterns: Sequences of notes arranged in rows.
- Rows per pattern: defines the time resolution.
- Instrument synth: oscillator + ADSR + filters per instrument
- Custom oscillators: sine, square, triangle, sawtooth, noise, or custom waveform.
- Controls: volume, detune.
- Effects: filter cutoff, noise level.
- Playback: looping over patterns.
- Keyboard shortcuts: editing notes, navigating patterns.
- Sharing songs: encode song data in URL hash or use URL shortening.
3. Minimal Example / Implementation Outline
Here’s a very simplified approach of how you can implement something like this (conceptually).
<!DOCTYPE html>
<html>
<head>
<title>Simple HTML Chiptune Tracker</title>
<style>
body { font-family: monospace; background: #222; color: #eee; }
#tracker { display: grid; grid-template-columns: repeat(8, 50px); }
.cell { border: 1px solid #444; padding: 5px; text-align: center; cursor: pointer; }
.cell.active { background: #0a0; color: #0f0; }
</style>
</head>
<body>
<h1>Simple Chiptune Tracker</h1>
<div>
BPM: <input type="number" id="bpm" value="120" min="30" max="300">
<button id="play">Play</button>
<button id="stop">Stop</button>
<button id="share">Share Song</button>
</div>
<div id="tracker"></div>
<script>
// Constants
const rowsPerPattern = 16;
const tracks = 4;
let bpm = 120;
let intervalId = null;
// Song data: 4 tracks, 16 rows, each holding a note (0 = silent)
let song = [];
for (let t = 0; t < tracks; t++) {
song[t] = new Array(rowsPerPattern).fill(null); // null = no note
}
const trackerEl = document.getElementById('tracker');
// Create the grid UI
function renderGrid() {
trackerEl.innerHTML = '';
trackerEl.style.gridTemplateColumns = `repeat(${tracks}, 50px)`;
for (let row = 0; row < rowsPerPattern; row++) {
for (let track = 0; track < tracks; track++) {
const cell = document.createElement('div');
cell.classList.add('cell');
cell.dataset.track = track;
cell.dataset.row = row;
cell.textContent = song[track][row] || '-';
cell.addEventListener('click', e => {
let current = song[track][row];
// Cycle notes C, D, E, F, G, A, B, - (null)
const notes = [null,'C','D','E','F','G','A','B'];
let index = notes.indexOf(current);
index = (index + 1) % notes.length;
song[track][row] = notes[index];
e.target.textContent = notes[index] || '-';
});
trackerEl.appendChild(cell);
}
}
}
renderGrid();
// Audio context and synth setup
const audioCtx = new (window.AudioContext || window.webkitAudioContext)();
// Map note names to frequencies (C4=261.63Hz)
const noteFreq = {
'C': 261.63,
'D': 293.66,
'E': 329.63,
'F': 349.23,
'G': 392.00,
'A': 440.00,
'B': 493.88
};
function playNote(note) {
if (!note) return;
const freq = noteFreq[note];
if (!freq) return;
const osc = audioCtx.createOscillator();
const gain = audioCtx.createGain();
osc.type = 'square'; // Chiptune classic
osc.frequency.value = freq;
// ADSR envelope simplified
gain.gain.setValueAtTime(0, audioCtx.currentTime);
gain.gain.linearRampToValueAtTime(0.3, audioCtx.currentTime + 0.01);
gain.gain.exponentialRampToValueAtTime(0.001, audioCtx.currentTime + 0.2);
osc.connect(gain).connect(audioCtx.destination);
osc.start(audioCtx.currentTime);
osc.stop(audioCtx.currentTime + 0.2);
}
// Playback
let currentRow = 0;
function playStep() {
for (let track = 0; track < tracks; track++) {
playNote(song[track][currentRow]);
}
// Highlight current row
[...trackerEl.children].forEach((cell, i)=>{
cell.classList.toggle('active', Math.floor(i / tracks) === currentRow);
});
currentRow = (currentRow + 1) % rowsPerPattern;
}
document.getElementById('bpm').addEventListener('change', e => {
bpm = parseInt(e.target.value,10);
if (intervalId) {
clearInterval(intervalId);
intervalId = setInterval(playStep, (60000 / bpm) / 4); // 4 steps per beat
}
});
document.getElementById('play').addEventListener('click', () => {
if (audioCtx.state === 'suspended') {
audioCtx.resume();
}
if (!intervalId) {
currentRow = 0;
intervalId = setInterval(playStep, (60000 / bpm) / 4);
}
});
document.getElementById('stop').addEventListener('click', () => {
clearInterval(intervalId);
intervalId = null;
[...trackerEl.children].forEach(c => c.classList.remove('active'));
});
// Share: encode song as JSON in URL hash
document.getElementById('share').addEventListener('click', () => {
const data = JSON.stringify(song);
// compress or just URI encode (simple example)
const encoded = encodeURIComponent(data);
const url = `${window.location.origin}${window.location.pathname}#${encoded}`;
navigator.clipboard.writeText(url)
.then(() => alert('Song URL copied to clipboard!'))
.catch(() => alert('Failed to copy URL.'));
});
// On load: if URL has song hash, load it
function loadFromHash() {
const hash = window.location.hash.slice(1);
if (hash) {
try {
const data = decodeURIComponent(hash);
const loadedSong = JSON.parse(data);
if (Array.isArray(loadedSong) && loadedSong.length === tracks) {
for (let t = 0; t < tracks; t++) {
for (let r = 0; r < rowsPerPattern; r++) {
song[t][r] = loadedSong[t][r];
}
}
renderGrid();
}
} catch (e) { /* ignore errors */ }
}
}
loadFromHash();
</script>
</body>
</html>
4. What’s Missing Compared to Your Request?
- Custom oscillators: you can let the user change oscillator type for each instrument — add UI controls.
- Volume / Detune: per note or per instrument controls — add sliders.
- ADSR / Filter: tone.js or WebAudio API can provide advanced envelopes and filters.
- Noise channel: add noise oscillator for percussion or effects.
- Keyboard shortcuts: bind keys for quick note entry/navigation.
- Multiple patterns per track: right now it’s just one pattern.
5. Libraries/Resources to Leverage
If you want, I can help you extend the demo with those advanced features or suggest existing fully-featured open-source projects to host or customize.
Summary
- You can build a lightweight chiptune tracker with HTML, JS + WebAudio.
- Use URL hash to share song data.
- Play with oscillator and ADSR for chiptune sounds.
- Add UI for patterns/tracks and keyboard shortcuts.
- Use existing libraries for sound and UI helpers.
If you want, I can help provide more specific code for:
- Implementing custom oscillator controls
- Adding ADSR envelopes and filters
- Keyboard shortcuts
- Multi pattern arrangements per track
Just ask!