Skip to content

Commit 7353b14

Browse files
authored
feat: Base implementation for media sync editor (#132)
1 parent 224c52b commit 7353b14

File tree

10 files changed

+1154
-25
lines changed

10 files changed

+1154
-25
lines changed

.vscode/settings.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,7 @@
2525
"titleBar.inactiveBackground": "#21573299",
2626
"titleBar.inactiveForeground": "#e7e7e799"
2727
},
28-
"peacock.color": "#215732"
28+
"peacock.color": "#215732",
29+
"editor.snippetSuggestions": "bottom",
30+
"emmet.showSuggestionsAsSnippets": true,
2931
}

docs/playground/playground.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ import { AlphaTabPlayground } from "@site/src/components/AlphaTabPlayground";
1111
<AlphaTabPlayground
1212
settings={{
1313
core: {
14-
file: "/files/canon.gp",
15-
tracks: [0],
14+
file: "/files/canon-full.gp",
15+
tracks: [0,1],
1616
},
1717
}}
1818
/>

package-lock.json

Lines changed: 45 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,18 @@
1616
"generate-alphatabdoc": "tsx scripts/generate-alphatabdoc.mts"
1717
},
1818
"dependencies": {
19-
"@coderline/alphatab": "^1.5.0-alpha.1394",
19+
"@coderline/alphatab": "^1.6.0-alpha.1416",
2020
"@docusaurus/core": "^3.7.0",
2121
"@docusaurus/preset-classic": "^3.7.0",
2222
"@docusaurus/theme-mermaid": "^3.7.0",
2323
"@fontsource/noto-sans": "^5.1.1",
2424
"@fontsource/noto-serif": "^5.1.1",
25+
"@fortawesome/free-brands-svg-icons": "^6.7.2",
2526
"@fortawesome/free-regular-svg-icons": "^6.7.2",
2627
"@fortawesome/free-solid-svg-icons": "^6.7.2",
2728
"@fortawesome/react-fontawesome": "^0.2.2",
2829
"@mdx-js/react": "^3.1.0",
30+
"@react-hook/resize-observer": "^2.0.2",
2931
"@uidotdev/usehooks": "^2.4.1",
3032
"@uiw/react-color": "^2.5.5",
3133
"@uiw/react-color-chrome": "^2.5.5",

src/components/AlphaTabPlayground/index.tsx

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
'use client';
22

3-
import type * as alphaTab from '@coderline/alphatab';
4-
import React, { useEffect, useState } from 'react';
3+
import * as alphaTab from '@coderline/alphatab';
4+
import React, { useState } from 'react';
55
import { useAlphaTab, useAlphaTabEvent } from '@site/src/hooks';
66
import styles from './styles.module.scss';
77
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
88
import * as solid from '@fortawesome/free-solid-svg-icons';
99
import { openFile } from '@site/src/utils';
10-
import { PlayerControlsGroup, SidePanel } from './player-controls-group';
10+
import { BottomPanel, PlayerControlsGroup, SidePanel } from './player-controls-group';
1111
import { PlaygroundSettings } from './playground-settings';
1212
import { Tooltip } from 'react-tooltip';
1313
import { PlaygroundTrackSelector } from './track-selector';
14+
import { MediaSyncEditor } from './media-sync-editor';
1415

1516
interface AlphaTabPlaygroundProps {
1617
settings?: alphaTab.json.SettingsJson;
@@ -20,12 +21,13 @@ export const AlphaTabPlayground: React.FC<AlphaTabPlaygroundProps> = ({ settings
2021
const viewPortRef = React.createRef<HTMLDivElement>();
2122
const [isLoading, setLoading] = useState(true);
2223
const [sidePanel, setSidePanel] = useState(SidePanel.None);
24+
const [bottomPanel, setBottomPanel] = useState(BottomPanel.None);
2325

2426
const [api, element] = useAlphaTab(s => {
2527
s.core.engine = 'svg';
2628
s.player.scrollElement = viewPortRef.current!;
2729
s.player.scrollOffsetY = -10;
28-
s.player.enablePlayer = true;
30+
s.player.playerMode = alphaTab.PlayerMode.EnabledAutomatic;
2931
if (settings) {
3032
s.fillFromJson(settings);
3133
}
@@ -88,7 +90,18 @@ export const AlphaTabPlayground: React.FC<AlphaTabPlaygroundProps> = ({ settings
8890
</div>
8991

9092
<div className={styles['at-footer']}>
91-
{api && <PlayerControlsGroup api={api} sidePanel={sidePanel} onSidePanelChange={setSidePanel} />}
93+
{api && api?.score && bottomPanel === BottomPanel.MediaSyncEditor && (
94+
<MediaSyncEditor api={api} score={api!.score} />
95+
)}
96+
{api && (
97+
<PlayerControlsGroup
98+
api={api}
99+
sidePanel={sidePanel}
100+
onSidePanelChange={setSidePanel}
101+
bottomPanel={bottomPanel}
102+
onBottomPanelChange={setBottomPanel}
103+
/>
104+
)}
92105
</div>
93106
</div>
94107
<Tooltip anchorSelect="[data-tooltip-content]" id="tooltip-playground" style={{ zIndex: 1200 }} />

0 commit comments

Comments
 (0)