spessasynth_lib 3.24.26 → 3.24.28

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.
@@ -33,19 +33,50 @@ export class Modulator
33
33
  currentValue = 0;
34
34
 
35
35
  /**
36
- * Creates a modulator
37
- * @param params {{srcEnum: number, secSrcEnum: number, dest: generatorTypes, amt: number, transform: number}}
36
+ * The source enumeration for this modulator
37
+ * @type {number}
38
+ */
39
+ sourceEnum;
40
+
41
+ /**
42
+ * The secondary source enumeration for this modulator
43
+ * @type {number}
38
44
  */
39
- constructor(params)
45
+ secondarySourceEnum;
46
+
47
+ /**
48
+ * The generator destination of this modulator
49
+ * @type {generatorTypes}
50
+ */
51
+ modulatorDestination;
52
+
53
+ /**
54
+ * The transform amount for this modulator
55
+ * @type {number}
56
+ */
57
+ transformAmount;
58
+
59
+ /**
60
+ * The transform type for this modulator
61
+ * @type {0|2}
62
+ */
63
+ transformType;
64
+
65
+ /**
66
+ * creates a modulator
67
+ * @param srcEnum {number}
68
+ * @param secSrcEnum {number}
69
+ * @param destination {generatorTypes|number}
70
+ * @param amount {number}
71
+ * @param transformType {number}
72
+ */
73
+ constructor(srcEnum, secSrcEnum, destination, amount, transformType)
40
74
  {
41
- this.sourceEnum = params.srcEnum;
42
- /**
43
- * @type {generatorTypes}
44
- */
45
- this.modulatorDestination = params.dest;
46
- this.secondarySourceEnum = params.secSrcEnum;
47
- this.transformAmount = params.amt;
48
- this.transformType = params.transform;
75
+ this.sourceEnum = srcEnum;
76
+ this.modulatorDestination = destination;
77
+ this.secondarySourceEnum = secSrcEnum;
78
+ this.transformAmount = amount;
79
+ this.transformType = transformType;
49
80
 
50
81
 
51
82
  if (this.modulatorDestination > 58)
@@ -96,13 +127,13 @@ export class Modulator
96
127
  */
97
128
  static copy(modulator)
98
129
  {
99
- return new Modulator({
100
- srcEnum: modulator.sourceEnum,
101
- secSrcEnum: modulator.secondarySourceEnum,
102
- transform: modulator.transformType,
103
- amt: modulator.transformAmount,
104
- dest: modulator.modulatorDestination
105
- });
130
+ return new Modulator(
131
+ modulator.sourceEnum,
132
+ modulator.secondarySourceEnum,
133
+ modulator.modulatorDestination,
134
+ modulator.transformAmount,
135
+ modulator.transformType
136
+ );
106
137
  }
107
138
 
108
139
  /**
@@ -121,62 +152,63 @@ export class Modulator
121
152
  }
122
153
 
123
154
  /**
124
- * Sum transform and create a NEW modulator
125
- * @param modulator {Modulator}
126
- * @returns {Modulator}
127
- */
128
- sumTransform(modulator)
129
- {
130
- return new Modulator({
131
- srcEnum: this.sourceEnum,
132
- secSrcEnum: this.secondarySourceEnum,
133
- dest: this.modulatorDestination,
134
- transform: this.transformType,
135
- amt: this.transformAmount + modulator.transformAmount
136
- });
137
- }
138
-
139
- /**
155
+ * @param mod {Modulator}
140
156
  * @returns {string}
141
157
  */
142
- debugString()
158
+ static debugString(mod)
143
159
  {
144
160
  function getKeyByValue(object, value)
145
161
  {
146
162
  return Object.keys(object).find(key => object[key] === value);
147
163
  }
148
164
 
149
- let sourceString = getKeyByValue(modulatorCurveTypes, this.sourceCurveType);
150
- sourceString += this.sourcePolarity === 0 ? " unipolar " : " bipolar ";
151
- sourceString += this.sourceDirection === 0 ? "forwards " : "backwards ";
152
- if (this.sourceUsesCC)
165
+ let sourceString = getKeyByValue(modulatorCurveTypes, mod.sourceCurveType);
166
+ sourceString += mod.sourcePolarity === 0 ? " unipolar " : " bipolar ";
167
+ sourceString += mod.sourceDirection === 0 ? "forwards " : "backwards ";
168
+ if (mod.sourceUsesCC)
153
169
  {
154
- sourceString += getKeyByValue(midiControllers, this.sourceIndex);
170
+ sourceString += getKeyByValue(midiControllers, mod.sourceIndex);
155
171
  }
156
172
  else
157
173
  {
158
- sourceString += getKeyByValue(modulatorSources, this.sourceIndex);
174
+ sourceString += getKeyByValue(modulatorSources, mod.sourceIndex);
159
175
  }
160
176
 
161
- let secSrcString = getKeyByValue(modulatorCurveTypes, this.secSrcCurveType);
162
- secSrcString += this.secSrcPolarity === 0 ? " unipolar " : " bipolar ";
163
- secSrcString += this.secSrcCurveType === 0 ? "forwards " : "backwards ";
164
- if (this.secSrcUsesCC)
177
+ let secSrcString = getKeyByValue(modulatorCurveTypes, mod.secSrcCurveType);
178
+ secSrcString += mod.secSrcPolarity === 0 ? " unipolar " : " bipolar ";
179
+ secSrcString += mod.secSrcCurveType === 0 ? "forwards " : "backwards ";
180
+ if (mod.secSrcUsesCC)
165
181
  {
166
- secSrcString += getKeyByValue(midiControllers, this.secSrcIndex);
182
+ secSrcString += getKeyByValue(midiControllers, mod.secSrcIndex);
167
183
  }
168
184
  else
169
185
  {
170
- secSrcString += getKeyByValue(modulatorSources, this.secSrcIndex);
186
+ secSrcString += getKeyByValue(modulatorSources, mod.secSrcIndex);
171
187
  }
172
188
  return `Modulator:
173
189
  Source: ${sourceString}
174
190
  Secondary source: ${secSrcString}
175
- Destination: ${getKeyByValue(generatorTypes, this.modulatorDestination)}
176
- Trasform amount: ${this.transformAmount}
177
- Transform type: ${this.transformType}
191
+ Destination: ${getKeyByValue(generatorTypes, mod.modulatorDestination)}
192
+ Trasform amount: ${mod.transformAmount}
193
+ Transform type: ${mod.transformType}
178
194
  \n\n`;
179
195
  }
196
+
197
+ /**
198
+ * Sum transform and create a NEW modulator
199
+ * @param modulator {Modulator}
200
+ * @returns {Modulator}
201
+ */
202
+ sumTransform(modulator)
203
+ {
204
+ return new Modulator(
205
+ this.sourceEnum,
206
+ this.secondarySourceEnum,
207
+ this.modulatorDestination,
208
+ this.transformAmount + modulator.transformAmount,
209
+ this.transformType
210
+ );
211
+ }
180
212
  }
181
213
 
182
214
  export const DEFAULT_ATTENUATION_MOD_AMOUNT = 960;
@@ -189,155 +221,155 @@ export function getModSourceEnum(curveType, polarity, direction, isCC, index)
189
221
 
190
222
  const soundFontModulators = [
191
223
  // vel to attenuation
192
- new Modulator({
193
- srcEnum: getModSourceEnum(
224
+ new Modulator(
225
+ getModSourceEnum(
194
226
  DEFAULT_ATTENUATION_MOD_CURVE_TYPE,
195
227
  0,
196
228
  1,
197
229
  0,
198
230
  modulatorSources.noteOnVelocity
199
231
  ),
200
- dest: generatorTypes.initialAttenuation,
201
- amt: DEFAULT_ATTENUATION_MOD_AMOUNT,
202
- secSrcEnum: 0x0,
203
- transform: 0
204
- }),
232
+ 0x0,
233
+ generatorTypes.initialAttenuation,
234
+ DEFAULT_ATTENUATION_MOD_AMOUNT,
235
+ 0
236
+ ),
205
237
 
206
238
  // mod wheel to vibrato
207
- new Modulator({ srcEnum: 0x0081, dest: generatorTypes.vibLfoToPitch, amt: 50, secSrcEnum: 0x0, transform: 0 }),
239
+ new Modulator(0x0081, 0x0, generatorTypes.vibLfoToPitch, 50, 0),
208
240
 
209
241
  // vol to attenuation
210
- new Modulator({
211
- srcEnum: getModSourceEnum(
242
+ new Modulator(
243
+ getModSourceEnum(
212
244
  DEFAULT_ATTENUATION_MOD_CURVE_TYPE,
213
245
  0,
214
246
  1,
215
247
  1,
216
248
  midiControllers.mainVolume
217
249
  ),
218
- dest: generatorTypes.initialAttenuation,
219
- amt: DEFAULT_ATTENUATION_MOD_AMOUNT,
220
- secSrcEnum: 0x0,
221
- transform: 0
222
- }),
250
+ 0x0,
251
+ generatorTypes.initialAttenuation,
252
+ DEFAULT_ATTENUATION_MOD_AMOUNT,
253
+ 0
254
+ ),
223
255
 
224
256
  // channel pressure to vibrato
225
- new Modulator({ srcEnum: 0x000D, dest: generatorTypes.vibLfoToPitch, amt: 50, secSrcEnum: 0x0, transform: 0 }),
257
+ new Modulator(0x000D, 0x0, generatorTypes.vibLfoToPitch, 50, 0),
226
258
 
227
259
  // pitch wheel to tuning
228
- new Modulator({ srcEnum: 0x020E, dest: generatorTypes.fineTune, amt: 12700, secSrcEnum: 0x0010, transform: 0 }),
260
+ new Modulator(0x020E, 0x0010, generatorTypes.fineTune, 12700, 0),
229
261
 
230
262
  // pan to uhh, pan
231
263
  // amount is 500 instead of 1000, see #59
232
- new Modulator({ srcEnum: 0x028A, dest: generatorTypes.pan, amt: 500, secSrcEnum: 0x0, transform: 0 }),
264
+ new Modulator(0x028A, 0x0, generatorTypes.pan, 500, 0),
233
265
 
234
266
  // expression to attenuation
235
- new Modulator({
236
- srcEnum: getModSourceEnum(
267
+ new Modulator(
268
+ getModSourceEnum(
237
269
  DEFAULT_ATTENUATION_MOD_CURVE_TYPE,
238
270
  0,
239
271
  1,
240
272
  1,
241
273
  midiControllers.expressionController
242
274
  ),
243
- dest: generatorTypes.initialAttenuation,
244
- amt: DEFAULT_ATTENUATION_MOD_AMOUNT,
245
- secSrcEnum: 0x0,
246
- transform: 0
247
- }),
275
+ 0x0,
276
+ generatorTypes.initialAttenuation,
277
+ DEFAULT_ATTENUATION_MOD_AMOUNT,
278
+ 0
279
+ ),
248
280
 
249
281
  // reverb effects to send
250
- new Modulator({ srcEnum: 0x00DB, dest: generatorTypes.reverbEffectsSend, amt: 200, secSrcEnum: 0x0, transform: 0 }),
282
+ new Modulator(0x00DB, 0x0, generatorTypes.reverbEffectsSend, 200, 0),
251
283
 
252
284
  // chorus effects to send
253
- new Modulator({ srcEnum: 0x00DD, dest: generatorTypes.chorusEffectsSend, amt: 200, secSrcEnum: 0x0, transform: 0 })
285
+ new Modulator(0x00DD, 0x0, generatorTypes.chorusEffectsSend, 200, 0)
254
286
  ];
255
287
 
256
288
  const customModulators = [
257
289
  // custom modulators heck yeah
258
290
  // poly pressure to vibrato
259
- new Modulator({
260
- srcEnum: getModSourceEnum(modulatorCurveTypes.linear, 0, 0, 0, modulatorSources.polyPressure),
261
- dest: generatorTypes.vibLfoToPitch,
262
- amt: 50,
263
- secSrcEnum: 0x0,
264
- transform: 0
265
- }),
291
+ new Modulator(
292
+ getModSourceEnum(modulatorCurveTypes.linear, 0, 0, 0, modulatorSources.polyPressure),
293
+ 0x0,
294
+ generatorTypes.vibLfoToPitch,
295
+ 50,
296
+ 0
297
+ ),
266
298
 
267
299
  // cc 92 (tremolo) to modLFO volume
268
- new Modulator({
269
- srcEnum: getModSourceEnum(
300
+ new Modulator(
301
+ getModSourceEnum(
270
302
  modulatorCurveTypes.linear,
271
303
  0,
272
304
  0,
273
305
  1,
274
306
  midiControllers.tremoloDepth
275
307
  ), /*linear forward unipolar cc 92 */
276
- dest: generatorTypes.modLfoToVolume,
277
- amt: 24,
278
- secSrcEnum: 0x0, // no controller
279
- transform: 0
280
- }),
308
+ 0x0, // no controller
309
+ generatorTypes.modLfoToVolume,
310
+ 24,
311
+ 0
312
+ ),
281
313
 
282
314
  // cc 73 (attack time) to volEnv attack
283
- new Modulator({
284
- srcEnum: getModSourceEnum(
315
+ new Modulator(
316
+ getModSourceEnum(
285
317
  modulatorCurveTypes.convex,
286
318
  1,
287
319
  0,
288
320
  1,
289
321
  midiControllers.attackTime
290
322
  ), // linear forward bipolar cc 72
291
- dest: generatorTypes.attackVolEnv,
292
- amt: 6000,
293
- secSrcEnum: 0x0, // no controller
294
- transform: 0
295
- }),
323
+ 0x0, // no controller
324
+ generatorTypes.attackVolEnv,
325
+ 6000,
326
+ 0
327
+ ),
296
328
 
297
329
  // cc 72 (release time) to volEnv release
298
- new Modulator({
299
- srcEnum: getModSourceEnum(
330
+ new Modulator(
331
+ getModSourceEnum(
300
332
  modulatorCurveTypes.linear,
301
333
  1,
302
334
  0,
303
335
  1,
304
336
  midiControllers.releaseTime
305
337
  ), // linear forward bipolar cc 72
306
- dest: generatorTypes.releaseVolEnv,
307
- amt: 3600,
308
- secSrcEnum: 0x0, // no controller
309
- transform: 0
310
- }),
338
+ 0x0, // no controller
339
+ generatorTypes.releaseVolEnv,
340
+ 3600,
341
+ 0
342
+ ),
311
343
 
312
344
  // cc 74 (brightness) to filterFc
313
- new Modulator({
314
- srcEnum: getModSourceEnum(
345
+ new Modulator(
346
+ getModSourceEnum(
315
347
  modulatorCurveTypes.linear,
316
348
  1,
317
349
  0,
318
350
  1,
319
351
  midiControllers.brightness
320
352
  ), // linear forwards bipolar cc 74
321
- dest: generatorTypes.initialFilterFc,
322
- amt: 6000,
323
- secSrcEnum: 0x0, // no controller
324
- transform: 0
325
- }),
353
+ 0x0, // no controller
354
+ generatorTypes.initialFilterFc,
355
+ 6000,
356
+ 0
357
+ ),
326
358
 
327
359
  // cc 71 (filter Q) to filter Q
328
- new Modulator({
329
- srcEnum: getModSourceEnum(
360
+ new Modulator(
361
+ getModSourceEnum(
330
362
  modulatorCurveTypes.linear,
331
363
  1,
332
364
  0,
333
365
  1,
334
366
  midiControllers.filterResonance
335
367
  ), // linear forwards bipolar cc 74
336
- dest: generatorTypes.initialFilterQ,
337
- amt: 250,
338
- secSrcEnum: 0x0, // no controller
339
- transform: 0
340
- })
368
+ 0x0, // no controller
369
+ generatorTypes.initialFilterQ,
370
+ 250,
371
+ 0
372
+ )
341
373
  ];
342
374
 
343
375
  export const defaultModulators = soundFontModulators.concat(customModulators);
@@ -384,12 +384,12 @@ export function getSF2ModulatorFromArticulator(
384
384
  }
385
385
 
386
386
  // return the modulator!
387
- return new Modulator({
388
- srcEnum: sourceEnumFinal,
389
- secSrcEnum: secSourceEnumFinal,
390
- dest: destinationGenerator,
391
- transform: 0x0,
392
- amt: newValue
393
- });
387
+ return new Modulator(
388
+ sourceEnumFinal,
389
+ secSourceEnumFinal,
390
+ destinationGenerator,
391
+ newValue,
392
+ 0x0
393
+ );
394
394
 
395
395
  }
@@ -28,34 +28,34 @@ export const DLSSources = {
28
28
  coarseTune: 0x102
29
29
  };
30
30
 
31
- export const DEFAULT_DLS_REVERB = new Modulator({
32
- srcEnum: 0x00DB,
33
- dest: generatorTypes.reverbEffectsSend,
34
- amt: 1000,
35
- secSrcEnum: 0x0,
36
- transform: 0
37
- });
31
+ export const DEFAULT_DLS_REVERB = new Modulator(
32
+ 0x00DB,
33
+ 0x0,
34
+ generatorTypes.reverbEffectsSend,
35
+ 1000,
36
+ 0
37
+ );
38
38
 
39
- export const DEFAULT_DLS_CHORUS = new Modulator({
40
- srcEnum: 0x00DD,
41
- dest: generatorTypes.chorusEffectsSend,
42
- amt: 1000,
43
- secSrcEnum: 0x0,
44
- transform: 0
45
- });
39
+ export const DEFAULT_DLS_CHORUS = new Modulator(
40
+ 0x00DD,
41
+ 0x0,
42
+ generatorTypes.chorusEffectsSend,
43
+ 1000,
44
+ 0
45
+ );
46
46
 
47
- export const DLS_1_NO_VIBRATO_MOD = new Modulator({
48
- srcEnum: 0x0081,
49
- dest: generatorTypes.vibLfoToPitch,
50
- amt: 0,
51
- secSrcEnum: 0x0,
52
- transform: 0
53
- });
47
+ export const DLS_1_NO_VIBRATO_MOD = new Modulator(
48
+ 0x0081,
49
+ 0x0,
50
+ generatorTypes.vibLfoToPitch,
51
+ 0,
52
+ 0
53
+ );
54
54
 
55
- export const DLS_1_NO_VIBRATO_PRESSURE = new Modulator({
56
- srcEnum: 0x000D,
57
- dest: generatorTypes.vibLfoToPitch,
58
- amt: 0,
59
- secSrcEnum: 0x0,
60
- transform: 0
61
- });
55
+ export const DLS_1_NO_VIBRATO_PRESSURE = new Modulator(
56
+ 0x000D,
57
+ 0x0,
58
+ generatorTypes.vibLfoToPitch,
59
+ 0,
60
+ 0
61
+ );
@@ -11,13 +11,12 @@ export class ReadModulator extends Modulator
11
11
  */
12
12
  constructor(dataArray)
13
13
  {
14
- super({
15
- srcEnum: readLittleEndian(dataArray, 2),
16
- dest: readLittleEndian(dataArray, 2),
17
- amt: signedInt16(dataArray[dataArray.currentIndex++], dataArray[dataArray.currentIndex++]),
18
- secSrcEnum: readLittleEndian(dataArray, 2),
19
- transform: readLittleEndian(dataArray, 2)
20
- });
14
+ const srcEnum = readLittleEndian(dataArray, 2);
15
+ const destination = readLittleEndian(dataArray, 2);
16
+ const amount = signedInt16(dataArray[dataArray.currentIndex++], dataArray[dataArray.currentIndex++]);
17
+ const secSrcEnum = readLittleEndian(dataArray, 2);
18
+ const transformType = readLittleEndian(dataArray, 2);
19
+ super(srcEnum, secSrcEnum, destination, amount, transformType);
21
20
  }
22
21
  }
23
22