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,263 +0,0 @@
|
|
|
1
|
-
import { readLittleEndian } from "../../utils/byte_functions/little_endian.js";
|
|
2
|
-
import { IndexedByteArray } from "../../utils/indexed_array.js";
|
|
3
|
-
import { RiffChunk } from "../basic_soundfont/riff_chunk.js";
|
|
4
|
-
import { BasicInstrumentZone, BasicPresetZone } from "../basic_soundfont/basic_zones.js";
|
|
5
|
-
import { Generator, generatorTypes } from "../basic_soundfont/generator.js";
|
|
6
|
-
import { Modulator } from "../basic_soundfont/modulator.js";
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* zones.js
|
|
10
|
-
* purpose: reads instrumend and preset zones from soundfont and gets their respective samples and generators and modulators
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
export class InstrumentZone extends BasicInstrumentZone
|
|
14
|
-
{
|
|
15
|
-
/**
|
|
16
|
-
* Creates a zone (instrument)
|
|
17
|
-
* @param dataArray {IndexedByteArray}
|
|
18
|
-
*/
|
|
19
|
-
constructor(dataArray)
|
|
20
|
-
{
|
|
21
|
-
super();
|
|
22
|
-
this.generatorZoneStartIndex = readLittleEndian(dataArray, 2);
|
|
23
|
-
this.modulatorZoneStartIndex = readLittleEndian(dataArray, 2);
|
|
24
|
-
this.modulatorZoneSize = 0;
|
|
25
|
-
this.generatorZoneSize = 0;
|
|
26
|
-
this.isGlobal = true;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
setZoneSize(modulatorZoneSize, generatorZoneSize)
|
|
30
|
-
{
|
|
31
|
-
this.modulatorZoneSize = modulatorZoneSize;
|
|
32
|
-
this.generatorZoneSize = generatorZoneSize;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* grab the generators
|
|
37
|
-
* @param generators {Generator[]}
|
|
38
|
-
*/
|
|
39
|
-
getGenerators(generators)
|
|
40
|
-
{
|
|
41
|
-
for (let i = this.generatorZoneStartIndex; i < this.generatorZoneStartIndex + this.generatorZoneSize; i++)
|
|
42
|
-
{
|
|
43
|
-
this.generators.push(generators[i]);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* grab the modulators
|
|
49
|
-
* @param modulators {Modulator[]}
|
|
50
|
-
*/
|
|
51
|
-
getModulators(modulators)
|
|
52
|
-
{
|
|
53
|
-
for (let i = this.modulatorZoneStartIndex; i < this.modulatorZoneStartIndex + this.modulatorZoneSize; i++)
|
|
54
|
-
{
|
|
55
|
-
this.modulators.push(modulators[i]);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Loads the zone's sample
|
|
61
|
-
* @param samples {BasicSample[]}
|
|
62
|
-
*/
|
|
63
|
-
getSample(samples)
|
|
64
|
-
{
|
|
65
|
-
let sampleID = this.generators.find(g => g.generatorType === generatorTypes.sampleID);
|
|
66
|
-
if (sampleID)
|
|
67
|
-
{
|
|
68
|
-
this.sample = samples[sampleID.generatorValue];
|
|
69
|
-
this.isGlobal = false;
|
|
70
|
-
this.sample.useCount++;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Reads the keyRange of the zone
|
|
76
|
-
*/
|
|
77
|
-
getKeyRange()
|
|
78
|
-
{
|
|
79
|
-
let range = this.generators.find(g => g.generatorType === generatorTypes.keyRange);
|
|
80
|
-
if (range)
|
|
81
|
-
{
|
|
82
|
-
this.keyRange.min = range.generatorValue & 0x7F;
|
|
83
|
-
this.keyRange.max = (range.generatorValue >> 8) & 0x7F;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* reads the velolicty range of the zone
|
|
89
|
-
*/
|
|
90
|
-
getVelRange()
|
|
91
|
-
{
|
|
92
|
-
let range = this.generators.find(g => g.generatorType === generatorTypes.velRange);
|
|
93
|
-
if (range)
|
|
94
|
-
{
|
|
95
|
-
this.velRange.min = range.generatorValue & 0x7F;
|
|
96
|
-
this.velRange.max = (range.generatorValue >> 8) & 0x7F;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* Reads the given instrument zone read
|
|
103
|
-
* @param zonesChunk {RiffChunk}
|
|
104
|
-
* @param instrumentGenerators {Generator[]}
|
|
105
|
-
* @param instrumentModulators {Modulator[]}
|
|
106
|
-
* @param instrumentSamples {BasicSample[]}
|
|
107
|
-
* @returns {InstrumentZone[]}
|
|
108
|
-
*/
|
|
109
|
-
export function readInstrumentZones(zonesChunk, instrumentGenerators, instrumentModulators, instrumentSamples)
|
|
110
|
-
{
|
|
111
|
-
/**
|
|
112
|
-
* @type {InstrumentZone[]}
|
|
113
|
-
*/
|
|
114
|
-
let zones = [];
|
|
115
|
-
while (zonesChunk.chunkData.length > zonesChunk.chunkData.currentIndex)
|
|
116
|
-
{
|
|
117
|
-
let zone = new InstrumentZone(zonesChunk.chunkData);
|
|
118
|
-
if (zones.length > 0)
|
|
119
|
-
{
|
|
120
|
-
let modulatorZoneSize = zone.modulatorZoneStartIndex - zones[zones.length - 1].modulatorZoneStartIndex;
|
|
121
|
-
let generatorZoneSize = zone.generatorZoneStartIndex - zones[zones.length - 1].generatorZoneStartIndex;
|
|
122
|
-
zones[zones.length - 1].setZoneSize(modulatorZoneSize, generatorZoneSize);
|
|
123
|
-
zones[zones.length - 1].getGenerators(instrumentGenerators);
|
|
124
|
-
zones[zones.length - 1].getModulators(instrumentModulators);
|
|
125
|
-
zones[zones.length - 1].getSample(instrumentSamples);
|
|
126
|
-
zones[zones.length - 1].getKeyRange();
|
|
127
|
-
zones[zones.length - 1].getVelRange();
|
|
128
|
-
}
|
|
129
|
-
zones.push(zone);
|
|
130
|
-
}
|
|
131
|
-
if (zones.length > 1)
|
|
132
|
-
{
|
|
133
|
-
// remove terminal
|
|
134
|
-
zones.pop();
|
|
135
|
-
}
|
|
136
|
-
return zones;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
export class PresetZone extends BasicPresetZone
|
|
140
|
-
{
|
|
141
|
-
/**
|
|
142
|
-
* Creates a zone (preset)
|
|
143
|
-
* @param dataArray {IndexedByteArray}
|
|
144
|
-
*/
|
|
145
|
-
constructor(dataArray)
|
|
146
|
-
{
|
|
147
|
-
super();
|
|
148
|
-
this.generatorZoneStartIndex = readLittleEndian(dataArray, 2);
|
|
149
|
-
this.modulatorZoneStartIndex = readLittleEndian(dataArray, 2);
|
|
150
|
-
this.modulatorZoneSize = 0;
|
|
151
|
-
this.generatorZoneSize = 0;
|
|
152
|
-
this.isGlobal = true;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
setZoneSize(modulatorZoneSize, generatorZoneSize)
|
|
156
|
-
{
|
|
157
|
-
this.modulatorZoneSize = modulatorZoneSize;
|
|
158
|
-
this.generatorZoneSize = generatorZoneSize;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
/**
|
|
162
|
-
* grab the generators
|
|
163
|
-
* @param generators {Generator[]}
|
|
164
|
-
*/
|
|
165
|
-
getGenerators(generators)
|
|
166
|
-
{
|
|
167
|
-
for (let i = this.generatorZoneStartIndex; i < this.generatorZoneStartIndex + this.generatorZoneSize; i++)
|
|
168
|
-
{
|
|
169
|
-
this.generators.push(generators[i]);
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
/**
|
|
174
|
-
* grab the modulators
|
|
175
|
-
* @param modulators {Modulator[]}
|
|
176
|
-
*/
|
|
177
|
-
getModulators(modulators)
|
|
178
|
-
{
|
|
179
|
-
for (let i = this.modulatorZoneStartIndex; i < this.modulatorZoneStartIndex + this.modulatorZoneSize; i++)
|
|
180
|
-
{
|
|
181
|
-
this.modulators.push(modulators[i]);
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
/**
|
|
186
|
-
* grab the instrument
|
|
187
|
-
* @param instruments {BasicInstrument[]}
|
|
188
|
-
*/
|
|
189
|
-
getInstrument(instruments)
|
|
190
|
-
{
|
|
191
|
-
let instrumentID = this.generators.find(g => g.generatorType === generatorTypes.instrument);
|
|
192
|
-
if (instrumentID)
|
|
193
|
-
{
|
|
194
|
-
this.instrument = instruments[instrumentID.generatorValue];
|
|
195
|
-
this.instrument.addUseCount();
|
|
196
|
-
this.isGlobal = false;
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
/**
|
|
201
|
-
* Reads the keyRange of the zone
|
|
202
|
-
*/
|
|
203
|
-
getKeyRange()
|
|
204
|
-
{
|
|
205
|
-
let range = this.generators.find(g => g.generatorType === generatorTypes.keyRange);
|
|
206
|
-
if (range)
|
|
207
|
-
{
|
|
208
|
-
this.keyRange.min = range.generatorValue & 0x7F;
|
|
209
|
-
this.keyRange.max = (range.generatorValue >> 8) & 0x7F;
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
/**
|
|
214
|
-
* reads the velolicty range of the zone
|
|
215
|
-
*/
|
|
216
|
-
getVelRange()
|
|
217
|
-
{
|
|
218
|
-
let range = this.generators.find(g => g.generatorType === generatorTypes.velRange);
|
|
219
|
-
if (range)
|
|
220
|
-
{
|
|
221
|
-
this.velRange.min = range.generatorValue & 0x7F;
|
|
222
|
-
this.velRange.max = (range.generatorValue >> 8) & 0x7F;
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
/**
|
|
228
|
-
* Reads the given preset zone read
|
|
229
|
-
* @param zonesChunk {RiffChunk}
|
|
230
|
-
* @param presetGenerators {Generator[]}
|
|
231
|
-
* @param instruments {BasicInstrument[]}
|
|
232
|
-
* @param presetModulators {Modulator[]}
|
|
233
|
-
* @returns {PresetZone[]}
|
|
234
|
-
*/
|
|
235
|
-
export function readPresetZones(zonesChunk, presetGenerators, presetModulators, instruments)
|
|
236
|
-
{
|
|
237
|
-
/**
|
|
238
|
-
* @type {PresetZone[]}
|
|
239
|
-
*/
|
|
240
|
-
let zones = [];
|
|
241
|
-
while (zonesChunk.chunkData.length > zonesChunk.chunkData.currentIndex)
|
|
242
|
-
{
|
|
243
|
-
let zone = new PresetZone(zonesChunk.chunkData);
|
|
244
|
-
if (zones.length > 0)
|
|
245
|
-
{
|
|
246
|
-
let modulatorZoneSize = zone.modulatorZoneStartIndex - zones[zones.length - 1].modulatorZoneStartIndex;
|
|
247
|
-
let generatorZoneSize = zone.generatorZoneStartIndex - zones[zones.length - 1].generatorZoneStartIndex;
|
|
248
|
-
zones[zones.length - 1].setZoneSize(modulatorZoneSize, generatorZoneSize);
|
|
249
|
-
zones[zones.length - 1].getGenerators(presetGenerators);
|
|
250
|
-
zones[zones.length - 1].getModulators(presetModulators);
|
|
251
|
-
zones[zones.length - 1].getInstrument(instruments);
|
|
252
|
-
zones[zones.length - 1].getKeyRange();
|
|
253
|
-
zones[zones.length - 1].getVelRange();
|
|
254
|
-
}
|
|
255
|
-
zones.push(zone);
|
|
256
|
-
}
|
|
257
|
-
if (zones.length > 1)
|
|
258
|
-
{
|
|
259
|
-
// remove terminal
|
|
260
|
-
zones.pop();
|
|
261
|
-
}
|
|
262
|
-
return zones;
|
|
263
|
-
}
|
package/synthetizer/README.md
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
## This is the main synthesizer folder.
|
|
2
|
-
|
|
3
|
-
The code here is responsible for making the actual sound.
|
|
4
|
-
This is the heart of the SpessaSynth library.
|
|
5
|
-
|
|
6
|
-
- `audio_engine` - the core synthesis engine, it theoretically can run on non-browser environments.
|
|
7
|
-
- `audio_effects` - the WebAudioAPI audio effects.
|
|
8
|
-
- `worklet_wrapper` - the wrapper for the core synthesis engine using audio worklets.
|
|
9
|
-
|
|
10
|
-
`worklet_processor.min.js` - the minified worklet processor code to import.
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { DEFAULT_CHORUS_CONFIG } from "./fancy_chorus.js";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @typedef {Object} SynthConfig
|
|
5
|
-
* @property {boolean?} chorusEnabled - indicates if the chorus effect is enabled.
|
|
6
|
-
* @property {ChorusConfig?} chorusConfig - the configuration for chorus. Pass undefined to use defaults
|
|
7
|
-
* @property {boolean?} reverbEnabled - indicates if the reverb effect is enabled.
|
|
8
|
-
* @property {AudioBuffer?} reverbImpulseResponse - the impulse response for the reverb. Pass undefined to use defaults
|
|
9
|
-
* @property {{
|
|
10
|
-
* worklet: function(context: object, name: string, options?: Object)
|
|
11
|
-
* }?} audioNodeCreators - custom audio node creation functions for Web Audio wrappers.
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* @type {SynthConfig}
|
|
17
|
-
*/
|
|
18
|
-
export const DEFAULT_SYNTH_CONFIG = {
|
|
19
|
-
chorusEnabled: true,
|
|
20
|
-
chorusConfig: DEFAULT_CHORUS_CONFIG,
|
|
21
|
-
|
|
22
|
-
reverbEnabled: true,
|
|
23
|
-
reverbImpulseResponse: undefined, // will load the integrated one
|
|
24
|
-
audioNodeCreators: undefined
|
|
25
|
-
};
|
|
@@ -1,162 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* fancy_chorus.js
|
|
3
|
-
* purpose: creates a simple chorus effect node
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* @typedef {{
|
|
8
|
-
* oscillator: OscillatorNode,
|
|
9
|
-
* oscillatorGain: GainNode,
|
|
10
|
-
* delay: DelayNode
|
|
11
|
-
* }} ChorusNode
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* @typedef {Object} ChorusConfig
|
|
16
|
-
* @property {number?} nodesAmount - the amount of delay nodes (for each channel) and the corresponding oscillators
|
|
17
|
-
* @property {number?} defaultDelay - the initial delay, in seconds
|
|
18
|
-
* @property {number?} delayVariation - the difference between delays in the delay nodes
|
|
19
|
-
* @property {number?} stereoDifference - the difference of delays between two channels (added to the left channel and subtracted from the right)
|
|
20
|
-
* @property {number?} oscillatorFrequency - the initial delay time oscillator frequency, in Hz.
|
|
21
|
-
* @property {number?} oscillatorFrequencyVariation - the difference between frequencies of oscillators, in Hz
|
|
22
|
-
* @property {number?} oscillatorGain - how much will oscillator alter the delay in delay nodes, in seconds
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
|
-
const NODES_AMOUNT = 4;
|
|
26
|
-
const DEFAULT_DELAY = 0.03;
|
|
27
|
-
const DELAY_VARIATION = 0.01;
|
|
28
|
-
const STEREO_DIFF = 0.02;
|
|
29
|
-
|
|
30
|
-
const OSC_FREQ = 0.2;
|
|
31
|
-
const OSC_FREQ_VARIATION = 0.05;
|
|
32
|
-
const OSC_GAIN = 0.003;
|
|
33
|
-
|
|
34
|
-
export const DEFAULT_CHORUS_CONFIG = {
|
|
35
|
-
nodesAmount: NODES_AMOUNT,
|
|
36
|
-
defaultDelay: DEFAULT_DELAY,
|
|
37
|
-
delayVariation: DELAY_VARIATION,
|
|
38
|
-
stereoDifference: STEREO_DIFF,
|
|
39
|
-
oscillatorFrequency: OSC_FREQ,
|
|
40
|
-
oscillatorFrequencyVariation: OSC_FREQ_VARIATION,
|
|
41
|
-
oscillatorGain: OSC_GAIN
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
export class FancyChorus
|
|
45
|
-
{
|
|
46
|
-
/**
|
|
47
|
-
* Creates a fancy chorus effect
|
|
48
|
-
* @param output {AudioNode}
|
|
49
|
-
* @param config {ChorusConfig}
|
|
50
|
-
*/
|
|
51
|
-
constructor(output, config = DEFAULT_CHORUS_CONFIG)
|
|
52
|
-
{
|
|
53
|
-
const context = output.context;
|
|
54
|
-
|
|
55
|
-
this.input = context.createChannelSplitter(2);
|
|
56
|
-
|
|
57
|
-
const merger = context.createChannelMerger(2);
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* @type {ChorusNode[]}
|
|
61
|
-
*/
|
|
62
|
-
const chorusNodesLeft = [];
|
|
63
|
-
/**
|
|
64
|
-
* @type {ChorusNode[]}
|
|
65
|
-
*/
|
|
66
|
-
const chorusNodesRight = [];
|
|
67
|
-
let freq = config.oscillatorFrequency;
|
|
68
|
-
let delay = config.defaultDelay;
|
|
69
|
-
for (let i = 0; i < config.nodesAmount; i++)
|
|
70
|
-
{
|
|
71
|
-
// left node
|
|
72
|
-
this.createChorusNode(
|
|
73
|
-
freq,
|
|
74
|
-
delay - config.stereoDifference,
|
|
75
|
-
chorusNodesLeft,
|
|
76
|
-
0,
|
|
77
|
-
merger,
|
|
78
|
-
0,
|
|
79
|
-
context,
|
|
80
|
-
config
|
|
81
|
-
);
|
|
82
|
-
// right node
|
|
83
|
-
this.createChorusNode(
|
|
84
|
-
freq,
|
|
85
|
-
delay + config.stereoDifference,
|
|
86
|
-
chorusNodesRight,
|
|
87
|
-
1,
|
|
88
|
-
merger,
|
|
89
|
-
1,
|
|
90
|
-
context,
|
|
91
|
-
config
|
|
92
|
-
);
|
|
93
|
-
freq += config.oscillatorFrequencyVariation;
|
|
94
|
-
delay += config.delayVariation;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
merger.connect(output);
|
|
98
|
-
this.merger = merger;
|
|
99
|
-
this.chorusLeft = chorusNodesLeft;
|
|
100
|
-
this.chorusRight = chorusNodesRight;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
delete()
|
|
104
|
-
{
|
|
105
|
-
this.input.disconnect();
|
|
106
|
-
delete this.input;
|
|
107
|
-
this.merger.disconnect();
|
|
108
|
-
delete this.merger;
|
|
109
|
-
for (const chorusLeftElement of this.chorusLeft)
|
|
110
|
-
{
|
|
111
|
-
chorusLeftElement.delay.disconnect();
|
|
112
|
-
chorusLeftElement.oscillator.disconnect();
|
|
113
|
-
chorusLeftElement.oscillatorGain.disconnect();
|
|
114
|
-
delete chorusLeftElement.delay;
|
|
115
|
-
delete chorusLeftElement.oscillatorGain;
|
|
116
|
-
delete chorusLeftElement.oscillatorGain;
|
|
117
|
-
}
|
|
118
|
-
for (const chorusRightElement of this.chorusRight)
|
|
119
|
-
{
|
|
120
|
-
chorusRightElement.delay.disconnect();
|
|
121
|
-
chorusRightElement.oscillator.disconnect();
|
|
122
|
-
chorusRightElement.oscillatorGain.disconnect();
|
|
123
|
-
delete chorusRightElement.delay;
|
|
124
|
-
delete chorusRightElement.oscillatorGain;
|
|
125
|
-
delete chorusRightElement.oscillatorGain;
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
* @param freq {number}
|
|
131
|
-
* @param delay {number}
|
|
132
|
-
* @param list {ChorusNode[]}
|
|
133
|
-
* @param input {number}
|
|
134
|
-
* @param output {AudioNode}
|
|
135
|
-
* @param outputNum {number}
|
|
136
|
-
* @param context {BaseAudioContext}
|
|
137
|
-
* @param config {ChorusConfig}
|
|
138
|
-
*/
|
|
139
|
-
createChorusNode(freq, delay, list, input, output, outputNum, context, config)
|
|
140
|
-
{
|
|
141
|
-
const oscillator = context.createOscillator();
|
|
142
|
-
oscillator.type = "sine";
|
|
143
|
-
oscillator.frequency.value = freq;
|
|
144
|
-
const gainNode = context.createGain();
|
|
145
|
-
gainNode.gain.value = config.oscillatorGain;
|
|
146
|
-
const delayNode = context.createDelay();
|
|
147
|
-
delayNode.delayTime.value = delay;
|
|
148
|
-
|
|
149
|
-
oscillator.connect(gainNode);
|
|
150
|
-
gainNode.connect(delayNode.delayTime);
|
|
151
|
-
oscillator.start(context.currentTime /*+ delay*/);
|
|
152
|
-
|
|
153
|
-
this.input.connect(delayNode, input);
|
|
154
|
-
delayNode.connect(output, 0, outputNum);
|
|
155
|
-
|
|
156
|
-
list.push({
|
|
157
|
-
oscillator: oscillator,
|
|
158
|
-
oscillatorGain: gainNode,
|
|
159
|
-
delay: delayNode
|
|
160
|
-
});
|
|
161
|
-
}
|
|
162
|
-
}
|