It sounds like you're looking to create or use an HTML-based chiptune tracker with these features:
- control over BPM (tempo)
- patterns with several rows per pattern
- multiple synths/instruments with custom oscillators
- settings for volume, detune, ADSR envelopes, filters, and noise
- ability to share songs (like via URL hash or permalink)
- support for keyboard shortcuts
- looping support
- no demo or sample playback constraints (maybe "no demo" = no auto demo play)
How to achieve this (overview + suggestions)
1. Use/Build an HTML5 Chiptune Tracker
Building a tracker like this from scratch is feasible with Web Audio API + JavaScript. Alternatively, there are existing open-source projects you could modify or get inspired by.
Here’s a minimal tech stack and architecture overview if you want to build or customize:
- UI: HTML + CSS for tracker interface – pattern grid, instrument editor, transport controls
- Audio synthesis: Web Audio API
- Pattern storage: JS objects/arrays for steps, instruments, parameters
- Share song: encode the song data as a compressed string or JSON, then put it in URL hash (like
/#<data>). On page load, parse and load.
- Shortcuts: Use
keydown event listeners
- Loop: Playback engine loops pattern playback
Core concepts in tracker-based chiptunes
- BPM & Speed: define how fast rows advance
- Patterns: sequences of rows (lines)
- Rows per pattern: typical trackers have anywhere 16–64 rows/pattern
- Synth/instruments: each with oscillator(s), ADSR envelope, volume, detune, filter, noise on/off
- Playback engine: schedules events per row based on timing
Example Libraries / References
- jsSID and jsnes use Web Audio to emulate old sounds
- FamiTracker is a famous native NES tracker; web alternatives exist
- BeepBox (beepbox.co) - browser chiptune sequencer with many options, has shareable URL
- Tone.js - powerful Web Audio framework that can build synths with oscillators, envelopes, filters
Minimal sample code snippet for sound generation and simple playback loop
<!DOCTYPE html>
<html>
<head><title>Simple Chiptune Tracker Skeleton</title></head>
<body>
<h1>Chiptune Tracker Demo</h1>
<button id="playBtn">Play / Stop</button>
<pre id="state"></pre>
<script>
const AudioCtx = window.AudioContext || window.webkitAudioContext;
const ctx = new AudioCtx();
// Simple instrument with custom oscillator, volume, detune, ADSR and filter
class Instrument {
constructor(options = {}) {
this.oscType = options.oscType || 'square'; // square wave typical chiptune
this.detune = options.detune || 0;
this.volume = options.volume || 0.3;
this.attack = options.attack || 0.01;
this.decay = options.decay || 0.1;
this.sustain = options.sustain || 0.6;
this.release = options.release || 0.2;
this.filterFreq = options.filterFreq || 1000;
this.filterQ = options.filterQ || 1;
}
playNote(freq, startTime, duration) {
const osc = ctx.createOscillator();
const gainNode = ctx.createGain();
const filter = ctx.createBiquadFilter();
osc.type = this.oscType;
osc.frequency.setValueAtTime(freq, startTime);
osc.detune.setValueAtTime(this.detune, startTime);
filter.type = 'lowpass';
filter.frequency.setValueAtTime(this.filterFreq, startTime);
filter.Q.setValueAtTime(this.filterQ, startTime);
osc.connect(filter);
filter.connect(gainNode);
gainNode.connect(ctx.destination);
// ADSR envelope
gainNode.gain.setValueAtTime(0, startTime);
gainNode.gain.linearRampToValueAtTime(this.volume, startTime + this.attack);
gainNode.gain.linearRampToValueAtTime(this.sustain * this.volume, startTime + this.attack + this.decay);
gainNode.gain.setValueAtTime(this.sustain * this.volume, startTime + duration - this.release);
gainNode.gain.linearRampToValueAtTime(0, startTime + duration);
osc.start(startTime);
osc.stop(startTime + duration);
}
}
// Song data structure
const bpm = 120;
const rowsPerPattern = 16;
const instruments = [
new Instrument({oscType:'square', volume:0.2}),
new Instrument({oscType:'triangle', volume:0.15, detune:10})
];
// Simple pattern: [instrument index, MIDI note # or frequency]
const pattern = [
[0, 440], [ , ], [0, 523], [ , ], [1, 392], [ , ], [1, 349], [ , ],
[0, 440], [ , ], [0, 523], [ , ], [1, 392], [ , ], [1, 349], [ , ],
];
let playing = false;
let startTime;
function millisPerRow() {
return (60000 / bpm) / 4; // Assume 4 rows per beat (speed)
}
function playPattern() {
startTime = ctx.currentTime + 0.1;
pattern.forEach((note, i) => {
if (!note || note.length < 2 || note[0] === undefined || note[1] === undefined) return;
const inst = instruments[note[0]];
const freq = note[1];
const rowTime = startTime + (i * millisPerRow()) / 1000;
inst.playNote(freq, rowTime, millisPerRow() / 1000 * 0.9);
});
}
document.getElementById('playBtn').onclick = () => {
if (!playing) {
playPattern();
playing = true;
document.getElementById('state').innerText = 'Playing...';
} else {
// In real tracker, stop all notes and sequence here, but Web Audio can't
// stop oscillators once started, so we just reset play state.
playing = false;
document.getElementById('state').innerText = 'Stopped';
}
};
</script>
</body>
</html>
What about share / URL hash?
You serialize your song data into a compact format (e.g., base64 or JSON + compression), then append to window.location.hash:
window.location.hash = encodeURIComponent(JSON.stringify(songData));
On load:
if(window.location.hash.length > 1){
const data = decodeURIComponent(window.location.hash.slice(1));
const songData = JSON.parse(data);
// Load the songData into your tracker
}
Summary steps for your project:
- Design a tracker UI with pattern editor and instrument editor
- Build synth engine with Web Audio oscillators, envelopes, filters, noise
- Implement pattern playback engine with BPM and row timing control
- Add keyboard shortcuts to facilitate editing and playback
- Implement URL hash save/load for sharing songs easily
- Add loop functionality toggled via UI button or shortcut
If you want help modifying an existing open source project or need a fully featured tracker example, let me know, I can suggest some projects or help with code!