/usr/share/faust/webaudio/webaudio-asm-poly-footer.html is in faust-common 0.9.95~repack1-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 | <script>
var isWebKitAudio = (typeof (webkitAudioContext) !== "undefined");
var audio_context = (isWebKitAudio) ? new webkitAudioContext() : new AudioContext();
var max_polyphony = 16;
var audio_input = null;
var midi_input = [];
var DSP_poly = null;
var faustsvg = null;
function changeBufferSize(buffer_size)
{
var new_buffer_size = buffer_size.options[buffer_size.selectedIndex].value;
console.log(new_buffer_size);
startNewDSP(new_buffer_size);
}
// MIDI input handling
function keyOn(channel, pitch, velocity)
{
if (DSP_poly) {
DSP_poly.keyOn(channel, pitch, velocity);
}
}
function keyOff(channel, pitch)
{
if (DSP_poly) {
DSP_poly.keyOff(channel, pitch);
}
}
function pitchWheel(channel, wheel)
{
if (DSP_poly) {
DSP_poly.pitchWheel(channel, wheel);
}
}
function ctrlChange(channel, ctrl, value)
{
if (DSP_poly) {
DSP_poly.ctrlChange(channel, ctrl, value);
}
}
function midiMessageReceived(ev)
{
var cmd = ev.data[0] >> 4;
var channel = ev.data[0] & 0xf;
var data1 = ev.data[1];
var data2 = ev.data[2];
//console.log(ev);
if (channel === 9) {
return;
} else if (cmd === 8 || ((cmd === 9) && (data2 === 0))) {
keyOff(channel, data1);
} else if (cmd === 9) {
keyOn(channel, data1, data2);
} else if (cmd === 11) {
ctrlChange(channel, data1, data2);
} else if (cmd === 14) {
pitchWheel(channel, ((data2 * 128.0 + data1)-8192)/8192.0);
}
}
function onerrorcallback(error)
{
console.log(error);
}
function onsuccesscallbackJazz(access)
{
var inputs = access.getInputs();
for (var i = 0; i <inputs.length; i++) {
var input = access.getInput(inputs[i]);
midi_input.push(input);
input.onmessage = midiMessageReceived;
}
}
function onsuccesscallbackStandard(access)
{
for (var input of access.inputs.values()) {
midi_input.push(input);
input.onmidimessage = midiMessageReceived;
console.log(input.name);
}
}
function activateMIDIInput()
{
console.log("activateMIDIInput");
if (typeof (navigator.requestMIDIAccess) !== "undefined") {
if (navigator.requestMIDIAccess() != undefined) {
navigator.requestMIDIAccess().then(onsuccesscallbackStandard, onerrorcallback);
} else{
navigator.requestMIDIAccess(onsuccesscallbackJazz, onerrorcallback);
}
} else {
alert("MIDI input cannot be activated, either your browser still does't have it, or you need to explicitly activate it.");
}
}
// Audio input handling
function activateAudioInput()
{
if (!navigator.getUserMedia) {
navigator.getUserMedia = navigator.webkitGetUserMedia || navigator.mozGetUserMedia;
}
if (navigator.getUserMedia) {
navigator.getUserMedia({audio:true}, getDevice, function(e) {
alert('Error getting audio input');
console.log(e);
});
} else {
alert('Audio input API not available');
}
}
function getDevice(device)
{
// Create an AudioNode from the stream.
audio_input = audio_context.createMediaStreamSource(device);
// Connect it to the destination.
audio_input.connect(DSP_poly.getProcessor());
}
function startDSPAux(buffer_size)
{
activateMIDIInput();
if (DSP_poly) {
if (audio_input) {
audio_input.disconnect(DSP_poly.getProcessor());
}
_f4u$t.hard_delete(faustsvg);
DSP_poly.stop();
DSP_poly.destroy();
}
DSP_poly = faust.DSP_poly(audio_context, buffer_size, max_polyphony);
DSP_poly.start();
console.log(DSP_poly.json());
// kludge...ideally, this needs to not be part of the imported JS
_f4u$t.main_loop = function() {}
faustsvg = $('<div />');
$('body').append(faustsvg);
var handler = _f4u$t.main(DSP_poly.json(), faustsvg, DSP_poly.setParamValue);
DSP_poly.setHandler(handler);
}
function startDSP()
{
startDSPAux(1024);
}
function startNewDSP(buffer_size)
{
startDSPAux(buffer_size);
}
// To activate audio on iOS
window.addEventListener('touchstart', function() {
// create empty buffer
var buffer = audio_context.createBuffer(1, 1, 22050);
var source = audio_context.createBufferSource();
source.buffer = buffer;
// connect to output (your speakers)
source.connect(audio_context.destination);
// play the file
source.noteOn(0);
}, false);
// Polyphonic instrument
$(startDSP);
</script>
<P>
<center>
<form method="POST" name="menu" >
<select name="selectedBuffer"
onChange="changeBufferSize(this.form.selectedBuffer)">
<option value = 256 > 256 </option>
<option value = 512> 512 </option>
<option selected value = 1024> 1024 </option>
<option value = 2048> 2048 </option>
<option value = 4096> 4096 </option>
<option value = 8192> 8192 </option>
</select>
</form>
</center>
|