@libraz/libsonare 1.2.0 → 1.2.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/dist/index.d.ts +41 -1
- package/dist/index.js +43 -0
- package/dist/index.js.map +1 -1
- package/dist/sonare.wasm +0 -0
- package/dist/worklet.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +65 -0
- package/src/public_types.ts +10 -0
- package/src/sonare.js.d.ts +13 -0
- package/src/wasm_types.ts +11 -0
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -66,6 +66,7 @@ import type {
|
|
|
66
66
|
StftResult,
|
|
67
67
|
StreamingEqualizerConfig,
|
|
68
68
|
StreamingPlatform,
|
|
69
|
+
StreamingRetuneConfig,
|
|
69
70
|
TempogramMode,
|
|
70
71
|
} from './public_types';
|
|
71
72
|
import { KeyProfile as KeyProfileValues, Mode, PitchClass } from './public_types';
|
|
@@ -162,6 +163,7 @@ export type {
|
|
|
162
163
|
StftResult,
|
|
163
164
|
StreamingEqualizerConfig,
|
|
164
165
|
StreamingPlatform,
|
|
166
|
+
StreamingRetuneConfig,
|
|
165
167
|
Timbre,
|
|
166
168
|
TimeSignature,
|
|
167
169
|
} from './public_types';
|
|
@@ -1683,6 +1685,69 @@ export class StreamingEqualizer {
|
|
|
1683
1685
|
}
|
|
1684
1686
|
}
|
|
1685
1687
|
|
|
1688
|
+
// ============================================================================
|
|
1689
|
+
// StreamingRetune Class
|
|
1690
|
+
// ============================================================================
|
|
1691
|
+
|
|
1692
|
+
/**
|
|
1693
|
+
* Block-by-block mono voice retune / pitch shifter.
|
|
1694
|
+
*
|
|
1695
|
+
* State is maintained across {@link processMono} calls. Call {@link prepare}
|
|
1696
|
+
* before processing, and call {@link delete} (or use `try/finally`) to release
|
|
1697
|
+
* the underlying WASM object.
|
|
1698
|
+
*/
|
|
1699
|
+
export class StreamingRetune {
|
|
1700
|
+
private retune: import('./wasm_types').WasmStreamingRetune;
|
|
1701
|
+
|
|
1702
|
+
constructor(config: StreamingRetuneConfig = {}) {
|
|
1703
|
+
if (!module) {
|
|
1704
|
+
throw new Error('Module not initialized. Call init() first.');
|
|
1705
|
+
}
|
|
1706
|
+
this.retune = module.createStreamingRetune(config as Record<string, unknown>);
|
|
1707
|
+
}
|
|
1708
|
+
|
|
1709
|
+
/**
|
|
1710
|
+
* Allocate and initialize native state for the given sample rate and maximum
|
|
1711
|
+
* process block size.
|
|
1712
|
+
*/
|
|
1713
|
+
prepare(sampleRate: number, maxBlockSize: number): void {
|
|
1714
|
+
this.retune.prepare(sampleRate, maxBlockSize);
|
|
1715
|
+
}
|
|
1716
|
+
|
|
1717
|
+
/** Reset delay, grain, and overlap-add state without changing config. */
|
|
1718
|
+
reset(): void {
|
|
1719
|
+
this.retune.reset();
|
|
1720
|
+
}
|
|
1721
|
+
|
|
1722
|
+
/**
|
|
1723
|
+
* Update retune settings. Changing `grainSize` takes effect after the next
|
|
1724
|
+
* {@link prepare} call.
|
|
1725
|
+
*/
|
|
1726
|
+
setConfig(config: StreamingRetuneConfig): void {
|
|
1727
|
+
this.retune.setConfig(config as Record<string, unknown>);
|
|
1728
|
+
}
|
|
1729
|
+
|
|
1730
|
+
/** Current native config. */
|
|
1731
|
+
config(): Required<StreamingRetuneConfig> {
|
|
1732
|
+
return this.retune.config();
|
|
1733
|
+
}
|
|
1734
|
+
|
|
1735
|
+
/** Resolved grain size in samples after {@link prepare}. */
|
|
1736
|
+
grainSize(): number {
|
|
1737
|
+
return this.retune.grainSize();
|
|
1738
|
+
}
|
|
1739
|
+
|
|
1740
|
+
/** Process one mono block, returning the shifted samples (same length). */
|
|
1741
|
+
processMono(samples: Float32Array): Float32Array {
|
|
1742
|
+
return this.retune.processMono(samples);
|
|
1743
|
+
}
|
|
1744
|
+
|
|
1745
|
+
/** Release the underlying WASM object. Safe to call only once. */
|
|
1746
|
+
delete(): void {
|
|
1747
|
+
this.retune.delete();
|
|
1748
|
+
}
|
|
1749
|
+
}
|
|
1750
|
+
|
|
1686
1751
|
// ============================================================================
|
|
1687
1752
|
// Mixer Class (scene-based persistent mixer)
|
|
1688
1753
|
// ============================================================================
|
package/src/public_types.ts
CHANGED
|
@@ -845,6 +845,16 @@ export interface StreamingEqualizerConfig {
|
|
|
845
845
|
maxBlockSize?: number;
|
|
846
846
|
}
|
|
847
847
|
|
|
848
|
+
/** Configuration for {@link StreamingRetune}. */
|
|
849
|
+
export interface StreamingRetuneConfig {
|
|
850
|
+
/** Pitch shift in semitones, clamped by the native processor to +/-24. */
|
|
851
|
+
semitones?: number;
|
|
852
|
+
/** Wet/dry mix, clamped by the native processor to 0..1. */
|
|
853
|
+
mix?: number;
|
|
854
|
+
/** Grain size in samples. Use 0/omit to derive it from the sample rate. */
|
|
855
|
+
grainSize?: number;
|
|
856
|
+
}
|
|
857
|
+
|
|
848
858
|
/** Options for {@link StreamingEqualizer.match}. */
|
|
849
859
|
export interface EqMatchOptions {
|
|
850
860
|
sampleRate?: number;
|
package/src/sonare.js.d.ts
CHANGED
|
@@ -1081,6 +1081,9 @@ interface SonareModule {
|
|
|
1081
1081
|
// Streaming - StreamingEqualizer
|
|
1082
1082
|
createEqualizer: (config: Record<string, unknown>) => WasmStreamingEqualizer;
|
|
1083
1083
|
|
|
1084
|
+
// Streaming - StreamingRetune
|
|
1085
|
+
createStreamingRetune: (config: Record<string, unknown>) => WasmStreamingRetune;
|
|
1086
|
+
|
|
1084
1087
|
// Mixing - scene-based Mixer
|
|
1085
1088
|
createMixerFromSceneJson: (json: string, sampleRate: number, blockSize: number) => WasmMixer;
|
|
1086
1089
|
mixerPresetJson: (presetName: string) => string;
|
|
@@ -1133,6 +1136,16 @@ interface WasmStreamingEqualizer {
|
|
|
1133
1136
|
delete: () => void;
|
|
1134
1137
|
}
|
|
1135
1138
|
|
|
1139
|
+
interface WasmStreamingRetune {
|
|
1140
|
+
prepare: (sampleRate: number, maxBlockSize: number) => void;
|
|
1141
|
+
reset: () => void;
|
|
1142
|
+
setConfig: (config: Record<string, unknown>) => void;
|
|
1143
|
+
config: () => { semitones: number; mix: number; grainSize: number };
|
|
1144
|
+
grainSize: () => number;
|
|
1145
|
+
processMono: (samples: Float32Array) => Float32Array;
|
|
1146
|
+
delete: () => void;
|
|
1147
|
+
}
|
|
1148
|
+
|
|
1136
1149
|
interface WasmMixer {
|
|
1137
1150
|
compile: () => void;
|
|
1138
1151
|
processStereo: (
|
package/src/wasm_types.ts
CHANGED
|
@@ -426,6 +426,16 @@ export interface WasmStreamingEqualizer {
|
|
|
426
426
|
delete: () => void;
|
|
427
427
|
}
|
|
428
428
|
|
|
429
|
+
export interface WasmStreamingRetune {
|
|
430
|
+
prepare: (sampleRate: number, maxBlockSize: number) => void;
|
|
431
|
+
reset: () => void;
|
|
432
|
+
setConfig: (config: Record<string, unknown>) => void;
|
|
433
|
+
config: () => { semitones: number; mix: number; grainSize: number };
|
|
434
|
+
grainSize: () => number;
|
|
435
|
+
processMono: (samples: Float32Array) => Float32Array;
|
|
436
|
+
delete: () => void;
|
|
437
|
+
}
|
|
438
|
+
|
|
429
439
|
export interface WasmEngineClip {
|
|
430
440
|
id?: number;
|
|
431
441
|
channels: Float32Array[];
|
|
@@ -1243,6 +1253,7 @@ export interface SonareModule {
|
|
|
1243
1253
|
|
|
1244
1254
|
createStreamingMasteringChain: (config: Record<string, unknown>) => WasmStreamingMasteringChain;
|
|
1245
1255
|
createEqualizer: (config: Record<string, unknown>) => WasmStreamingEqualizer;
|
|
1256
|
+
createStreamingRetune: (config: Record<string, unknown>) => WasmStreamingRetune;
|
|
1246
1257
|
createMixerFromSceneJson: (json: string, sampleRate: number, blockSize: number) => WasmMixer;
|
|
1247
1258
|
mixerPresetJson: (presetName: string) => string;
|
|
1248
1259
|
}
|