It looks like you want to create (or use) an HTML-based chiptune tracker with features including:
- BPM control
- Patterns and rows per pattern
- Synth per instrument with customizable oscillator types
- Volume, detune, ADSR envelope, filter, and noise controls per instrument
- Ability to share songs (via URL or export)
- Keyboard shortcuts for playback, editing, looping, etc.
- Looping capability
- No demo or pre-loaded songs included (empty or user-created only)
What you might want
You’re describing a simple but full-featured web chiptune tracker, similar to projects like BeepBox or JSFXR trackers, but simpler or custom, e.g., with your own interface or functionality.
How to proceed
1. Use an existing open source chiptune tracker
If you just want a ready-to-use web tracker with those features, here are few options:
If you want to build your own basic chiptune tracker in HTML/JS, then next section.
2. Building your own web chiptune tracker — outline
General structure:
- Use HTML5 + CSS for UI
- Use Web Audio API for sound synthesis
- Store song as JSON or similar (instruments + patterns + params)
Main components you need:
- Sequencer grid: patterns × rows per pattern × channels (instruments)
- Instrument editor: oscillator type (sine, square, triangle, noise), ADSR (attack, decay, sustain, release), volume, detune, filter freq/reso, noise toggle/level
- Playback engine: Web Audio scheduler that uses the BPM and rows per pattern to schedule notes
- Song storage: array of patterns, each with rows and note data per channel
- UI controls: for editing notes, changing BPM, adding/removing patterns, looping toggle
- Keyboard shortcuts: play/pause, step forward/back, loop toggle, maybe copy/paste pattern, etc.
- Share: serialize song JSON on demand, generate sharable URL with encoded data or export JSON file
3. Example starting point — minimal code snippet
Here’s a very minimal skeleton of components you might use (not full tracker, but starting pieces):
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Basic Chiptune Tracker</title>
<style>
body { font-family: monospace; background: #222; color: #eee; }
#sequencer { display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; }
.cell { width: 40px; height: 25px; background: #444; text-align: center; line-height: 25px; cursor: pointer; }
.cell.playing { background: #f80; }
</style>
</head>
<body>
<h1>Chiptune Tracker Prototype</h1>
<div>
BPM: <input type="number" id="bpm" value="120" min="30" max="300" />
Rows per pattern: <input type="number" id="rows" value="16" min="4" max="64" />
<button id="playPause">Play</button>
<button id="loopToggle">Loop: Off</button>
</div>
<div id="sequencer"></div>
<script>
const rowsInput = document.getElementById('rows');
const bpmInput = document.getElementById('bpm');
const playPauseBtn = document.getElementById('playPause');
const loopToggleBtn = document.getElementById('loopToggle');
const sequencer = document.getElementById('sequencer');
// Constants
const channels = 4; // 4 instruments
let rowsPerPattern = parseInt(rowsInput.value);
let bpm = parseInt(bpmInput.value);
let isPlaying = false;
let loop = false;
let currentRow = 0;
// Simple pattern: 1 pattern, rows x channels, notes stored as freq or null
let pattern = [];
for(let r=0; r<rowsPerPattern; r++) {
pattern[r] = new Array(channels).fill(null);
}
// Build sequencer UI grid
function renderGrid() {
sequencer.innerHTML = '';
sequencer.style.gridTemplateColumns = `repeat(${channels}, 40px)`;
for(let r=0; r<rowsPerPattern; r++) {
for(let c=0; c<channels; c++) {
const cell = document.createElement('div');
cell.classList.add('cell');
cell.dataset.row = r;
cell.dataset.channel = c;
cell.textContent = pattern[r][c] ? Math.round(pattern[r][c]) : '-';
cell.onclick = () => {
// Simple toggle between C4 (261.6) and empty
if(pattern[r][c]) pattern[r][c] = null;
else pattern[r][c] = 261.6;
cell.textContent = pattern[r][c] ? Math.round(pattern[r][c]) : '-';
};
sequencer.appendChild(cell);
}
}
}
renderGrid();
// Audio context and synth setup
const AudioContext = window.AudioContext || window.webkitAudioContext;
const ctx = new AudioContext();
function playFreq(freq) {
const osc = ctx.createOscillator();
const gainNode = ctx.createGain();
osc.type = 'square'; // Basic chiptune square wave
osc.frequency.value = freq;
gainNode.gain.setValueAtTime(0.2, ctx.currentTime);
osc.connect(gainNode).connect(ctx.destination);
osc.start();
osc.stop(ctx.currentTime + (60 / bpm) / 4); // short note (16th note length)
// ADSR could be added here with gain ramps
}
let intervalId;
function playStep() {
// Highlight current row
[...sequencer.children].forEach(cell => {
if (parseInt(cell.dataset.row) === currentRow) cell.classList.add('playing');
else cell.classList.remove('playing');
});
// Play all notes on current row
for(let c=0; c<channels; c++) {
if(pattern[currentRow][c]) {
playFreq(pattern[currentRow][c]);
}
}
currentRow++;
if(currentRow >= rowsPerPattern) {
if(loop) currentRow = 0;
else {
clearInterval(intervalId);
isPlaying = false;
playPauseBtn.textContent = 'Play';
}
}
}
playPauseBtn.onclick = () => {
if (!isPlaying) {
ctx.resume(); // resume audio context if suspended
currentRow = 0;
intervalId = setInterval(playStep, (60000 / bpm) / 4); // 16th note interval
playPauseBtn.textContent = 'Stop';
isPlaying = true;
} else {
clearInterval(intervalId);
playPauseBtn.textContent = 'Play';
isPlaying = false;
}
};
loopToggleBtn.onclick = () => {
loop = !loop;
loopToggleBtn.textContent = `Loop: ${loop ? 'On' : 'Off'}`;
};
bpmInput.onchange = () => {
bpm = parseInt(bpmInput.value);
if (isPlaying) {
clearInterval(intervalId);
intervalId = setInterval(playStep, (60000 / bpm) / 4);
}
}
rowsInput.onchange = () => {
rowsPerPattern = parseInt(rowsInput.value);
// Reset pattern and re-render grid
pattern = [];
for(let r=0; r<rowsPerPattern; r++) {
pattern[r] = new Array(channels).fill(null);
}
renderGrid();
}
</script>
</body>
</html>
This is a very basic tracker with:
- 4 channels/instruments, square wave oscillator
- Editing notes as toggles on the grid (sets C4 note or silence)
- Play/pause, BPM, rows per pattern controls
- Loop toggle and loop playback
- No demo songs included (empty grid on load)
To extend this, you could:
- Add UI to select oscillator type (square, triangle, sawtooth, noise via noise buffer)
- ADSR envelope adjustments on gain node
- Filter node per instrument
- Volume and detune options on oscillator
- Multiple patterns and pattern chaining
- Keyboard shortcuts for playback control and editing
- Save/load song data as JSON / encode into base64 string for sharing in URL hash
4. Sharing songs via URL hash
You can serialize your pattern + instruments state into a JSON string, compress or base64-encode it, and append to URL after /#. On page load, decode and load it. This allows song sharing without backend.
For example:
// Example encode
const songData = { bpm, rowsPerPattern, pattern /* + instruments... */ };
const encoded = btoa(JSON.stringify(songData));
window.location.hash = encoded;
// On load
if(window.location.hash.length > 1) {
const data = JSON.parse(atob(window.location.hash.slice(1)));
// Load and set state
}
Summary
You can either:
- Use/fork BeepBox or other existing open source chiptune trackers that fit your requirements.
- Build your own tracker with HTML+JS+WebAudio using the outline & skeleton above.
If you want, I can help you build any part in more detail, like instrument editor, full polyphony, or sharing. Just ask!