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.
- package/README.md +29 -114
- package/index.js +33 -33
- package/package.json +16 -6
- package/external_midi/README.md +0 -4
- package/external_midi/midi_handler.js +0 -130
- package/external_midi/web_midi_link.js +0 -43
- package/externals/fflate/LICENSE +0 -21
- package/externals/fflate/fflate.min.js +0 -1
- package/externals/stbvorbis_sync/@types/stbvorbis_sync.d.ts +0 -12
- package/externals/stbvorbis_sync/LICENSE +0 -202
- package/externals/stbvorbis_sync/NOTICE +0 -6
- package/externals/stbvorbis_sync/stbvorbis_sync.min.js +0 -1
- package/midi/README.md +0 -32
- package/midi/basic_midi.js +0 -565
- package/midi/midi_builder.js +0 -202
- package/midi/midi_data.js +0 -63
- package/midi/midi_loader.js +0 -324
- package/midi/midi_message.js +0 -254
- package/midi/midi_sequence.js +0 -225
- package/midi/midi_tools/get_note_times.js +0 -154
- package/midi/midi_tools/midi_editor.js +0 -611
- package/midi/midi_tools/midi_writer.js +0 -99
- package/midi/midi_tools/rmidi_writer.js +0 -567
- package/midi/midi_tools/used_keys_loaded.js +0 -238
- package/midi/xmf_loader.js +0 -454
- package/sequencer/README.md +0 -32
- package/sequencer/sequencer_engine/events.js +0 -207
- package/sequencer/sequencer_engine/play.js +0 -353
- package/sequencer/sequencer_engine/process_event.js +0 -169
- package/sequencer/sequencer_engine/process_tick.js +0 -106
- package/sequencer/sequencer_engine/sequencer_engine.js +0 -337
- package/sequencer/sequencer_engine/song_control.js +0 -229
- package/sequencer/worklet_wrapper/default_sequencer_options.js +0 -8
- package/sequencer/worklet_wrapper/sequencer.js +0 -807
- package/sequencer/worklet_wrapper/sequencer_message.js +0 -53
- package/soundfont/README.md +0 -13
- package/soundfont/basic_soundfont/basic_instrument.js +0 -77
- package/soundfont/basic_soundfont/basic_preset.js +0 -336
- package/soundfont/basic_soundfont/basic_sample.js +0 -197
- package/soundfont/basic_soundfont/basic_soundfont.js +0 -565
- package/soundfont/basic_soundfont/basic_zone.js +0 -64
- package/soundfont/basic_soundfont/basic_zones.js +0 -43
- package/soundfont/basic_soundfont/generator.js +0 -220
- package/soundfont/basic_soundfont/modulator.js +0 -378
- package/soundfont/basic_soundfont/riff_chunk.js +0 -149
- package/soundfont/basic_soundfont/write_dls/art2.js +0 -173
- package/soundfont/basic_soundfont/write_dls/articulator.js +0 -49
- package/soundfont/basic_soundfont/write_dls/combine_zones.js +0 -400
- package/soundfont/basic_soundfont/write_dls/ins.js +0 -103
- package/soundfont/basic_soundfont/write_dls/lins.js +0 -18
- package/soundfont/basic_soundfont/write_dls/modulator_converter.js +0 -330
- package/soundfont/basic_soundfont/write_dls/rgn2.js +0 -121
- package/soundfont/basic_soundfont/write_dls/wave.js +0 -94
- package/soundfont/basic_soundfont/write_dls/write_dls.js +0 -119
- package/soundfont/basic_soundfont/write_dls/wsmp.js +0 -78
- package/soundfont/basic_soundfont/write_dls/wvpl.js +0 -32
- package/soundfont/basic_soundfont/write_sf2/ibag.js +0 -39
- package/soundfont/basic_soundfont/write_sf2/igen.js +0 -80
- package/soundfont/basic_soundfont/write_sf2/imod.js +0 -46
- package/soundfont/basic_soundfont/write_sf2/inst.js +0 -34
- package/soundfont/basic_soundfont/write_sf2/pbag.js +0 -39
- package/soundfont/basic_soundfont/write_sf2/pgen.js +0 -82
- package/soundfont/basic_soundfont/write_sf2/phdr.js +0 -42
- package/soundfont/basic_soundfont/write_sf2/pmod.js +0 -46
- package/soundfont/basic_soundfont/write_sf2/sdta.js +0 -80
- package/soundfont/basic_soundfont/write_sf2/shdr.js +0 -55
- package/soundfont/basic_soundfont/write_sf2/write.js +0 -222
- package/soundfont/dls/articulator_converter.js +0 -396
- package/soundfont/dls/dls_destinations.js +0 -38
- package/soundfont/dls/dls_preset.js +0 -44
- package/soundfont/dls/dls_sample.js +0 -75
- package/soundfont/dls/dls_soundfont.js +0 -186
- package/soundfont/dls/dls_sources.js +0 -62
- package/soundfont/dls/dls_zone.js +0 -95
- package/soundfont/dls/read_articulation.js +0 -299
- package/soundfont/dls/read_instrument.js +0 -121
- package/soundfont/dls/read_instrument_list.js +0 -17
- package/soundfont/dls/read_lart.js +0 -35
- package/soundfont/dls/read_region.js +0 -152
- package/soundfont/dls/read_samples.js +0 -270
- package/soundfont/load_soundfont.js +0 -21
- package/soundfont/read_sf2/generators.js +0 -46
- package/soundfont/read_sf2/instruments.js +0 -66
- package/soundfont/read_sf2/modulators.js +0 -36
- package/soundfont/read_sf2/presets.js +0 -80
- package/soundfont/read_sf2/samples.js +0 -304
- package/soundfont/read_sf2/soundfont.js +0 -305
- package/soundfont/read_sf2/zones.js +0 -263
- package/synthetizer/README.md +0 -10
- package/synthetizer/audio_effects/effects_config.js +0 -25
- package/synthetizer/audio_effects/fancy_chorus.js +0 -162
- package/synthetizer/audio_effects/rb_compressed.min.js +0 -1
- package/synthetizer/audio_effects/reverb.js +0 -35
- package/synthetizer/audio_effects/reverb_as_binary.js +0 -18
- package/synthetizer/audio_engine/README.md +0 -25
- package/synthetizer/audio_engine/engine_components/compute_modulator.js +0 -266
- package/synthetizer/audio_engine/engine_components/controller_tables.js +0 -88
- package/synthetizer/audio_engine/engine_components/key_modifier_manager.js +0 -149
- package/synthetizer/audio_engine/engine_components/lfo.js +0 -26
- package/synthetizer/audio_engine/engine_components/lowpass_filter.js +0 -282
- package/synthetizer/audio_engine/engine_components/midi_audio_channel.js +0 -471
- package/synthetizer/audio_engine/engine_components/modulation_envelope.js +0 -181
- package/synthetizer/audio_engine/engine_components/modulator_curves.js +0 -89
- package/synthetizer/audio_engine/engine_components/soundfont_manager/sfman_message.js +0 -9
- package/synthetizer/audio_engine/engine_components/soundfont_manager/soundfont_manager.js +0 -254
- package/synthetizer/audio_engine/engine_components/stereo_panner.js +0 -120
- package/synthetizer/audio_engine/engine_components/unit_converter.js +0 -73
- package/synthetizer/audio_engine/engine_components/voice.js +0 -519
- package/synthetizer/audio_engine/engine_components/volume_envelope.js +0 -401
- package/synthetizer/audio_engine/engine_components/wavetable_oscillator.js +0 -263
- package/synthetizer/audio_engine/engine_methods/controller_control/controller_change.js +0 -132
- package/synthetizer/audio_engine/engine_methods/controller_control/master_parameters.js +0 -48
- package/synthetizer/audio_engine/engine_methods/controller_control/reset_controllers.js +0 -241
- package/synthetizer/audio_engine/engine_methods/create_midi_channel.js +0 -27
- package/synthetizer/audio_engine/engine_methods/data_entry/data_entry_coarse.js +0 -253
- package/synthetizer/audio_engine/engine_methods/data_entry/data_entry_fine.js +0 -66
- package/synthetizer/audio_engine/engine_methods/mute_channel.js +0 -17
- package/synthetizer/audio_engine/engine_methods/note_on.js +0 -174
- package/synthetizer/audio_engine/engine_methods/portamento_time.js +0 -92
- package/synthetizer/audio_engine/engine_methods/program_change.js +0 -61
- package/synthetizer/audio_engine/engine_methods/render_voice.js +0 -196
- package/synthetizer/audio_engine/engine_methods/soundfont_management/clear_sound_font.js +0 -30
- package/synthetizer/audio_engine/engine_methods/soundfont_management/get_preset.js +0 -22
- package/synthetizer/audio_engine/engine_methods/soundfont_management/reload_sound_font.js +0 -40
- package/synthetizer/audio_engine/engine_methods/soundfont_management/send_preset_list.js +0 -34
- package/synthetizer/audio_engine/engine_methods/soundfont_management/set_embedded_sound_font.js +0 -21
- package/synthetizer/audio_engine/engine_methods/stopping_notes/kill_note.js +0 -20
- package/synthetizer/audio_engine/engine_methods/stopping_notes/note_off.js +0 -55
- package/synthetizer/audio_engine/engine_methods/stopping_notes/stop_all_channels.js +0 -16
- package/synthetizer/audio_engine/engine_methods/stopping_notes/stop_all_notes.js +0 -30
- package/synthetizer/audio_engine/engine_methods/stopping_notes/voice_killing.js +0 -63
- package/synthetizer/audio_engine/engine_methods/system_exclusive.js +0 -744
- package/synthetizer/audio_engine/engine_methods/tuning_control/channel_pressure.js +0 -24
- package/synthetizer/audio_engine/engine_methods/tuning_control/pitch_wheel.js +0 -33
- package/synthetizer/audio_engine/engine_methods/tuning_control/poly_pressure.js +0 -31
- package/synthetizer/audio_engine/engine_methods/tuning_control/set_master_tuning.js +0 -15
- package/synthetizer/audio_engine/engine_methods/tuning_control/set_modulation_depth.js +0 -27
- package/synthetizer/audio_engine/engine_methods/tuning_control/set_octave_tuning.js +0 -19
- package/synthetizer/audio_engine/engine_methods/tuning_control/set_tuning.js +0 -27
- package/synthetizer/audio_engine/engine_methods/tuning_control/transpose_all_channels.js +0 -15
- package/synthetizer/audio_engine/engine_methods/tuning_control/transpose_channel.js +0 -34
- package/synthetizer/audio_engine/main_processor.js +0 -765
- package/synthetizer/audio_engine/message_protocol/README.md +0 -13
- package/synthetizer/audio_engine/message_protocol/message_sending.js +0 -22
- package/synthetizer/audio_engine/message_protocol/worklet_message.js +0 -107
- package/synthetizer/audio_engine/snapshot/apply_synthesizer_snapshot.js +0 -14
- package/synthetizer/audio_engine/snapshot/channel_snapshot.js +0 -175
- package/synthetizer/audio_engine/snapshot/synthesizer_snapshot.js +0 -122
- package/synthetizer/synth_constants.js +0 -20
- package/synthetizer/worklet_processor.min.js +0 -21
- package/synthetizer/worklet_wrapper/key_modifier_manager.js +0 -104
- package/synthetizer/worklet_wrapper/synth_event_handler.js +0 -214
- package/synthetizer/worklet_wrapper/synth_soundfont_manager.js +0 -111
- package/synthetizer/worklet_wrapper/synthetizer.js +0 -1027
- package/synthetizer/worklet_wrapper/worklet_processor.js +0 -340
- package/synthetizer/worklet_wrapper/worklet_url.js +0 -16
- package/utils/README.md +0 -5
- package/utils/buffer_to_wav.js +0 -186
- package/utils/byte_functions/big_endian.js +0 -32
- package/utils/byte_functions/little_endian.js +0 -77
- package/utils/byte_functions/string.js +0 -107
- package/utils/byte_functions/variable_length_quantity.js +0 -42
- package/utils/fill_with_defaults.js +0 -21
- package/utils/indexed_array.js +0 -52
- package/utils/loggin.js +0 -79
- package/utils/other.js +0 -92
- package/utils/sysex_detector.js +0 -58
- package/utils/xg_hacks.js +0 -193
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
# About the message protocol
|
|
2
|
-
Since spessasynth runs in the audioWorklet thread, here is an explanation of how it works:
|
|
3
|
-
|
|
4
|
-
There's one processor per synthesizer, with a `MessagePort` for communication.
|
|
5
|
-
Each processor has a single `WorkletSequencer` instance that is idle by default.
|
|
6
|
-
|
|
7
|
-
The `Synthetizer`,
|
|
8
|
-
`Sequencer` and `SoundFontManager` classes are all interfaces
|
|
9
|
-
that do not do anything except sending the commands to te processor.
|
|
10
|
-
|
|
11
|
-
The synthesizer sends the commands (note on, off, etc.) directly to the processor where they are processed and executed.
|
|
12
|
-
|
|
13
|
-
The sequencer sends the commands through the connected synthesizer's messagePort, which then get processed as sequencer messages and routed
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { returnMessageType } from "./worklet_message.js";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Calls synth event from the worklet side
|
|
5
|
-
* @param eventName {EventTypes} the event name
|
|
6
|
-
* @param eventData {EventCallbackData}
|
|
7
|
-
* @this {SpessaSynthProcessor}
|
|
8
|
-
*/
|
|
9
|
-
export function callEvent(eventName, eventData)
|
|
10
|
-
{
|
|
11
|
-
if (!this.enableEventSystem)
|
|
12
|
-
{
|
|
13
|
-
return;
|
|
14
|
-
}
|
|
15
|
-
this.post({
|
|
16
|
-
messageType: returnMessageType.eventCall,
|
|
17
|
-
messageData: {
|
|
18
|
-
eventName: eventName,
|
|
19
|
-
eventData: eventData
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
}
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @enum {number}
|
|
3
|
-
* // NOTE: Every message needs a channel number (if not relevant or all, set to -1)
|
|
4
|
-
* @property {number} midiMessage - 0 -> [messageData<Uint8Array>, channelOffset<number>, force<boolean>, options<SynthMethodOptions>]
|
|
5
|
-
* @property {number} ccReset - 7 -> (no data) note: if channel is -1 then reset all channels
|
|
6
|
-
* @property {number} setChannelVibrato - 8 -> {frequencyHz: number, depthCents: number, delaySeconds: number} note: if channel is -1 then stop all channels note 2: if rate is -1, it means locking
|
|
7
|
-
* @property {number} soundFontManager - 9 -> [messageType<WorkletSoundfontManagerMessageType> messageData<any>] note: refer to sfman_message.js
|
|
8
|
-
* @property {number} stopAll - 10 -> force<number> (0 false, 1 true) note: if channel is -1 then stop all channels
|
|
9
|
-
* @property {number} killNotes - 11 -> amount<number>
|
|
10
|
-
* @property {number} muteChannel - 12 -> isMuted<boolean>
|
|
11
|
-
* @property {number} addNewChannel - 13 -> (no data)
|
|
12
|
-
* @property {number} customCcChange - 14 -> [ccNumber<number>, ccValue<number>]
|
|
13
|
-
* @property {number} debugMessage - 15 -> (no data)
|
|
14
|
-
* @property {number} setMasterParameter - 17 -> [parameter<masterParameterType>, value<number>]
|
|
15
|
-
* @property {number} setDrums - 18 -> isDrums<boolean>
|
|
16
|
-
* @property {number} transpose - 19 -> [semitones<number>, force<boolean>] note: if channel is -1 then transpose all channels
|
|
17
|
-
* @property {number} highPerformanceMode - 20 -> isOn<boolean>
|
|
18
|
-
* @property {number} lockController - 21 -> [controllerNumber<number>, isLocked<boolean>]
|
|
19
|
-
* @property {number} sequencerSpecific - 22 -> [messageType<SpessaSynthSequencerMessageType> messageData<any>] note: refer to sequencer_message.js
|
|
20
|
-
* @property {number} requestSynthesizerSnapshot - 23 -> (no data)
|
|
21
|
-
* @property {number} setLogLevel - 24 -> [enableInfo<boolean>, enableWarning<boolean>, enableGroup<boolean>, enableTable<boolean>]
|
|
22
|
-
* @property {number} keyModifier - 25 -> [messageType<workletKeyModifierMessageType> messageData<any>]
|
|
23
|
-
* @property {number} setEffectsGain - 26 -> [reverbGain<number>, chorusGain<number>]
|
|
24
|
-
* @property {number} destroyWorklet - 27 -> (no data)
|
|
25
|
-
*/
|
|
26
|
-
export const workletMessageType = {
|
|
27
|
-
midiMessage: 0,
|
|
28
|
-
// free 6 slots here, use when needed instead of adding new ones
|
|
29
|
-
ccReset: 7,
|
|
30
|
-
setChannelVibrato: 8,
|
|
31
|
-
soundFontManager: 9,
|
|
32
|
-
stopAll: 10,
|
|
33
|
-
killNotes: 11,
|
|
34
|
-
muteChannel: 12,
|
|
35
|
-
addNewChannel: 13,
|
|
36
|
-
customcCcChange: 14,
|
|
37
|
-
debugMessage: 15,
|
|
38
|
-
// free slot here
|
|
39
|
-
setMasterParameter: 17,
|
|
40
|
-
setDrums: 18,
|
|
41
|
-
transpose: 19,
|
|
42
|
-
highPerformanceMode: 20,
|
|
43
|
-
lockController: 21,
|
|
44
|
-
sequencerSpecific: 22,
|
|
45
|
-
requestSynthesizerSnapshot: 23,
|
|
46
|
-
setLogLevel: 24,
|
|
47
|
-
keyModifierManager: 25,
|
|
48
|
-
setEffectsGain: 26,
|
|
49
|
-
destroyWorklet: 27
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
export const ALL_CHANNELS_OR_DIFFERENT_ACTION = -1;
|
|
54
|
-
/**
|
|
55
|
-
* @typedef {{
|
|
56
|
-
* channelNumber: number
|
|
57
|
-
* messageType: (workletMessageType|number),
|
|
58
|
-
* messageData: (
|
|
59
|
-
* boolean|
|
|
60
|
-
* (number|Uint8Array|object)[]
|
|
61
|
-
* |undefined
|
|
62
|
-
* |boolean[]
|
|
63
|
-
* |boolean
|
|
64
|
-
* |Voice[]
|
|
65
|
-
* |number
|
|
66
|
-
* |{rate: number, depth: number, delay: number}
|
|
67
|
-
* |ArrayBuffer
|
|
68
|
-
* |{messageType: SpessaSynthSequencerMessageType, messageData: any}
|
|
69
|
-
* |{messageType: workletKeyModifierMessageType, messageData: any}
|
|
70
|
-
* )
|
|
71
|
-
* }} WorkletMessage
|
|
72
|
-
*/
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* @typedef {Object} WorkletReturnMessage
|
|
76
|
-
* @property {returnMessageType} messageType - the message's type
|
|
77
|
-
* @property {{
|
|
78
|
-
* eventName: string,
|
|
79
|
-
* eventData: any
|
|
80
|
-
* }|ChannelProperty
|
|
81
|
-
* |{presetName: string, bank: number, program: number}[]
|
|
82
|
-
* |string
|
|
83
|
-
* |{messageType: SpessaSynthSequencerReturnMessageType, messageData: any}
|
|
84
|
-
* |SynthesizerSnapshot
|
|
85
|
-
* |[WorkletSoundfontManagerMessageType, any]} messageData - the message's data
|
|
86
|
-
*
|
|
87
|
-
* 0 - channel property change -> [channel<number>, property<ChannelProperty>] see message_sending.js line 29
|
|
88
|
-
* 1 - event call -> {eventName<string>, eventData:<the event's data>}
|
|
89
|
-
* 2 - master parameter change -> [parameter<masterParameterType>, value<string|number>]
|
|
90
|
-
* 3 - sequencer specific -> [messageType<SpessaSynthSequencerReturnMessageType> messageData<any>] note: refer to sequencer_message.js
|
|
91
|
-
* 4 - synthesizer snapshot -> snapshot<SynthesizerSnapshot> note: refer to synthesizer_snapshot.js
|
|
92
|
-
* 5 - isFullyInitialized -> (no data)
|
|
93
|
-
* 6 - soundfontError -> errorMessage<string>
|
|
94
|
-
*/
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* @enum {number}
|
|
98
|
-
*/
|
|
99
|
-
export const returnMessageType = {
|
|
100
|
-
channelPropertyChange: 0,
|
|
101
|
-
eventCall: 1,
|
|
102
|
-
masterParameterChange: 2,
|
|
103
|
-
sequencerSpecific: 3,
|
|
104
|
-
synthesizerSnapshot: 4,
|
|
105
|
-
isFullyInitialized: 5,
|
|
106
|
-
soundfontError: 6
|
|
107
|
-
};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { SpessaSynthInfo } from "../../../utils/loggin.js";
|
|
2
|
-
import { consoleColors } from "../../../utils/other.js";
|
|
3
|
-
import { SynthesizerSnapshot } from "./synthesizer_snapshot.js";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Applies the snapshot to the synth
|
|
7
|
-
* @param snapshot {SynthesizerSnapshot}
|
|
8
|
-
* @this {SpessaSynthProcessor}
|
|
9
|
-
*/
|
|
10
|
-
export function applySynthesizerSnapshot(snapshot)
|
|
11
|
-
{
|
|
12
|
-
SynthesizerSnapshot.applySnapshot(this, snapshot);
|
|
13
|
-
SpessaSynthInfo("%cFinished applying snapshot!", consoleColors.info);
|
|
14
|
-
}
|
|
@@ -1,175 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Represents a snapshot of a single channel's state in the synthesizer.
|
|
3
|
-
*/
|
|
4
|
-
export class ChannelSnapshot
|
|
5
|
-
{
|
|
6
|
-
/**
|
|
7
|
-
* The channel's MIDI program number.
|
|
8
|
-
* @type {number}
|
|
9
|
-
*/
|
|
10
|
-
program;
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* The channel's bank number.
|
|
14
|
-
* @type {number}
|
|
15
|
-
*/
|
|
16
|
-
bank;
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* If the bank is LSB. For restoring.
|
|
20
|
-
* @type {boolean}
|
|
21
|
-
*/
|
|
22
|
-
isBankLSB;
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* The name of the patch currently loaded in the channel.
|
|
26
|
-
* @type {string}
|
|
27
|
-
*/
|
|
28
|
-
patchName;
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Indicates whether the channel's program change is disabled.
|
|
32
|
-
* @type {boolean}
|
|
33
|
-
*/
|
|
34
|
-
lockPreset;
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Indicates the MIDI system when the preset was locked
|
|
38
|
-
* @type {SynthSystem}
|
|
39
|
-
*/
|
|
40
|
-
lockedSystem;
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* The array of all MIDI controllers (in 14-bit values) with the modulator sources at the end.
|
|
44
|
-
* @type {Int16Array}
|
|
45
|
-
*/
|
|
46
|
-
midiControllers;
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* An array of booleans, indicating if the controller with a current index is locked.
|
|
50
|
-
* @type {boolean[]}
|
|
51
|
-
*/
|
|
52
|
-
lockedControllers;
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Array of custom (not SF2) control values such as RPN pitch tuning, transpose, modulation depth, etc.
|
|
56
|
-
* @type {Float32Array}
|
|
57
|
-
*/
|
|
58
|
-
customControllers;
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Indicates whether the channel vibrato is locked.
|
|
62
|
-
* @type {boolean}
|
|
63
|
-
*/
|
|
64
|
-
lockVibrato;
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* The channel's vibrato settings.
|
|
68
|
-
* @type {Object}
|
|
69
|
-
* @property {number} depth - Vibrato depth, in gain.
|
|
70
|
-
* @property {number} delay - Vibrato delay from note on in seconds.
|
|
71
|
-
* @property {number} rate - Vibrato rate in Hz.
|
|
72
|
-
*/
|
|
73
|
-
channelVibrato;
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* Key shift for the channel.
|
|
77
|
-
* @type {number}
|
|
78
|
-
*/
|
|
79
|
-
channelTransposeKeyShift;
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* The channel's octave tuning in cents.
|
|
83
|
-
* @type {Int8Array}
|
|
84
|
-
*/
|
|
85
|
-
channelOctaveTuning;
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* Indicates whether the channel is muted.
|
|
89
|
-
* @type {boolean}
|
|
90
|
-
*/
|
|
91
|
-
isMuted;
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* Overrides velocity if greater than 0, otherwise disabled.
|
|
95
|
-
* @type {number}
|
|
96
|
-
*/
|
|
97
|
-
velocityOverride;
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* Indicates whether the channel is a drum channel.
|
|
101
|
-
* @type {boolean}
|
|
102
|
-
*/
|
|
103
|
-
drumChannel;
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* Creates a snapshot of a single channel's state in the synthesizer.
|
|
107
|
-
* @param workletProcessor {SpessaSynthProcessor}
|
|
108
|
-
* @param channelNumber {number}
|
|
109
|
-
* @returns {ChannelSnapshot}
|
|
110
|
-
*/
|
|
111
|
-
static getChannelSnapshot(workletProcessor, channelNumber)
|
|
112
|
-
{
|
|
113
|
-
const channelObject = workletProcessor.midiAudioChannels[channelNumber];
|
|
114
|
-
const channelSnapshot = new ChannelSnapshot();
|
|
115
|
-
// program data
|
|
116
|
-
channelSnapshot.program = channelObject.preset.program;
|
|
117
|
-
channelSnapshot.bank = channelObject.getBankSelect();
|
|
118
|
-
channelSnapshot.isBankLSB = channelSnapshot.bank !== channelObject.bank;
|
|
119
|
-
channelSnapshot.lockPreset = channelObject.lockPreset;
|
|
120
|
-
channelSnapshot.lockedSystem = channelObject.lockedSystem;
|
|
121
|
-
channelSnapshot.patchName = channelObject.preset.presetName;
|
|
122
|
-
|
|
123
|
-
// controller data
|
|
124
|
-
channelSnapshot.midiControllers = channelObject.midiControllers;
|
|
125
|
-
channelSnapshot.lockedControllers = channelObject.lockedControllers;
|
|
126
|
-
channelSnapshot.customControllers = channelObject.customControllers;
|
|
127
|
-
|
|
128
|
-
// vibrato data
|
|
129
|
-
channelSnapshot.channelVibrato = channelObject.channelVibrato;
|
|
130
|
-
channelSnapshot.lockVibrato = channelObject.lockGSNRPNParams;
|
|
131
|
-
|
|
132
|
-
// tuning and transpose data
|
|
133
|
-
channelSnapshot.channelTransposeKeyShift = channelObject.channelTransposeKeyShift;
|
|
134
|
-
channelSnapshot.channelOctaveTuning = channelObject.channelOctaveTuning;
|
|
135
|
-
|
|
136
|
-
// other data
|
|
137
|
-
channelSnapshot.isMuted = channelObject.isMuted;
|
|
138
|
-
channelSnapshot.velocityOverride = channelObject.velocityOverride;
|
|
139
|
-
channelSnapshot.drumChannel = channelObject.drumChannel;
|
|
140
|
-
return channelSnapshot;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
/**
|
|
144
|
-
* Applies the snapshot to the specified channel.
|
|
145
|
-
* @param workletProcessor {SpessaSynthProcessor}
|
|
146
|
-
* @param channelNumber {number}
|
|
147
|
-
* @param channelSnapshot {ChannelSnapshot}
|
|
148
|
-
*/
|
|
149
|
-
static applyChannelSnapshot(workletProcessor, channelNumber, channelSnapshot)
|
|
150
|
-
{
|
|
151
|
-
const channelObject = workletProcessor.midiAudioChannels[channelNumber];
|
|
152
|
-
channelObject.muteChannel(channelSnapshot.isMuted);
|
|
153
|
-
channelObject.setDrums(channelSnapshot.drumChannel);
|
|
154
|
-
|
|
155
|
-
// restore controllers
|
|
156
|
-
channelObject.midiControllers = channelSnapshot.midiControllers;
|
|
157
|
-
channelObject.lockedControllers = channelSnapshot.lockedControllers;
|
|
158
|
-
channelObject.customControllers = channelSnapshot.customControllers;
|
|
159
|
-
channelObject.updateChannelTuning();
|
|
160
|
-
|
|
161
|
-
// restore vibrato and transpose
|
|
162
|
-
channelObject.channelVibrato = channelSnapshot.channelVibrato;
|
|
163
|
-
channelObject.lockGSNRPNParams = channelSnapshot.lockVibrato;
|
|
164
|
-
channelObject.channelTransposeKeyShift = channelSnapshot.channelTransposeKeyShift;
|
|
165
|
-
channelObject.channelOctaveTuning = channelSnapshot.channelOctaveTuning;
|
|
166
|
-
channelObject.velocityOverride = channelSnapshot.velocityOverride;
|
|
167
|
-
|
|
168
|
-
// restore preset and lock
|
|
169
|
-
channelObject.setPresetLock(false);
|
|
170
|
-
channelObject.setBankSelect(channelSnapshot.bank, channelSnapshot.isBankLSB);
|
|
171
|
-
channelObject.programChange(channelSnapshot.program);
|
|
172
|
-
channelObject.setPresetLock(channelSnapshot.lockPreset);
|
|
173
|
-
channelObject.lockedSystem = channelSnapshot.lockedSystem;
|
|
174
|
-
}
|
|
175
|
-
}
|
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
import { SpessaSynthInfo } from "../../../utils/loggin.js";
|
|
2
|
-
import { consoleColors } from "../../../utils/other.js";
|
|
3
|
-
import { ChannelSnapshot } from "./channel_snapshot.js";
|
|
4
|
-
import { masterParameterType } from "../engine_methods/controller_control/master_parameters.js";
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Represents a snapshot of the synthesizer's state.
|
|
8
|
-
*/
|
|
9
|
-
export class SynthesizerSnapshot
|
|
10
|
-
{
|
|
11
|
-
/**
|
|
12
|
-
* The individual channel snapshots.
|
|
13
|
-
* @type {ChannelSnapshot[]}
|
|
14
|
-
*/
|
|
15
|
-
channelSnapshots;
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Key modifiers.
|
|
19
|
-
* @type {KeyModifier[][]}
|
|
20
|
-
*/
|
|
21
|
-
keyMappings;
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Main synth volume (set by MIDI), from 0 to 1.
|
|
25
|
-
* @type {number}
|
|
26
|
-
*/
|
|
27
|
-
mainVolume;
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Master stereo panning, from -1 to 1.
|
|
31
|
-
* @type {number}
|
|
32
|
-
*/
|
|
33
|
-
pan;
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* The synth's interpolation type.
|
|
37
|
-
* @type {interpolationTypes}
|
|
38
|
-
*/
|
|
39
|
-
interpolation;
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* The synth's system. Values can be "gs", "gm", "gm2" or "xg".
|
|
43
|
-
* @type {SynthSystem}
|
|
44
|
-
*/
|
|
45
|
-
system;
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* The current synth transposition in semitones. Can be a float.
|
|
49
|
-
* @type {number}
|
|
50
|
-
*/
|
|
51
|
-
transposition;
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* The effect configuration object.
|
|
55
|
-
* @type {SynthConfig}
|
|
56
|
-
*/
|
|
57
|
-
effectsConfig;
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Creates a snapshot of the synthesizer's state.
|
|
62
|
-
* @param workletProcessor {SpessaSynthProcessor}
|
|
63
|
-
* @returns {SynthesizerSnapshot}
|
|
64
|
-
*/
|
|
65
|
-
static createSynthesizerSnapshot(workletProcessor)
|
|
66
|
-
{
|
|
67
|
-
const snapshot = new SynthesizerSnapshot();
|
|
68
|
-
// channel snapshots
|
|
69
|
-
snapshot.channelSnapshots =
|
|
70
|
-
workletProcessor.midiAudioChannels.map((_, i) =>
|
|
71
|
-
ChannelSnapshot.getChannelSnapshot(workletProcessor, i));
|
|
72
|
-
|
|
73
|
-
// key mappings
|
|
74
|
-
snapshot.keyMappings = workletProcessor.keyModifierManager.getMappings();
|
|
75
|
-
// pan and volume
|
|
76
|
-
snapshot.mainVolume = workletProcessor.midiVolume;
|
|
77
|
-
snapshot.pan = workletProcessor.pan;
|
|
78
|
-
|
|
79
|
-
// others
|
|
80
|
-
snapshot.system = workletProcessor.system;
|
|
81
|
-
snapshot.interpolation = workletProcessor.interpolationType;
|
|
82
|
-
snapshot.transposition = workletProcessor.transposition;
|
|
83
|
-
|
|
84
|
-
// effect config is stored on the main thread, leave it empty
|
|
85
|
-
snapshot.effectsConfig = {};
|
|
86
|
-
return snapshot;
|
|
87
|
-
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* Applies the snapshot to the synthesizer.
|
|
92
|
-
* @param workletProcessor {SpessaSynthProcessor}
|
|
93
|
-
* @param snapshot {SynthesizerSnapshot}
|
|
94
|
-
*/
|
|
95
|
-
static applySnapshot(workletProcessor, snapshot)
|
|
96
|
-
{
|
|
97
|
-
// restore system
|
|
98
|
-
workletProcessor.setSystem(snapshot.system);
|
|
99
|
-
|
|
100
|
-
// restore pan and volume
|
|
101
|
-
workletProcessor.setMasterParameter(masterParameterType.mainVolume, snapshot.mainVolume);
|
|
102
|
-
workletProcessor.setMasterParameter(masterParameterType.masterPan, snapshot.pan);
|
|
103
|
-
workletProcessor.transposeAllChannels(snapshot.transposition);
|
|
104
|
-
workletProcessor.interpolationType = snapshot.interpolation;
|
|
105
|
-
workletProcessor.keyModifierManager.setMappings(snapshot.keyMappings);
|
|
106
|
-
|
|
107
|
-
// add channels if more needed
|
|
108
|
-
while (workletProcessor.midiAudioChannels.length < snapshot.channelSnapshots.length)
|
|
109
|
-
{
|
|
110
|
-
workletProcessor.createWorkletChannel();
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
// restore channels
|
|
114
|
-
snapshot.channelSnapshots.forEach((channelSnapshot, index) =>
|
|
115
|
-
{
|
|
116
|
-
ChannelSnapshot.applyChannelSnapshot(workletProcessor, index, channelSnapshot);
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
SpessaSynthInfo("%cFinished restoring controllers!", consoleColors.info);
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Synthesizer's default voice cap
|
|
3
|
-
* @type {number}
|
|
4
|
-
*/
|
|
5
|
-
export const VOICE_CAP = 350;
|
|
6
|
-
/**
|
|
7
|
-
* Default MIDI drum channel
|
|
8
|
-
* @type {number}
|
|
9
|
-
*/
|
|
10
|
-
export const DEFAULT_PERCUSSION = 9;
|
|
11
|
-
/**
|
|
12
|
-
* MIDI channel count
|
|
13
|
-
* @type {number}
|
|
14
|
-
*/
|
|
15
|
-
export const MIDI_CHANNEL_COUNT = 16;
|
|
16
|
-
/**
|
|
17
|
-
* Default bank select and SysEx mode
|
|
18
|
-
* @type {string}
|
|
19
|
-
*/
|
|
20
|
-
export const DEFAULT_SYNTH_MODE = "gs";
|