@kidlib/web-audio 0.1.0 → 0.1.2
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 +9 -4
- package/dist/components.d.ts +2 -2
- package/dist/components.js +254 -396
- package/dist/index.d.ts +50 -50
- package/dist/index.js +4948 -7455
- package/dist/io.d.ts +11 -11
- package/dist/io.js +129 -191
- package/dist/keymap-C9_BObLQ.js +239 -0
- package/dist/processors/processors.js +1464 -1612
- package/package.json +25 -34
- package/dist/keymap-3lZMR1Ak.js +0 -167
package/dist/index.d.ts
CHANGED
|
@@ -12,9 +12,9 @@ declare const AudioRecorderState: {
|
|
|
12
12
|
|
|
13
13
|
declare type AudioRecorderState = (typeof AudioRecorderState)[keyof typeof AudioRecorderState];
|
|
14
14
|
|
|
15
|
-
declare type BaseNodeType =
|
|
15
|
+
declare type BaseNodeType = "instrument" | "voice" | "fx" | "param" | "container" | "recorder" | "audiograph";
|
|
16
16
|
|
|
17
|
-
declare type BusNodeName =
|
|
17
|
+
declare type BusNodeName = "input" | "output" | "dryMix" | "wetMix" | "hpf" | "lpf" | "distortion" | "feedback" | "reverb" | "compressor" | "limiter" | "delay";
|
|
18
18
|
|
|
19
19
|
declare type BusNodeTypeMap = {
|
|
20
20
|
input: ILibAudioNode<GainNode>;
|
|
@@ -36,7 +36,7 @@ declare type BusSendName = `${BusNodeName}_send`;
|
|
|
36
36
|
/** False in Safari — AudioContext.setSinkId is Chromium/Firefox only */
|
|
37
37
|
export declare function canSetOutputDevice(): boolean;
|
|
38
38
|
|
|
39
|
-
declare type ContainerType =
|
|
39
|
+
declare type ContainerType = "pool" | "chain" | "audiolib";
|
|
40
40
|
|
|
41
41
|
/**
|
|
42
42
|
* Creates and initializes a new audio recorder
|
|
@@ -49,12 +49,12 @@ export declare function createAudioRecorder(context?: AudioContext): Promise<Rec
|
|
|
49
49
|
/**
|
|
50
50
|
* Creates a new SamplePlayer instance
|
|
51
51
|
*
|
|
52
|
-
* @param buffer -
|
|
52
|
+
* @param buffer - Audio buffer data to use for the player
|
|
53
53
|
* @param polyphony - Number of voices for polyphony (default: 16)
|
|
54
54
|
* @param context - Optional AudioContext (will use global context if not provided)
|
|
55
55
|
* @returns A new SamplePlayer instance
|
|
56
56
|
*/
|
|
57
|
-
export declare function createSamplePlayer(buffer
|
|
57
|
+
export declare function createSamplePlayer(buffer: AudioBuffer | ArrayBuffer, polyphony?: number, context?: AudioContext): Promise<SamplePlayer>;
|
|
58
58
|
|
|
59
59
|
/** Custom Audiolib waveform */
|
|
60
60
|
declare const CUSTOM_WAVEFORMS: readonly ["pulse", "bandlimited-sawtooth", "supersaw", "warm-pad", "metallic", "formant", "white-noise", "pink-noise", "brown-noise", "colored-noise", "random-harmonic", "custom-function"];
|
|
@@ -144,7 +144,7 @@ export declare class CustomEnvelope implements LibNode {
|
|
|
144
144
|
dispose(): void;
|
|
145
145
|
}
|
|
146
146
|
|
|
147
|
-
declare type CustomFxType =
|
|
147
|
+
declare type CustomFxType = "feedback-delay" | "harmonic-feedback" | "distortion" | "dattorro-reverb";
|
|
148
148
|
|
|
149
149
|
declare type CustomLibWaveform = (typeof CUSTOM_WAVEFORMS)[number];
|
|
150
150
|
|
|
@@ -222,7 +222,7 @@ declare class DattorroReverb implements ILibAudioNode {
|
|
|
222
222
|
setParam(name: string, value: number, time?: number): void;
|
|
223
223
|
getAudioParam(name: string): AudioParam | null;
|
|
224
224
|
setAmountMacro(amount: number): void;
|
|
225
|
-
setPreset(preset?:
|
|
225
|
+
setPreset(preset?: "room" | "church" | "freeze" | "ether" | "default", rampTime?: number): void;
|
|
226
226
|
/**
|
|
227
227
|
DIFFUSION PARAMETER (0.0 - 1.0, default: 0.7)
|
|
228
228
|
Controls reverb density and scatter. Higher = more complex tail.
|
|
@@ -273,7 +273,7 @@ declare interface DefaultWorkletConfig extends WorkletConfig {
|
|
|
273
273
|
message: WorkletMessage;
|
|
274
274
|
}
|
|
275
275
|
|
|
276
|
-
declare type DelayCharacter =
|
|
276
|
+
declare type DelayCharacter = "clean" | "bitCrushed" | "filtered";
|
|
277
277
|
|
|
278
278
|
declare type DelayConfig = {
|
|
279
279
|
params: DelayParams;
|
|
@@ -297,8 +297,8 @@ declare type DistortionConfig = {
|
|
|
297
297
|
};
|
|
298
298
|
|
|
299
299
|
declare type DistortionMsg = {
|
|
300
|
-
type:
|
|
301
|
-
mode:
|
|
300
|
+
type: "setLimitingMode";
|
|
301
|
+
mode: "soft-clipping" | "hard-clipping";
|
|
302
302
|
};
|
|
303
303
|
|
|
304
304
|
declare type DistortionParams = {
|
|
@@ -315,7 +315,7 @@ export declare class EnvelopeData {
|
|
|
315
315
|
#private;
|
|
316
316
|
points: EnvelopePoint[];
|
|
317
317
|
constructor(points: EnvelopePoint[] | undefined, valueRange: [number, number] | undefined, durationSeconds: number, sustainIdx?: number, releaseIdx?: number);
|
|
318
|
-
addPoint(time: number, value: number, curve?:
|
|
318
|
+
addPoint(time: number, value: number, curve?: "linear" | "exponential"): void;
|
|
319
319
|
updatePoint(index: number, time?: number, value?: number): void;
|
|
320
320
|
updateStartPoint: (time?: number, value?: number) => void;
|
|
321
321
|
updateEndPoint: (time?: number, value?: number) => void;
|
|
@@ -339,10 +339,10 @@ export declare class EnvelopeData {
|
|
|
339
339
|
export declare type EnvelopePoint = {
|
|
340
340
|
time: number;
|
|
341
341
|
value: number;
|
|
342
|
-
curve?:
|
|
342
|
+
curve?: "linear" | "exponential";
|
|
343
343
|
};
|
|
344
344
|
|
|
345
|
-
export declare type EnvelopeType =
|
|
345
|
+
export declare type EnvelopeType = "amp-env" | "pitch-env" | "filter-env" | "loop-env" | "default-env";
|
|
346
346
|
|
|
347
347
|
declare type FbDelayConfig = {
|
|
348
348
|
params: FbDelayParams;
|
|
@@ -350,14 +350,14 @@ declare type FbDelayConfig = {
|
|
|
350
350
|
};
|
|
351
351
|
|
|
352
352
|
declare type FbDelayMsg = {
|
|
353
|
-
type:
|
|
353
|
+
type: "setAutoGain";
|
|
354
354
|
enabled: boolean;
|
|
355
355
|
amount: number;
|
|
356
356
|
} | {
|
|
357
|
-
type:
|
|
357
|
+
type: "triggerDecay";
|
|
358
358
|
baseFeedbackAmount: number;
|
|
359
359
|
} | {
|
|
360
|
-
type:
|
|
360
|
+
type: "stopDecay";
|
|
361
361
|
};
|
|
362
362
|
|
|
363
363
|
declare type FbDelayParams = {
|
|
@@ -495,13 +495,13 @@ declare class InstrumentBus implements ILibAudioNode {
|
|
|
495
495
|
/**
|
|
496
496
|
* Set the character modes for the delay processor, in the order in which to process (e.g. ['filtered', 'bitCrushed'])
|
|
497
497
|
*/
|
|
498
|
-
setDelayCharacter(modes: Array<
|
|
498
|
+
setDelayCharacter(modes: Array<"clean" | "bitCrushed" | "filtered">): this;
|
|
499
499
|
setReverbSize(amount: number): this;
|
|
500
500
|
setReverbDecay(decay: number): this;
|
|
501
501
|
setDistortionMacro(amount: number): void;
|
|
502
502
|
setDrive(amount: number): this;
|
|
503
503
|
setClippingMacro(amount: number): this;
|
|
504
|
-
setClippingMode(mode:
|
|
504
|
+
setClippingMode(mode: "soft-clipping" | "hard-clipping"): void;
|
|
505
505
|
setFeedbackAmount(amount: number): this;
|
|
506
506
|
setFeedbackPitchScale(value: number): this;
|
|
507
507
|
setFeedbackDecay(amount: number): this;
|
|
@@ -551,11 +551,11 @@ declare class InstrumentBus implements ILibAudioNode {
|
|
|
551
551
|
onMessage(type: string, handler: MessageHandler<Message>): () => void;
|
|
552
552
|
}
|
|
553
553
|
|
|
554
|
-
declare type InstrumentType =
|
|
554
|
+
declare type InstrumentType = "sample-player" | "synth";
|
|
555
555
|
|
|
556
556
|
export declare type KeyMap = Record<string, number>;
|
|
557
557
|
|
|
558
|
-
export declare type KeymapKey =
|
|
558
|
+
export declare type KeymapKey = "piano" | "major" | "minor" | "pentatonic" | "chromatic";
|
|
559
559
|
|
|
560
560
|
export declare const keymaps: Record<KeymapKey, KeyMap>;
|
|
561
561
|
|
|
@@ -629,7 +629,7 @@ declare class MacroParam {
|
|
|
629
629
|
init(): Promise<void>;
|
|
630
630
|
addTarget(targetParam: AudioParam, paramType: string, scaleFactor?: number): this;
|
|
631
631
|
ramp(targetValue: number, duration: number, constant: number, options?: {
|
|
632
|
-
method?:
|
|
632
|
+
method?: "exponential" | "linear";
|
|
633
633
|
debounceMs?: number;
|
|
634
634
|
onComplete?: () => void;
|
|
635
635
|
onCompleteDelayMs?: number;
|
|
@@ -678,7 +678,7 @@ declare interface Message {
|
|
|
678
678
|
|
|
679
679
|
declare type MessageHandler<T> = (data: T) => void;
|
|
680
680
|
|
|
681
|
-
declare type NativeAudioNode =
|
|
681
|
+
declare type NativeAudioNode = "AudioWorkletNode" | "GainNode" | "BiquadFilterNode" | "AudioBufferSourceNode" | "DynamicsCompressorNode";
|
|
682
682
|
|
|
683
683
|
declare type NodeID_2 = string;
|
|
684
684
|
|
|
@@ -772,12 +772,12 @@ export declare class Recorder implements LibNode {
|
|
|
772
772
|
}
|
|
773
773
|
|
|
774
774
|
export declare type RecorderInput = {
|
|
775
|
-
type:
|
|
775
|
+
type: "microphone";
|
|
776
776
|
deviceId?: string;
|
|
777
777
|
} | {
|
|
778
|
-
type:
|
|
778
|
+
type: "display";
|
|
779
779
|
} | {
|
|
780
|
-
type:
|
|
780
|
+
type: "audio-node";
|
|
781
781
|
node: AudioNode;
|
|
782
782
|
};
|
|
783
783
|
|
|
@@ -798,20 +798,20 @@ export declare type RecorderStartOptions = Partial<RecorderOptions> & {
|
|
|
798
798
|
|
|
799
799
|
declare const ROOT_NOTES: {
|
|
800
800
|
readonly C: 0;
|
|
801
|
-
readonly
|
|
801
|
+
readonly "C#": 1;
|
|
802
802
|
readonly Db: 1;
|
|
803
803
|
readonly D: 2;
|
|
804
|
-
readonly
|
|
804
|
+
readonly "D#": 3;
|
|
805
805
|
readonly Eb: 3;
|
|
806
806
|
readonly E: 4;
|
|
807
807
|
readonly F: 5;
|
|
808
|
-
readonly
|
|
808
|
+
readonly "F#": 6;
|
|
809
809
|
readonly Gb: 6;
|
|
810
810
|
readonly G: 7;
|
|
811
|
-
readonly
|
|
811
|
+
readonly "G#": 8;
|
|
812
812
|
readonly Ab: 8;
|
|
813
813
|
readonly A: 9;
|
|
814
|
-
readonly
|
|
814
|
+
readonly "A#": 10;
|
|
815
815
|
readonly Bb: 10;
|
|
816
816
|
readonly B: 11;
|
|
817
817
|
};
|
|
@@ -845,11 +845,11 @@ export declare class SamplePlayer implements ILibInstrumentNode {
|
|
|
845
845
|
get output(): GainNode;
|
|
846
846
|
get now(): number;
|
|
847
847
|
get initialized(): boolean;
|
|
848
|
-
getMacrosAudioParam(paramName:
|
|
849
|
-
getMacro(paramName:
|
|
848
|
+
getMacrosAudioParam(paramName: "loopStart" | "loopEnd"): AudioParam;
|
|
849
|
+
getMacro(paramName: "loopStart" | "loopEnd"): MacroParam;
|
|
850
850
|
setModulationAmount: (modType: "AM" | "FM", amount: number) => void;
|
|
851
|
-
setModulationWaveform(modType?:
|
|
852
|
-
syncLFOsToNoteFreq(lfoId:
|
|
851
|
+
setModulationWaveform(modType?: "AM" | "FM", waveform?: CustomLibWaveform | OscillatorType | PeriodicWave, customWaveOptions?: WaveformOptions): void;
|
|
852
|
+
syncLFOsToNoteFreq(lfoId: "gain-lfo" | "pitch-lfo", enabled: boolean): void;
|
|
853
853
|
freezeActiveVoices(freeze: boolean): this;
|
|
854
854
|
loadSample(buffer: AudioBuffer | ArrayBuffer, modSampleRate?: number, preprocessOptions?: Partial<PreProcessOptions>): Promise<AudioBuffer | null>;
|
|
855
855
|
cropSample(startSeconds?: number, endSeconds?: number, fadeMs?: number): Promise<AudioBuffer | null>;
|
|
@@ -888,7 +888,7 @@ export declare class SamplePlayer implements ILibInstrumentNode {
|
|
|
888
888
|
setSustainPedal(pressed: boolean): this;
|
|
889
889
|
sustainPedalOn: () => this;
|
|
890
890
|
sustainPedalOff: () => this;
|
|
891
|
-
setPlaybackDirection(direction:
|
|
891
|
+
setPlaybackDirection(direction: "forward" | "reverse"): this;
|
|
892
892
|
setLoopDurationDriftAmount(amount: number): this;
|
|
893
893
|
setPanDriftEnabled: (enabled: boolean) => this;
|
|
894
894
|
setTimestretchEnabled: (enabled: boolean) => this;
|
|
@@ -903,7 +903,7 @@ export declare class SamplePlayer implements ILibInstrumentNode {
|
|
|
903
903
|
setKeytrackLoopAmount(amount: number): this;
|
|
904
904
|
getKeytrackLoopAmount: () => number;
|
|
905
905
|
get tempo(): number;
|
|
906
|
-
setLoopPoint(loopPoint:
|
|
906
|
+
setLoopPoint(loopPoint: "start" | "end", loopStartSeconds: number, loopEndSeconds: number, rampDuration?: number): this;
|
|
907
907
|
scrollLoopPoints(loopStart: number, loopEnd: number): this;
|
|
908
908
|
setParam(name: string, value: number): this;
|
|
909
909
|
applyParams(params: SamplerParamPatch): this;
|
|
@@ -941,7 +941,7 @@ export declare class SamplePlayer implements ILibInstrumentNode {
|
|
|
941
941
|
setFeedbackDecay(value: number): void;
|
|
942
942
|
setFeedbackLowpassCutoff(freqHz: number): void;
|
|
943
943
|
setFeedbackAmount: (amount: number) => void;
|
|
944
|
-
setFeedbackMode(mode:
|
|
944
|
+
setFeedbackMode(mode: "monophonic" | "polyphonic" | "double-trouble"): void;
|
|
945
945
|
setFeedbackPitchScale(value: number): void;
|
|
946
946
|
get mainOut(): GainNode;
|
|
947
947
|
get outputBus(): InstrumentBus;
|
|
@@ -1052,8 +1052,8 @@ declare class SampleVoice {
|
|
|
1052
1052
|
secondsFromNow?: number | undefined;
|
|
1053
1053
|
}): this;
|
|
1054
1054
|
stop(timestamp?: number): this;
|
|
1055
|
-
setModulationAmount(modType:
|
|
1056
|
-
setModulationWaveform(modType?:
|
|
1055
|
+
setModulationAmount(modType: "AM" | "FM", amount: number): this;
|
|
1056
|
+
setModulationWaveform(modType?: "AM" | "FM", waveform?: CustomLibWaveform | OscillatorType | PeriodicWave, customWaveOptions?: WaveformOptions): this;
|
|
1057
1057
|
enableEnvelope: (envType: EnvelopeType) => void;
|
|
1058
1058
|
disableEnvelope: (envType: EnvelopeType) => void;
|
|
1059
1059
|
setEnvelopeTimeScale: (envType: EnvelopeType, timeScale: number) => void;
|
|
@@ -1125,7 +1125,7 @@ declare class SampleVoice {
|
|
|
1125
1125
|
glideTime?: number;
|
|
1126
1126
|
cancelPrevious?: boolean;
|
|
1127
1127
|
}): this;
|
|
1128
|
-
setPlaybackDirection(direction:
|
|
1128
|
+
setPlaybackDirection(direction: "forward" | "reverse"): this;
|
|
1129
1129
|
setLoopDurationDriftAmount(amount: number): this;
|
|
1130
1130
|
setPanDriftEnabled: (enabled: boolean) => this;
|
|
1131
1131
|
setTimestretchEnabled: (enabled: boolean) => this;
|
|
@@ -1190,7 +1190,7 @@ declare const SCALE_PATTERNS: {
|
|
|
1190
1190
|
export declare function setAudioOutputDevice(deviceId: string): Promise<void>;
|
|
1191
1191
|
|
|
1192
1192
|
declare type SetDelayCharacterMsg = {
|
|
1193
|
-
type:
|
|
1193
|
+
type: "setCharacter";
|
|
1194
1194
|
modes: DelayCharacter[];
|
|
1195
1195
|
};
|
|
1196
1196
|
|
|
@@ -1198,10 +1198,10 @@ declare type SetDelayCharacterMsg = {
|
|
|
1198
1198
|
export declare const SUPPORTED_WAVEFORMS: readonly SupportedWaveform[];
|
|
1199
1199
|
|
|
1200
1200
|
/** Union type of all supported waveforms */
|
|
1201
|
-
export declare type SupportedWaveform =
|
|
1201
|
+
export declare type SupportedWaveform = "sine" | "sawtooth" | "square" | "triangle" | CustomLibWaveform;
|
|
1202
1202
|
|
|
1203
1203
|
declare type TriggerDelayMsg = {
|
|
1204
|
-
type:
|
|
1204
|
+
type: "trigger";
|
|
1205
1205
|
};
|
|
1206
1206
|
|
|
1207
1207
|
declare class ValueSnapper {
|
|
@@ -1210,8 +1210,8 @@ declare class ValueSnapper {
|
|
|
1210
1210
|
setScale(rootNote: keyof typeof ROOT_NOTES, scalePattern: readonly number[] | number[], tuningOffset: number | undefined, // in semitones
|
|
1211
1211
|
lowestOctave: number | undefined, highestOctave: number | undefined, normalize: NormalizeOptions | false, snapToZeroCrossings?: number[] | false): number[];
|
|
1212
1212
|
setRootNote(rootNote: keyof typeof ROOT_NOTES): void;
|
|
1213
|
-
setAllowedPeriods(periods: number[], normalize: NormalizeOptions | false, snapToZeroCrossings?: number[] | false, direction?:
|
|
1214
|
-
snapToValue(target: number, allowedValues?: number[], tolerance?: number, preferDirection?:
|
|
1213
|
+
setAllowedPeriods(periods: number[], normalize: NormalizeOptions | false, snapToZeroCrossings?: number[] | false, direction?: "left" | "right" | "any"): number[];
|
|
1214
|
+
snapToValue(target: number, allowedValues?: number[], tolerance?: number, preferDirection?: "left" | "right" | "any"): number;
|
|
1215
1215
|
snapToMusicalPeriod(targetPeriod: number, allowedPeriods?: number[]): number;
|
|
1216
1216
|
setAllowedValues(values: number[], normalize: NormalizeOptions | false): number[];
|
|
1217
1217
|
get rootNote(): "C" | "C#" | "Db" | "D" | "D#" | "Eb" | "E" | "F" | "F#" | "Gb" | "G" | "G#" | "Ab" | "A" | "A#" | "Bb" | "B";
|
|
@@ -1234,7 +1234,7 @@ declare const VoiceState: {
|
|
|
1234
1234
|
|
|
1235
1235
|
declare type VoiceState = (typeof VoiceState)[keyof typeof VoiceState];
|
|
1236
1236
|
|
|
1237
|
-
declare type VoiceType =
|
|
1237
|
+
declare type VoiceType = "sample-voice" | "karplus-strong-voice" | "osc-voice" | "noise-voice";
|
|
1238
1238
|
|
|
1239
1239
|
/**
|
|
1240
1240
|
* Generic options interface that can be used with any CustomLibWaveform type
|
|
@@ -1268,11 +1268,11 @@ declare class WorkletNode<TConfig extends WorkletConfig = DefaultWorkletConfig>
|
|
|
1268
1268
|
private _processorReady;
|
|
1269
1269
|
private _messageQueue;
|
|
1270
1270
|
constructor(audioContext: AudioContext, processorName: string, options?: AudioWorkletNodeOptions);
|
|
1271
|
-
setParam<K extends keyof TConfig[
|
|
1272
|
-
getParam<K extends keyof TConfig[
|
|
1273
|
-
sendProcessorMessage(message: TConfig[
|
|
1271
|
+
setParam<K extends keyof TConfig["params"]>(name: K, value: TConfig["params"][K]): this;
|
|
1272
|
+
getParam<K extends keyof TConfig["params"]>(name: K): AudioParam | undefined;
|
|
1273
|
+
sendProcessorMessage(message: TConfig["message"]): this;
|
|
1274
1274
|
private _onProcessorMessage?;
|
|
1275
|
-
onProcessorMessage(callback: (event: MessageEvent<TConfig[
|
|
1275
|
+
onProcessorMessage(callback: (event: MessageEvent<TConfig["message"]>) => void): this;
|
|
1276
1276
|
dispose(): void;
|
|
1277
1277
|
}
|
|
1278
1278
|
|