spessasynth_lib 3.20.37 → 3.20.40

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.
@@ -69,6 +69,11 @@ export class Modulator {
69
69
  secSrcUsesCC: number;
70
70
  secSrcIndex: number;
71
71
  secSrcCurveType: number;
72
+ /**
73
+ * The current computed value of this modulator
74
+ * @type {number}
75
+ */
76
+ currentValue: number;
72
77
  /**
73
78
  * Sums transform and creates a NEW modulator
74
79
  * @param modulator {Modulator}
@@ -252,6 +252,13 @@ export class Synthetizer {
252
252
  * @param userChange {boolean} indicates if the program change has been called by user. defaults to false
253
253
  */
254
254
  programChange(channel: number, programNumber: number, userChange?: boolean): void;
255
+ /**
256
+ * Overrides velocity on a given channel
257
+ * @param channel {number} usually 0-15: the channel to change
258
+ * @param velocity {number} 1-127, the velocity to use.
259
+ * 0 Disables this functionality
260
+ */
261
+ velocityOverride(channel: number, velocity: number): void;
255
262
  /**
256
263
  * Causes the given midi channel to ignore controller messages for the given controller number
257
264
  * @param channel {number} usually 0-15: the channel to lock
@@ -9,6 +9,7 @@
9
9
  * @property {Int16Array} keyCentTuning - tuning of individual keys in cents
10
10
  * @property {boolean} holdPedal - indicates whether the hold pedal is active
11
11
  * @property {boolean} drumChannel - indicates whether the channel is a drum channel
12
+ * @property {number} velocityOverride - overrides velocity if > 0 otherwise disabled
12
13
  *
13
14
  * @property {dataEntryStates} dataEntryState - the current state of the data entry
14
15
  * @property {number} NRPCoarse - the current coarse value of the Non-Registered Parameter
@@ -57,6 +58,13 @@ export namespace customControllers {
57
58
  }
58
59
  export const CUSTOM_CONTROLLER_TABLE_SIZE: number;
59
60
  export const customResetArray: Float32Array;
61
+ /**
62
+ * This is a channel configuration enum, it is internally sent from Synthetizer via controller change
63
+ */
64
+ export type channelConfiguration = number;
65
+ export namespace channelConfiguration {
66
+ let velocityOverride: number;
67
+ }
60
68
  export type WorkletProcessorChannel = {
61
69
  /**
62
70
  * - array of MIDI controller values + the values used by modulators as source (pitch bend, bend range etc.)
@@ -90,6 +98,10 @@ export type WorkletProcessorChannel = {
90
98
  * - indicates whether the channel is a drum channel
91
99
  */
92
100
  drumChannel: boolean;
101
+ /**
102
+ * - overrides velocity if > 0 otherwise disabled
103
+ */
104
+ velocityOverride: number;
93
105
  /**
94
106
  * - the current state of the data entry
95
107
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spessasynth_lib",
3
- "version": "3.20.37",
3
+ "version": "3.20.40",
4
4
  "description": "MIDI and SoundFont2/DLS library with no compromises",
5
5
  "browser": "index.js",
6
6
  "types": "@types/index.d.ts",
@@ -84,6 +84,12 @@ export class Modulator{
84
84
  //this.precomputeModulatorTransform();
85
85
  }
86
86
 
87
+ /**
88
+ * The current computed value of this modulator
89
+ * @type {number}
90
+ */
91
+ currentValue = 0;
92
+
87
93
  /**
88
94
  * @param modulator {Modulator}
89
95
  * @returns {Modulator}
@@ -258,6 +264,15 @@ export const defaultModulators = [
258
264
  amt: 4000,
259
265
  secSrcEnum: 0x0, // no controller
260
266
  transform: 0
267
+ }),
268
+
269
+ // cc 71 (filter q) to filterq
270
+ new Modulator({
271
+ srcEnum: getModSourceEnum(modulatorCurveTypes.linear, 1, 0 , 1, midiControllers.timbreHarmonicContent), // linear forwards bipolar cc 74
272
+ dest: generatorTypes.initialFilterQ,
273
+ amt: 250,
274
+ secSrcEnum: 0x0, // no controller
275
+ transform: 0
261
276
  })
262
277
  ];
263
278
 
@@ -12,6 +12,7 @@ import {
12
12
  import { SpessaSynthInfo, SpessaSynthWarn } from '../utils/loggin.js'
13
13
  import { DEFAULT_EFFECTS_CONFIG } from './audio_effects/effects_config.js'
14
14
  import { SoundfontManager } from './synth_soundfont_manager.js'
15
+ import { channelConfiguration } from './worklet_system/worklet_utilities/worklet_processor_channel.js'
15
16
 
16
17
 
17
18
  /**
@@ -484,6 +485,7 @@ export class Synthetizer {
484
485
  */
485
486
  controllerChange(channel, controllerNumber, controllerValue, force=false)
486
487
  {
488
+ if(controllerNumber > 127 || controllerNumber < 0) throw new Error(`Invalid controller number: ${controllerNumber}`);
487
489
  controllerValue = Math.floor(controllerValue);
488
490
  controllerNumber = Math.floor(controllerNumber);
489
491
  this.post({
@@ -631,6 +633,21 @@ export class Synthetizer {
631
633
  })
632
634
  }
633
635
 
636
+ /**
637
+ * Overrides velocity on a given channel
638
+ * @param channel {number} usually 0-15: the channel to change
639
+ * @param velocity {number} 1-127, the velocity to use.
640
+ * 0 Disables this functionality
641
+ */
642
+ velocityOverride(channel, velocity)
643
+ {
644
+ this.post({
645
+ channelNumber: channel,
646
+ messageType: workletMessageType.ccChange,
647
+ messageData: [channelConfiguration.velocityOverride, velocity, true]
648
+ })
649
+ }
650
+
634
651
  /**
635
652
  * Causes the given midi channel to ignore controller messages for the given controller number
636
653
  * @param channel {number} usually 0-15: the channel to lock