Demo Principal
CDN v3.0.0

Añade estas dos etiquetas a tu página — antes de </body> o en <head> :

Motor Synth
<script src="https://cdn.chiptune-synth.8binami.com/3.0.0/chiptune-synth.min.js"></script>
Sound Font (170+ instruments)
<script src="https://cdn.chiptune-synth.8binami.com/3.0.0/chiptune-sound-font.min.js"></script>

Primeros Pasos

Aprende ChiptuneSynth paso a paso — haz clic en "Ejecutar" para escuchar cada ejemplo en vivo

1

¡Hola, Chiptune!

Crea un sintetizador, inícialo y reproduce tu primer efecto de sonido — todo en 3 líneas.

const synth = new ChiptuneSynth();
await synth.init();
synth.playPreset('coin');  // ding!
El AudioContext requiere un gesto del usuario (clic) para iniciar — por eso usamos un botón.
2

Reproducir una Nota por Nombre

Reproduce el Do central durante medio segundo en la pista Lead (pista 0).

synth.playNoteByName('C', 4, 0, 0.5);
// note, octave, track, duration (seconds)
3

Reproducir una Melodía

Programa múltiples notas con tiempo para crear una melodía simple.

const melody = [
  { note:'C', oct:4, time:0 },
  { note:'E', oct:4, time:0.25 },
  { note:'G', oct:4, time:0.5 },
  { note:'C', oct:5, time:0.75 }
];
melody.forEach(n =>
  setTimeout(() =>
    synth.playNoteByName(n.note, n.oct, 0, 0.3),
    n.time * 1000
  )
);
4

Cargar un Instrumento

Cambia de la onda cuadrada predeterminada a un violín y reproduce una nota.

synth.loadInstrument('violin', 0);
synth.playNoteByName('A', 4, 0, 1.5);
// Available: piano, violin, cello, flute, organ,
// brass, harmonica, synthLead, synthPad, synthBass,
// marimba, electricGuitar
5

Capas Multi-Pista

Reproduce diferentes instrumentos en diferentes pistas al mismo tiempo.

synth.loadInstrument('synthPad', 0);  // Lead
synth.loadInstrument('synthBass', 1); // Bass

// Play a chord on the pad
synth.playNoteByName('C', 4, 0, 2);
synth.playNoteByName('E', 4, 0, 2);
synth.playNoteByName('G', 4, 0, 2);

// Bass note underneath
synth.playNoteByName('C', 2, 1, 2);
6

Ajustar el Sonido

Personaliza el envolvente, el vibrato y la forma de onda para moldear tu sonido.

// Slow attack pad
synth.updateEnvelope(0, {
  attack: 0.5, decay: 0.3,
  sustain: 0.6, release: 1.0
});

// Add vibrato
synth.updateVibrato(0, {
  rate: 5, depth: 8
});

// Change waveform to sawtooth
synth.updateTrack(0, { type: 'sawtooth' });

synth.playNoteByName('D', 4, 0, 2.5);
7

Combo de SFX de Juego

Encadena múltiples efectos de sonido — recoge moneda, sube de nivel, ¡dispara!

synth.playPreset('coin');
setTimeout(() => synth.playPreset('powerup'), 400);
setTimeout(() => synth.playPreset('laser'), 1200);
setTimeout(() => synth.playPreset('explosion'), 1500);
setTimeout(() => synth.playPreset('1up'), 2200);
8

Visualización de Forma de Onda

Dibuja la forma de onda de audio en vivo en un canvas — ¡ideal para interfaces de juegos!

function draw() {
  const data = synth.getWaveformData();
  ctx.clearRect(0, 0, canvas.width, canvas.height);
  ctx.strokeStyle = '#00f0ff';
  ctx.beginPath();
  data.forEach((v, i) => {
    const x = (i / data.length) * canvas.width;
    const y = (v / 255) * canvas.height;
    i === 0 ? ctx.moveTo(x, y) : ctx.lineTo(x, y);
  });
  ctx.stroke();
  requestAnimationFrame(draw);
}
draw();