@kidlib/web-audio 0.1.2 → 0.1.4
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 +2 -0
- package/dist/index.d.ts +29 -7
- package/dist/index.js +208 -176
- package/dist/processors/processors.js +20 -20
- package/package.json +6 -3
package/README.md
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -667,7 +667,7 @@ declare class MacroParam {
|
|
|
667
667
|
protected sendMessage(type: string, data: any): void;
|
|
668
668
|
dispose(): void;
|
|
669
669
|
connect(target: AudioParam, nodeType: NodeType, scaleFactor?: number): this;
|
|
670
|
-
disconnect(target?: AudioParam
|
|
670
|
+
disconnect(target?: AudioParam): void;
|
|
671
671
|
}
|
|
672
672
|
|
|
673
673
|
declare interface Message {
|
|
@@ -788,8 +788,6 @@ declare type RecorderOptions = {
|
|
|
788
788
|
autoStop: boolean;
|
|
789
789
|
stopThreshold: number;
|
|
790
790
|
silenceTimeoutMs: number;
|
|
791
|
-
preprocess: boolean;
|
|
792
|
-
preprocessOptions: object;
|
|
793
791
|
};
|
|
794
792
|
|
|
795
793
|
export declare type RecorderStartOptions = Partial<RecorderOptions> & {
|
|
@@ -817,7 +815,7 @@ declare const ROOT_NOTES: {
|
|
|
817
815
|
};
|
|
818
816
|
|
|
819
817
|
export declare interface SampleLoader {
|
|
820
|
-
loadSample(
|
|
818
|
+
loadSample(buffer: AudioBuffer | ArrayBuffer): Promise<AudioBuffer | null>;
|
|
821
819
|
}
|
|
822
820
|
|
|
823
821
|
export declare class SamplePlayer implements ILibInstrumentNode {
|
|
@@ -825,6 +823,7 @@ export declare class SamplePlayer implements ILibInstrumentNode {
|
|
|
825
823
|
readonly nodeId: NodeID_2;
|
|
826
824
|
readonly nodeType: "sample-player";
|
|
827
825
|
readonly context: AudioContext;
|
|
826
|
+
static readonly MAX_LAYERS = 4;
|
|
828
827
|
randomizeVelocity: boolean;
|
|
829
828
|
voicePool: SampleVoicePool;
|
|
830
829
|
outBus: InstrumentBus;
|
|
@@ -851,7 +850,18 @@ export declare class SamplePlayer implements ILibInstrumentNode {
|
|
|
851
850
|
setModulationWaveform(modType?: "AM" | "FM", waveform?: CustomLibWaveform | OscillatorType | PeriodicWave, customWaveOptions?: WaveformOptions): void;
|
|
852
851
|
syncLFOsToNoteFreq(lfoId: "gain-lfo" | "pitch-lfo", enabled: boolean): void;
|
|
853
852
|
freezeActiveVoices(freeze: boolean): this;
|
|
853
|
+
/**
|
|
854
|
+
* Load a single sample. Equivalent to `loadLayers([buffer])`: any previously
|
|
855
|
+
* loaded extra layers are cleared.
|
|
856
|
+
*/
|
|
854
857
|
loadSample(buffer: AudioBuffer | ArrayBuffer, modSampleRate?: number, preprocessOptions?: Partial<PreProcessOptions>): Promise<AudioBuffer | null>;
|
|
858
|
+
/**
|
|
859
|
+
* Replace the whole layer set. Layers are summed inside the voice worklet at
|
|
860
|
+
* one shared playhead, so they play in unison and layer 0 is the authority
|
|
861
|
+
* for duration, loop points, start/end and zero crossings. Layers shorter
|
|
862
|
+
* than layer 0 fall silent at their own end; longer ones are truncated.
|
|
863
|
+
*/
|
|
864
|
+
loadLayers(buffers: (AudioBuffer | ArrayBuffer)[], modSampleRate?: number, preprocessOptions?: Partial<PreProcessOptions>): Promise<AudioBuffer[] | null>;
|
|
855
865
|
cropSample(startSeconds?: number, endSeconds?: number, fadeMs?: number): Promise<AudioBuffer | null>;
|
|
856
866
|
detectPitch(buffer: AudioBuffer): Promise<{
|
|
857
867
|
frequency: number;
|
|
@@ -906,7 +916,7 @@ export declare class SamplePlayer implements ILibInstrumentNode {
|
|
|
906
916
|
setLoopPoint(loopPoint: "start" | "end", loopStartSeconds: number, loopEndSeconds: number, rampDuration?: number): this;
|
|
907
917
|
scrollLoopPoints(loopStart: number, loopEnd: number): this;
|
|
908
918
|
setParam(name: string, value: number): this;
|
|
909
|
-
applyParams(params:
|
|
919
|
+
applyParams(params: SamplerParams): this;
|
|
910
920
|
/** PARAM GETTERS */
|
|
911
921
|
getAudioParam(name: string): AudioParam | null;
|
|
912
922
|
getStartPoint(): number;
|
|
@@ -956,6 +966,8 @@ export declare class SamplePlayer implements ILibInstrumentNode {
|
|
|
956
966
|
get loopEnd(): number;
|
|
957
967
|
get isLoaded(): boolean;
|
|
958
968
|
get audiobuffer(): AudioBuffer | null;
|
|
969
|
+
/** All loaded layers. Index 0 is the authority layer (=== `audiobuffer`). */
|
|
970
|
+
get layers(): readonly AudioBuffer[];
|
|
959
971
|
dispose(): void;
|
|
960
972
|
}
|
|
961
973
|
|
|
@@ -976,7 +988,10 @@ export declare interface SamplerParamDescriptor {
|
|
|
976
988
|
|
|
977
989
|
export declare type SamplerParamKey = keyof typeof samplerParams;
|
|
978
990
|
|
|
979
|
-
|
|
991
|
+
/** @deprecated Renamed to {@link SamplerParams}. Removed in the next minor. */
|
|
992
|
+
export declare type SamplerParamPatch = SamplerParams;
|
|
993
|
+
|
|
994
|
+
export declare type SamplerParams = Partial<SamplerParamValues>;
|
|
980
995
|
|
|
981
996
|
export declare const samplerParams: Record<"distortion" | "delayTime" | "feedback" | "feedbackDecay" | "drive" | "loopEnd" | "loopStart" | "volume" | "dryWet" | "glide" | "tempo" | "lowpassFilter" | "highpassFilter" | "feedbackPitch" | "feedbackLpf" | "clipping" | "amMod" | "reverbSend" | "reverbSize" | "delaySend" | "delayFeedback" | "gainLFORate" | "gainLFODepth" | "pitchLFORate" | "pitchLFODepth" | "trimStart" | "trimEnd" | "loopDuration" | "loopRampDuration" | "loopDurationDrift" | "keytrackLoop", SamplerParamDescriptor>;
|
|
982
997
|
|
|
@@ -1035,6 +1050,13 @@ declare class SampleVoice {
|
|
|
1035
1050
|
});
|
|
1036
1051
|
init(): Promise<void>;
|
|
1037
1052
|
loadBuffer(buffer: AudioBuffer, zeroCrossings?: number[]): Promise<boolean>;
|
|
1053
|
+
/**
|
|
1054
|
+
* Replace the whole layer set. Layers are summed at one shared playhead, so
|
|
1055
|
+
* layer 0 is the authority for duration and all range math; the rest only
|
|
1056
|
+
* add samples. A layer at the wrong sample rate is dropped on its own,
|
|
1057
|
+
* leaving the others playable, except layer 0: losing it fails the load.
|
|
1058
|
+
*/
|
|
1059
|
+
loadLayers(buffers: AudioBuffer[], zeroCrossings?: number[]): Promise<boolean>;
|
|
1038
1060
|
freeze(freeze: boolean): this;
|
|
1039
1061
|
setGlideTime(seconds: number): void;
|
|
1040
1062
|
trigger(options: {
|
|
@@ -1144,7 +1166,7 @@ declare class SampleVoicePool implements LibNode {
|
|
|
1144
1166
|
disconnect(): void;
|
|
1145
1167
|
onMessage(type: string, handler: MessageHandler<Message>): () => void;
|
|
1146
1168
|
sendUpstreamMessage(type: string, data: any): this;
|
|
1147
|
-
|
|
1169
|
+
setLayers(buffers: AudioBuffer[], zeroCrossings?: number[]): this;
|
|
1148
1170
|
allocate(available?: Set<SampleVoice>, releasing?: Set<SampleVoice>): SampleVoice | undefined;
|
|
1149
1171
|
prevMidiNote: number;
|
|
1150
1172
|
noteOn(midiNote: MidiValue, velocity?: MidiValue, secondsFromNow?: number, glideTime?: number): MidiValue | null;
|