@libraz/libsonare 1.2.3 → 1.3.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.
Files changed (43) hide show
  1. package/README.md +38 -1
  2. package/dist/index.d.ts +1 -2842
  3. package/dist/index.js +3667 -1984
  4. package/dist/index.js.map +1 -1
  5. package/dist/sonare-rt-module.js +1 -1
  6. package/dist/sonare-rt.js +1 -1
  7. package/dist/sonare-rt.wasm +0 -0
  8. package/dist/sonare.js +1 -1
  9. package/dist/sonare.wasm +0 -0
  10. package/dist/worklet.d.ts +4816 -483
  11. package/dist/worklet.js +747 -440
  12. package/dist/worklet.js.map +1 -1
  13. package/package.json +2 -1
  14. package/src/analysis_helpers.ts +152 -0
  15. package/src/audio.ts +493 -0
  16. package/src/codes.ts +56 -0
  17. package/src/effects_mastering.ts +964 -0
  18. package/src/feature_core.ts +248 -0
  19. package/src/feature_music.ts +419 -0
  20. package/src/feature_pitch.ts +80 -0
  21. package/src/feature_resample.ts +21 -0
  22. package/src/feature_spectral.ts +330 -0
  23. package/src/feature_spectrogram.ts +454 -0
  24. package/src/features.ts +84 -0
  25. package/src/index.ts +341 -4963
  26. package/src/live_audio.ts +47 -0
  27. package/src/metering.ts +380 -0
  28. package/src/mixer.ts +523 -0
  29. package/src/module_state.ts +14 -0
  30. package/src/opfs_clip_pages.ts +203 -0
  31. package/src/project.ts +1614 -0
  32. package/src/public_types.ts +177 -2
  33. package/src/quick_analysis.ts +508 -0
  34. package/src/realtime_engine.ts +667 -0
  35. package/src/realtime_voice_changer.ts +275 -0
  36. package/src/scale.ts +42 -0
  37. package/src/sonare.js.d.ts +302 -4
  38. package/src/stream_analyzer.ts +275 -0
  39. package/src/stream_types.ts +26 -1
  40. package/src/streaming_mixing.ts +18 -0
  41. package/src/streaming_processors.ts +335 -0
  42. package/src/validation.ts +82 -0
  43. package/src/web_midi.ts +366 -0
package/README.md CHANGED
@@ -161,7 +161,9 @@ If your bundler doesn't automatically resolve the `.wasm` file, specify its path
161
161
  import wasmUrl from '@libraz/libsonare/wasm?url'; // Vite
162
162
  import { init } from '@libraz/libsonare';
163
163
 
164
- await init({ wasmPath: wasmUrl });
164
+ // `locateFile(path, prefix)` is called by the Emscripten loader to resolve the
165
+ // `.wasm` file; return your bundler-provided URL for it.
166
+ await init({ locateFile: (path) => (path.endsWith('.wasm') ? wasmUrl : path) });
165
167
  ```
166
168
 
167
169
  ### Real-time Streaming
@@ -295,6 +297,40 @@ console.log(realtime.outLeft[0], realtime.outRight[0]);
295
297
  mixer.delete();
296
298
  ```
297
299
 
300
+ ### Headless DAW project
301
+
302
+ `Project` is a headless arrangement model: audio & MIDI tracks and clips, MIDI
303
+ sequencing, SMF / MIDI 2.0 Clip File I/O, deterministic JSON save/load, and an
304
+ offline `bounce`. Every mutation routes through an undoable history, and musical
305
+ positions are PPQ (quarter notes). Call `delete()` (or wrap in `try/finally`) to
306
+ release the WASM object — the embind handle is not garbage-collected.
307
+
308
+ ```typescript
309
+ import { init, Project } from '@libraz/libsonare';
310
+
311
+ await init();
312
+
313
+ const project = new Project();
314
+ try {
315
+ project.setSampleRate(48000);
316
+
317
+ const { clipId } = project.addMidiClip(0, 4); // { trackId, clipId }
318
+ project.setMidiEvents(clipId, [
319
+ Project.midiNoteOn(0, 0, 0, 60, 100), // ppq, group, channel, note, velocity
320
+ Project.midiNoteOff(1, 0, 0, 60),
321
+ ]);
322
+
323
+ const json = project.toJson(); // deterministic, byte-stable within a build
324
+ const smf = project.exportSmf(); // Uint8Array — Standard MIDI File
325
+ const midi2 = project.exportClipFile(); // Uint8Array — MIDI 2.0 Clip File (lossless)
326
+
327
+ const { hasTimeline, diagnostics } = project.compile();
328
+ const audio = project.bounce({ numChannels: 2 }); // interleaved Float32Array
329
+ } finally {
330
+ project.delete();
331
+ }
332
+ ```
333
+
298
334
  ### AudioWorklet bridge
299
335
 
300
336
  The package exposes an optional worklet entry that uses the same `sonare.wasm`
@@ -450,6 +486,7 @@ chain.delete(); // release WASM memory
450
486
  - **Pitch**: YIN, pYIN algorithms with optional `fillNa`
451
487
  - **Decomposition & loudness**: NMF decomposition, nearest-neighbour filtering, multichannel LUFS, EBU R128 LRA
452
488
  - **Streaming**: Real-time analysis with progressive estimates
489
+ - **Headless DAW**: `Project` arrangement model — audio/MIDI tracks & clips, undo/redo, MIDI sequencing, SMF / MIDI 2.0 Clip File I/O, deterministic JSON, offline `bounce`
453
490
  - **Conversions**: Hz/mel/MIDI/note, frames/time, resample
454
491
 
455
492
  ## Also available