|
24 | 24 | } |
25 | 25 | </style> |
26 | 26 | <script src='https://surikov.github.io/webaudiofont/npm/dist/WebAudioFontPlayer.js'></script> |
27 | | - <script src='https://surikov.github.io/webaudiofontdata/sound/0250_SoundBlasterOld_sf2.js'></script> |
28 | 27 | <script> |
29 | 28 | var AudioContextFunc = window.AudioContext || window.webkitAudioContext; |
30 | 29 | var audioContext = new AudioContextFunc(); |
| 30 | + var channels = new Map(); |
31 | 31 | var player=new WebAudioFontPlayer(); |
32 | | - player.loader.decodeAfterLoading(audioContext, '_tone_0250_SoundBlasterOld_sf2'); |
33 | 32 |
|
34 | | - function play_note(semitones, seconds){ |
35 | | - player.queueWaveTable(audioContext, audioContext.destination |
36 | | - , _tone_0250_SoundBlasterOld_sf2, 0, semitones, seconds); |
| 33 | + function play_note(channel, semitones, seconds, volume){ |
| 34 | + const info = channels.get(channel); |
| 35 | + if (info) { |
| 36 | + player.queueWaveTable(audioContext, audioContext.destination, window[info.variable], 0, semitones, seconds, volume); |
| 37 | + } |
37 | 38 | } |
38 | 39 |
|
39 | | - function load_instrument(program) { |
| 40 | + function init_channel(channel, program) { |
| 41 | + var nn = player.loader.findInstrument(program); |
| 42 | + var info = player.loader.instrumentInfo(nn); |
| 43 | + channels.set(channel, info); |
| 44 | + console.log('init_channel(', channel, program, ') -> info:', info); |
| 45 | + player.loader.startLoad(audioContext, info.url, info.variable); |
| 46 | + } |
| 47 | + |
| 48 | + function load_instruments() { |
| 49 | + player.loader.waitLoad(function () { |
| 50 | + console.log('load_instruments: finished', channels); |
| 51 | + }); |
40 | 52 | } |
41 | 53 | </script> |
42 | 54 | </head> |
|
0 commit comments