spessasynth_lib 0.0.1
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/.idea/modules.xml +8 -0
- package/.idea/spessasynth_lib.iml +12 -0
- package/.idea/vcs.xml +6 -0
- package/copy_version.sh +38 -0
- package/index.js +73 -0
- package/package/@types/externals/stbvorbis_sync/stbvorbis_sync.min.d.ts +1 -0
- package/package/@types/index.d.ts +34 -0
- package/package/@types/midi_handler/midi_handler.d.ts +39 -0
- package/package/@types/midi_handler/web_midi_link.d.ts +12 -0
- package/package/@types/midi_parser/midi_data.d.ts +95 -0
- package/package/@types/midi_parser/midi_editor.d.ts +45 -0
- package/package/@types/midi_parser/midi_loader.d.ts +100 -0
- package/package/@types/midi_parser/midi_message.d.ts +154 -0
- package/package/@types/midi_parser/midi_writer.d.ts +6 -0
- package/package/@types/midi_parser/rmidi_writer.d.ts +9 -0
- package/package/@types/midi_parser/used_keys_loaded.d.ts +7 -0
- package/package/@types/sequencer/sequencer.d.ts +180 -0
- package/package/@types/sequencer/worklet_sequencer/sequencer_message.d.ts +28 -0
- package/package/@types/soundfont/read/generators.d.ts +98 -0
- package/package/@types/soundfont/read/instruments.d.ts +50 -0
- package/package/@types/soundfont/read/modulators.d.ts +73 -0
- package/package/@types/soundfont/read/presets.d.ts +87 -0
- package/package/@types/soundfont/read/riff_chunk.d.ts +31 -0
- package/package/@types/soundfont/read/samples.d.ts +134 -0
- package/package/@types/soundfont/read/zones.d.ts +141 -0
- package/package/@types/soundfont/soundfont.d.ts +76 -0
- package/package/@types/soundfont/write/ibag.d.ts +6 -0
- package/package/@types/soundfont/write/igen.d.ts +6 -0
- package/package/@types/soundfont/write/imod.d.ts +6 -0
- package/package/@types/soundfont/write/inst.d.ts +6 -0
- package/package/@types/soundfont/write/pbag.d.ts +6 -0
- package/package/@types/soundfont/write/pgen.d.ts +6 -0
- package/package/@types/soundfont/write/phdr.d.ts +6 -0
- package/package/@types/soundfont/write/pmod.d.ts +6 -0
- package/package/@types/soundfont/write/sdta.d.ts +11 -0
- package/package/@types/soundfont/write/shdr.d.ts +8 -0
- package/package/@types/soundfont/write/soundfont_trimmer.d.ts +6 -0
- package/package/@types/soundfont/write/write.d.ts +21 -0
- package/package/@types/synthetizer/audio_effects/effects_config.d.ts +29 -0
- package/package/@types/synthetizer/audio_effects/fancy_chorus.d.ts +93 -0
- package/package/@types/synthetizer/audio_effects/reverb.d.ts +7 -0
- package/package/@types/synthetizer/synth_event_handler.d.ts +161 -0
- package/package/@types/synthetizer/synthetizer.d.ts +294 -0
- package/package/@types/synthetizer/worklet_system/message_protocol/worklet_message.d.ts +89 -0
- package/package/@types/synthetizer/worklet_system/worklet_utilities/worklet_processor_channel.d.ts +134 -0
- package/package/@types/synthetizer/worklet_url.d.ts +5 -0
- package/package/@types/utils/buffer_to_wav.d.ts +8 -0
- package/package/@types/utils/byte_functions/big_endian.d.ts +13 -0
- package/package/@types/utils/byte_functions/little_endian.d.ts +35 -0
- package/package/@types/utils/byte_functions/string.d.ts +22 -0
- package/package/@types/utils/byte_functions/variable_length_quantity.d.ts +12 -0
- package/package/@types/utils/indexed_array.d.ts +21 -0
- package/package/@types/utils/loggin.d.ts +26 -0
- package/package/@types/utils/other.d.ts +32 -0
- package/package/LICENSE +26 -0
- package/package/README.md +84 -0
- package/package/externals/NOTICE +9 -0
- package/package/externals/libvorbis/@types/OggVorbisEncoder.d.ts +34 -0
- package/package/externals/libvorbis/OggVorbisEncoder.min.js +1 -0
- package/package/externals/stbvorbis_sync/@types/stbvorbis_sync.d.ts +12 -0
- package/package/externals/stbvorbis_sync/LICENSE +202 -0
- package/package/externals/stbvorbis_sync/stbvorbis_sync.min.js +1 -0
- package/package/index.js +73 -0
- package/package/midi_handler/README.md +3 -0
- package/package/midi_handler/midi_handler.js +118 -0
- package/package/midi_handler/web_midi_link.js +41 -0
- package/package/midi_parser/README.md +3 -0
- package/package/midi_parser/midi_data.js +121 -0
- package/package/midi_parser/midi_editor.js +557 -0
- package/package/midi_parser/midi_loader.js +502 -0
- package/package/midi_parser/midi_message.js +234 -0
- package/package/midi_parser/midi_writer.js +95 -0
- package/package/midi_parser/rmidi_writer.js +271 -0
- package/package/midi_parser/used_keys_loaded.js +172 -0
- package/package/package.json +43 -0
- package/package/sequencer/README.md +23 -0
- package/package/sequencer/sequencer.js +439 -0
- package/package/sequencer/worklet_sequencer/events.js +92 -0
- package/package/sequencer/worklet_sequencer/play.js +309 -0
- package/package/sequencer/worklet_sequencer/process_event.js +167 -0
- package/package/sequencer/worklet_sequencer/process_tick.js +85 -0
- package/package/sequencer/worklet_sequencer/sequencer_message.js +39 -0
- package/package/sequencer/worklet_sequencer/song_control.js +193 -0
- package/package/sequencer/worklet_sequencer/worklet_sequencer.js +218 -0
- package/package/soundfont/README.md +8 -0
- package/package/soundfont/read/generators.js +212 -0
- package/package/soundfont/read/instruments.js +125 -0
- package/package/soundfont/read/modulators.js +249 -0
- package/package/soundfont/read/presets.js +300 -0
- package/package/soundfont/read/riff_chunk.js +81 -0
- package/package/soundfont/read/samples.js +398 -0
- package/package/soundfont/read/zones.js +310 -0
- package/package/soundfont/soundfont.js +357 -0
- package/package/soundfont/write/ibag.js +39 -0
- package/package/soundfont/write/igen.js +75 -0
- package/package/soundfont/write/imod.js +46 -0
- package/package/soundfont/write/inst.js +34 -0
- package/package/soundfont/write/pbag.js +39 -0
- package/package/soundfont/write/pgen.js +77 -0
- package/package/soundfont/write/phdr.js +42 -0
- package/package/soundfont/write/pmod.js +46 -0
- package/package/soundfont/write/sdta.js +72 -0
- package/package/soundfont/write/shdr.js +54 -0
- package/package/soundfont/write/soundfont_trimmer.js +169 -0
- package/package/soundfont/write/write.js +180 -0
- package/package/synthetizer/README.md +6 -0
- package/package/synthetizer/audio_effects/effects_config.js +21 -0
- package/package/synthetizer/audio_effects/fancy_chorus.js +120 -0
- package/package/synthetizer/audio_effects/impulse_response_2.flac +0 -0
- package/package/synthetizer/audio_effects/reverb.js +24 -0
- package/package/synthetizer/synth_event_handler.js +156 -0
- package/package/synthetizer/synthetizer.js +766 -0
- package/package/synthetizer/worklet_processor.min.js +13 -0
- package/package/synthetizer/worklet_system/README.md +6 -0
- package/package/synthetizer/worklet_system/main_processor.js +363 -0
- package/package/synthetizer/worklet_system/message_protocol/handle_message.js +197 -0
- package/package/synthetizer/worklet_system/message_protocol/message_sending.js +74 -0
- package/package/synthetizer/worklet_system/message_protocol/worklet_message.js +121 -0
- package/package/synthetizer/worklet_system/minify_processor.sh +4 -0
- package/package/synthetizer/worklet_system/worklet_methods/controller_control.js +230 -0
- package/package/synthetizer/worklet_system/worklet_methods/data_entry.js +277 -0
- package/package/synthetizer/worklet_system/worklet_methods/note_off.js +109 -0
- package/package/synthetizer/worklet_system/worklet_methods/note_on.js +91 -0
- package/package/synthetizer/worklet_system/worklet_methods/program_control.js +183 -0
- package/package/synthetizer/worklet_system/worklet_methods/reset_controllers.js +177 -0
- package/package/synthetizer/worklet_system/worklet_methods/snapshot.js +129 -0
- package/package/synthetizer/worklet_system/worklet_methods/system_exclusive.js +272 -0
- package/package/synthetizer/worklet_system/worklet_methods/tuning_control.js +195 -0
- package/package/synthetizer/worklet_system/worklet_methods/vibrato_control.js +29 -0
- package/package/synthetizer/worklet_system/worklet_methods/voice_control.js +233 -0
- package/package/synthetizer/worklet_system/worklet_processor.js +9 -0
- package/package/synthetizer/worklet_system/worklet_utilities/lfo.js +23 -0
- package/package/synthetizer/worklet_system/worklet_utilities/lowpass_filter.js +130 -0
- package/package/synthetizer/worklet_system/worklet_utilities/modulation_envelope.js +73 -0
- package/package/synthetizer/worklet_system/worklet_utilities/modulator_curves.js +86 -0
- package/package/synthetizer/worklet_system/worklet_utilities/stereo_panner.js +81 -0
- package/package/synthetizer/worklet_system/worklet_utilities/unit_converter.js +66 -0
- package/package/synthetizer/worklet_system/worklet_utilities/volume_envelope.js +265 -0
- package/package/synthetizer/worklet_system/worklet_utilities/wavetable_oscillator.js +83 -0
- package/package/synthetizer/worklet_system/worklet_utilities/worklet_modulator.js +234 -0
- package/package/synthetizer/worklet_system/worklet_utilities/worklet_processor_channel.js +116 -0
- package/package/synthetizer/worklet_system/worklet_utilities/worklet_voice.js +272 -0
- package/package/synthetizer/worklet_url.js +5 -0
- package/package/utils/README.md +4 -0
- package/package/utils/buffer_to_wav.js +101 -0
- package/package/utils/byte_functions/big_endian.js +28 -0
- package/package/utils/byte_functions/little_endian.js +74 -0
- package/package/utils/byte_functions/string.js +97 -0
- package/package/utils/byte_functions/variable_length_quantity.js +37 -0
- package/package/utils/encode_vorbis.js +30 -0
- package/package/utils/indexed_array.js +41 -0
- package/package/utils/loggin.js +79 -0
- package/package/utils/other.js +54 -0
- package/package.json +43 -0
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reads the given instrument zone read
|
|
3
|
+
* @param zonesChunk {RiffChunk}
|
|
4
|
+
* @param instrumentGenerators {Generator[]}
|
|
5
|
+
* @param instrumentModulators {Modulator[]}
|
|
6
|
+
* @param instrumentSamples {Sample[]}
|
|
7
|
+
* @returns {InstrumentZone[]}
|
|
8
|
+
*/
|
|
9
|
+
export function readInstrumentZones(zonesChunk: RiffChunk, instrumentGenerators: Generator[], instrumentModulators: Modulator[], instrumentSamples: Sample[]): InstrumentZone[];
|
|
10
|
+
/**
|
|
11
|
+
* Reads the given preset zone read
|
|
12
|
+
* @param zonesChunk {RiffChunk}
|
|
13
|
+
* @param presetGenerators {Generator[]}
|
|
14
|
+
* @param instruments {Instrument[]}
|
|
15
|
+
* @param presetModulators {Modulator[]}
|
|
16
|
+
* @returns {PresetZone[]}
|
|
17
|
+
*/
|
|
18
|
+
export function readPresetZones(zonesChunk: RiffChunk, presetGenerators: Generator[], presetModulators: Modulator[], instruments: Instrument[]): PresetZone[];
|
|
19
|
+
/**
|
|
20
|
+
* zones.js
|
|
21
|
+
* purpose: reads instrumend and preset zones from soundfont and gets their respective samples and generators and modulators
|
|
22
|
+
*/
|
|
23
|
+
export class InstrumentZone {
|
|
24
|
+
/**
|
|
25
|
+
* Creates a zone (instrument)
|
|
26
|
+
* @param dataArray {IndexedByteArray}
|
|
27
|
+
* @param index {number}
|
|
28
|
+
*/
|
|
29
|
+
constructor(dataArray: IndexedByteArray, index: number);
|
|
30
|
+
generatorZoneStartIndex: number;
|
|
31
|
+
modulatorZoneStartIndex: number;
|
|
32
|
+
modulatorZoneSize: number;
|
|
33
|
+
generatorZoneSize: number;
|
|
34
|
+
zoneID: number;
|
|
35
|
+
keyRange: {
|
|
36
|
+
min: number;
|
|
37
|
+
max: number;
|
|
38
|
+
};
|
|
39
|
+
velRange: {
|
|
40
|
+
min: number;
|
|
41
|
+
max: number;
|
|
42
|
+
};
|
|
43
|
+
isGlobal: boolean;
|
|
44
|
+
useCount: number;
|
|
45
|
+
/**
|
|
46
|
+
* @type {Generator[]}
|
|
47
|
+
*/
|
|
48
|
+
generators: Generator[];
|
|
49
|
+
/**
|
|
50
|
+
* @type {Modulator[]}
|
|
51
|
+
*/
|
|
52
|
+
modulators: Modulator[];
|
|
53
|
+
deleteZone(): void;
|
|
54
|
+
setZoneSize(modulatorZoneSize: any, generatorZoneSize: any): void;
|
|
55
|
+
/**
|
|
56
|
+
* grab the generators
|
|
57
|
+
* @param generators {Generator[]}
|
|
58
|
+
*/
|
|
59
|
+
getGenerators(generators: Generator[]): void;
|
|
60
|
+
/**
|
|
61
|
+
* grab the modulators
|
|
62
|
+
* @param modulators {Modulator[]}
|
|
63
|
+
*/
|
|
64
|
+
getModulators(modulators: Modulator[]): void;
|
|
65
|
+
/**
|
|
66
|
+
* Loads the zone's sample
|
|
67
|
+
* @param samples {Sample[]}
|
|
68
|
+
*/
|
|
69
|
+
getSample(samples: Sample[]): void;
|
|
70
|
+
sample: Sample;
|
|
71
|
+
/**
|
|
72
|
+
* Reads the keyRange of the zone
|
|
73
|
+
*/
|
|
74
|
+
getKeyRange(): void;
|
|
75
|
+
/**
|
|
76
|
+
* reads the velolicty range of the zone
|
|
77
|
+
*/
|
|
78
|
+
getVelRange(): void;
|
|
79
|
+
}
|
|
80
|
+
export class PresetZone {
|
|
81
|
+
/**
|
|
82
|
+
* Creates a zone (preset)
|
|
83
|
+
* @param dataArray {IndexedByteArray}
|
|
84
|
+
* @param index {number}
|
|
85
|
+
*/
|
|
86
|
+
constructor(dataArray: IndexedByteArray, index: number);
|
|
87
|
+
generatorZoneStartIndex: number;
|
|
88
|
+
modulatorZoneStartIndex: number;
|
|
89
|
+
modulatorZoneSize: number;
|
|
90
|
+
generatorZoneSize: number;
|
|
91
|
+
zoneID: number;
|
|
92
|
+
keyRange: {
|
|
93
|
+
min: number;
|
|
94
|
+
max: number;
|
|
95
|
+
};
|
|
96
|
+
velRange: {
|
|
97
|
+
min: number;
|
|
98
|
+
max: number;
|
|
99
|
+
};
|
|
100
|
+
isGlobal: boolean;
|
|
101
|
+
/**
|
|
102
|
+
* @type {Generator[]}
|
|
103
|
+
*/
|
|
104
|
+
generators: Generator[];
|
|
105
|
+
/**
|
|
106
|
+
* @type {Modulator[]}
|
|
107
|
+
*/
|
|
108
|
+
modulators: Modulator[];
|
|
109
|
+
setZoneSize(modulatorZoneSize: any, generatorZoneSize: any): void;
|
|
110
|
+
deleteZone(): void;
|
|
111
|
+
/**
|
|
112
|
+
* grab the generators
|
|
113
|
+
* @param generators {Generator[]}
|
|
114
|
+
*/
|
|
115
|
+
getGenerators(generators: Generator[]): void;
|
|
116
|
+
/**
|
|
117
|
+
* grab the modulators
|
|
118
|
+
* @param modulators {Modulator[]}
|
|
119
|
+
*/
|
|
120
|
+
getModulators(modulators: Modulator[]): void;
|
|
121
|
+
/**
|
|
122
|
+
* grab the instrument
|
|
123
|
+
* @param instruments {Instrument[]}
|
|
124
|
+
*/
|
|
125
|
+
getInstrument(instruments: Instrument[]): void;
|
|
126
|
+
instrument: Instrument;
|
|
127
|
+
/**
|
|
128
|
+
* Reads the keyRange of the zone
|
|
129
|
+
*/
|
|
130
|
+
getKeyRange(): void;
|
|
131
|
+
/**
|
|
132
|
+
* reads the velolicty range of the zone
|
|
133
|
+
*/
|
|
134
|
+
getVelRange(): void;
|
|
135
|
+
}
|
|
136
|
+
import { RiffChunk } from "./riff_chunk.js";
|
|
137
|
+
import { Generator } from "./generators.js";
|
|
138
|
+
import { Modulator } from "./modulators.js";
|
|
139
|
+
import { Sample } from "./samples.js";
|
|
140
|
+
import { Instrument } from "./instruments.js";
|
|
141
|
+
import { IndexedByteArray } from "../../utils/indexed_array.js";
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* soundfont.js
|
|
3
|
+
* purpose: parses a soundfont2 file
|
|
4
|
+
*/
|
|
5
|
+
export class SoundFont2 {
|
|
6
|
+
/**
|
|
7
|
+
* Merges soundfonts with the given order. Keep in mind that the info read is copied from the first one
|
|
8
|
+
* @param soundfonts {...SoundFont2} the soundfonts to merge, the first overwrites the last
|
|
9
|
+
* @returns {SoundFont2}
|
|
10
|
+
*/
|
|
11
|
+
static mergeSoundfonts(...soundfonts: SoundFont2[]): SoundFont2;
|
|
12
|
+
/**
|
|
13
|
+
* Initializes a new SoundFont2 Parser and parses the given data array
|
|
14
|
+
* @param arrayBuffer {ArrayBuffer|{presets: Preset[], info: Object<string, string>}}
|
|
15
|
+
*/
|
|
16
|
+
constructor(arrayBuffer: ArrayBuffer | {
|
|
17
|
+
presets: Preset[];
|
|
18
|
+
info: {
|
|
19
|
+
[x: string]: string;
|
|
20
|
+
};
|
|
21
|
+
});
|
|
22
|
+
presets: Preset[];
|
|
23
|
+
soundFontInfo: {
|
|
24
|
+
[x: string]: string;
|
|
25
|
+
};
|
|
26
|
+
dataArray: IndexedByteArray;
|
|
27
|
+
sampleDataStartIndex: number;
|
|
28
|
+
samples: import("./read/samples.js").Sample[];
|
|
29
|
+
/**
|
|
30
|
+
* read all the instruments
|
|
31
|
+
* @type {Instrument[]}
|
|
32
|
+
*/
|
|
33
|
+
instruments: Instrument[];
|
|
34
|
+
removeUnusedElements(): void;
|
|
35
|
+
/**
|
|
36
|
+
* @param instrument {Instrument}
|
|
37
|
+
*/
|
|
38
|
+
deleteInstrument(instrument: Instrument): void;
|
|
39
|
+
/**
|
|
40
|
+
* @param sample {Sample}
|
|
41
|
+
*/
|
|
42
|
+
deleteSample(sample: Sample): void;
|
|
43
|
+
/**
|
|
44
|
+
* @param preset {Preset}
|
|
45
|
+
*/
|
|
46
|
+
deletePreset(preset: Preset): void;
|
|
47
|
+
/**
|
|
48
|
+
* @param chunk {RiffChunk}
|
|
49
|
+
* @param expected {string}
|
|
50
|
+
*/
|
|
51
|
+
verifyHeader(chunk: RiffChunk, expected: string): void;
|
|
52
|
+
/**
|
|
53
|
+
* @param text {string}
|
|
54
|
+
* @param expected {string}
|
|
55
|
+
*/
|
|
56
|
+
verifyText(text: string, expected: string): void;
|
|
57
|
+
/**
|
|
58
|
+
* Get the appropriate preset
|
|
59
|
+
* @param bankNr {number}
|
|
60
|
+
* @param presetNr {number}
|
|
61
|
+
* @returns {Preset}
|
|
62
|
+
*/
|
|
63
|
+
getPreset(bankNr: number, presetNr: number): Preset;
|
|
64
|
+
/**
|
|
65
|
+
* gets preset by name
|
|
66
|
+
* @param presetName {string}
|
|
67
|
+
* @returns {Preset}
|
|
68
|
+
*/
|
|
69
|
+
getPresetByName(presetName: string): Preset;
|
|
70
|
+
write: typeof write;
|
|
71
|
+
}
|
|
72
|
+
import { Preset } from "./read/presets.js";
|
|
73
|
+
import { IndexedByteArray } from '../utils/indexed_array.js';
|
|
74
|
+
import { Instrument } from "./read/instruments.js";
|
|
75
|
+
import { RiffChunk } from './read/riff_chunk.js';
|
|
76
|
+
import { write } from './write/write.js';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @this {SoundFont2}
|
|
3
|
+
* @param smplStartOffsets {number[]}
|
|
4
|
+
* @param smplEndOffsets {number[]}
|
|
5
|
+
* @param compress {boolean}
|
|
6
|
+
* @param quality {number}
|
|
7
|
+
* @param vorbisFunc {EncodeVorbisFunction}
|
|
8
|
+
* @returns {IndexedByteArray}
|
|
9
|
+
*/
|
|
10
|
+
export function getSDTA(this: SoundFont2, smplStartOffsets: number[], smplEndOffsets: number[], compress: boolean, quality: number, vorbisFunc: EncodeVorbisFunction): IndexedByteArray;
|
|
11
|
+
import { IndexedByteArray } from '../../utils/indexed_array.js';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @this {SoundFont2}
|
|
3
|
+
* @param smplStartOffsets {number[]}
|
|
4
|
+
* @param smplEndOffsets {number[]}
|
|
5
|
+
* @returns {IndexedByteArray}
|
|
6
|
+
*/
|
|
7
|
+
export function getSHDR(this: SoundFont2, smplStartOffsets: number[], smplEndOffsets: number[]): IndexedByteArray;
|
|
8
|
+
import { IndexedByteArray } from '../../utils/indexed_array.js';
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Write the soundfont as an .sf2 file. This method is DESTRUCTIVE
|
|
3
|
+
* @this {SoundFont2}
|
|
4
|
+
* @param {SoundFont2WriteOptions} options
|
|
5
|
+
* @returns {Uint8Array}
|
|
6
|
+
*/
|
|
7
|
+
export function write(this: SoundFont2, options?: SoundFont2WriteOptions): Uint8Array;
|
|
8
|
+
export type SoundFont2WriteOptions = {
|
|
9
|
+
/**
|
|
10
|
+
* - if the soundfont should be compressed with the ogg vorbis codec
|
|
11
|
+
*/
|
|
12
|
+
compress: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* - the vorbis compression quality, from -0.1 to 1
|
|
15
|
+
*/
|
|
16
|
+
compressionQuality: number;
|
|
17
|
+
/**
|
|
18
|
+
* - the encode vorbis function. Can be undefined if not compressing.
|
|
19
|
+
*/
|
|
20
|
+
compressionFunction: EncodeVorbisFunction | undefined;
|
|
21
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {Object} EffectsConfig
|
|
3
|
+
* @property {boolean} chorusEnabled - indicates if the chorus effect is enabled.
|
|
4
|
+
* @property {ChorusConfig} chorusConfig - the configuration for chorus. Pass undefined to use defaults
|
|
5
|
+
* @property {boolean} reverbEnabled - indicates if the reverb effect is enabled.
|
|
6
|
+
* @property {AudioBuffer} reverbImpulseResponse - the impulse response for the reverb. Pass undefined to use defaults
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* @type {EffectsConfig}
|
|
10
|
+
*/
|
|
11
|
+
export const DEFAULT_EFFECTS_CONFIG: EffectsConfig;
|
|
12
|
+
export type EffectsConfig = {
|
|
13
|
+
/**
|
|
14
|
+
* - indicates if the chorus effect is enabled.
|
|
15
|
+
*/
|
|
16
|
+
chorusEnabled: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* - the configuration for chorus. Pass undefined to use defaults
|
|
19
|
+
*/
|
|
20
|
+
chorusConfig: ChorusConfig;
|
|
21
|
+
/**
|
|
22
|
+
* - indicates if the reverb effect is enabled.
|
|
23
|
+
*/
|
|
24
|
+
reverbEnabled: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* - the impulse response for the reverb. Pass undefined to use defaults
|
|
27
|
+
*/
|
|
28
|
+
reverbImpulseResponse: AudioBuffer;
|
|
29
|
+
};
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
export namespace DEFAULT_CHORUS_CONFIG {
|
|
2
|
+
export { NODES_AMOUNT as nodesAmount };
|
|
3
|
+
export { DEFAULT_DELAY as defaultDelay };
|
|
4
|
+
export { DELAY_VARIATION as delayVariation };
|
|
5
|
+
export { STEREO_DIFF as stereoDifference };
|
|
6
|
+
export { OSC_FREQ as oscillatorFrequency };
|
|
7
|
+
export { OSC_FREQ_VARIATION as oscillatorFrequencyVariation };
|
|
8
|
+
export { OSC_GAIN as oscillatorGain };
|
|
9
|
+
}
|
|
10
|
+
export class FancyChorus {
|
|
11
|
+
/**
|
|
12
|
+
* Creates a fancy chorus effect
|
|
13
|
+
* @param output {AudioNode}
|
|
14
|
+
* @param config {ChorusConfig}
|
|
15
|
+
*/
|
|
16
|
+
constructor(output: AudioNode, config?: ChorusConfig);
|
|
17
|
+
input: ChannelSplitterNode;
|
|
18
|
+
/**
|
|
19
|
+
* @param freq {number}
|
|
20
|
+
* @param delay {number}
|
|
21
|
+
* @param list {ChorusNode[]}
|
|
22
|
+
* @param input {number}
|
|
23
|
+
* @param output {AudioNode}
|
|
24
|
+
* @param outputNum {number}
|
|
25
|
+
* @param context {BaseAudioContext}
|
|
26
|
+
* @param config {ChorusConfig}
|
|
27
|
+
*/
|
|
28
|
+
createChorusNode(freq: number, delay: number, list: ChorusNode[], input: number, output: AudioNode, outputNum: number, context: BaseAudioContext, config: ChorusConfig): void;
|
|
29
|
+
}
|
|
30
|
+
export type ChorusNode = {
|
|
31
|
+
oscillator: OscillatorNode;
|
|
32
|
+
oscillatorGain: GainNode;
|
|
33
|
+
delay: DelayNode;
|
|
34
|
+
};
|
|
35
|
+
export type ChorusConfig = {
|
|
36
|
+
/**
|
|
37
|
+
* - the amount of delay nodes (for each channel) and the corresponding oscillators
|
|
38
|
+
*/
|
|
39
|
+
nodesAmount: number;
|
|
40
|
+
/**
|
|
41
|
+
* - the initial delay, in seconds
|
|
42
|
+
*/
|
|
43
|
+
defaultDelay: number;
|
|
44
|
+
/**
|
|
45
|
+
* - the difference between delays in the delay nodes
|
|
46
|
+
*/
|
|
47
|
+
delayVariation: number;
|
|
48
|
+
/**
|
|
49
|
+
* - the difference of delays between two channels (added to the left channel and subtracted from the right)
|
|
50
|
+
*/
|
|
51
|
+
stereoDifference: number;
|
|
52
|
+
/**
|
|
53
|
+
* - the initial delay oscillator frequency, in Hz.
|
|
54
|
+
*/
|
|
55
|
+
oscillatorFrequency: number;
|
|
56
|
+
/**
|
|
57
|
+
* - the difference between frequencies of oscillators, in Hz
|
|
58
|
+
*/
|
|
59
|
+
oscillatorFrequencyVariation: number;
|
|
60
|
+
/**
|
|
61
|
+
* - how much will oscillator alter the delay in delay nodes, in seconds
|
|
62
|
+
*/
|
|
63
|
+
oscillatorGain: number;
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* fancy_chorus.js
|
|
67
|
+
* purpose: creates a simple chorus effect node
|
|
68
|
+
*/
|
|
69
|
+
/**
|
|
70
|
+
* @typedef {{
|
|
71
|
+
* oscillator: OscillatorNode,
|
|
72
|
+
* oscillatorGain: GainNode,
|
|
73
|
+
* delay: DelayNode
|
|
74
|
+
* }} ChorusNode
|
|
75
|
+
*/
|
|
76
|
+
/**
|
|
77
|
+
* @typedef {Object} ChorusConfig
|
|
78
|
+
* @property {number} nodesAmount - the amount of delay nodes (for each channel) and the corresponding oscillators
|
|
79
|
+
* @property {number} defaultDelay - the initial delay, in seconds
|
|
80
|
+
* @property {number} delayVariation - the difference between delays in the delay nodes
|
|
81
|
+
* @property {number} stereoDifference - the difference of delays between two channels (added to the left channel and subtracted from the right)
|
|
82
|
+
* @property {number} oscillatorFrequency - the initial delay oscillator frequency, in Hz.
|
|
83
|
+
* @property {number} oscillatorFrequencyVariation - the difference between frequencies of oscillators, in Hz
|
|
84
|
+
* @property {number} oscillatorGain - how much will oscillator alter the delay in delay nodes, in seconds
|
|
85
|
+
*/
|
|
86
|
+
declare const NODES_AMOUNT: 4;
|
|
87
|
+
declare const DEFAULT_DELAY: 0.03;
|
|
88
|
+
declare const DELAY_VARIATION: 0.01;
|
|
89
|
+
declare const STEREO_DIFF: 0.02;
|
|
90
|
+
declare const OSC_FREQ: 0.3;
|
|
91
|
+
declare const OSC_FREQ_VARIATION: 0.05;
|
|
92
|
+
declare const OSC_GAIN: 0.003;
|
|
93
|
+
export {};
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* synth_event_handler.js
|
|
3
|
+
* purpose: manages the synthesizer's event system, calling assinged functions when synthesizer requests dispatching the event
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
*
|
|
7
|
+
* @typedef {{
|
|
8
|
+
* midiNote: number,
|
|
9
|
+
* channel: number,
|
|
10
|
+
* velocity: number
|
|
11
|
+
* }} NoteOnCallback
|
|
12
|
+
*
|
|
13
|
+
* @typedef {{
|
|
14
|
+
* midiNote: number,
|
|
15
|
+
* channel: number
|
|
16
|
+
* }} NoteOffCallback
|
|
17
|
+
*
|
|
18
|
+
* @typedef {{
|
|
19
|
+
* channel: number,
|
|
20
|
+
* isDrumChannel: boolean
|
|
21
|
+
* }} DrumChangeCallback
|
|
22
|
+
*
|
|
23
|
+
* @typedef {{
|
|
24
|
+
* channel: number,
|
|
25
|
+
* program: number,
|
|
26
|
+
* bank: number,
|
|
27
|
+
* userCalled: boolean
|
|
28
|
+
* }} ProgramChangeCallback
|
|
29
|
+
*
|
|
30
|
+
* @typedef {{
|
|
31
|
+
* channel: number,
|
|
32
|
+
* controllerNumber: number,
|
|
33
|
+
* controllerValue: number
|
|
34
|
+
* }} ControllerChangeCallback
|
|
35
|
+
*
|
|
36
|
+
* @typedef {{
|
|
37
|
+
* channel:number,
|
|
38
|
+
* isMuted: boolean
|
|
39
|
+
* }} MuteChannelCallback
|
|
40
|
+
*
|
|
41
|
+
* @typedef {{
|
|
42
|
+
* presetName: string,
|
|
43
|
+
* bank: number,
|
|
44
|
+
* program: number
|
|
45
|
+
* }[]} PresetListChangeCallback
|
|
46
|
+
*
|
|
47
|
+
*
|
|
48
|
+
* @typedef {{
|
|
49
|
+
* channel: number,
|
|
50
|
+
* MSB: number,
|
|
51
|
+
* LSB: number
|
|
52
|
+
* }} PitchWheelCallback
|
|
53
|
+
*
|
|
54
|
+
* @typedef {{
|
|
55
|
+
* channel: number,
|
|
56
|
+
* pressure: number
|
|
57
|
+
* }} ChannelPressureCallback
|
|
58
|
+
*
|
|
59
|
+
* @typedef {string} SoundfontErrorCallback
|
|
60
|
+
*
|
|
61
|
+
*
|
|
62
|
+
* @typedef {
|
|
63
|
+
* NoteOnCallback |
|
|
64
|
+
* NoteOffCallback |
|
|
65
|
+
* DrumChangeCallback |
|
|
66
|
+
* ProgramChangeCallback |
|
|
67
|
+
* ControllerChangeCallback |
|
|
68
|
+
* MuteChannelCallback |
|
|
69
|
+
* PresetListChangeCallback |
|
|
70
|
+
* PitchWheelCallback |
|
|
71
|
+
* SoundfontErrorCallback |
|
|
72
|
+
* ChannelPressureCallback |
|
|
73
|
+
* undefined
|
|
74
|
+
* } EventCallbackData
|
|
75
|
+
*/
|
|
76
|
+
/**
|
|
77
|
+
* @typedef {
|
|
78
|
+
* "noteon"|
|
|
79
|
+
* "noteoff"|
|
|
80
|
+
* "pitchwheel"|
|
|
81
|
+
* "controllerchange"|
|
|
82
|
+
* "programchange"|
|
|
83
|
+
* "channelpressure"|
|
|
84
|
+
* "polypressure" |
|
|
85
|
+
* "drumchange"|
|
|
86
|
+
* "stopall"|
|
|
87
|
+
* "newchannel"|
|
|
88
|
+
* "mutechannel"|
|
|
89
|
+
* "presetlistchange"|
|
|
90
|
+
* "allcontrollerreset"|
|
|
91
|
+
* "soundfonterror"} EventTypes
|
|
92
|
+
*/
|
|
93
|
+
export class EventHandler {
|
|
94
|
+
/**
|
|
95
|
+
* The main list of events
|
|
96
|
+
* @type {Object<EventTypes, Object<string, function(EventCallbackData)>>}
|
|
97
|
+
*/
|
|
98
|
+
events: any;
|
|
99
|
+
/**
|
|
100
|
+
* Adds a new event listener
|
|
101
|
+
* @param name {EventTypes}
|
|
102
|
+
* @param id {string} the unique identifier for the event (to delete it
|
|
103
|
+
* @param callback {function(EventCallbackData)}
|
|
104
|
+
*/
|
|
105
|
+
addEvent(name: EventTypes, id: string, callback: (arg0: EventCallbackData) => any): void;
|
|
106
|
+
/**
|
|
107
|
+
* Removes an event listener
|
|
108
|
+
* @param name {EventTypes}
|
|
109
|
+
* @param id {string}
|
|
110
|
+
*/
|
|
111
|
+
removeEvent(name: EventTypes, id: string): void;
|
|
112
|
+
/**
|
|
113
|
+
* Calls the given event
|
|
114
|
+
* @param name {EventTypes}
|
|
115
|
+
* @param eventData {EventCallbackData}
|
|
116
|
+
*/
|
|
117
|
+
callEvent(name: EventTypes, eventData: EventCallbackData): void;
|
|
118
|
+
}
|
|
119
|
+
export type NoteOnCallback = {
|
|
120
|
+
midiNote: number;
|
|
121
|
+
channel: number;
|
|
122
|
+
velocity: number;
|
|
123
|
+
};
|
|
124
|
+
export type NoteOffCallback = {
|
|
125
|
+
midiNote: number;
|
|
126
|
+
channel: number;
|
|
127
|
+
};
|
|
128
|
+
export type DrumChangeCallback = {
|
|
129
|
+
channel: number;
|
|
130
|
+
isDrumChannel: boolean;
|
|
131
|
+
};
|
|
132
|
+
export type ProgramChangeCallback = {
|
|
133
|
+
channel: number;
|
|
134
|
+
program: number;
|
|
135
|
+
bank: number;
|
|
136
|
+
userCalled: boolean;
|
|
137
|
+
};
|
|
138
|
+
export type ControllerChangeCallback = {
|
|
139
|
+
channel: number;
|
|
140
|
+
controllerNumber: number;
|
|
141
|
+
controllerValue: number;
|
|
142
|
+
};
|
|
143
|
+
export type MuteChannelCallback = {
|
|
144
|
+
channel: number;
|
|
145
|
+
isMuted: boolean;
|
|
146
|
+
};
|
|
147
|
+
export type PresetListChangeCallback = {
|
|
148
|
+
presetName: string;
|
|
149
|
+
bank: number;
|
|
150
|
+
program: number;
|
|
151
|
+
}[];
|
|
152
|
+
export type PitchWheelCallback = {
|
|
153
|
+
channel: number;
|
|
154
|
+
MSB: number;
|
|
155
|
+
LSB: number;
|
|
156
|
+
};
|
|
157
|
+
export type ChannelPressureCallback = {
|
|
158
|
+
channel: number;
|
|
159
|
+
pressure: number;
|
|
160
|
+
};
|
|
161
|
+
export type SoundfontErrorCallback = string;
|