Jazz-Soft.net

We make it sound!

Home » Examples » Echo

Echo

How it works

Play the lower piano via a mouse/touch, or a computer keyboard, or an external MIDI instrument,
and see the echo transposed an octave up on the upper piano.

Page source

<!DOCTYPE html>
<html>
<head>
<title>Echo</title>
<script src="JZZ.js"></script>
<script src="JZZ.synth.OSC.js"></script>
<script src="JZZ.input.ASCII.js"></script>
<script src="JZZ.input.Kbd.js"></script>
</head>

<body>
<h1>Echo</h1>

<div id=piano_out></div>
<div id=piano_in></div>

<script><!--
JZZ.synth.OSC.register('Web Audio');
var midi_in = JZZ().openMidiIn();                      // default MIDI-In (if available)
var midi_out = JZZ().openMidiOut();                    // default MIDI-Out
var piano_in = JZZ.input.Kbd({ at:'piano_in' });   // lower piano
var piano_out = JZZ.input.Kbd({ at:'piano_out', chan:1, active:false });
                                                       // upper piano
var ascii = JZZ.input.ASCII({                          // computer keyboard
  A:'F#4', Z:'G4', S:'G#4', X:'A4', D:'Bb4', C:'B4', V:'C5', G:'C#5', B:'D5',
  H:'D#5', N:'E5', M:'F5', K:'F#5', '<':'G5', L:'G#5', '>':'A5', ':':'Bb5'
});

var map_to_0 = JZZ.createNew({ _receive: function(msg) {  // change channel
  this.emit(msg.setChannel(0));
}});

var delay = JZZ.createNew({ _receive: function(msg) {     // delay, transpose, change channel
  this.wait(500).emit(msg.setNote(msg.getNote() + 12).setChannel(1));
}});

midi_in.connect(map_to_0);
map_to_0.connect(ascii);
ascii.connect(piano_in);
piano_in.connect(midi_out);
piano_in.connect(delay);
delay.connect(piano_out);
piano_out.connect(midi_out);

--></script>

</body>
</html>

See also