solid-pianoroll 0.0.21 → 0.0.23
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.
- package/dist/cjs/index.js +504 -371
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +506 -373
- package/dist/esm/index.js.map +1 -1
- package/dist/source/PianoRoll.jsx +50 -63
- package/dist/source/PianoRollGrid.jsx +22 -46
- package/dist/source/PianoRollKeys.jsx +10 -21
- package/dist/source/PianoRollNotes.jsx +93 -110
- package/dist/source/PianoRollNotesScroller.jsx +16 -0
- package/dist/source/PianoRollScale.jsx +29 -0
- package/dist/source/PianoRollScrollZoomViewPort.jsx +49 -0
- package/dist/source/PianoRollTrackList.jsx +2 -3
- package/dist/source/PianoRollTrackListScroller.jsx +16 -0
- package/dist/source/index.jsx +1 -1
- package/dist/source/usePianoRollGrid.js +45 -0
- package/dist/source/usePianoRollState.js +19 -5
- package/dist/source/{PlayHead.jsx → viewport/PlayHead.jsx} +11 -12
- package/dist/source/viewport/ScrollZoomContainer.jsx +2 -2
- package/dist/source/viewport/ZoomSliderControl.jsx +4 -1
- package/dist/types/PianoRollContext.d.ts +26 -12
- package/dist/types/PianoRollNotesScroller.d.ts +3 -0
- package/dist/types/PianoRollScale.d.ts +2 -0
- package/dist/types/PianoRollScrollZoomViewPort.d.ts +3 -0
- package/dist/types/PianoRollTrackListScroller.d.ts +3 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/usePianoRollGrid.d.ts +13 -0
- package/dist/types/usePianoRollState.d.ts +14 -6
- package/dist/types/{PlayHead.d.ts → viewport/PlayHead.d.ts} +3 -3
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import styles from "./PianoRollTrackList.module.
|
|
1
|
+
import styles from "./PianoRollTrackList.module.scss";
|
|
2
2
|
import { createMemo, Index, Show } from "solid-js";
|
|
3
3
|
import { useViewPortDimension } from "./viewport/ScrollZoomViewPort";
|
|
4
4
|
import { usePianoRollContext } from "./PianoRollContext";
|
|
@@ -12,11 +12,10 @@ const PianoRollTrackList = () => {
|
|
|
12
12
|
return (<Show when={virtualDimensions().size > 0}>
|
|
13
13
|
<div classList={{
|
|
14
14
|
[styles["Track"]]: true,
|
|
15
|
+
[styles["selected"]]: index === context.selectedTrackIndex,
|
|
15
16
|
}} title={track().name} style={{
|
|
16
17
|
top: `${virtualDimensions().offset}px`,
|
|
17
18
|
height: `${virtualDimensions().size}px`,
|
|
18
|
-
background: index === context.selectedTrackIndex ? "gray" : "lightgrey",
|
|
19
|
-
cursor: "pointer",
|
|
20
19
|
}} onClick={() => context.onSelectedTrackIndexChange?.(index)}>
|
|
21
20
|
{index} {track().name || "[unnamed track]"}
|
|
22
21
|
</div>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { createEffect, createSignal } from "solid-js";
|
|
2
|
+
import { usePianoRollContext } from "./PianoRollContext";
|
|
3
|
+
import useBoundingClientRect from "./useBoundingClientRect";
|
|
4
|
+
import ScrollZoomContainer from "./viewport/ScrollZoomContainer";
|
|
5
|
+
const PianoRollTrackListScroller = (props) => {
|
|
6
|
+
const context = usePianoRollContext();
|
|
7
|
+
const [ref, setRef] = createSignal();
|
|
8
|
+
const clientRect = useBoundingClientRect(ref);
|
|
9
|
+
createEffect(() => {
|
|
10
|
+
context.onTracksScrollerClientRectChange(clientRect());
|
|
11
|
+
});
|
|
12
|
+
return (<ScrollZoomContainer ref={setRef} horizontalDimensionName="horizontalTracks" verticalDimensionName="verticalTracks" showScrollbar={context.mode === "keys"}>
|
|
13
|
+
{props.children}
|
|
14
|
+
</ScrollZoomContainer>);
|
|
15
|
+
};
|
|
16
|
+
export default PianoRollTrackListScroller;
|
package/dist/source/index.jsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import PianoRoll from "./PianoRoll";
|
|
2
|
-
import PlayHead from "./PlayHead";
|
|
2
|
+
import PlayHead from "./viewport/PlayHead";
|
|
3
3
|
import useNotes from "./useNotes";
|
|
4
4
|
import createPianoRollstate from "./usePianoRollState";
|
|
5
5
|
export { PianoRoll, createPianoRollstate, useNotes, PlayHead };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { createMemo } from "solid-js";
|
|
2
|
+
import { usePianoRollContext } from "./PianoRollContext";
|
|
3
|
+
import { useViewPortDimension } from "./viewport/ScrollZoomViewPort";
|
|
4
|
+
const usePianoRollGrid = () => {
|
|
5
|
+
const context = usePianoRollContext();
|
|
6
|
+
const horizontalViewPort = createMemo(() => useViewPortDimension("horizontal"));
|
|
7
|
+
const measureTicks = createMemo(() => context.ppq * 4);
|
|
8
|
+
const selectedGridDivisorTicks = createMemo(() => measureTicks() / context.gridDivision);
|
|
9
|
+
function calculateVisibleGridDivisorTicks(value) {
|
|
10
|
+
const visibleRange = horizontalViewPort().calculateVisibleRange();
|
|
11
|
+
if (visibleRange <= 0)
|
|
12
|
+
return 0;
|
|
13
|
+
if (visibleRange / value > 100) {
|
|
14
|
+
return calculateVisibleGridDivisorTicks(value * 2);
|
|
15
|
+
}
|
|
16
|
+
if (visibleRange / value < 30) {
|
|
17
|
+
return calculateVisibleGridDivisorTicks(value / 2);
|
|
18
|
+
}
|
|
19
|
+
return value;
|
|
20
|
+
}
|
|
21
|
+
const gridDivisorTicks = createMemo(() => calculateVisibleGridDivisorTicks(selectedGridDivisorTicks()));
|
|
22
|
+
const gridArray = createMemo(() => {
|
|
23
|
+
const numberOfLines = Math.ceil(horizontalViewPort().calculateVisibleRange() / gridDivisorTicks() + 1);
|
|
24
|
+
const startIndex = Math.floor(context.position / gridDivisorTicks());
|
|
25
|
+
return Array.from({ length: numberOfLines }).map((_, i) => {
|
|
26
|
+
const index = i + startIndex;
|
|
27
|
+
const ticks = index * gridDivisorTicks();
|
|
28
|
+
const measurePosition = ticks / context.ppq / 4 + 1;
|
|
29
|
+
const bars = Math.floor(measurePosition);
|
|
30
|
+
const beats = Math.floor((measurePosition - bars) * 4);
|
|
31
|
+
const label = `${bars}${beats ? `.${beats}` : ""}`;
|
|
32
|
+
return {
|
|
33
|
+
index,
|
|
34
|
+
ticks,
|
|
35
|
+
isHighlighted: Math.ceil(((index + 1) * selectedGridDivisorTicks()) / measureTicks()) % 2 === 0,
|
|
36
|
+
hasHighlightedBorder: (index * gridDivisorTicks()) % selectedGridDivisorTicks() === 0,
|
|
37
|
+
showLabel: ((index * selectedGridDivisorTicks()) / measureTicks()) % 2 === 0,
|
|
38
|
+
virtualDimensions: horizontalViewPort().calculatePixelDimensions(ticks, gridDivisorTicks()),
|
|
39
|
+
label,
|
|
40
|
+
};
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
return gridArray;
|
|
44
|
+
};
|
|
45
|
+
export default usePianoRollGrid;
|
|
@@ -14,7 +14,9 @@ const defaultState = {
|
|
|
14
14
|
duration: 0,
|
|
15
15
|
tracks: [],
|
|
16
16
|
selectedTrackIndex: 0,
|
|
17
|
-
pressedKeys:
|
|
17
|
+
pressedKeys: {},
|
|
18
|
+
notesScrollerClientRect: { left: 0, width: 0, top: 0, height: 0 },
|
|
19
|
+
tracksScrollerClientRect: { left: 0, width: 0, top: 0, height: 0 },
|
|
18
20
|
};
|
|
19
21
|
const propNameToHandlerName = (name) => `on${name[0]?.toUpperCase()}${name.slice(1)}Change`;
|
|
20
22
|
export const pianoRollStatePropNames = [
|
|
@@ -25,6 +27,7 @@ export const pianoRollStatePropNames = [
|
|
|
25
27
|
"onRemoveNote",
|
|
26
28
|
"onNoteDown",
|
|
27
29
|
"onNoteUp",
|
|
30
|
+
"isKeyDown",
|
|
28
31
|
];
|
|
29
32
|
const createPianoRollstate = (initialState) => {
|
|
30
33
|
const [state, setState] = createStore({
|
|
@@ -74,12 +77,22 @@ const createPianoRollstate = (initialState) => {
|
|
|
74
77
|
...notes.slice(noteIndex + 1),
|
|
75
78
|
]);
|
|
76
79
|
};
|
|
77
|
-
const
|
|
78
|
-
handlers.onPressedKeysChange?.(
|
|
80
|
+
const updateKeyPressedState = (trackIndex, keyNumber, value) => {
|
|
81
|
+
handlers.onPressedKeysChange?.({
|
|
82
|
+
...state.pressedKeys,
|
|
83
|
+
[trackIndex]: {
|
|
84
|
+
...state.pressedKeys[trackIndex],
|
|
85
|
+
[keyNumber]: value,
|
|
86
|
+
},
|
|
87
|
+
});
|
|
79
88
|
};
|
|
80
|
-
const
|
|
81
|
-
|
|
89
|
+
const onNoteDown = (trackIndex, keyNumber) => {
|
|
90
|
+
updateKeyPressedState(trackIndex, keyNumber, true);
|
|
82
91
|
};
|
|
92
|
+
const onNoteUp = (trackIndex, keyNumber) => {
|
|
93
|
+
updateKeyPressedState(trackIndex, keyNumber, false);
|
|
94
|
+
};
|
|
95
|
+
const isKeyDown = (trackIndex, keyNumber) => !!state.pressedKeys[trackIndex]?.[keyNumber];
|
|
83
96
|
return mergeProps(state, {
|
|
84
97
|
...handlers,
|
|
85
98
|
onNoteChange,
|
|
@@ -87,6 +100,7 @@ const createPianoRollstate = (initialState) => {
|
|
|
87
100
|
onRemoveNote,
|
|
88
101
|
onNoteDown,
|
|
89
102
|
onNoteUp,
|
|
103
|
+
isKeyDown,
|
|
90
104
|
});
|
|
91
105
|
};
|
|
92
106
|
export default createPianoRollstate;
|
|
@@ -1,23 +1,22 @@
|
|
|
1
|
-
import { createEffect, createMemo,
|
|
2
|
-
import { clamp } from "./
|
|
3
|
-
import { useViewPortDimension } from "./
|
|
1
|
+
import { createEffect, createMemo, splitProps } from "solid-js";
|
|
2
|
+
import { clamp } from "./createViewPortDimension";
|
|
3
|
+
import { useViewPortDimension } from "./ScrollZoomViewPort";
|
|
4
4
|
const PlayHead = (allProps) => {
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
"playHeadPosition",
|
|
5
|
+
const [props, divProps] = splitProps(allProps, [
|
|
6
|
+
"position",
|
|
8
7
|
"sync",
|
|
9
|
-
"onPlayHeadPositionChange",
|
|
10
8
|
"onPositionChange",
|
|
9
|
+
"dimensionName",
|
|
11
10
|
]);
|
|
12
|
-
const viewPort = useViewPortDimension("horizontal");
|
|
11
|
+
const viewPort = useViewPortDimension(props.dimensionName ?? "horizontal");
|
|
13
12
|
createEffect(() => {
|
|
14
13
|
if (!props.sync)
|
|
15
14
|
return;
|
|
16
15
|
const maxPosition = viewPort.range;
|
|
17
|
-
const newPosition = clamp(props.
|
|
18
|
-
|
|
16
|
+
const newPosition = clamp(props.position - viewPort.range / viewPort.zoom / 2, 0, maxPosition);
|
|
17
|
+
viewPort.onPositionChange?.(newPosition);
|
|
19
18
|
});
|
|
20
|
-
const leftPosition = createMemo(() => viewPort.calculatePixelOffset(props.
|
|
19
|
+
const leftPosition = createMemo(() => viewPort.calculatePixelOffset(props.position));
|
|
21
20
|
return (<div class="PlayHead" {...divProps} style={{
|
|
22
21
|
position: "absolute",
|
|
23
22
|
height: "100%",
|
|
@@ -31,7 +30,7 @@ const PlayHead = (allProps) => {
|
|
|
31
30
|
event.stopPropagation();
|
|
32
31
|
const handleMouseMove = ({ clientX }) => {
|
|
33
32
|
const newPosition = viewPort.calculatePosition(clientX);
|
|
34
|
-
props.
|
|
33
|
+
props.onPositionChange?.(newPosition);
|
|
35
34
|
};
|
|
36
35
|
const handleMouseUp = () => {
|
|
37
36
|
window.removeEventListener("mousemove", handleMouseMove);
|
|
@@ -36,12 +36,12 @@ const ScrollZoomContainer = (props) => {
|
|
|
36
36
|
if (event.altKey) {
|
|
37
37
|
event.preventDefault();
|
|
38
38
|
if (Math.abs(event.deltaX) > Math.abs(event.deltaY)) {
|
|
39
|
-
horizontalViewPort()?.onZoomChange?.(horizontalViewPort().zoom
|
|
39
|
+
horizontalViewPort()?.onZoomChange?.(horizontalViewPort().zoom / (1 + event.deltaX / horizontalViewPort().pixelSize));
|
|
40
40
|
const maxPosition = horizontalViewPort().calculateMaxPosition();
|
|
41
41
|
horizontalViewPort()?.onPositionChange?.(Math.min(maxPosition, horizontalViewPort()?.position));
|
|
42
42
|
}
|
|
43
43
|
else {
|
|
44
|
-
verticalViewPort()?.onZoomChange?.(verticalViewPort().zoom
|
|
44
|
+
verticalViewPort()?.onZoomChange?.(verticalViewPort().zoom / (1 + event.deltaY / verticalViewPort().pixelSize));
|
|
45
45
|
const maxVerticalPosition = verticalViewPort().calculateMaxPosition();
|
|
46
46
|
verticalViewPort()?.onPositionChange?.(Math.min(maxVerticalPosition, verticalViewPort()?.position));
|
|
47
47
|
}
|
|
@@ -3,7 +3,10 @@ import { useViewPortDimension } from "./ScrollZoomViewPort";
|
|
|
3
3
|
const ZoomSliderControl = (props) => {
|
|
4
4
|
const propsWithDefaults = mergeProps({ orientation: "horizontal" }, props);
|
|
5
5
|
const dimension = createMemo(() => useViewPortDimension(props.dimensionName ?? propsWithDefaults.orientation));
|
|
6
|
-
return (<input min={dimension().minZoom} max={dimension().maxZoom} step={0.01} {...props} value={dimension().zoom} onInput={(event) =>
|
|
6
|
+
return (<input min={dimension().minZoom} max={dimension().maxZoom} step={0.01} {...props} value={dimension().zoom} onInput={(event) => {
|
|
7
|
+
const value = event.currentTarget.valueAsNumber;
|
|
8
|
+
dimension().onZoomChange?.(value);
|
|
9
|
+
}} type="range" {...{ orient: propsWithDefaults.orientation }} style={propsWithDefaults.orientation === "vertical"
|
|
7
10
|
? {
|
|
8
11
|
margin: 0,
|
|
9
12
|
"margin-left": "4px",
|
|
@@ -16,12 +16,15 @@ export declare const PianoRollContextProvider: import("solid-js/types/reactive/s
|
|
|
16
16
|
duration: number;
|
|
17
17
|
tracks: import("./types").Track[];
|
|
18
18
|
selectedTrackIndex: number;
|
|
19
|
-
pressedKeys: number
|
|
19
|
+
pressedKeys: Record<number, Record<number, boolean>>;
|
|
20
|
+
notesScrollerClientRect: Pick<import("./useBoundingClientRect").ClientRect, "height" | "width" | "left" | "top">;
|
|
21
|
+
tracksScrollerClientRect: Pick<import("./useBoundingClientRect").ClientRect, "height" | "width" | "left" | "top">;
|
|
20
22
|
onNoteChange: (trackIndex: number, noteIndex: number, note: import("./types").Note) => void;
|
|
21
23
|
onInsertNote: (trackIndex: number, note: import("./types").Note) => number;
|
|
22
24
|
onRemoveNote: (trackIndex: number, noteIndex: number) => void;
|
|
23
|
-
onNoteDown: (keyNumber: number) => void;
|
|
24
|
-
onNoteUp: (keyNumber: number) => void;
|
|
25
|
+
onNoteDown: (trackIndex: number, keyNumber: number) => void;
|
|
26
|
+
onNoteUp: (trackIndex: number, keyNumber: number) => void;
|
|
27
|
+
isKeyDown: (trackIndex: number, keyNumber: number) => boolean;
|
|
25
28
|
onPpqChange: (value: number) => void;
|
|
26
29
|
onModeChange: (value: "keys" | "tracks") => void;
|
|
27
30
|
onPositionChange: (value: number) => void;
|
|
@@ -35,7 +38,9 @@ export declare const PianoRollContextProvider: import("solid-js/types/reactive/s
|
|
|
35
38
|
onDurationChange: (value: number) => void;
|
|
36
39
|
onTracksChange: (value: import("./types").Track[]) => void;
|
|
37
40
|
onSelectedTrackIndexChange: (value: number) => void;
|
|
38
|
-
onPressedKeysChange: (value: number
|
|
41
|
+
onPressedKeysChange: (value: Record<number, Record<number, boolean>>) => void;
|
|
42
|
+
onNotesScrollerClientRectChange: (value: Pick<import("./useBoundingClientRect").ClientRect, "height" | "width" | "left" | "top">) => void;
|
|
43
|
+
onTracksScrollerClientRectChange: (value: Pick<import("./useBoundingClientRect").ClientRect, "height" | "width" | "left" | "top">) => void;
|
|
39
44
|
}>;
|
|
40
45
|
export declare const usePianoRollContext: () => {
|
|
41
46
|
showAllTracks?: boolean;
|
|
@@ -54,12 +59,15 @@ export declare const usePianoRollContext: () => {
|
|
|
54
59
|
duration: number;
|
|
55
60
|
tracks: import("./types").Track[];
|
|
56
61
|
selectedTrackIndex: number;
|
|
57
|
-
pressedKeys: number
|
|
62
|
+
pressedKeys: Record<number, Record<number, boolean>>;
|
|
63
|
+
notesScrollerClientRect: Pick<import("./useBoundingClientRect").ClientRect, "height" | "width" | "left" | "top">;
|
|
64
|
+
tracksScrollerClientRect: Pick<import("./useBoundingClientRect").ClientRect, "height" | "width" | "left" | "top">;
|
|
58
65
|
onNoteChange: (trackIndex: number, noteIndex: number, note: import("./types").Note) => void;
|
|
59
66
|
onInsertNote: (trackIndex: number, note: import("./types").Note) => number;
|
|
60
67
|
onRemoveNote: (trackIndex: number, noteIndex: number) => void;
|
|
61
|
-
onNoteDown: (keyNumber: number) => void;
|
|
62
|
-
onNoteUp: (keyNumber: number) => void;
|
|
68
|
+
onNoteDown: (trackIndex: number, keyNumber: number) => void;
|
|
69
|
+
onNoteUp: (trackIndex: number, keyNumber: number) => void;
|
|
70
|
+
isKeyDown: (trackIndex: number, keyNumber: number) => boolean;
|
|
63
71
|
onPpqChange: (value: number) => void;
|
|
64
72
|
onModeChange: (value: "keys" | "tracks") => void;
|
|
65
73
|
onPositionChange: (value: number) => void;
|
|
@@ -73,7 +81,9 @@ export declare const usePianoRollContext: () => {
|
|
|
73
81
|
onDurationChange: (value: number) => void;
|
|
74
82
|
onTracksChange: (value: import("./types").Track[]) => void;
|
|
75
83
|
onSelectedTrackIndexChange: (value: number) => void;
|
|
76
|
-
onPressedKeysChange: (value: number
|
|
84
|
+
onPressedKeysChange: (value: Record<number, Record<number, boolean>>) => void;
|
|
85
|
+
onNotesScrollerClientRectChange: (value: Pick<import("./useBoundingClientRect").ClientRect, "height" | "width" | "left" | "top">) => void;
|
|
86
|
+
onTracksScrollerClientRectChange: (value: Pick<import("./useBoundingClientRect").ClientRect, "height" | "width" | "left" | "top">) => void;
|
|
77
87
|
};
|
|
78
88
|
export declare const splitContextProps: (allProps: PianoRollProps) => [Pick<PianoRollProps, "onDurationChange" | keyof {
|
|
79
89
|
ppq: number;
|
|
@@ -89,8 +99,10 @@ export declare const splitContextProps: (allProps: PianoRollProps) => [Pick<Pian
|
|
|
89
99
|
duration: number;
|
|
90
100
|
tracks: import("./types").Track[];
|
|
91
101
|
selectedTrackIndex: number;
|
|
92
|
-
pressedKeys: number
|
|
93
|
-
|
|
102
|
+
pressedKeys: Record<number, Record<number, boolean>>;
|
|
103
|
+
notesScrollerClientRect: Pick<import("./useBoundingClientRect").ClientRect, "height" | "width" | "left" | "top">;
|
|
104
|
+
tracksScrollerClientRect: Pick<import("./useBoundingClientRect").ClientRect, "height" | "width" | "left" | "top">;
|
|
105
|
+
} | "onPpqChange" | "onModeChange" | "onPositionChange" | "onZoomChange" | "onVerticalZoomChange" | "onVerticalPositionChange" | "onVerticalTrackZoomChange" | "onVerticalTrackPositionChange" | "onGridDivisionChange" | "onSnapToGridChange" | "onTracksChange" | "onSelectedTrackIndexChange" | "onPressedKeysChange" | "onNotesScrollerClientRectChange" | "onTracksScrollerClientRectChange" | "onNoteChange" | "onInsertNote" | "onRemoveNote" | "onNoteDown" | "onNoteUp" | "isKeyDown" | "showAllTracks" | "showTrackList">, Omit<PianoRollProps, "onDurationChange" | keyof {
|
|
94
106
|
ppq: number;
|
|
95
107
|
mode: "keys" | "tracks";
|
|
96
108
|
position: number;
|
|
@@ -104,5 +116,7 @@ export declare const splitContextProps: (allProps: PianoRollProps) => [Pick<Pian
|
|
|
104
116
|
duration: number;
|
|
105
117
|
tracks: import("./types").Track[];
|
|
106
118
|
selectedTrackIndex: number;
|
|
107
|
-
pressedKeys: number
|
|
108
|
-
|
|
119
|
+
pressedKeys: Record<number, Record<number, boolean>>;
|
|
120
|
+
notesScrollerClientRect: Pick<import("./useBoundingClientRect").ClientRect, "height" | "width" | "left" | "top">;
|
|
121
|
+
tracksScrollerClientRect: Pick<import("./useBoundingClientRect").ClientRect, "height" | "width" | "left" | "top">;
|
|
122
|
+
} | "onPpqChange" | "onModeChange" | "onPositionChange" | "onZoomChange" | "onVerticalZoomChange" | "onVerticalPositionChange" | "onVerticalTrackZoomChange" | "onVerticalTrackPositionChange" | "onGridDivisionChange" | "onSnapToGridChange" | "onTracksChange" | "onSelectedTrackIndexChange" | "onPressedKeysChange" | "onNotesScrollerClientRectChange" | "onTracksScrollerClientRectChange" | "onNoteChange" | "onInsertNote" | "onRemoveNote" | "onNoteDown" | "onNoteUp" | "isKeyDown" | "showAllTracks" | "showTrackList">];
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import PianoRoll from "./PianoRoll";
|
|
2
|
-
import PlayHead from "./PlayHead";
|
|
2
|
+
import PlayHead from "./viewport/PlayHead";
|
|
3
3
|
import useNotes from "./useNotes";
|
|
4
4
|
import createPianoRollstate from "./usePianoRollState";
|
|
5
5
|
export { PianoRoll, createPianoRollstate, useNotes, PlayHead };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
declare const usePianoRollGrid: () => import("solid-js").Accessor<{
|
|
2
|
+
index: number;
|
|
3
|
+
ticks: number;
|
|
4
|
+
isHighlighted: boolean;
|
|
5
|
+
hasHighlightedBorder: boolean;
|
|
6
|
+
showLabel: boolean;
|
|
7
|
+
virtualDimensions: {
|
|
8
|
+
offset: number;
|
|
9
|
+
size: number;
|
|
10
|
+
};
|
|
11
|
+
label: string;
|
|
12
|
+
}[]>;
|
|
13
|
+
export default usePianoRollGrid;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { GridDivision } from "./PianoRoll";
|
|
2
2
|
import { Note, Track } from "./types";
|
|
3
|
+
import { ClientRect } from "./useBoundingClientRect";
|
|
3
4
|
type PianoRollState = {
|
|
4
5
|
ppq: number;
|
|
5
6
|
mode: "keys" | "tracks";
|
|
@@ -14,9 +15,11 @@ type PianoRollState = {
|
|
|
14
15
|
duration: number;
|
|
15
16
|
tracks: Track[];
|
|
16
17
|
selectedTrackIndex: number;
|
|
17
|
-
pressedKeys: number
|
|
18
|
+
pressedKeys: Record<number, Record<number, boolean>>;
|
|
19
|
+
notesScrollerClientRect: Pick<ClientRect, "left" | "width" | "top" | "height">;
|
|
20
|
+
tracksScrollerClientRect: Pick<ClientRect, "left" | "width" | "top" | "height">;
|
|
18
21
|
};
|
|
19
|
-
export declare const pianoRollStatePropNames: ("onDurationChange" | keyof PianoRollState | "onPpqChange" | "onModeChange" | "onPositionChange" | "onZoomChange" | "onVerticalZoomChange" | "onVerticalPositionChange" | "onVerticalTrackZoomChange" | "onVerticalTrackPositionChange" | "onGridDivisionChange" | "onSnapToGridChange" | "onTracksChange" | "onSelectedTrackIndexChange" | "onPressedKeysChange" | "onNoteChange" | "onInsertNote" | "onRemoveNote" | "onNoteDown" | "onNoteUp")[];
|
|
22
|
+
export declare const pianoRollStatePropNames: ("onDurationChange" | keyof PianoRollState | "onPpqChange" | "onModeChange" | "onPositionChange" | "onZoomChange" | "onVerticalZoomChange" | "onVerticalPositionChange" | "onVerticalTrackZoomChange" | "onVerticalTrackPositionChange" | "onGridDivisionChange" | "onSnapToGridChange" | "onTracksChange" | "onSelectedTrackIndexChange" | "onPressedKeysChange" | "onNotesScrollerClientRectChange" | "onTracksScrollerClientRectChange" | "onNoteChange" | "onInsertNote" | "onRemoveNote" | "onNoteDown" | "onNoteUp" | "isKeyDown")[];
|
|
20
23
|
declare const createPianoRollstate: (initialState?: Partial<PianoRollState>) => {
|
|
21
24
|
ppq: number;
|
|
22
25
|
mode: "keys" | "tracks";
|
|
@@ -31,12 +34,15 @@ declare const createPianoRollstate: (initialState?: Partial<PianoRollState>) =>
|
|
|
31
34
|
duration: number;
|
|
32
35
|
tracks: Track[];
|
|
33
36
|
selectedTrackIndex: number;
|
|
34
|
-
pressedKeys: number
|
|
37
|
+
pressedKeys: Record<number, Record<number, boolean>>;
|
|
38
|
+
notesScrollerClientRect: Pick<ClientRect, "left" | "width" | "top" | "height">;
|
|
39
|
+
tracksScrollerClientRect: Pick<ClientRect, "left" | "width" | "top" | "height">;
|
|
35
40
|
onNoteChange: (trackIndex: number, noteIndex: number, note: Note) => void;
|
|
36
41
|
onInsertNote: (trackIndex: number, note: Note) => number;
|
|
37
42
|
onRemoveNote: (trackIndex: number, noteIndex: number) => void;
|
|
38
|
-
onNoteDown: (keyNumber: number) => void;
|
|
39
|
-
onNoteUp: (keyNumber: number) => void;
|
|
43
|
+
onNoteDown: (trackIndex: number, keyNumber: number) => void;
|
|
44
|
+
onNoteUp: (trackIndex: number, keyNumber: number) => void;
|
|
45
|
+
isKeyDown: (trackIndex: number, keyNumber: number) => boolean;
|
|
40
46
|
onPpqChange: (value: number) => void;
|
|
41
47
|
onModeChange: (value: "keys" | "tracks") => void;
|
|
42
48
|
onPositionChange: (value: number) => void;
|
|
@@ -50,6 +56,8 @@ declare const createPianoRollstate: (initialState?: Partial<PianoRollState>) =>
|
|
|
50
56
|
onDurationChange: (value: number) => void;
|
|
51
57
|
onTracksChange: (value: Track[]) => void;
|
|
52
58
|
onSelectedTrackIndexChange: (value: number) => void;
|
|
53
|
-
onPressedKeysChange: (value: number
|
|
59
|
+
onPressedKeysChange: (value: Record<number, Record<number, boolean>>) => void;
|
|
60
|
+
onNotesScrollerClientRectChange: (value: Pick<ClientRect, "height" | "width" | "left" | "top">) => void;
|
|
61
|
+
onTracksScrollerClientRectChange: (value: Pick<ClientRect, "height" | "width" | "left" | "top">) => void;
|
|
54
62
|
};
|
|
55
63
|
export default createPianoRollstate;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { JSX } from "solid-js";
|
|
2
2
|
declare const PlayHead: (allProps: {
|
|
3
|
-
|
|
3
|
+
position: number;
|
|
4
|
+
onPositionChange?: (playHeadPosition: number) => void;
|
|
4
5
|
sync?: boolean;
|
|
5
|
-
|
|
6
|
-
onPositionChange?: (position: number) => void;
|
|
6
|
+
dimensionName?: string;
|
|
7
7
|
} & JSX.HTMLAttributes<HTMLDivElement>) => JSX.Element;
|
|
8
8
|
export default PlayHead;
|
package/package.json
CHANGED