@dawcore/midi 0.0.1 → 0.0.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.
Files changed (2) hide show
  1. package/README.md +39 -4
  2. package/package.json +7 -5
package/README.md CHANGED
@@ -1,15 +1,50 @@
1
1
  # @dawcore/midi
2
2
 
3
- Framework-agnostic MIDI file loading and parsing for the dawcore family.
3
+ Framework-agnostic MIDI file loading and parsing for the dawcore family. No React, no DOM, no Lit — pure functions built on `@tonejs/midi`.
4
4
 
5
5
  Used by `@dawcore/components` (the Lit web component layer, via `editor.loadMidi()`) and `@waveform-playlist/midi` (the React `useMidiTracks` hook).
6
6
 
7
- ## Exports
7
+ ## Installation
8
8
 
9
- - `parseMidiFile(data, options?)` — parse a MIDI `ArrayBuffer`
10
- - `parseMidiUrl(url, options?, signal?)` — fetch and parse a `.mid` URL
9
+ ```bash
10
+ npm install @dawcore/midi
11
+ ```
12
+
13
+ No peer dependencies. `@dawcore/components` declares this package as an *optional* peer dependency — add it to your own dependencies to enable `editor.loadMidi()` (it's dynamic-imported on first call, so non-MIDI users ship zero parser bytes).
14
+
15
+ ## Quick Start
16
+
17
+ ```typescript
18
+ import { parseMidiUrl, parseMidiFile } from '@dawcore/midi';
19
+
20
+ // Fetch and parse a .mid URL (optional AbortSignal for cancellation)
21
+ const midi = await parseMidiUrl('/media/song.mid');
22
+ // midi: { tracks, duration, name, bpm, timeSignature }
23
+
24
+ for (const track of midi.tracks) {
25
+ // track: { name, notes, duration, channel, instrument, programNumber }
26
+ console.log(track.name, track.notes.length + ' notes');
27
+ }
28
+
29
+ // Or parse an ArrayBuffer you already have (e.g. from a File input)
30
+ const buffer = await file.arrayBuffer();
31
+ const parsed = parseMidiFile(buffer, { flatten: true }); // merge all tracks into one
32
+ ```
33
+
34
+ Note timings are in seconds, already tempo-adjusted by `@tonejs/midi`. Tracks without notes are filtered out.
35
+
36
+ ## API
37
+
38
+ - `parseMidiFile(data: ArrayBuffer, options?)` — parse MIDI data into `ParsedMidi`
39
+ - `parseMidiUrl(url: string, options?, signal?)` — fetch and parse a `.mid` URL
40
+ - Options: `{ flatten?: boolean }` — merge all MIDI tracks into a single track
11
41
  - Types: `ParsedMidi`, `ParsedMidiTrack`, `ParseMidiOptions`, `MidiLoadOptions`, `MidiLoadResult`
12
42
 
43
+ ## Examples & Documentation
44
+
45
+ - [`examples/dawcore-tone/midi-load.html`](https://github.com/naomiaro/waveform-playlist/blob/main/examples/dawcore-tone/midi-load.html) — loading a `.mid` file (URL or file input) into `<daw-editor>` via `editor.loadMidi()`, with cancellation (`pnpm example:dawcore-tone`)
46
+ - [MIDI guide](https://naomiaro.github.io/waveform-playlist/docs/react/guides/midi) — covers both the React (`@waveform-playlist/midi`) and Web Components (`@dawcore/components`) paths, which share this package's parser underneath
47
+
13
48
  ## License
14
49
 
15
50
  MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dawcore/midi",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "description": "Framework-agnostic MIDI file loading and parsing for the dawcore family",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -16,6 +16,8 @@
16
16
  "keywords": [
17
17
  "midi",
18
18
  "dawcore",
19
+ "daw",
20
+ "audio-editor",
19
21
  "web-audio",
20
22
  "tonejs"
21
23
  ],
@@ -36,12 +38,12 @@
36
38
  ],
37
39
  "dependencies": {
38
40
  "@tonejs/midi": "^2.0.28",
39
- "@waveform-playlist/core": "12.1.0"
41
+ "@waveform-playlist/core": "12.6.0"
40
42
  },
41
43
  "devDependencies": {
42
- "tsup": "^8.0.1",
43
- "typescript": "^5.3.3",
44
- "vitest": "^3.0.0"
44
+ "tsup": "^8.5.1",
45
+ "typescript": "^5.9.3",
46
+ "vitest": "^3.2.6"
45
47
  },
46
48
  "scripts": {
47
49
  "build": "tsup",