@sudobility/music_types 0.9.0 → 0.11.0

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.
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Platform-bound audio decoding and encoding.
3
+ *
4
+ * Web uses Web Audio, which already understands wav and mp3 (and therefore
5
+ * `.mpa`, which is the same MPEG audio) — React Native will need something
6
+ * else entirely, which is why this is an interface rather than a function.
7
+ *
8
+ * The *analysis* is deliberately not here: pitch tracking, segmentation and
9
+ * tempo detection are pure functions over samples and live in music_lib, where
10
+ * they can be tested with a synthesised tone and no browser.
11
+ */
12
+ export type DecodedAudio = {
13
+ samples: Float32Array;
14
+ sampleRate: number;
15
+ };
16
+ export interface AudioCodec {
17
+ /**
18
+ * Decode `.wav`/`.mp3`/`.mpa` to **mono** PCM.
19
+ *
20
+ * Channels are mixed down rather than preserved: the analysis is monophonic,
21
+ * so stereo would double the work for nothing.
22
+ */
23
+ decode(bytes: ArrayBuffer): Promise<DecodedAudio>;
24
+ encodeWav(audio: DecodedAudio): ArrayBuffer;
25
+ encodeMp3(audio: DecodedAudio): ArrayBuffer;
26
+ }
27
+ /** One note to sound in an offline render. */
28
+ export type RenderEvent = {
29
+ midi: number;
30
+ startSec: number;
31
+ durationSec: number;
32
+ /** 0..1, as the synth voices expect. */
33
+ velocity: number;
34
+ midiProgram: number;
35
+ isPercussion: boolean;
36
+ };
37
+ /**
38
+ * Offline audio rendering — the platform-bound half of audio export.
39
+ *
40
+ * Takes events somebody else decided on (`renderEvents` in music_lib works out
41
+ * mute, solo and timing), so everything musical stays testable without an
42
+ * audio context and only the scheduling lives behind this interface.
43
+ */
44
+ export interface AudioRenderer {
45
+ render(events: readonly RenderEvent[], durationSec: number): Promise<DecodedAudio>;
46
+ }
47
+ //# sourceMappingURL=audio.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"audio.d.ts","sourceRoot":"","sources":["../../src/platform/audio.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,MAAM,MAAM,YAAY,GAAG;IAAE,OAAO,EAAE,YAAY,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CAAC;AAEzE,MAAM,WAAW,UAAU;IACzB;;;;;OAKG;IACH,MAAM,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;IAClD,SAAS,CAAC,KAAK,EAAE,YAAY,GAAG,WAAW,CAAC;IAC5C,SAAS,CAAC,KAAK,EAAE,YAAY,GAAG,WAAW,CAAC;CAC7C;AAED,8CAA8C;AAC9C,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,wCAAwC;IACxC,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,OAAO,CAAC;CACvB,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,WAAW,aAAa;IAC5B,MAAM,CAAC,MAAM,EAAE,SAAS,WAAW,EAAE,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;CACpF"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Platform-bound audio decoding and encoding.
3
+ *
4
+ * Web uses Web Audio, which already understands wav and mp3 (and therefore
5
+ * `.mpa`, which is the same MPEG audio) — React Native will need something
6
+ * else entirely, which is why this is an interface rather than a function.
7
+ *
8
+ * The *analysis* is deliberately not here: pitch tracking, segmentation and
9
+ * tempo detection are pure functions over samples and live in music_lib, where
10
+ * they can be tested with a synthesised tone and no browser.
11
+ */
12
+ export {};
13
+ //# sourceMappingURL=audio.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"audio.js","sourceRoot":"","sources":["../../src/platform/audio.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG"}
@@ -1,3 +1,4 @@
1
+ export * from './audio.js';
1
2
  /**
2
3
  * Platform interfaces. Type-only contracts whose implementations live in
3
4
  * `@sudobility/music_io`, which serves web and React Native from one import
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/platform/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/platform/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B;;;;GAIG;AACH,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC"}
@@ -1,3 +1,4 @@
1
+ export * from './audio.js';
1
2
  /**
2
3
  * Platform interfaces. Type-only contracts whose implementations live in
3
4
  * `@sudobility/music_io`, which serves web and React Native from one import
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/platform/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/platform/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B;;;;GAIG;AACH,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sudobility/music_types",
3
- "version": "0.9.0",
3
+ "version": "0.11.0",
4
4
  "description": "TypeScript types and Zod schemas for the ScoreSmith music API - scores, generation contracts, project payloads",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",