spessasynth_lib 3.25.22 → 3.26.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (168) hide show
  1. package/README.md +29 -114
  2. package/index.js +33 -33
  3. package/package.json +16 -6
  4. package/external_midi/README.md +0 -4
  5. package/external_midi/midi_handler.js +0 -130
  6. package/external_midi/web_midi_link.js +0 -43
  7. package/externals/fflate/LICENSE +0 -21
  8. package/externals/fflate/fflate.min.js +0 -1
  9. package/externals/stbvorbis_sync/@types/stbvorbis_sync.d.ts +0 -12
  10. package/externals/stbvorbis_sync/LICENSE +0 -202
  11. package/externals/stbvorbis_sync/NOTICE +0 -6
  12. package/externals/stbvorbis_sync/stbvorbis_sync.min.js +0 -1
  13. package/midi/README.md +0 -32
  14. package/midi/basic_midi.js +0 -565
  15. package/midi/midi_builder.js +0 -202
  16. package/midi/midi_data.js +0 -63
  17. package/midi/midi_loader.js +0 -324
  18. package/midi/midi_message.js +0 -254
  19. package/midi/midi_sequence.js +0 -225
  20. package/midi/midi_tools/get_note_times.js +0 -154
  21. package/midi/midi_tools/midi_editor.js +0 -611
  22. package/midi/midi_tools/midi_writer.js +0 -99
  23. package/midi/midi_tools/rmidi_writer.js +0 -567
  24. package/midi/midi_tools/used_keys_loaded.js +0 -238
  25. package/midi/xmf_loader.js +0 -454
  26. package/sequencer/README.md +0 -32
  27. package/sequencer/sequencer_engine/events.js +0 -207
  28. package/sequencer/sequencer_engine/play.js +0 -353
  29. package/sequencer/sequencer_engine/process_event.js +0 -169
  30. package/sequencer/sequencer_engine/process_tick.js +0 -106
  31. package/sequencer/sequencer_engine/sequencer_engine.js +0 -337
  32. package/sequencer/sequencer_engine/song_control.js +0 -229
  33. package/sequencer/worklet_wrapper/default_sequencer_options.js +0 -8
  34. package/sequencer/worklet_wrapper/sequencer.js +0 -807
  35. package/sequencer/worklet_wrapper/sequencer_message.js +0 -53
  36. package/soundfont/README.md +0 -13
  37. package/soundfont/basic_soundfont/basic_instrument.js +0 -77
  38. package/soundfont/basic_soundfont/basic_preset.js +0 -336
  39. package/soundfont/basic_soundfont/basic_sample.js +0 -197
  40. package/soundfont/basic_soundfont/basic_soundfont.js +0 -565
  41. package/soundfont/basic_soundfont/basic_zone.js +0 -64
  42. package/soundfont/basic_soundfont/basic_zones.js +0 -43
  43. package/soundfont/basic_soundfont/generator.js +0 -220
  44. package/soundfont/basic_soundfont/modulator.js +0 -378
  45. package/soundfont/basic_soundfont/riff_chunk.js +0 -149
  46. package/soundfont/basic_soundfont/write_dls/art2.js +0 -173
  47. package/soundfont/basic_soundfont/write_dls/articulator.js +0 -49
  48. package/soundfont/basic_soundfont/write_dls/combine_zones.js +0 -400
  49. package/soundfont/basic_soundfont/write_dls/ins.js +0 -103
  50. package/soundfont/basic_soundfont/write_dls/lins.js +0 -18
  51. package/soundfont/basic_soundfont/write_dls/modulator_converter.js +0 -330
  52. package/soundfont/basic_soundfont/write_dls/rgn2.js +0 -121
  53. package/soundfont/basic_soundfont/write_dls/wave.js +0 -94
  54. package/soundfont/basic_soundfont/write_dls/write_dls.js +0 -119
  55. package/soundfont/basic_soundfont/write_dls/wsmp.js +0 -78
  56. package/soundfont/basic_soundfont/write_dls/wvpl.js +0 -32
  57. package/soundfont/basic_soundfont/write_sf2/ibag.js +0 -39
  58. package/soundfont/basic_soundfont/write_sf2/igen.js +0 -80
  59. package/soundfont/basic_soundfont/write_sf2/imod.js +0 -46
  60. package/soundfont/basic_soundfont/write_sf2/inst.js +0 -34
  61. package/soundfont/basic_soundfont/write_sf2/pbag.js +0 -39
  62. package/soundfont/basic_soundfont/write_sf2/pgen.js +0 -82
  63. package/soundfont/basic_soundfont/write_sf2/phdr.js +0 -42
  64. package/soundfont/basic_soundfont/write_sf2/pmod.js +0 -46
  65. package/soundfont/basic_soundfont/write_sf2/sdta.js +0 -80
  66. package/soundfont/basic_soundfont/write_sf2/shdr.js +0 -55
  67. package/soundfont/basic_soundfont/write_sf2/write.js +0 -222
  68. package/soundfont/dls/articulator_converter.js +0 -396
  69. package/soundfont/dls/dls_destinations.js +0 -38
  70. package/soundfont/dls/dls_preset.js +0 -44
  71. package/soundfont/dls/dls_sample.js +0 -75
  72. package/soundfont/dls/dls_soundfont.js +0 -186
  73. package/soundfont/dls/dls_sources.js +0 -62
  74. package/soundfont/dls/dls_zone.js +0 -95
  75. package/soundfont/dls/read_articulation.js +0 -299
  76. package/soundfont/dls/read_instrument.js +0 -121
  77. package/soundfont/dls/read_instrument_list.js +0 -17
  78. package/soundfont/dls/read_lart.js +0 -35
  79. package/soundfont/dls/read_region.js +0 -152
  80. package/soundfont/dls/read_samples.js +0 -270
  81. package/soundfont/load_soundfont.js +0 -21
  82. package/soundfont/read_sf2/generators.js +0 -46
  83. package/soundfont/read_sf2/instruments.js +0 -66
  84. package/soundfont/read_sf2/modulators.js +0 -36
  85. package/soundfont/read_sf2/presets.js +0 -80
  86. package/soundfont/read_sf2/samples.js +0 -304
  87. package/soundfont/read_sf2/soundfont.js +0 -305
  88. package/soundfont/read_sf2/zones.js +0 -263
  89. package/synthetizer/README.md +0 -10
  90. package/synthetizer/audio_effects/effects_config.js +0 -25
  91. package/synthetizer/audio_effects/fancy_chorus.js +0 -162
  92. package/synthetizer/audio_effects/rb_compressed.min.js +0 -1
  93. package/synthetizer/audio_effects/reverb.js +0 -35
  94. package/synthetizer/audio_effects/reverb_as_binary.js +0 -18
  95. package/synthetizer/audio_engine/README.md +0 -25
  96. package/synthetizer/audio_engine/engine_components/compute_modulator.js +0 -266
  97. package/synthetizer/audio_engine/engine_components/controller_tables.js +0 -88
  98. package/synthetizer/audio_engine/engine_components/key_modifier_manager.js +0 -149
  99. package/synthetizer/audio_engine/engine_components/lfo.js +0 -26
  100. package/synthetizer/audio_engine/engine_components/lowpass_filter.js +0 -282
  101. package/synthetizer/audio_engine/engine_components/midi_audio_channel.js +0 -471
  102. package/synthetizer/audio_engine/engine_components/modulation_envelope.js +0 -181
  103. package/synthetizer/audio_engine/engine_components/modulator_curves.js +0 -89
  104. package/synthetizer/audio_engine/engine_components/soundfont_manager/sfman_message.js +0 -9
  105. package/synthetizer/audio_engine/engine_components/soundfont_manager/soundfont_manager.js +0 -254
  106. package/synthetizer/audio_engine/engine_components/stereo_panner.js +0 -120
  107. package/synthetizer/audio_engine/engine_components/unit_converter.js +0 -73
  108. package/synthetizer/audio_engine/engine_components/voice.js +0 -519
  109. package/synthetizer/audio_engine/engine_components/volume_envelope.js +0 -401
  110. package/synthetizer/audio_engine/engine_components/wavetable_oscillator.js +0 -263
  111. package/synthetizer/audio_engine/engine_methods/controller_control/controller_change.js +0 -132
  112. package/synthetizer/audio_engine/engine_methods/controller_control/master_parameters.js +0 -48
  113. package/synthetizer/audio_engine/engine_methods/controller_control/reset_controllers.js +0 -241
  114. package/synthetizer/audio_engine/engine_methods/create_midi_channel.js +0 -27
  115. package/synthetizer/audio_engine/engine_methods/data_entry/data_entry_coarse.js +0 -253
  116. package/synthetizer/audio_engine/engine_methods/data_entry/data_entry_fine.js +0 -66
  117. package/synthetizer/audio_engine/engine_methods/mute_channel.js +0 -17
  118. package/synthetizer/audio_engine/engine_methods/note_on.js +0 -174
  119. package/synthetizer/audio_engine/engine_methods/portamento_time.js +0 -92
  120. package/synthetizer/audio_engine/engine_methods/program_change.js +0 -61
  121. package/synthetizer/audio_engine/engine_methods/render_voice.js +0 -196
  122. package/synthetizer/audio_engine/engine_methods/soundfont_management/clear_sound_font.js +0 -30
  123. package/synthetizer/audio_engine/engine_methods/soundfont_management/get_preset.js +0 -22
  124. package/synthetizer/audio_engine/engine_methods/soundfont_management/reload_sound_font.js +0 -40
  125. package/synthetizer/audio_engine/engine_methods/soundfont_management/send_preset_list.js +0 -34
  126. package/synthetizer/audio_engine/engine_methods/soundfont_management/set_embedded_sound_font.js +0 -21
  127. package/synthetizer/audio_engine/engine_methods/stopping_notes/kill_note.js +0 -20
  128. package/synthetizer/audio_engine/engine_methods/stopping_notes/note_off.js +0 -55
  129. package/synthetizer/audio_engine/engine_methods/stopping_notes/stop_all_channels.js +0 -16
  130. package/synthetizer/audio_engine/engine_methods/stopping_notes/stop_all_notes.js +0 -30
  131. package/synthetizer/audio_engine/engine_methods/stopping_notes/voice_killing.js +0 -63
  132. package/synthetizer/audio_engine/engine_methods/system_exclusive.js +0 -744
  133. package/synthetizer/audio_engine/engine_methods/tuning_control/channel_pressure.js +0 -24
  134. package/synthetizer/audio_engine/engine_methods/tuning_control/pitch_wheel.js +0 -33
  135. package/synthetizer/audio_engine/engine_methods/tuning_control/poly_pressure.js +0 -31
  136. package/synthetizer/audio_engine/engine_methods/tuning_control/set_master_tuning.js +0 -15
  137. package/synthetizer/audio_engine/engine_methods/tuning_control/set_modulation_depth.js +0 -27
  138. package/synthetizer/audio_engine/engine_methods/tuning_control/set_octave_tuning.js +0 -19
  139. package/synthetizer/audio_engine/engine_methods/tuning_control/set_tuning.js +0 -27
  140. package/synthetizer/audio_engine/engine_methods/tuning_control/transpose_all_channels.js +0 -15
  141. package/synthetizer/audio_engine/engine_methods/tuning_control/transpose_channel.js +0 -34
  142. package/synthetizer/audio_engine/main_processor.js +0 -765
  143. package/synthetizer/audio_engine/message_protocol/README.md +0 -13
  144. package/synthetizer/audio_engine/message_protocol/message_sending.js +0 -22
  145. package/synthetizer/audio_engine/message_protocol/worklet_message.js +0 -107
  146. package/synthetizer/audio_engine/snapshot/apply_synthesizer_snapshot.js +0 -14
  147. package/synthetizer/audio_engine/snapshot/channel_snapshot.js +0 -175
  148. package/synthetizer/audio_engine/snapshot/synthesizer_snapshot.js +0 -122
  149. package/synthetizer/synth_constants.js +0 -20
  150. package/synthetizer/worklet_processor.min.js +0 -21
  151. package/synthetizer/worklet_wrapper/key_modifier_manager.js +0 -104
  152. package/synthetizer/worklet_wrapper/synth_event_handler.js +0 -214
  153. package/synthetizer/worklet_wrapper/synth_soundfont_manager.js +0 -111
  154. package/synthetizer/worklet_wrapper/synthetizer.js +0 -1027
  155. package/synthetizer/worklet_wrapper/worklet_processor.js +0 -340
  156. package/synthetizer/worklet_wrapper/worklet_url.js +0 -16
  157. package/utils/README.md +0 -5
  158. package/utils/buffer_to_wav.js +0 -186
  159. package/utils/byte_functions/big_endian.js +0 -32
  160. package/utils/byte_functions/little_endian.js +0 -77
  161. package/utils/byte_functions/string.js +0 -107
  162. package/utils/byte_functions/variable_length_quantity.js +0 -42
  163. package/utils/fill_with_defaults.js +0 -21
  164. package/utils/indexed_array.js +0 -52
  165. package/utils/loggin.js +0 -79
  166. package/utils/other.js +0 -92
  167. package/utils/sysex_detector.js +0 -58
  168. package/utils/xg_hacks.js +0 -193
@@ -1,744 +0,0 @@
1
- import { arrayToHexString, consoleColors } from "../../../utils/other.js";
2
- import { SpessaSynthInfo, SpessaSynthWarn } from "../../../utils/loggin.js";
3
- import { midiControllers } from "../../../midi/midi_message.js";
4
- import { ALL_CHANNELS_OR_DIFFERENT_ACTION } from "../message_protocol/worklet_message.js";
5
- import { isSystemXG } from "../../../utils/xg_hacks.js";
6
- import { masterParameterType } from "./controller_control/master_parameters.js";
7
-
8
- /**
9
- * KeyNum: tuning
10
- * @typedef {MTSNoteTuning[]} MTSProgramTuning
11
- */
12
-
13
- /**
14
- * @typedef {Object} MTSNoteTuning
15
- * @property {number} midiNote - the base midi note to use, -1 means no change
16
- * @property {number} centTuning - additional tuning
17
- */
18
-
19
- /**
20
- * Calculates freqency for MIDI Tuning Standard
21
- * @param byte1 {number}
22
- * @param byte2 {number}
23
- * @param byte3 {number}
24
- * @return {{midiNote: number, centTuning: number|null}}
25
- */
26
- function getTuning(byte1, byte2, byte3)
27
- {
28
- const midiNote = byte1;
29
- const fraction = (byte2 << 7) | byte3; // Combine byte2 and byte3 into a 14-bit number
30
-
31
- // no change
32
- if (byte1 === 0x7F && byte2 === 0x7F && byte3 === 0x7F)
33
- {
34
- return { midiNote: -1, centTuning: null };
35
- }
36
-
37
- // calculate cent tuning
38
- return { midiNote: midiNote, centTuning: fraction * 0.0061 };
39
- }
40
-
41
- /**
42
- * The text types for the synth display
43
- * @enum {number}
44
- */
45
- export const SynthDisplayType = {
46
- SoundCanvasText: 0,
47
- XGText: 1,
48
- SoundCanvasDotDisplay: 2
49
- };
50
-
51
-
52
- /**
53
- * Executes a system exclusive
54
- * @param messageData {number[]|IndexedByteArray} - the message data without f0
55
- * @param channelOffset {number}
56
- * @this {SpessaSynthProcessor}
57
- */
58
- export function systemExclusive(messageData, channelOffset = 0)
59
- {
60
- const type = messageData[0];
61
- if (this.deviceID !== ALL_CHANNELS_OR_DIFFERENT_ACTION && messageData[1] !== 0x7F)
62
- {
63
- if (this.deviceID !== messageData[1])
64
- {
65
- // not our device ID
66
- return;
67
- }
68
- }
69
- switch (type)
70
- {
71
- default:
72
- SpessaSynthWarn(
73
- `%cUnrecognized SysEx: %c${arrayToHexString(messageData)}`,
74
- consoleColors.warn,
75
- consoleColors.unrecognized
76
- );
77
- break;
78
-
79
- // non realtime
80
- case 0x7E:
81
- case 0x7F:
82
- switch (messageData[2])
83
- {
84
- case 0x04:
85
- let cents;
86
- // device control
87
- switch (messageData[3])
88
- {
89
- case 0x01:
90
- // main volume
91
- const vol = messageData[5] << 7 | messageData[4];
92
- this.setMIDIVolume(vol / 16384);
93
- SpessaSynthInfo(
94
- `%cMaster Volume. Volume: %c${vol}`,
95
- consoleColors.info,
96
- consoleColors.value
97
- );
98
- break;
99
-
100
- case 0x02:
101
- // main balance
102
- // midi spec page 62
103
- const balance = messageData[5] << 7 | messageData[4];
104
- const pan = (balance - 8192) / 8192;
105
- this.setMasterParameter(masterParameterType.masterPan, pan);
106
- SpessaSynthInfo(
107
- `%cMaster Pan. Pan: %c${pan}`,
108
- consoleColors.info,
109
- consoleColors.value
110
- );
111
- break;
112
-
113
-
114
- case 0x03:
115
- // fine-tuning
116
- const tuningValue = ((messageData[5] << 7) | messageData[6]) - 8192;
117
- cents = Math.floor(tuningValue / 81.92); // [-100;+99] cents range
118
- this.setMasterTuning(cents);
119
- SpessaSynthInfo(
120
- `%cMaster Fine Tuning. Cents: %c${cents}`,
121
- consoleColors.info,
122
- consoleColors.value
123
- );
124
- break;
125
-
126
- case 0x04:
127
- // coarse tuning
128
- // lsb is ignored
129
- const semitones = messageData[5] - 64;
130
- cents = semitones * 100;
131
- this.setMasterTuning(cents);
132
- SpessaSynthInfo(
133
- `%cMaster Coarse Tuning. Cents: %c${cents}`,
134
- consoleColors.info,
135
- consoleColors.value
136
- );
137
- break;
138
-
139
- default:
140
- SpessaSynthWarn(
141
- `%cUnrecognized MIDI Device Control Real-time message: %c${arrayToHexString(messageData)}`,
142
- consoleColors.warn,
143
- consoleColors.unrecognized
144
- );
145
- }
146
- break;
147
-
148
- case 0x09:
149
- // gm system related
150
- if (messageData[3] === 0x01)
151
- {
152
- SpessaSynthInfo("%cGM1 system on", consoleColors.info);
153
- this.setSystem("gm");
154
- }
155
- else if (messageData[3] === 0x03)
156
- {
157
- SpessaSynthInfo("%cGM2 system on", consoleColors.info);
158
- this.setSystem("gm2");
159
- }
160
- else
161
- {
162
- SpessaSynthInfo("%cGM system off, defaulting to GS", consoleColors.info);
163
- this.setSystem("gs");
164
- }
165
- break;
166
-
167
- // MIDI Tuning standard
168
- // https://midi.org/midi-tuning-updated-specification
169
- case 0x08:
170
- switch (messageData[3])
171
- {
172
- // single note change
173
- // single note change bank
174
- case 0x02:
175
- case 0x07:
176
- let currentMessageIndex = 4;
177
- if (messageData[3] === 0x07)
178
- {
179
- // skip the bank
180
- currentMessageIndex++;
181
- }
182
- // get program and number of changes
183
- const tuningProgram = messageData[currentMessageIndex++];
184
- const numberOfChanges = messageData[currentMessageIndex++];
185
- for (let i = 0; i < numberOfChanges; i++)
186
- {
187
- // set the given tuning to the program
188
- this.tunings[tuningProgram][messageData[currentMessageIndex++]] = getTuning(
189
- messageData[currentMessageIndex++],
190
- messageData[currentMessageIndex++],
191
- messageData[currentMessageIndex++]
192
- );
193
- }
194
- SpessaSynthInfo(
195
- `%cSingle Note Tuning. Program: %c${tuningProgram}%c Keys affected: %c${numberOfChanges}`,
196
- consoleColors.info,
197
- consoleColors.recognized,
198
- consoleColors.info,
199
- consoleColors.recognized
200
- );
201
- break;
202
-
203
- // octave tuning (1 byte)
204
- // and octave tuning (2 bytes)
205
- case 0x09:
206
- case 0x08:
207
- // get tuning:
208
- const newOctaveTuning = new Int8Array(12);
209
- // start from bit 7
210
- if (messageData[3] === 0x08)
211
- {
212
- // 1 byte tuning: 0 is -64 cents, 64 is 0, 127 is +63
213
- for (let i = 0; i < 12; i++)
214
- {
215
- newOctaveTuning[i] = messageData[7 + i] - 64;
216
- }
217
- }
218
- else
219
- {
220
- // 2 byte tuning. Like fine tune: 0 is -100 cents, 8192 is 0 cents, 16,383 is +100 cents
221
- for (let i = 0; i < 24; i += 2)
222
- {
223
- const tuning = ((messageData[7 + i] << 7) | messageData[8 + i]) - 8192;
224
- newOctaveTuning[i / 2] = Math.floor(tuning / 81.92); // map to [-100;+99] cents
225
- }
226
- }
227
- // apply to channels (ordered from 0)
228
- // bit 1: 14 and 15
229
- if ((messageData[4] & 1) === 1)
230
- {
231
- this.midiAudioChannels[14 + channelOffset].setOctaveTuning(newOctaveTuning);
232
- }
233
- if (((messageData[4] >> 1) & 1) === 1)
234
- {
235
- this.midiAudioChannels[15 + channelOffset].setOctaveTuning(newOctaveTuning);
236
- }
237
-
238
- // bit 2: channels 7 to 13
239
- for (let i = 0; i < 7; i++)
240
- {
241
- const bit = (messageData[5] >> i) & 1;
242
- if (bit === 1)
243
- {
244
- this.midiAudioChannels[7 + i + channelOffset].setOctaveTuning(newOctaveTuning);
245
- }
246
- }
247
-
248
- // bit 3: channels 0 to 16
249
- for (let i = 0; i < 7; i++)
250
- {
251
- const bit = (messageData[6] >> i) & 1;
252
- if (bit === 1)
253
- {
254
- this.midiAudioChannels[i + channelOffset].setOctaveTuning(newOctaveTuning);
255
- }
256
- }
257
-
258
- SpessaSynthInfo(
259
- `%cMIDI Octave Scale ${
260
- messageData[3] === 0x08 ? "(1 byte)" : "(2 bytes)"
261
- } tuning via Tuning: %c${newOctaveTuning.join(" ")}`,
262
- consoleColors.info,
263
- consoleColors.value
264
- );
265
- break;
266
-
267
- default:
268
- SpessaSynthWarn(
269
- `%cUnrecognized MIDI Tuning standard message: %c${arrayToHexString(messageData)}`,
270
- consoleColors.warn,
271
- consoleColors.unrecognized
272
- );
273
- break;
274
- }
275
- break;
276
-
277
- default:
278
- SpessaSynthWarn(
279
- `%cUnrecognized MIDI Realtime/non realtime message: %c${arrayToHexString(messageData)}`,
280
- consoleColors.warn,
281
- consoleColors.unrecognized
282
- );
283
-
284
- }
285
- break;
286
-
287
- // this is a roland sysex
288
- // http://www.bandtrax.com.au/sysex.htm
289
- // https://cdn.roland.com/assets/media/pdf/AT-20R_30R_MI.pdf
290
- case 0x41:
291
-
292
- function notRecognized()
293
- {
294
- // this is some other GS sysex...
295
- SpessaSynthWarn(
296
- `%cUnrecognized Roland %cGS %cSysEx: %c${arrayToHexString(messageData)}`,
297
- consoleColors.warn,
298
- consoleColors.recognized,
299
- consoleColors.warn,
300
- consoleColors.unrecognized
301
- );
302
- }
303
-
304
- if (messageData[2] === 0x42 && messageData[3] === 0x12)
305
- {
306
- // this is a GS sysex
307
- // messageData[5] and [6] is the system parameter, messageData[7] is the value
308
- const messageValue = messageData[7];
309
- if (messageData[6] === 0x7F)
310
- {
311
- // GS mode set
312
- if (messageValue === 0x00)
313
- {
314
- // this is a GS reset
315
- SpessaSynthInfo("%cGS Reset received!", consoleColors.info);
316
- this.resetAllControllers(false);
317
- this.setSystem("gs");
318
- }
319
- else if (messageValue === 0x7F)
320
- {
321
- // GS mode off
322
- SpessaSynthInfo("%cGS system off, switching to GM2", consoleColors.info);
323
- this.resetAllControllers(false);
324
- this.setSystem("gm2");
325
- }
326
- return;
327
- }
328
- else if (messageData[4] === 0x40)
329
- {
330
- // this is a system parameter
331
- if ((messageData[5] & 0x10) > 0)
332
- {
333
- // this is an individual part (channel) parameter
334
- // determine the channel 0 means channel 10 (default), 1 means 1 etc.
335
- const channel = [9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 13, 14, 15][messageData[5] & 0x0F] + channelOffset;
336
- // for example, 0x1A means A = 11, which corresponds to channel 12 (counting from 1)
337
- const channelObject = this.midiAudioChannels[channel];
338
- switch (messageData[6])
339
- {
340
- default:
341
- // this is some other GS sysex...
342
- notRecognized();
343
- break;
344
-
345
- case 0x15:
346
- // this is the Use for Drum Part sysex (multiple drums)
347
- const isDrums = messageValue > 0 && messageData[5] >> 4; // if set to other than 0, is a drum channel
348
- channelObject.setDrums(isDrums);
349
- SpessaSynthInfo(
350
- `%cChannel %c${channel}%c ${isDrums ?
351
- "is now a drum channel"
352
- :
353
- "now isn't a drum channel"
354
- }%c via: %c${arrayToHexString(messageData)}`,
355
- consoleColors.info,
356
- consoleColors.value,
357
- consoleColors.recognized,
358
- consoleColors.info,
359
- consoleColors.value
360
- );
361
- return;
362
-
363
- case 0x16:
364
- // this is the pitch key shift sysex
365
- const keyShift = messageValue - 64;
366
- channelObject.transposeChannel(keyShift);
367
- SpessaSynthInfo(
368
- `%cChannel %c${channel}%c pitch shift. Semitones %c${keyShift}%c, with %c${arrayToHexString(
369
- messageData)}`,
370
- consoleColors.info,
371
- consoleColors.recognized,
372
- consoleColors.info,
373
- consoleColors.value,
374
- consoleColors.info,
375
- consoleColors.value
376
- );
377
- return;
378
-
379
- // pan position
380
- case 0x1C:
381
- // 0 is random
382
- let panpot = messageValue;
383
- if (panpot === 0)
384
- {
385
- channelObject.randomPan = true;
386
- SpessaSynthInfo(
387
- `%cRandom pan is set to %cON%c for %c${channel}`,
388
- consoleColors.info,
389
- consoleColors.recognized,
390
- consoleColors.info,
391
- consoleColors.value
392
- );
393
- }
394
- else
395
- {
396
- channelObject.randomPan = false;
397
- channelObject.controllerChange(midiControllers.pan, panpot);
398
- }
399
- break;
400
-
401
- // chorus send
402
- case 0x21:
403
- channelObject.controllerChange(midiControllers.chorusDepth, messageValue);
404
- break;
405
-
406
- // reverb send
407
- case 0x22:
408
- channelObject.controllerChange(midiControllers.reverbDepth, messageValue);
409
- break;
410
-
411
- case 0x40:
412
- case 0x41:
413
- case 0x42:
414
- case 0x43:
415
- case 0x44:
416
- case 0x45:
417
- case 0x46:
418
- case 0x47:
419
- case 0x48:
420
- case 0x49:
421
- case 0x4A:
422
- case 0x4B:
423
- // scale tuning: up to 12 bytes
424
- const tuningBytes = messageData.length - 9; // data starts at 7, minus checksum and f7
425
- // read em bytes
426
- const newTuning = new Int8Array(12);
427
- for (let i = 0; i < tuningBytes; i++)
428
- {
429
- newTuning[i] = messageData[i + 7] - 64;
430
- }
431
- channelObject.setOctaveTuning(newTuning);
432
- const cents = messageValue - 64;
433
- SpessaSynthInfo(
434
- `%cChannel %c${channel}%c octave scale tuning. Cents %c${newTuning.join(
435
- " ")}%c, with %c${arrayToHexString(messageData)}`,
436
- consoleColors.info,
437
- consoleColors.recognized,
438
- consoleColors.info,
439
- consoleColors.value,
440
- consoleColors.info,
441
- consoleColors.value
442
- );
443
- channelObject.setTuning(cents);
444
- break;
445
- }
446
- return;
447
- }
448
- else
449
- // this is a global system parameter
450
- if (messageData[5] === 0x00 && messageData[6] === 0x06)
451
- {
452
- // roland master pan
453
- SpessaSynthInfo(
454
- `%cRoland GS Master Pan set to: %c${messageValue}%c with: %c${arrayToHexString(
455
- messageData)}`,
456
- consoleColors.info,
457
- consoleColors.value,
458
- consoleColors.info,
459
- consoleColors.value
460
- );
461
- this.setMasterParameter(masterParameterType.masterPan, (messageValue - 64) / 64);
462
- return;
463
- }
464
- else if (messageData[5] === 0x00 && messageData[6] === 0x05)
465
- {
466
- // roland master key shift (transpose)
467
- const transpose = messageValue - 64;
468
- SpessaSynthInfo(
469
- `%cRoland GS Master Key-Shift set to: %c${transpose}%c with: %c${arrayToHexString(
470
- messageData)}`,
471
- consoleColors.info,
472
- consoleColors.value,
473
- consoleColors.info,
474
- consoleColors.value
475
- );
476
- this.setMasterTuning(transpose * 100);
477
- return;
478
- }
479
- else if (messageData[5] === 0x00 && messageData[6] === 0x04)
480
- {
481
- // roland GS master volume
482
- SpessaSynthInfo(
483
- `%cRoland GS Master Volume set to: %c${messageValue}%c with: %c${arrayToHexString(
484
- messageData)}`,
485
- consoleColors.info,
486
- consoleColors.value,
487
- consoleColors.info,
488
- consoleColors.value
489
- );
490
- this.setMIDIVolume(messageValue / 127);
491
- return;
492
- }
493
- }
494
- // this is some other GS sysex...
495
- notRecognized();
496
- return;
497
- }
498
- else if (messageData[2] === 0x45 && messageData[3] === 0x12)
499
- {
500
- // 0x45: GS Display Data, 0x12: DT1 (Device Transmit)
501
- // check for embedded copyright
502
- // (roland SC display sysex) http://www.bandtrax.com.au/sysex.htm
503
-
504
- if (
505
- messageData[4] === 0x10 && // Sound Canvas Display
506
- messageData[6] === 0x00 // Data follows
507
- )
508
- {
509
- if (messageData[5] === 0x00) // Display letters
510
- {
511
- // get the text
512
- // and header ends with (checksum) F7
513
- const text = new Uint8Array(messageData.slice(7, messageData.length - 2));
514
- this.callEvent(
515
- "synthdisplay",
516
- {
517
- displayData: text,
518
- displayType: SynthDisplayType.SoundCanvasText
519
- }
520
- );
521
- }
522
- else if (messageData[5] === 0x01) // Matrix display
523
- {
524
- // get the data
525
- // and header ends with (checksum) F7
526
- const dotMatrixData = new Uint8Array(messageData.slice(7, messageData.length - 3));
527
- this.callEvent(
528
- "synthdisplay",
529
- {
530
- displayData: dotMatrixData,
531
- displayType: SynthDisplayType.SoundCanvasDotDisplay
532
- }
533
- );
534
- SpessaSynthInfo(
535
- `%cRoland SC Display Dot Matrix via: %c${arrayToHexString(
536
- messageData)}`,
537
- consoleColors.info,
538
- consoleColors.value
539
- );
540
- }
541
- else
542
- {
543
- // this is some other GS sysex...
544
- notRecognized();
545
- }
546
- }
547
- }
548
- else if (messageData[2] === 0x16 && messageData[3] === 0x12 && messageData[4] === 0x10)
549
- {
550
- // this is a roland master volume message
551
- this.setMIDIVolume(messageData[7] / 100);
552
- SpessaSynthInfo(
553
- `%cRoland Master Volume control set to: %c${messageData[7]}%c via: %c${arrayToHexString(
554
- messageData)}`,
555
- consoleColors.info,
556
- consoleColors.value,
557
- consoleColors.info,
558
- consoleColors.value
559
- );
560
- return;
561
- }
562
- else
563
- {
564
- // this is something else...
565
- SpessaSynthWarn(
566
- `%cUnrecognized Roland SysEx: %c${arrayToHexString(messageData)}`,
567
- consoleColors.warn,
568
- consoleColors.unrecognized
569
- );
570
- return;
571
- }
572
- break;
573
-
574
- // yamaha
575
- // http://www.studio4all.de/htmle/main91.html
576
- case 0x43:
577
- // XG sysex
578
- if (messageData[2] === 0x4C)
579
- {
580
- // XG system parameter
581
- if (messageData[3] === 0x00 && messageData[4] === 0x00)
582
- {
583
- switch (messageData[5])
584
- {
585
- // master volume
586
- case 0x04:
587
- const vol = messageData[6];
588
- this.setMIDIVolume(vol / 127);
589
- SpessaSynthInfo(
590
- `%cXG master volume. Volume: %c${vol}`,
591
- consoleColors.info,
592
- consoleColors.recognized
593
- );
594
- break;
595
-
596
- // master transpose
597
- case 0x06:
598
- const transpose = messageData[6] - 64;
599
- this.transposeAllChannels(transpose);
600
- SpessaSynthInfo(
601
- `%cXG master transpose. Volume: %c${transpose}`,
602
- consoleColors.info,
603
- consoleColors.recognized
604
- );
605
- break;
606
-
607
- // XG on
608
- case 0x7E:
609
- SpessaSynthInfo("%cXG system on", consoleColors.info);
610
- this.resetAllControllers(false);
611
- this.setSystem("xg");
612
- break;
613
- }
614
- }
615
- else
616
- // XG part parameter
617
- if (messageData[3] === 0x08)
618
- {
619
- if (!isSystemXG(this.system))
620
- {
621
- return;
622
- }
623
- const channel = messageData[4] + channelOffset;
624
- if (channel >= this.midiAudioChannels.length)
625
- {
626
- // invalid channel
627
- return;
628
- }
629
- const channelObject = this.midiAudioChannels[channel];
630
- const value = messageData[6];
631
- switch (messageData[5])
632
- {
633
- // bank-select MSB
634
- case 0x01:
635
- channelObject.controllerChange(midiControllers.bankSelect, value);
636
- break;
637
-
638
- // bank-select LSB
639
- case 0x02:
640
- channelObject.controllerChange(midiControllers.lsbForControl0BankSelect, value);
641
- break;
642
-
643
- // program change
644
- case 0x03:
645
- channelObject.programChange(value);
646
- break;
647
-
648
- // note shift
649
- case 0x08:
650
- if (channelObject.drumChannel)
651
- {
652
- return;
653
- }
654
- const semitones = value - 64;
655
- channelObject.channelTransposeKeyShift = semitones;
656
- break;
657
-
658
- // volume
659
- case 0x0B:
660
- channelObject.controllerChange(midiControllers.mainVolume, value);
661
- break;
662
-
663
- // pan position
664
- case 0x0E:
665
- let pan = value;
666
- if (pan === 0)
667
- {
668
- // 0 means random
669
- channelObject.randomPan = true;
670
- SpessaSynthInfo(
671
- `%cRandom pan is set to %cON%c for %c${channel}`,
672
- consoleColors.info,
673
- consoleColors.recognized,
674
- consoleColors.info,
675
- consoleColors.value
676
- );
677
- }
678
- else
679
- {
680
- channelObject.controllerChange(midiControllers.pan, pan);
681
- }
682
- break;
683
-
684
- // reverb
685
- case 0x13:
686
- channelObject.controllerChange(midiControllers.reverbDepth, value);
687
- break;
688
-
689
- // chorus
690
- case 0x12:
691
- channelObject.controllerChange(midiControllers.chorusDepth, value);
692
- break;
693
-
694
- default:
695
- SpessaSynthWarn(
696
- `%cUnrecognized Yamaha XG Part Setup: %c${messageData[5].toString(16)
697
- .toUpperCase()}`,
698
- consoleColors.warn,
699
- consoleColors.unrecognized
700
- );
701
- }
702
- }
703
- else if (
704
- messageData[3] === 0x06 && // XG System parameter
705
- messageData[4] === 0x00 // System Byte
706
- )
707
- {
708
- // displayed letters (remove F7 at the end)
709
- // include byte 5 as it seems to be line information (useful)
710
- const textData = new Uint8Array(messageData.slice(5, messageData.length - 1));
711
- this.callEvent(
712
- "synthdisplay",
713
- {
714
- displayData: textData,
715
- displayType: SynthDisplayType.XGText
716
- }
717
- );
718
- }
719
- else if (isSystemXG(this.system))
720
- {
721
- SpessaSynthWarn(
722
- `%cUnrecognized Yamaha XG SysEx: %c${arrayToHexString(messageData)}`,
723
- consoleColors.warn,
724
- consoleColors.unrecognized
725
- );
726
- }
727
-
728
- }
729
- else
730
- {
731
- if (isSystemXG(this.system))
732
- {
733
- SpessaSynthWarn(
734
- `%cUnrecognized Yamaha SysEx: %c${arrayToHexString(messageData)}`,
735
- consoleColors.warn,
736
- consoleColors.unrecognized
737
- );
738
- }
739
- }
740
- break;
741
-
742
-
743
- }
744
- }