cp-midi-player 0.1.0 → 0.2.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.
@@ -1,6 +1,6 @@
1
1
  export declare const PACKAGE_NAME = "cp-midi-player";
2
2
  /**
3
- * Where the player finds its worklet, SoundFont, artwork and font.
3
+ * Where the player finds its worklet, SoundFont and font.
4
4
  *
5
5
  * When the script is itself a file from `dist/` (a self-hosted copy, or a CDN
6
6
  * URL that names the file), the assets sit next to it. Anything else, such as
@@ -1,5 +1,5 @@
1
- import { type AudioTrackSource, type CpMidiPlayer } from "./player";
2
- export type { AudioTrackSource, CpMidiPlayer, SoundFontSource } from "./player";
1
+ import { type AudioTrackSource, type CpMidiPlayer, type TrackRailMode } from "./player";
2
+ export type { AudioTrackSource, CpMidiPlayer, SoundFontSource, TrackRailMode } from "./player";
3
3
  export type MountOptions = {
4
4
  /** MIDI file URL or bytes. */
5
5
  src: string | ArrayBuffer;
@@ -11,7 +11,7 @@ export type MountOptions = {
11
11
  */
12
12
  soundFont?: string | ArrayBuffer;
13
13
  soundFontLabel?: string;
14
- /** Folder holding the worklet, SoundFont, sprite and font. Defaults to the script's folder. */
14
+ /** Folder holding the worklet, SoundFont and font. Defaults to the script's folder. */
15
15
  assetBase?: string;
16
16
  /** "auto" follows prefers-color-scheme. */
17
17
  theme?: "auto" | "dark" | "light";
@@ -27,6 +27,19 @@ export type MountOptions = {
27
27
  soundFontMenu?: boolean;
28
28
  /** Initial view: "arrangement" (tracks, the default) or "piano-roll". */
29
29
  viewMode?: "piano-roll" | "arrangement";
30
+ /**
31
+ * The track list beside the notes: "open" (the default) or "collapsed" to its
32
+ * instrument icons, which visitors can toggle; "hidden" leaves it out entirely,
33
+ * along with the Tracks/Roll switch.
34
+ */
35
+ trackRail?: TrackRailMode;
36
+ /** Draw a piano keyboard beside the Roll view's pitch rows. Default false. */
37
+ pianoKeys?: boolean;
38
+ /**
39
+ * Starting height of each track in the Tracks view, 52–180 px. Without it tracks
40
+ * fit the player's height (up to 88 px). Visitors can still change it.
41
+ */
42
+ trackHeight?: number;
30
43
  /** Recordings (mix, stems) that play in step with the MIDI as extra mixer rows. */
31
44
  audioTracks?: readonly AudioTrackSource[];
32
45
  };
@@ -0,0 +1,2 @@
1
+ export declare function getInstrumentIconSvg(index: number): string;
2
+ export declare const instrumentIconCount: number;
@@ -49,13 +49,28 @@ export type PlayerConfig = {
49
49
  viewerState?: unknown;
50
50
  /** View used when neither viewerState nor saved state names one. */
51
51
  defaultViewMode?: ViewerMode;
52
+ /**
53
+ * The track rail: "open" (default) or "collapsed" to its instrument icons, which
54
+ * a visitor can toggle and saved state remembers; "hidden" removes it and its toggle.
55
+ */
56
+ trackRail?: TrackRailMode;
57
+ /** Draw a piano keyboard beside the Roll view's pitch rows. Off by default. */
58
+ pianoKeys?: boolean;
59
+ /**
60
+ * Starting track height in the Tracks view, 52–180 px; without it rows fit the
61
+ * player's height. A height the visitor picks (and saved state keeps) wins.
62
+ */
63
+ trackHeight?: number;
52
64
  audioTracks?: readonly AudioTrackSource[];
53
65
  host: PlayerHost;
54
66
  };
67
+ export type TrackRailMode = "open" | "collapsed" | "hidden";
55
68
  export type CpMidiPlayer = {
56
69
  readonly duration: number;
57
70
  /** MIDI tracks plus audio tracks, once ready has resolved. */
58
71
  readonly trackCount: number;
72
+ /** The track height the page or the visitor chose, in px; undefined while tracks fit the player. */
73
+ readonly trackHeight: number | undefined;
59
74
  readonly currentTime: number;
60
75
  readonly playing: boolean;
61
76
  readonly ready: Promise<void>;
@@ -13,6 +13,7 @@ export type PersistedViewerState = {
13
13
  arrangementTrackHeight: number;
14
14
  arrangementTrackHeightManual: boolean;
15
15
  pianoRollRowHeight: number;
16
+ trackRailCollapsed: boolean;
16
17
  tracks: Record<string, PersistedTrackState>;
17
18
  };
18
19
  export declare const DEFAULT_ARRANGEMENT_TRACK_HEIGHT = 88;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cp-midi-player",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Drop-in multi-track MIDI player for web pages: a <cp-midi-player> custom element with track and piano-roll views, mute/solo mixer, SoundFont playback, and audio stems in sync.",
5
5
  "license": "MIT",
6
6
  "type": "module",
Binary file