It sounds like you're describing a web-based HTML chiptune tracker with specific features and constraints. To clarify, you want a tracker app or code that includes:
- BPM (Beats Per Minute) control
- Patterns and rows per pattern
- Multiple synths per instrument, with custom oscillators
- Control over volume, detune, ADSR envelope, filter, and noise
- Ability to share songs (e.g., permalink or export)
- Keyboard shortcuts for actions like duplicate, delete, loop
- Support for patterns or songs that include "/#" (maybe for comments or special commands)
- No demo or example songs included (clean slate)
If you're looking for either:
- Recommendations of existing projects or libraries that fit this description, or
- A snippet/template or minimal tracker code to start with,
let me provide some guidance and options.
1. Existing Projects to Consider
There are several popular HTML/JS chiptune trackers which might fit most of your requirements:
-
FamiStudio (https://famistudio.org/)
A very full-featured NES-era chiptune tracker. Desktop app but uses modern tech.
-
BeepBox (https://beepbox.co/)
Browser-based chiptune tracker with pattern, rows, BPM, multiple synths, volume, detune, and filters. Also supports sharing via URL.
- Supports custom waveforms via partials editor
- Has keyboard shortcuts
- No complex noise control in built-in synth, but does support noise channel
- Source code available at https://github.com/jumme/beepbox
-
Websid (by cmpm) https://github.com/cmpm/websid
A SID (Atari chiptune) player and tracker in the browser.
-
JSFXR and chiptune2.js provide FX and synthesis but are more limited.
2. Building a Minimal Version (Overview)
If you want to build your own from scratch using the Web Audio API, here is how the features map roughly.
-
BPM and rows per pattern:
Implement a sequencer timer that steps through pattern rows based on BPM and row count.
-
Patterns:
Store songs as arrays of patterns, each pattern an array of rows, each row holding notes and instrument data.
-
Synth Per Instrument with Custom Oscillators:
Use OscillatorNode with custom waveforms (PeriodicWave), or combine multiple OscillatorNodes for complex sounds.
-
Volume, Detune, ADSR:
Volume via GainNode per voice.
Detune via detune property of oscillator.
ADSR via automation / gain envelope.
-
Filter & Noise:
Use BiquadFilterNode for filter.
Generate noise by filling an AudioBuffer with random values, play via AudioBufferSourceNode.
-
Sharing Songs:
Serialize song data to JSON or compact string; encode in URL or export.
-
Keyboard Shortcuts for Dupe, Delete, Loop:
Use standard JS event listeners to bind keys (e.g., Ctrl+D for dup, Del for delete, L for loop toggle).
-
"/#" Support:
If by "/#" you mean comments or a specific syntax in pattern data, implement a parser that ignores or handles these lines.
-
No demo included:
Ship application starting with an empty song/project.
3. Example Code Snippet for a Simple Synth with BPM, Rows, and ADSR
Below is a very basic skeleton for a small chiptune engine:
<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8" /><title>Minimal HTML Chiptune Tracker</title></head>
<body>
<button id="play">Play</button>
<input id="bpm" type="number" value="120" min="30" max="300" /> BPM
<script>
const audioCtx = new (window.AudioContext || window.webkitAudioContext)();
const bpmInput = document.getElementById('bpm');
let bpm = +bpmInput.value;
bpmInput.onchange = () => bpm = +bpmInput.value;
const patternLength = 16; // rows per pattern
let currentRow = 0;
const sampleRate = 44100;
// Simple instrument: oscillator + gain + ADSR
function playNote(freq, duration = 0.3) {
const osc = audioCtx.createOscillator();
const gainNode = audioCtx.createGain();
const filter = audioCtx.createBiquadFilter();
filter.type = "lowpass";
filter.frequency.value = 1000;
osc.type = 'square'; // Could extend to custom waves
osc.frequency.value = freq;
osc.detune.value = 0; // detune in cents
osc.connect(filter);
filter.connect(gainNode);
gainNode.connect(audioCtx.destination);
const now = audioCtx.currentTime;
// ADSR envelope
const attack = 0.05;
const decay = 0.1;
const sustainLevel = 0.7;
const release = 0.2;
gainNode.gain.setValueAtTime(0, now);
gainNode.gain.linearRampToValueAtTime(1, now + attack);
gainNode.gain.linearRampToValueAtTime(sustainLevel, now + attack + decay);
gainNode.gain.setValueAtTime(sustainLevel, now + duration);
gainNode.gain.linearRampToValueAtTime(0, now + duration + release);
osc.start(now);
osc.stop(now + duration + release);
}
// Example song data: pattern with notes in Hz or null for rest
const songPattern = [
440, null, 494, null, 523, null, 587, null,
659, null, 698, null, 784, null, 880, null
];
let playing = false;
let intervalId = null;
function playSequence() {
if (currentRow >= patternLength) currentRow = 0;
const freq = songPattern[currentRow];
if (freq) playNote(freq);
currentRow++;
}
// Convert BPM to interval in ms for one row (assuming 4 rows per beat)
function intervalFromBPM(bpm) {
return (60000 / bpm) / 4;
}
document.getElementById('play').addEventListener('click', () => {
if (playing) {
clearInterval(intervalId);
playing = false;
} else {
// Make sure audio context resumed on user interaction
audioCtx.resume();
intervalId = setInterval(() => {
playSequence();
}, intervalFromBPM(bpm));
playing = true;
}
});
</script>
</body>
</html>
This is just a very minimal start showing:
- BPM controlling the speed of the pattern playback
- A 16-row pattern playing simple square notes
- Basic ADSR envelope applied via GainNode automation
- No UI apart from Play and BPM input
- No pattern editor yet (you would build a grid interface for pattern and instrument editing)
4. Next Steps if You Want a Full Tracker
- Build a UI grid for pattern editing with input for notes, instruments
- Add instruments management with multiple oscillators per instrument
- Add controls for volume, detune, ADSR, filter, noise per instrument
- Serialize the full song state for sharing URLs or exporting
- Add keyboard shortcuts with
keydown listeners to dupe rows/patterns, delete notes, toggle loop modes
- Handle pattern data parsing with support for lines starting with "/#" as comments or special flags
5. Summary
- For ready use or inspiration, check out BeepBox; it matches many requested features and is a good open-source code base.
- For custom builds, start from a minimal Web Audio API pattern sequencer like the snippet above, then add features one by one.
- Keyboard shortcuts and song sharing are UI and state-management tasks; consider using modern JS frameworks or plain JS with event handlers.
If you'd like, I can help you build a more complete tracker or add specific features step-by-step. Just ask!