It sounds like you're describing a very specific type of HTML-based chiptune tracker or music tracker web app with features such as:
If you want something small, BeepBox is a great near-complete solution.
html
<!DOCTYPE html>
<html>
<head><title>Mini Chiptune Tracker</title></head>
<body>
<button id="playBtn">Play</button>
<script>
// Simple example with 1 instrument: square wave with ADSR
const audioCtx = new (window.AudioContext || window.webkitAudioContext)();
const bpm = 120;
const rowsPerPattern = 16;
const secondsPerRow = 60 / bpm / 4; // 4 rows per beat
// Example pattern: array of notes (MIDI note numbers or null)
const pattern = [60, 62, 64, 65, 67, 69, 71, 72, null, 72, 71, 69, 67, 65, 64, 62];
// Simple ADSR function
function playNote(freq, startTime, duration) {
const osc = audioCtx.createOscillator();
osc.type = 'square';
osc.frequency.setValueAtTime(freq, startTime);
const gain = audioCtx.createGain();
gain.gain.setValueAtTime(0, startTime);
gain.gain.linearRampToValueAtTime(0.3, startTime + 0.01); // Attack
gain.gain.linearRampToValueAtTime(0.25, startTime + 0.1); // Decay
gain.gain.setValueAtTime(0.25, startTime + duration - 0.05); // Sustain
gain.gain.linearRampToValueAtTime(0, startTime + duration); // Release
osc.connect(gain);
gain.connect(audioCtx.destination);
osc.start(startTime);
osc.stop(startTime + duration);
}
// Converts MIDI note to frequency
function midiToFreq(midi) {
return 440 * Math.pow(2, (midi - 69) / 12);
}
document.getElementById('playBtn').onclick = () => {
const now = audioCtx.currentTime;
for(let i=0; i<pattern.length; i++) {
const note = pattern[i];
if (note !== null) {
playNote(midiToFreq(note), now + i*secondsPerRow, secondsPerRow * 0.9);
}
}
}
</script>
</body>
</html>
If you want, I can help you write a more advanced minimal tracker skeleton implementing: