solid-pianoroll 0.0.13 → 0.0.15

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,4 +1,4 @@
1
- import { createMemo, createSignal, Index, Show } from "solid-js";
1
+ import { batch, createMemo, createSignal, For, Show } from "solid-js";
2
2
  import { usePianoRollContext } from "./PianoRollContext";
3
3
  import { useViewPortDimension } from "./viewport/ScrollZoomViewPort";
4
4
  import styles from "./PianoRollNotes.module.scss";
@@ -12,38 +12,44 @@ const PianoRollNotes = (props) => {
12
12
  : value;
13
13
  const insertOrUpdateNote = (event) => {
14
14
  const position = horizontalViewPort().calculatePosition(event.clientX);
15
- const midi = context.condensed
16
- ? 60
17
- : 127 - Math.floor(verticalViewPort().calculatePosition(event.clientY));
15
+ const existingNote = currentNote();
16
+ const midi = context.mode === "keys"
17
+ ? 127 - Math.floor(verticalViewPort().calculatePosition(event.clientY))
18
+ : existingNote?.midi ?? 60;
19
+ const targetTrackIndex = context.mode === "tracks"
20
+ ? Math.floor(verticalViewPort().calculatePosition(event.clientY))
21
+ : context.selectedTrackIndex ?? 0;
18
22
  const eventPositionTicks = Math.floor(position / gridDivisionTicks()) * gridDivisionTicks();
19
23
  const velocity = 127;
20
- const existingNote = newNote();
21
24
  const ticks = existingNote?.ticks ?? eventPositionTicks;
22
25
  const durationTicks = existingNote?.ticks
23
26
  ? eventPositionTicks - existingNote?.ticks
24
27
  : gridDivisionTicks();
25
28
  const note = { midi, ticks, durationTicks, velocity };
26
29
  if (existingNote) {
27
- context.onNoteChange?.(newNoteIndex(), note);
28
- return newNoteIndex();
30
+ context.onNoteChange?.(currentNoteTrackIndex(), currentNoteIndex(), note);
31
+ return currentNoteIndex();
29
32
  }
30
33
  else {
31
- return context.onInsertNote?.(note) ?? -1;
34
+ return context.onInsertNote?.(targetTrackIndex, note) ?? -1;
32
35
  }
33
36
  };
34
37
  const [isDragging, setIsDragging] = createSignal(false);
35
38
  const [noteDragMode, setNoteDragMode] = createSignal();
36
- const [newNoteIndex, setNewNoteIndex] = createSignal(-1);
39
+ const [currentNoteIndex, setCurrentNoteIndex] = createSignal(-1);
40
+ const [currentNoteTrackIndex, setCurrentNoteTrackIndex] = createSignal(-1);
37
41
  const [isMouseDown, setIsMouseDown] = createSignal(false);
38
- const newNote = createMemo(() => context.notes[newNoteIndex()]);
42
+ const currentNote = createMemo(() => context.tracks[currentNoteTrackIndex()]?.notes[currentNoteIndex()]);
39
43
  const getClasses = (noteDragMode) => {
40
44
  return noteDragMode ? [styles.Note, styles[noteDragMode]] : [styles.Note];
41
45
  };
42
46
  return (<div class={styles.PianoRollNotes} ref={props.ref} onMouseDown={(event) => {
43
- console.log("down");
44
- setIsMouseDown(true);
45
- const index = insertOrUpdateNote(event);
46
- setNewNoteIndex(index);
47
+ batch(() => {
48
+ setIsMouseDown(true);
49
+ const index = insertOrUpdateNote(event);
50
+ setCurrentNoteTrackIndex(context.selectedTrackIndex ?? 0);
51
+ setCurrentNoteIndex(index);
52
+ });
47
53
  }} onMouseMove={(event) => {
48
54
  if (isDragging())
49
55
  return;
@@ -52,7 +58,7 @@ const PianoRollNotes = (props) => {
52
58
  return;
53
59
  }
54
60
  const index = insertOrUpdateNote(event);
55
- setNewNoteIndex(index);
61
+ setCurrentNoteIndex(index);
56
62
  }} onMouseUp={(event) => {
57
63
  setIsMouseDown(false);
58
64
  if (!event.altKey)
@@ -61,82 +67,112 @@ const PianoRollNotes = (props) => {
61
67
  }} onDblClick={(event) => {
62
68
  insertOrUpdateNote(event);
63
69
  }} onClick={(event) => {
64
- if (newNote()) {
65
- setNewNoteIndex(-1);
70
+ if (currentNote()) {
71
+ setCurrentNoteIndex(-1);
66
72
  return;
67
73
  }
68
74
  if (!event.altKey)
69
75
  return;
70
76
  insertOrUpdateNote(event);
71
77
  }}>
72
- <Index each={context.notes}>
73
- {(note, index) => {
74
- const verticalVirtualDimensions = createMemo(() => verticalViewPort().calculatePixelDimensions(127 - note().midi, 1));
75
- const horizontalDimensions = createMemo(() => horizontalViewPort().calculatePixelDimensions(note().ticks, note().durationTicks));
76
- return (<Show when={(verticalViewPort().isVisible(verticalVirtualDimensions()) || context.condensed) &&
77
- horizontalViewPort().isVisible(horizontalDimensions())}>
78
- <div class={getClasses(noteDragMode()).join(" ")} onMouseMove={(event) => {
79
- if (isDragging())
80
- return;
81
- event.stopPropagation();
82
- const relativeX = horizontalViewPort().calculatePixelValue(horizontalViewPort().calculatePosition(event.clientX));
83
- const noteStartX = horizontalViewPort().calculatePixelValue(note().ticks);
84
- const noteEndX = horizontalViewPort().calculatePixelValue(note().ticks + note().durationTicks);
85
- setNoteDragMode(relativeX - noteStartX < 3
86
- ? "trimStart"
87
- : noteEndX - relativeX < 3
88
- ? "trimEnd"
89
- : "move");
90
- }} onDblClick={(event) => {
91
- event.stopPropagation();
92
- context.onRemoveNote?.(index);
93
- }} onMouseDown={(event) => {
94
- event.stopPropagation();
95
- setIsDragging(true);
96
- const initialPosition = horizontalViewPort().calculatePosition(event.clientX);
97
- const diffPosition = initialPosition - note().ticks;
98
- const handleMouseMove = (mouseMoveEvent) => {
99
- const ticks = snapValueToGridIfEnabled(Math.max(horizontalViewPort().calculatePosition(mouseMoveEvent.clientX) -
100
- diffPosition, 0), mouseMoveEvent.altKey);
101
- context.onNoteChange?.(index, {
102
- ...note(),
103
- ...(noteDragMode() === "move" &&
104
- !context.condensed && {
105
- midi: Math.round(127 - verticalViewPort().calculatePosition(mouseMoveEvent.clientY)),
106
- }),
107
- ...((noteDragMode() === "move" || noteDragMode() === "trimStart") && {
108
- ticks,
109
- }),
110
- ...(noteDragMode() === "trimStart" && {
111
- durationTicks: note().durationTicks + note().ticks - ticks,
112
- }),
113
- ...(noteDragMode() === "trimEnd" && {
114
- durationTicks: snapValueToGridIfEnabled(horizontalViewPort().calculatePosition(mouseMoveEvent.clientX) -
115
- note().ticks, mouseMoveEvent.altKey),
116
- }),
117
- });
118
- };
119
- const handleMouseUp = () => {
120
- setIsDragging(false);
121
- window.removeEventListener("mousemove", handleMouseMove);
122
- window.removeEventListener("mouseup", handleMouseUp);
123
- };
124
- window.addEventListener("mousemove", handleMouseMove);
125
- window.addEventListener("mouseup", handleMouseUp);
126
- }} style={{
127
- "background-color": `rgba(255,0,0, ${(128 + note().velocity) / 256})`,
128
- ...(context.condensed
129
- ? { top: 0, height: "100%" }
130
- : {
78
+ <For each={context.tracks}>
79
+ {(track, trackIndex) => {
80
+ return (<Show when={trackIndex() === context.selectedTrackIndex ||
81
+ context.showAllTracks ||
82
+ context.mode === "tracks"}>
83
+ <For each={track.notes}>
84
+ {(note, noteIndex) => {
85
+ const verticalVirtualDimensions = createMemo(() => verticalViewPort().calculatePixelDimensions(context.mode === "keys" ? 127 - note.midi : trackIndex(), 1));
86
+ const horizontalDimensions = createMemo(() => horizontalViewPort().calculatePixelDimensions(note.ticks, note.durationTicks));
87
+ return (<Show when={verticalViewPort().isVisible(verticalVirtualDimensions()) &&
88
+ horizontalViewPort().isVisible(horizontalDimensions())}>
89
+ <div class={getClasses(noteDragMode()).join(" ")} draggable={false} onMouseMove={(event) => {
90
+ if (isDragging())
91
+ return;
92
+ event.stopPropagation();
93
+ const relativeX = horizontalViewPort().calculatePixelValue(horizontalViewPort().calculatePosition(event.clientX));
94
+ const noteStartX = horizontalViewPort().calculatePixelValue(note.ticks);
95
+ const noteEndX = horizontalViewPort().calculatePixelValue(note.ticks + note.durationTicks);
96
+ setNoteDragMode(relativeX - noteStartX < 3
97
+ ? "trimStart"
98
+ : noteEndX - relativeX < 3
99
+ ? "trimEnd"
100
+ : "move");
101
+ }} onDblClick={(event) => {
102
+ event.stopPropagation();
103
+ context.onRemoveNote?.(trackIndex(), noteIndex());
104
+ }} onMouseDown={(event) => {
105
+ event.stopPropagation();
106
+ setIsDragging(true);
107
+ setCurrentNoteIndex(noteIndex());
108
+ setCurrentNoteTrackIndex(trackIndex());
109
+ const initialPosition = horizontalViewPort().calculatePosition(event.clientX);
110
+ const diffPosition = initialPosition - note.ticks;
111
+ const handleMouseMove = (mouseMoveEvent) => {
112
+ const note = currentNote();
113
+ if (!note)
114
+ return;
115
+ const ticks = snapValueToGridIfEnabled(Math.max(horizontalViewPort().calculatePosition(mouseMoveEvent.clientX) -
116
+ diffPosition, 0), mouseMoveEvent.altKey);
117
+ const updatedNote = {
118
+ ...note,
119
+ ...(noteDragMode() === "move" &&
120
+ context.mode === "keys" && {
121
+ midi: Math.round(127 -
122
+ verticalViewPort().calculatePosition(mouseMoveEvent.clientY)),
123
+ }),
124
+ ...((noteDragMode() === "move" || noteDragMode() === "trimStart") && {
125
+ ticks,
126
+ }),
127
+ ...(noteDragMode() === "trimStart" && {
128
+ durationTicks: note.durationTicks + note.ticks - ticks,
129
+ }),
130
+ ...(noteDragMode() === "trimEnd" && {
131
+ durationTicks: snapValueToGridIfEnabled(horizontalViewPort().calculatePosition(mouseMoveEvent.clientX) -
132
+ note.ticks, mouseMoveEvent.altKey),
133
+ }),
134
+ };
135
+ const previousTrackIndex = currentNoteTrackIndex();
136
+ const previousNoteIndex = currentNoteIndex();
137
+ const targetTrackIndex = context.mode === "tracks"
138
+ ? Math.floor(verticalViewPort().calculatePosition(mouseMoveEvent.clientY))
139
+ : previousTrackIndex;
140
+ if (targetTrackIndex === previousTrackIndex) {
141
+ context.onNoteChange?.(previousTrackIndex, previousNoteIndex, updatedNote);
142
+ }
143
+ else {
144
+ batch(() => {
145
+ if (context.onInsertNote) {
146
+ context.onRemoveNote?.(previousTrackIndex, previousNoteIndex);
147
+ const newNoteIndex = context.onInsertNote(targetTrackIndex, updatedNote);
148
+ setCurrentNoteTrackIndex(targetTrackIndex);
149
+ setCurrentNoteIndex(newNoteIndex);
150
+ }
151
+ });
152
+ }
153
+ };
154
+ const handleMouseUp = () => {
155
+ setIsDragging(false);
156
+ setCurrentNoteIndex(-1);
157
+ setCurrentNoteTrackIndex(-1);
158
+ window.removeEventListener("mousemove", handleMouseMove);
159
+ window.removeEventListener("mouseup", handleMouseUp);
160
+ };
161
+ window.addEventListener("mousemove", handleMouseMove);
162
+ window.addEventListener("mouseup", handleMouseUp);
163
+ }} style={{
164
+ "background-color": `rgba(255,0,0, ${(128 + note.velocity) / 256})`,
131
165
  top: `${verticalVirtualDimensions().offset}px`,
132
166
  height: `${verticalVirtualDimensions().size}px`,
133
- }),
134
- left: `${horizontalDimensions().offset}px`,
135
- width: `${horizontalDimensions().size}px`,
136
- }}></div>
167
+ left: `${horizontalDimensions().offset}px`,
168
+ width: `${horizontalDimensions().size}px`,
169
+ }}></div>
170
+ </Show>);
171
+ }}
172
+ </For>
137
173
  </Show>);
138
174
  }}
139
- </Index>
175
+ </For>
140
176
  </div>);
141
177
  };
142
178
  export default PianoRollNotes;
@@ -0,0 +1,28 @@
1
+ import styles from "./PianoRollTrackList.module.css";
2
+ import { createMemo, Index, Show } from "solid-js";
3
+ import { useViewPortDimension } from "./viewport/ScrollZoomViewPort";
4
+ import { usePianoRollContext } from "./PianoRollContext";
5
+ const PianoRollTrackList = () => {
6
+ const viewPort = createMemo(() => useViewPortDimension("vertical"));
7
+ const context = usePianoRollContext();
8
+ return (<div class={styles.PianoRollTrackList}>
9
+ <Index each={context.tracks}>
10
+ {(track, index) => {
11
+ const virtualDimensions = createMemo(() => viewPort().calculatePixelDimensions(context.mode === "tracks" ? index : index * 8, context.mode === "tracks" ? 1 : 8));
12
+ return (<Show when={virtualDimensions().size > 0}>
13
+ <div classList={{
14
+ [styles["Track"]]: true,
15
+ }} title={track().name} style={{
16
+ top: `${virtualDimensions().offset}px`,
17
+ height: `${virtualDimensions().size}px`,
18
+ background: index === context.selectedTrackIndex ? "gray" : "lightgrey",
19
+ cursor: "pointer",
20
+ }} onClick={() => context.onSelectedTrackIndexChange?.(index)}>
21
+ {index} {track().name || "[unnamed track]"}
22
+ </div>
23
+ </Show>);
24
+ }}
25
+ </Index>
26
+ </div>);
27
+ };
28
+ export default PianoRollTrackList;
@@ -0,0 +1,47 @@
1
+ import { createEffect, createMemo, mergeProps, splitProps } from "solid-js";
2
+ import { clamp } from "./viewport/createViewPortDimension";
3
+ import { useViewPortDimension } from "./viewport/ScrollZoomViewPort";
4
+ const PlayHead = (allProps) => {
5
+ const propsWithDefauls = mergeProps({ playHeadPosition: 0, sync: false }, allProps);
6
+ const [props, divProps] = splitProps(propsWithDefauls, [
7
+ "playHeadPosition",
8
+ "sync",
9
+ "onPlayHeadPositionChange",
10
+ "onPositionChange",
11
+ ]);
12
+ const viewPort = useViewPortDimension("horizontal");
13
+ createEffect(() => {
14
+ if (!props.sync)
15
+ return;
16
+ const maxPosition = viewPort.range;
17
+ const newPosition = clamp(props.playHeadPosition - viewPort.range / viewPort.zoom / 2, 0, maxPosition);
18
+ props.onPositionChange?.(newPosition);
19
+ });
20
+ const leftPosition = createMemo(() => viewPort.calculatePixelOffset(props.playHeadPosition));
21
+ return (<div class="PlayHead" {...divProps} style={{
22
+ position: "absolute",
23
+ height: "100%",
24
+ width: "2px",
25
+ left: `${leftPosition()}px`,
26
+ "background-color": "green",
27
+ cursor: "pointer",
28
+ ...(typeof divProps.style === "object" && divProps.style),
29
+ }} onMouseDown={(event) => {
30
+ event.preventDefault();
31
+ event.stopPropagation();
32
+ const handleMouseMove = ({ movementX }) => {
33
+ const { parentElement } = event.currentTarget;
34
+ if (!parentElement)
35
+ return;
36
+ const newPosition = viewPort.calculatePosition(leftPosition() + movementX);
37
+ props.onPlayHeadPositionChange?.(newPosition);
38
+ };
39
+ const handleMouseUp = () => {
40
+ window.removeEventListener("mousemove", handleMouseMove);
41
+ window.removeEventListener("mouseup", handleMouseUp);
42
+ };
43
+ window.addEventListener("mousemove", handleMouseMove);
44
+ window.addEventListener("mouseup", handleMouseUp);
45
+ }}/>);
46
+ };
47
+ export default PlayHead;
@@ -1,5 +1,5 @@
1
- import MultiTrackPianoRoll from "./MultiTrackPianoRoll";
2
1
  import PianoRoll from "./PianoRoll";
2
+ import PlayHead from "./PlayHead";
3
3
  import useNotes from "./useNotes";
4
4
  import usePianoRoll from "./usePianoRoll";
5
- export { PianoRoll, MultiTrackPianoRoll, usePianoRoll, useNotes };
5
+ export { PianoRoll, usePianoRoll, useNotes, PlayHead };
@@ -1,11 +1,11 @@
1
1
  import { createSignal } from "solid-js";
2
2
  const usePianoRoll = () => {
3
3
  const [ppq, onPpqChange] = createSignal(120);
4
- const [condensed, onCondensedChange] = createSignal(false);
4
+ const [mode, onModeChange] = createSignal("tracks");
5
5
  const [position, onPositionChange] = createSignal(0);
6
6
  const [zoom, onZoomChange] = createSignal(10);
7
7
  const [verticalZoom, onVerticalZoomChange] = createSignal(5);
8
- const [verticalPosition, onVerticalPositionChange] = createSignal(64);
8
+ const [verticalPosition, onVerticalPositionChange] = createSignal(44);
9
9
  const [gridDivision, onGridDivisionChange] = createSignal(4);
10
10
  const [snapToGrid, onSnapToGridChange] = createSignal(true);
11
11
  const [duration, onDurationChange] = createSignal(0);
@@ -24,8 +24,8 @@ const usePianoRoll = () => {
24
24
  onGridDivisionChange,
25
25
  snapToGrid,
26
26
  onSnapToGridChange,
27
- condensed,
28
- onCondensedChange,
27
+ mode,
28
+ onModeChange,
29
29
  duration,
30
30
  onDurationChange,
31
31
  };
@@ -3,6 +3,7 @@ import { createStore } from "solid-js/store";
3
3
  export default function createViewPortDimension(getState) {
4
4
  const getStateWithFunctions = () => ({
5
5
  ...getState(),
6
+ calculatePixelOffset,
6
7
  calculatePixelValue,
7
8
  calculatePosition,
8
9
  calculatePixelDimensions,
@@ -1,12 +1,15 @@
1
- import { JSX } from "solid-js";
2
- import { Note } from "./types";
1
+ import { JSX, ParentProps } from "solid-js";
2
+ import { Note, Track } from "./types";
3
3
  export type GridDivision = 1 | 2 | 4 | 8 | 16 | 32 | 64;
4
4
  export type PianoRollProps = {
5
5
  ppq: number;
6
- notes: Note[];
6
+ tracks: Track[];
7
7
  gridDivision: GridDivision;
8
8
  snapToGrid: boolean;
9
- condensed?: boolean;
9
+ mode: "keys" | "tracks";
10
+ showAllTracks?: boolean;
11
+ showTrackList?: boolean;
12
+ selectedTrackIndex: number;
10
13
  verticalPosition: number;
11
14
  verticalZoom: number;
12
15
  position: number;
@@ -16,9 +19,10 @@ export type PianoRollProps = {
16
19
  onVerticalPositionChange?: (zoom: number) => void;
17
20
  onZoomChange?: (zoom: number) => void;
18
21
  onPositionChange?: (zoom: number) => void;
19
- onNoteChange?: (index: number, note: Note) => void;
20
- onInsertNote?: (note: Note) => number;
21
- onRemoveNote?: (index: number) => void;
22
+ onNoteChange?: (trackIndex: number, noteIndex: number, note: Note) => void;
23
+ onInsertNote?: (trackIndex: number, note: Note) => number;
24
+ onRemoveNote?: (trackIndex: number, noteIndex: number) => void;
25
+ onSelectedTrackIndexChange?: (trackIndex: number) => void;
22
26
  };
23
- declare const PianoRoll: (allProps: PianoRollProps & JSX.IntrinsicElements["div"]) => JSX.Element;
27
+ declare const PianoRoll: (allProps: ParentProps<PianoRollProps & JSX.IntrinsicElements["div"]>) => JSX.Element;
24
28
  export default PianoRoll;
@@ -1,4 +1,5 @@
1
+ import { JSX } from "solid-js";
1
2
  import { PianoRollProps } from "./PianoRoll";
2
3
  export declare const PianoRollContextProvider: import("solid-js/types/reactive/signal").ContextProviderComponent<PianoRollProps>;
3
4
  export declare const usePianoRollContext: () => PianoRollProps;
4
- export declare const splitContextProps: (allProps: PianoRollProps) => [Pick<PianoRollProps, "position" | "condensed" | "zoom" | "onZoomChange" | "onPositionChange" | "notes" | "duration" | "gridDivision" | "ppq" | "snapToGrid" | "verticalPosition" | "verticalZoom" | "onInsertNote" | "onNoteChange" | "onRemoveNote" | "onVerticalPositionChange" | "onVerticalZoomChange">, Omit<PianoRollProps, "position" | "condensed" | "zoom" | "onZoomChange" | "onPositionChange" | "notes" | "duration" | "gridDivision" | "ppq" | "snapToGrid" | "verticalPosition" | "verticalZoom" | "onInsertNote" | "onNoteChange" | "onRemoveNote" | "onVerticalPositionChange" | "onVerticalZoomChange">];
5
+ export declare const splitContextProps: (allProps: PianoRollProps & JSX.IntrinsicElements["div"]) => [Pick<PianoRollProps & JSX.HTMLAttributes<HTMLDivElement>, "position" | "zoom" | "mode" | "duration" | "gridDivision" | "tracks" | "ppq" | "snapToGrid" | "verticalPosition" | "verticalZoom" | "onInsertNote" | "onNoteChange" | "onPositionChange" | "onRemoveNote" | "onVerticalPositionChange" | "onVerticalZoomChange" | "onZoomChange" | "showAllTracks" | "selectedTrackIndex" | "onSelectedTrackIndexChange">, Omit<PianoRollProps & JSX.HTMLAttributes<HTMLDivElement>, "position" | "zoom" | "mode" | "duration" | "gridDivision" | "tracks" | "ppq" | "snapToGrid" | "verticalPosition" | "verticalZoom" | "onInsertNote" | "onNoteChange" | "onPositionChange" | "onRemoveNote" | "onVerticalPositionChange" | "onVerticalZoomChange" | "onZoomChange" | "showAllTracks" | "selectedTrackIndex" | "onSelectedTrackIndexChange">];
@@ -0,0 +1,2 @@
1
+ declare const PianoRollTrackList: () => import("solid-js").JSX.Element;
2
+ export default PianoRollTrackList;
@@ -0,0 +1,8 @@
1
+ import { JSX } from "solid-js";
2
+ declare const PlayHead: (allProps: {
3
+ playHeadPosition?: number;
4
+ sync?: boolean;
5
+ onPlayHeadPositionChange?: (playHeadPosition: number) => void;
6
+ onPositionChange?: (position: number) => void;
7
+ } & JSX.HTMLAttributes<HTMLDivElement>) => JSX.Element;
8
+ export default PlayHead;
@@ -1,5 +1,5 @@
1
- import MultiTrackPianoRoll from "./MultiTrackPianoRoll";
2
1
  import PianoRoll from "./PianoRoll";
2
+ import PlayHead from "./PlayHead";
3
3
  import useNotes from "./useNotes";
4
4
  import usePianoRoll from "./usePianoRoll";
5
- export { PianoRoll, MultiTrackPianoRoll, usePianoRoll, useNotes };
5
+ export { PianoRoll, usePianoRoll, useNotes, PlayHead };
@@ -1,2 +1,6 @@
1
1
  import { Midi } from "@tonejs/midi";
2
2
  export type Note = Pick<ReturnType<Midi["tracks"][number]["notes"][number]["toJSON"]>, "durationTicks" | "midi" | "ticks" | "velocity">;
3
+ export type Track = {
4
+ name: string;
5
+ notes: Note[];
6
+ };
@@ -14,8 +14,8 @@ declare const usePianoRoll: () => {
14
14
  onGridDivisionChange: import("solid-js").Setter<GridDivision>;
15
15
  snapToGrid: import("solid-js").Accessor<boolean>;
16
16
  onSnapToGridChange: import("solid-js").Setter<boolean>;
17
- condensed: import("solid-js").Accessor<boolean>;
18
- onCondensedChange: import("solid-js").Setter<boolean>;
17
+ mode: import("solid-js").Accessor<"keys" | "tracks">;
18
+ onModeChange: import("solid-js").Setter<"keys" | "tracks">;
19
19
  duration: import("solid-js").Accessor<number>;
20
20
  onDurationChange: import("solid-js").Setter<number>;
21
21
  };
@@ -4,6 +4,7 @@ export declare const ScrollZoomViewPort: (props: ParentProps<{
4
4
  dimensions: Record<ViewPortDimensionName, () => Omit<ViewPortDimensionState, "name">>;
5
5
  }>) => import("solid-js").JSX.Element;
6
6
  export declare const useViewPortDimension: (name: ViewPortDimensionName) => {
7
+ calculatePixelOffset: (position: number) => number;
7
8
  calculatePixelValue: (position?: number) => number;
8
9
  calculatePosition: (offset: number) => number;
9
10
  calculatePixelDimensions: (position: number, length: number) => {
@@ -11,6 +11,7 @@ export type ViewPortDimensionState = {
11
11
  zoom: number;
12
12
  };
13
13
  export default function createViewPortDimension(getState: () => ViewPortDimensionState): {
14
+ calculatePixelOffset: (position: number) => number;
14
15
  calculatePixelValue: (position?: number) => number;
15
16
  calculatePosition: (offset: number) => number;
16
17
  calculatePixelDimensions: (position: number, length: number) => {
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.0.13",
2
+ "version": "0.0.15",
3
3
  "name": "solid-pianoroll",
4
4
  "description": "Pianoroll UI Control for Solid JS apps",
5
5
  "license": "MIT",
@@ -44,7 +44,8 @@
44
44
  "typecheck": "tsc --noEmit"
45
45
  },
46
46
  "optionalDependencies": {
47
- "@tonejs/midi": "^2.0.28"
47
+ "@tonejs/midi": "^2.0.28",
48
+ "tone": "^14.7.77"
48
49
  },
49
50
  "peerDependencies": {
50
51
  "solid-js": ">=1.0.0"