It sounds like you want to build (or get) a chiptune tracker implemented in plain HTML, CSS, and JS with these features:
- BPM control
- Chords
- Pattern size and rows per pattern
- Synth per instrument with customizable waveform (oscillator type)
- Volume, detune, ADSR envelope per instrument
- Filter and noise per instrument
- Ability to share/save songs (likely serialized URLs or JSON)
- Shortcuts for workflow (e.g., dupe, delete, copy, paste patterns)
- Pattern loop playback
- URL hash or fragment (
/#) based sharing or song loading
- No external demos or libraries, fully self-contained (no demo links)
I can help you by either:
- Pointing you to a minimal but functional example / starter code that implements these features
- Writing a basic starting code for you with core features to expand on
- Explaining how to structure such a project
Here’s a minimal outline and some example code snippets to get you started
1. Project structure
- index.html
- style.css
- tracker.js
2. Core things to implement
Data model
- Song: { bpm, instruments[], patterns[], rowsPerPattern, patternOrder[] }
- Instrument: { synth settings (osc type, volume, detune, ADSR, filter, noise) }
- Pattern: a 2D array of
notes per step (each step can be a note or chord)
- Notes: frequencies or MIDI note numbers
Playback engine
- Use Web Audio API for synth generation
- Scheduler that steps through pattern rows at bpm timing
- Play notes/chords per step
UI
- Pattern editor grid
- Controls for bpm
- Controls to add/remove/edit instruments, patterns
- Shortcut keys for dupe, delete, copy, paste pattern
- Share / load via URL hash with serialized song data
3. Example partial code snippets
Basic synth play (Web Audio API oscillator with ADSR)
js
class Synth {
constructor(audioCtx, options = {}) {
this.ctx = audioCtx;
this.oscType = options.oscType || 'square';
this.volume = options.volume || 0.1;
this.detune = options.detune || 0;
this.attack = options.attack || 0.01;
this.decay = options.decay || 0.1;
this.sustain = options.sustain || 0.5;
this.release = options.release || 0.3;
this.filterType = options.filterType || 'lowpass';
this.filterFreq = options.filterFreq || 1000;
this.filterQ = options.filterQ || 1;
this.noiseLevel = options.noiseLevel || 0;
}
playNote(freq, startTime, duration) {
const ctx = this.ctx;
// Oscillator
const osc = ctx.createOscillator();
osc.type = this.oscType;
osc.frequency.setValueAtTime(freq, startTime);
osc.detune.setValueAtTime(this.detune, startTime);
// Gain node for ADSR
const gain = ctx.createGain();
// Filter
const filter = ctx.createBiquadFilter();
filter.type = this.filterType;
filter.frequency.setValueAtTime(this.filterFreq, startTime);
filter.Q.setValueAtTime(this.filterQ, startTime);
// Noise source if needed
let noiseSource;
if(this.noiseLevel > 0) {
const bufferSize = 2 * ctx.sampleRate;
const noiseBuffer = ctx.createBuffer(1, bufferSize, ctx.sampleRate);
const output = noiseBuffer.getChannelData(0);
for(let i=0; i<bufferSize; i++) output[i] = (Math.random() * 2 - 1);
noiseSource = ctx.createBufferSource();
noiseSource.buffer = noiseBuffer;
noiseSource.loop = true;
const noiseGain = ctx.createGain();
noiseGain.gain.setValueAtTime(this.noiseLevel, startTime);
noiseSource.connect(noiseGain).connect(filter);
noiseSource.start(startTime);
noiseSource.stop(startTime + duration);
}
osc.connect(gain).connect(filter).connect(ctx.destination);
// ADSR envelope
const a = this.attack, d = this.decay, s = this.sustain, r = this.release;
gain.gain.setValueAtTime(0, startTime);
gain.gain.linearRampToValueAtTime(this.volume, startTime + a);
gain.gain.linearRampToValueAtTime(this.volume * s, startTime + a + d);
gain.gain.setValueAtTime(this.volume * s, startTime + duration);
gain.gain.linearRampToValueAtTime(0, startTime + duration + r);
osc.start(startTime);
osc.stop(startTime + duration + r);
}
}
Minimal playback and timing (simple scheduler)
js
class Player {
constructor(song, audioCtx) {
this.song = song;
this.ctx = audioCtx;
this.isPlaying = false;
this.currentRow = 0;
this.currentPatternIndex = 0;
this.nextNoteTime = 0;
}
start() {
this.isPlaying = true;
this.currentRow = 0;
this.currentPatternIndex = 0;
this.nextNoteTime = this.ctx.currentTime + 0.1;
this.scheduler();
}
stop() {
this.isPlaying = false;
}
scheduler() {
if(!this.isPlaying) return;
while(this.nextNoteTime < this.ctx.currentTime + 0.1) {
this.playCurrentStep(this.nextNoteTime);
this.nextStep();
this.nextNoteTime += 60 / this.song.bpm / this.song.rowsPerPattern;
}
requestAnimationFrame(() => this.scheduler());
}
playCurrentStep(time) {
const pattern = this.song.patterns[this.song.patternOrder[this.currentPatternIndex]];
if(!pattern) return;
const row = pattern[this.currentRow];
row.forEach( (note, instrumentIndex) => {
if(note) {
const instrument = this.song.instruments[instrumentIndex];
instrument.synth.playNote(note.freq, time, 60 / this.song.bpm / this.song.rowsPerPattern);
}
});
}
nextStep() {
this.currentRow++;
if(this.currentRow >= this.song.rowsPerPattern) {
this.currentRow = 0;
this.currentPatternIndex++;
if(this.currentPatternIndex >= this.song.patternOrder.length) {
this.currentPatternIndex = 0; // loop
}
}
}
}
Patterns + Notes example structure
js
// song object
const song = {
bpm: 120,
rowsPerPattern: 16,
instruments: [
{
synth: new Synth(audioCtx, {oscType: 'square', volume: 0.2}),
},
{
synth: new Synth(audioCtx, {oscType: 'triangle', volume: 0.15, noiseLevel: 0.05}),
}
],
patterns: [
[ // pattern 0
[ { freq: 440 }, null ], // row 0, two instruments
[ null, { freq: 660 } ], // row 1
// ...more rows as arrays of notes per instrument
],
// more patterns
],
patternOrder: [0], // play pattern 0 only
};
URL hash share/load example (JSON encoded in base64)
js
function saveSongToUrl(song) {
const json = JSON.stringify(song);
const base64 = btoa(json);
location.hash = base64;
}
function loadSongFromUrl() {
if(location.hash.length > 1) {
const base64 = location.hash.substr(1);
try {
const json = atob(base64);
return JSON.parse(json);
} catch(e) {
console.error('Failed to load song', e);
}
}
return null;
}
4. Keyboard shortcuts idea
Ctrl+C / Ctrl+V for copy paste pattern
Ctrl+D for duplicate pattern
Delete for deleting a selected pattern / row
- Loop toggle via spacebar or L
Implementing these requires UI event listeners tied to the selected element in the pattern editor.
5. Additional notes & resources
- Oscillator types:
'sine', 'square', 'sawtooth', 'triangle', or custom waveforms with PeriodicWave
- Adding filter and noise enriches the sound as per your request
- You can extend instruments with custom waveforms using Web Audio API
createPeriodicWave
- Avoid external dependencies to match "no demo" and fully contained requirement
If you want, I can prepare a full minimal working example with the above concepts, just let me know!