Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a55281b1aa | ||
|
|
b236d40053 | ||
|
|
ad518ad2a6 | ||
|
|
33626aaf55 | ||
|
|
7481fbf711 | ||
|
|
42735005b1 | ||
|
|
22606e7f79 | ||
|
|
a9d3331044 | ||
|
|
08e3e8f46d | ||
|
|
5c45ac845d | ||
|
|
3bb59d6021 | ||
|
|
aaed0f3548 | ||
|
|
dbbedf9ab3 | ||
|
|
ea98a547c1 | ||
|
|
091e940013 | ||
|
|
493a969ca8 | ||
|
|
3caf21794d | ||
|
|
302128fdbc | ||
|
|
e0c33ca624 | ||
|
|
5497b16ac0 | ||
|
|
eea360600b | ||
|
|
c93e985a47 | ||
|
|
adad6ec27f | ||
|
|
fa42c6f8a0 | ||
|
|
5425e1e3ff | ||
|
|
e7b6c0bb3e | ||
|
|
02eb8911e8 | ||
|
|
ec2792736d |
No files matched your search
@@ -10,3 +10,4 @@ ios/App/Pods/
|
|||||||
ios/App/DerivedData/
|
ios/App/DerivedData/
|
||||||
ios/App/*.xcworkspace/xcuserdata/
|
ios/App/*.xcworkspace/xcuserdata/
|
||||||
ios/App/*.xcodeproj/xcuserdata/
|
ios/App/*.xcodeproj/xcuserdata/
|
||||||
|
bug_image/*
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
# BeatHound
|
# BeatHound
|
||||||
|
|
||||||
BeatHound is a small, mobile-friendly beat maker. Place beats on labeled category rings, identify them by letter, rename legend categories with a long press, adjust pitch where supported, and play the loop in your browser.
|
BeatHound is a small, mobile-friendly beat maker. Place beats on labeled category rings, identify them by letter, rename legend categories with a long press, adjust pitch where supported, and play the loop in your browser. The current mobile app is an Android/e/OS prototype; iOS is not supported at this time for financial reasons.
|
||||||
|
|
||||||
## Start here
|
## Start here
|
||||||
|
|
||||||
@@ -30,20 +30,19 @@ Open the local web address shown by Vite. Choose a dance template or add a sound
|
|||||||
|
|
||||||
## Mobile downloads
|
## Mobile downloads
|
||||||
|
|
||||||
- [Android / e/OS debug APK](downloads/BeatHound-Android-eOS-1.0.0-debug.apk) — installable on Android API 24 or newer. The same APK is intended for compatible e/OS 4+ devices.
|
- [Android / e/OS debug APK 0.1.0](downloads/BeatHound-Android-eOS-0.1.0-debug.apk) — installable on Android API 24 or newer. The same APK is intended for compatible e/OS 4+ devices.
|
||||||
- **iOS:** An IPA is not included because iOS apps must be built and signed with Xcode on macOS. See the [native build guide](docs/native-builds.md).
|
|
||||||
|
|
||||||
The Android file is a debug-signed build for testing. It is not a Google Play release package.
|
The Android file is a debug-signed build for testing. It is not a Google Play release package. No iOS app or download is currently supported because of financial constraints.
|
||||||
|
|
||||||
## Build the mobile apps
|
## Build the Android prototype
|
||||||
|
|
||||||
The project uses Capacitor for native Android and iOS shells.
|
The mobile prototype uses Capacitor for Android.
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
npm run android:debug
|
npm run android:debug
|
||||||
```
|
```
|
||||||
|
|
||||||
The Android build needs JDK 21 and Android SDK Platform 36 / Build Tools 36.0.0. It writes the Gradle output and copies the APK to `downloads/BeatHound-Android-eOS-1.0.0-debug.apk`. For iOS, use macOS with Xcode: run `npm run ios:sync`, then `npm run ios:open` and archive/sign the app in Xcode. Full setup steps are in the [native build guide](docs/native-builds.md).
|
The Android build needs JDK 21 and Android SDK Platform 36 / Build Tools 36.0.0. It writes the Gradle output and copies the APK to `downloads/BeatHound-Android-eOS-0.1.0-debug.apk`. iOS is currently unsupported for financial reasons; see the [native build guide](docs/native-builds.md).
|
||||||
|
|
||||||
## Project checks
|
## Project checks
|
||||||
|
|
||||||
|
|||||||
@@ -7,8 +7,8 @@ android {
|
|||||||
applicationId "com.ninosaurier.beathound"
|
applicationId "com.ninosaurier.beathound"
|
||||||
minSdkVersion rootProject.ext.minSdkVersion
|
minSdkVersion rootProject.ext.minSdkVersion
|
||||||
targetSdkVersion rootProject.ext.targetSdkVersion
|
targetSdkVersion rootProject.ext.targetSdkVersion
|
||||||
versionCode 1
|
versionCode 4
|
||||||
versionName "1.0.0"
|
versionName "0.1.0"
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
aaptOptions {
|
aaptOptions {
|
||||||
// Files and dirs to omit from the packaged assets dir, modified to accommodate modern web apps.
|
// Files and dirs to omit from the packaged assets dir, modified to accommodate modern web apps.
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
android:label="@string/title_activity_main"
|
android:label="@string/title_activity_main"
|
||||||
android:theme="@style/AppTheme.NoActionBarLaunch"
|
android:theme="@style/AppTheme.NoActionBarLaunch"
|
||||||
android:launchMode="singleTask"
|
android:launchMode="singleTask"
|
||||||
|
android:windowSoftInputMode="adjustResize"
|
||||||
android:exported="true">
|
android:exported="true">
|
||||||
|
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 4.2 KiB |
|
Before Width: | Height: | Size: 3.4 KiB After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 3.8 KiB |
|
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 2.7 KiB |
|
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 8.0 KiB |
|
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 2.5 KiB |
|
Before Width: | Height: | Size: 3.9 KiB After Width: | Height: | Size: 5.8 KiB |
|
Before Width: | Height: | Size: 4.9 KiB After Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 6.4 KiB After Width: | Height: | Size: 5.1 KiB |
|
Before Width: | Height: | Size: 6.5 KiB After Width: | Height: | Size: 8.9 KiB |
|
Before Width: | Height: | Size: 9.6 KiB After Width: | Height: | Size: 25 KiB |
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 7.7 KiB |
|
Before Width: | Height: | Size: 9.2 KiB After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 33 KiB |
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 10 KiB |
@@ -1,4 +1,4 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
<color name="ic_launcher_background">#FFFFFF</color>
|
<color name="ic_launcher_background">#24215E</color>
|
||||||
</resources>
|
</resources>
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
# Native Mobile Builds
|
# Native Mobile Builds
|
||||||
|
|
||||||
BeatHound uses Capacitor to wrap the web app for Android and iOS. The `android/` and `ios/` folders contain the native projects.
|
BeatHound's current mobile target is an Android/e/OS prototype using Capacitor. An iOS project scaffold exists, but iOS is not supported at this time for financial reasons; there is no supported iOS build or distribution process.
|
||||||
|
|
||||||
## Android and e/OS
|
## Android and e/OS prototype
|
||||||
|
|
||||||
The Android project has a minimum SDK level of 24. It can run on Android 7.0 and newer. Compatible e/OS 4 or newer devices can install the same APK when their Android base meets that minimum.
|
The Android project has a minimum SDK level of 24. It can run on Android 7.0 and newer. Compatible e/OS 4 or newer devices can install the same APK when their Android base meets that minimum.
|
||||||
|
|
||||||
@@ -35,27 +35,16 @@ adb install downloads/BeatHound-Android-eOS-1.0.0-debug.apk
|
|||||||
|
|
||||||
You can also transfer the APK to the device and open it. The device may ask you to allow installation from that file source.
|
You can also transfer the APK to the device and open it. The device may ask you to allow installation from that file source.
|
||||||
|
|
||||||
## iOS
|
## iOS status
|
||||||
|
|
||||||
Capacitor's Xcode project is in `ios/App/App.xcodeproj`. An IPA must be built on macOS with Xcode and signed for distribution. This Linux build environment can prepare and sync the project, but it cannot produce or sign an IPA.
|
The repository contains an iOS project scaffold, but it is not a supported target. iOS development, testing, and distribution are currently out of scope for financial reasons. The unsigned IPA tooling is experimental and is not a supported release or installation path.
|
||||||
|
|
||||||
On a Mac:
|
|
||||||
|
|
||||||
1. Install Node.js and Xcode.
|
|
||||||
2. Run `npm install` in the repository.
|
|
||||||
3. Run `npm run ios:sync` to build the web assets and copy them into the iOS project.
|
|
||||||
4. Run `npm run ios:open` to open the project in Xcode.
|
|
||||||
5. Select an Apple development team and signing method in Xcode.
|
|
||||||
6. Archive the app and export the signed IPA from Xcode.
|
|
||||||
|
|
||||||
Do not commit Apple certificates, provisioning profiles, or signing keys to this repository. Add the exported IPA to `downloads/` only after it has been signed for the intended distribution method.
|
|
||||||
|
|
||||||
## Mobile build commands
|
## Mobile build commands
|
||||||
|
|
||||||
| Command | Result |
|
| Command | Result |
|
||||||
| --- | --- |
|
| --- | --- |
|
||||||
| `npm run build:mobile` | Builds the web assets with relative paths for Capacitor. |
|
| `npm run build:mobile` | Builds the web assets with relative paths for Capacitor. |
|
||||||
| `npm run cap:sync` | Builds web assets and syncs both native projects. |
|
| `npm run cap:sync` | Builds web assets and syncs the local Capacitor projects; Android/e/OS is the supported prototype target. |
|
||||||
| `npm run android:debug` | Builds and syncs Android, then creates a debug APK. |
|
| `npm run android:debug` | Builds and syncs Android, then creates a debug APK. |
|
||||||
| `npm run ios:sync` | Builds and syncs the iOS project. |
|
| `npm run ios:sync` | Syncs the iOS scaffold; this does not mean iOS is a supported target. |
|
||||||
| `npm run ios:open` | Opens the iOS project in Xcode; run this on macOS. |
|
| `npm run ios:open` | Opens the iOS scaffold in Xcode; iOS builds are unsupported. |
|
||||||
@@ -15,8 +15,7 @@ Main tools:
|
|||||||
- **React** builds the interface and manages state.
|
- **React** builds the interface and manages state.
|
||||||
- **TypeScript** checks types before the app is built.
|
- **TypeScript** checks types before the app is built.
|
||||||
- **Ionic React** provides page and control components.
|
- **Ionic React** provides page and control components.
|
||||||
- **Capacitor** wraps the web app in native Android and iOS projects.
|
- **Capacitor** wraps the web app in native projects. Android/e/OS is the current mobile prototype; iOS is not supported for financial reasons.
|
||||||
- **Capacitor** wraps the web app in native Android and iOS projects.
|
|
||||||
- **Ionicons** provides the control icons.
|
- **Ionicons** provides the control icons.
|
||||||
- **Vite** runs the local development server and builds the static site.
|
- **Vite** runs the local development server and builds the static site.
|
||||||
- **Vitest** runs the tests.
|
- **Vitest** runs the tests.
|
||||||
@@ -285,13 +284,13 @@ npm test
|
|||||||
|
|
||||||
The scripts are defined in `package.json`. `npm run build` first runs TypeScript with no output, then Vite writes the app's static production site to `dist/`. The React plugin and Vitest environment are set in `vite.config.ts`. TypeScript strict options are in `tsconfig.json`; ESLint rules are in `eslint.config.js`.
|
The scripts are defined in `package.json`. `npm run build` first runs TypeScript with no output, then Vite writes the app's static production site to `dist/`. The React plugin and Vitest environment are set in `vite.config.ts`. TypeScript strict options are in `tsconfig.json`; ESLint rules are in `eslint.config.js`.
|
||||||
|
|
||||||
`capacitor.config.ts` sets the native app ID and points Capacitor to `dist/`. The Android debug build is copied into `downloads/` by `npm run android:debug`. iOS project sync is available on all platforms, but creating a signed IPA requires macOS and Xcode.
|
`capacitor.config.ts` sets the native app ID and points Capacitor to `dist/`. The Android debug build is copied into `downloads/` by `npm run android:debug`. An iOS scaffold exists, but iOS development, testing, and distribution are not currently supported for financial reasons.
|
||||||
|
|
||||||
`capacitor.config.ts` points Capacitor to the `dist/` web build and defines the native app ID. `npm run build:mobile` uses relative asset paths so the native WebView can load local files.
|
`capacitor.config.ts` points Capacitor to the `dist/` web build and defines the native app ID. `npm run build:mobile` uses relative asset paths so the native WebView can load local files.
|
||||||
|
|
||||||
The documentation site uses VitePress. Run `npm run docs:dev` to work on it locally, `npm run docs:build` to create its static files in `docs/.vitepress/dist/`, and `npm run docs:preview` to view that build. The pages are Markdown files under `docs/`; navigation and local search are set in `docs/.vitepress/config.mts`.
|
The documentation site uses VitePress. Run `npm run docs:dev` to work on it locally, `npm run docs:build` to create its static files in `docs/.vitepress/dist/`, and `npm run docs:preview` to view that build. The pages are Markdown files under `docs/`; navigation and local search are set in `docs/.vitepress/config.mts`.
|
||||||
|
|
||||||
The project includes a web manifest and home-screen icons in `public/`, plus Capacitor wrappers in `android/` and `ios/`. It does not include a service worker, offline caching, persistence, or a server deployment configuration. Native build steps are in [Native Mobile Builds](native-builds.md).
|
The project includes a web manifest and home-screen icons in `public/`, plus Capacitor wrappers in `android/` and `ios/`. Android/e/OS is the current mobile prototype; the iOS scaffold is not a supported target. The project does not include a service worker, offline caching, persistence, or a server deployment configuration. Native build steps are in [Native Mobile Builds](native-builds.md).
|
||||||
|
|
||||||
## 10. Main implementation limits
|
## 10. Main implementation limits
|
||||||
|
|
||||||
@@ -301,4 +300,4 @@ The project includes a web manifest and home-screen icons in `public/`, plus Cap
|
|||||||
- Playback timing uses a browser interval and may drift under load.
|
- Playback timing uses a browser interval and may drift under load.
|
||||||
- Points are rounded to one of four playback subdivisions per main step when they play.
|
- Points are rounded to one of four playback subdivisions per main step when they play.
|
||||||
- The app makes audio with browser-generated oscillators and noise. It does not load user audio files.
|
- The app makes audio with browser-generated oscillators and noise. It does not load user audio files.
|
||||||
- iOS IPA creation requires macOS, Xcode, and signing configured outside this Linux build environment.
|
- iOS development, testing, and distribution are currently unsupported for financial reasons.
|
||||||
@@ -66,7 +66,7 @@ Browsers often block sound until the user interacts with the page. Press **Play*
|
|||||||
|
|
||||||
The app makes playback ticks with a browser timer. At each tick it checks whether a sound point should play. The exact timing can depend on the browser and the device.
|
The app makes playback ticks with a browser timer. At each tick it checks whether a sound point should play. The exact timing can depend on the browser and the device.
|
||||||
|
|
||||||
The page layout adapts to different screen sizes. The project includes a web app manifest, icons, and Capacitor projects for Android and iOS. It does not include code for saving patterns or working offline. See the [native build guide](native-builds.md) for mobile build requirements.
|
The page layout adapts to different screen sizes. The project includes a web app manifest and icons. The current mobile prototype targets Android/e/OS; iOS is not supported at this time for financial reasons. The app does not include code for saving patterns or working offline. See the [native build guide](native-builds.md) for mobile build requirements.
|
||||||
|
|
||||||
## 4. Run the project on your computer
|
## 4. Run the project on your computer
|
||||||
|
|
||||||
@@ -100,7 +100,7 @@ npm test
|
|||||||
|
|
||||||
## 5. How the software is organized
|
## 5. How the software is organized
|
||||||
|
|
||||||
BeatHound is a React and TypeScript app. Ionic React provides many of the buttons, popovers, and page elements. Vite runs the development server and builds the web app. Capacitor wraps that web app in Android and iOS projects.
|
BeatHound is a React and TypeScript app. Ionic React provides many of the buttons, popovers, and page elements. Vite runs the development server and builds the web app. Capacitor wraps that web app in native projects; Android/e/OS is the current mobile prototype, while iOS is unsupported for financial reasons.
|
||||||
|
|
||||||
The main path through the app is:
|
The main path through the app is:
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
# iOS availability
|
||||||
|
|
||||||
|
BeatHound currently has an Android/e/OS mobile prototype. iOS is not supported at this time for financial reasons, and no iOS app or download is provided.
|
||||||
|
|
||||||
|
An iOS project scaffold and experimental build tooling remain in the repository, but they are not maintained or supported for building, testing, or distribution. See the [native build guide](../../docs/native-builds.md#ios-status) for the current status.
|
||||||
|
Before Width: | Height: | Size: 108 KiB After Width: | Height: | Size: 74 KiB |
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "beat-hound",
|
"name": "beat-hound",
|
||||||
"version": "1.0.0",
|
"version": "0.1.0",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "beat-hound",
|
"name": "beat-hound",
|
||||||
"version": "1.0.0",
|
"version": "0.1.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@capacitor/android": "^8.6.2",
|
"@capacitor/android": "^8.6.2",
|
||||||
"@capacitor/core": "^8.6.2",
|
"@capacitor/core": "^8.6.2",
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "beat-hound",
|
"name": "beat-hound",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "1.0.0",
|
"version": "0.1.0",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite --host 0.0.0.0",
|
"dev": "vite --host 0.0.0.0",
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
"docs:build": "vitepress build docs",
|
"docs:build": "vitepress build docs",
|
||||||
"docs:preview": "vitepress preview docs --host 0.0.0.0",
|
"docs:preview": "vitepress preview docs --host 0.0.0.0",
|
||||||
"cap:sync": "npm run build:mobile && cap sync",
|
"cap:sync": "npm run build:mobile && cap sync",
|
||||||
"android:debug": "npm run build:mobile && cap sync android && cd android && ./gradlew assembleDebug && cd .. && mkdir -p downloads && cp android/app/build/outputs/apk/debug/app-debug.apk downloads/BeatHound-Android-eOS-1.0.0-debug.apk",
|
"android:debug": "npm run build:mobile && cap sync android && cd android && ./gradlew assembleDebug && cd .. && mkdir -p downloads && cp android/app/build/outputs/apk/debug/app-debug.apk downloads/BeatHound-Android-eOS-0.1.0-debug.apk",
|
||||||
"ios:sync": "npm run build:mobile && cap sync ios",
|
"ios:sync": "npm run build:mobile && cap sync ios",
|
||||||
"ios:open": "cap open ios",
|
"ios:open": "cap open ios",
|
||||||
"test": "vitest run",
|
"test": "vitest run",
|
||||||
|
|||||||
@@ -0,0 +1,50 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||||
|
cd "$ROOT_DIR"
|
||||||
|
|
||||||
|
if [[ "$(uname -s)" != "Darwin" ]]; then
|
||||||
|
printf 'Building an iOS IPA requires macOS and Xcode.\n' >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! command -v xcodebuild >/dev/null 2>&1; then
|
||||||
|
printf 'xcodebuild was not found. Install Xcode and its command line tools first.\n' >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
npm run ios:sync
|
||||||
|
|
||||||
|
DERIVED_DATA_DIR="$ROOT_DIR/ios/App/DerivedData/UnsignedIPA"
|
||||||
|
APP_PATH="$DERIVED_DATA_DIR/Build/Products/Release-iphoneos/App.app"
|
||||||
|
OUTPUT_DIR="$ROOT_DIR/downloads/ios"
|
||||||
|
OUTPUT_IPA="$OUTPUT_DIR/BeatHound-iOS-1.0.0-unsigned.ipa"
|
||||||
|
PACKAGE_DIR="$(mktemp -d)"
|
||||||
|
trap 'rm -rf "$PACKAGE_DIR"' EXIT
|
||||||
|
|
||||||
|
xcodebuild \
|
||||||
|
-project ios/App/App.xcodeproj \
|
||||||
|
-scheme App \
|
||||||
|
-configuration Release \
|
||||||
|
-sdk iphoneos \
|
||||||
|
-destination 'generic/platform=iOS' \
|
||||||
|
-derivedDataPath "$DERIVED_DATA_DIR" \
|
||||||
|
CODE_SIGNING_ALLOWED=NO \
|
||||||
|
CODE_SIGNING_REQUIRED=NO \
|
||||||
|
CODE_SIGN_IDENTITY='' \
|
||||||
|
build
|
||||||
|
|
||||||
|
if [[ ! -d "$APP_PATH" ]]; then
|
||||||
|
printf 'Xcode completed without producing the expected app at %s\n' "$APP_PATH" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
mkdir -p "$PACKAGE_DIR/Payload" "$OUTPUT_DIR"
|
||||||
|
ditto "$APP_PATH" "$PACKAGE_DIR/Payload/App.app"
|
||||||
|
(
|
||||||
|
cd "$PACKAGE_DIR"
|
||||||
|
/usr/bin/zip -qry "$OUTPUT_IPA" Payload
|
||||||
|
)
|
||||||
|
|
||||||
|
printf 'Created %s\n' "$OUTPUT_IPA"
|
||||||
@@ -22,7 +22,10 @@ function App() {
|
|||||||
return (
|
return (
|
||||||
<IonApp>
|
<IonApp>
|
||||||
<IonPage>
|
<IonPage>
|
||||||
<IonContent fullscreen className="app-content">
|
<IonContent
|
||||||
|
fullscreen
|
||||||
|
className={`app-content${isStudioView ? ' app-content-studio' : ''}`}
|
||||||
|
>
|
||||||
<div className="app-shell">
|
<div className="app-shell">
|
||||||
<AppHeader activeView={activeView} onNavigate={navigateTo} />
|
<AppHeader activeView={activeView} onNavigate={navigateTo} />
|
||||||
{isStudioView ? (
|
{isStudioView ? (
|
||||||
@@ -38,10 +41,8 @@ function App() {
|
|||||||
isPlaying={studio.sequencer.isPlaying}
|
isPlaying={studio.sequencer.isPlaying}
|
||||||
isStarting={studio.sequencer.isStarting}
|
isStarting={studio.sequencer.isStarting}
|
||||||
hasBeats={studio.sequencer.beats.length > 0}
|
hasBeats={studio.sequencer.beats.length > 0}
|
||||||
selectedBeat={studio.sequencer.selectedBeat}
|
|
||||||
onTogglePlayback={studio.sequencer.togglePlayback}
|
onTogglePlayback={studio.sequencer.togglePlayback}
|
||||||
onAddInstrument={studio.addSound}
|
onAddInstrument={studio.addSound}
|
||||||
onChangeBeatPitch={studio.sequencer.changeBeatPitch}
|
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</IonPage>
|
</IonPage>
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import { useRef } from 'react';
|
|
||||||
import { IonButton, IonIcon, IonPopover } from '@ionic/react';
|
import { IonButton, IonIcon, IonPopover } from '@ionic/react';
|
||||||
import { ellipsisVertical } from 'ionicons/icons';
|
import { ellipsisVertical } from 'ionicons/icons';
|
||||||
import { usePopoverDisclosure } from '../hooks/usePopoverDisclosure';
|
import { usePopoverDisclosure } from '../hooks/usePopoverDisclosure';
|
||||||
@@ -10,11 +9,9 @@ interface AppHeaderProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function AppHeader({ activeView, onNavigate }: AppHeaderProps) {
|
export function AppHeader({ activeView, onNavigate }: AppHeaderProps) {
|
||||||
const popoverRef = useRef<HTMLIonPopoverElement>(null);
|
|
||||||
const popover = usePopoverDisclosure();
|
const popover = usePopoverDisclosure();
|
||||||
|
|
||||||
function selectView(view: AppView): void {
|
function selectView(view: AppView): void {
|
||||||
void popoverRef.current?.dismiss();
|
|
||||||
onNavigate(view);
|
onNavigate(view);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -38,7 +35,7 @@ export function AppHeader({ activeView, onNavigate }: AppHeaderProps) {
|
|||||||
|
|
||||||
<div className="app-header-actions">
|
<div className="app-header-actions">
|
||||||
<IonButton
|
<IonButton
|
||||||
id="app-menu-trigger"
|
id={popover.triggerId}
|
||||||
className="app-menu-trigger"
|
className="app-menu-trigger"
|
||||||
fill="clear"
|
fill="clear"
|
||||||
aria-label="Open app menu"
|
aria-label="Open app menu"
|
||||||
@@ -51,11 +48,12 @@ export function AppHeader({ activeView, onNavigate }: AppHeaderProps) {
|
|||||||
|
|
||||||
<IonPopover
|
<IonPopover
|
||||||
className="app-menu-popover"
|
className="app-menu-popover"
|
||||||
ref={popoverRef}
|
trigger={popover.triggerId}
|
||||||
trigger="app-menu-trigger"
|
reference="trigger"
|
||||||
triggerAction="click"
|
size="auto"
|
||||||
side="bottom"
|
side="bottom"
|
||||||
alignment="end"
|
alignment="end"
|
||||||
|
dismissOnSelect
|
||||||
onDidPresent={popover.onDidPresent}
|
onDidPresent={popover.onDidPresent}
|
||||||
onDidDismiss={popover.onDidDismiss}
|
onDidDismiss={popover.onDidDismiss}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -2,45 +2,40 @@ import { useMemo } from 'react';
|
|||||||
import { IonButton, IonIcon } from '@ionic/react';
|
import { IonButton, IonIcon } from '@ionic/react';
|
||||||
import { trash } from 'ionicons/icons';
|
import { trash } from 'ionicons/icons';
|
||||||
import { BeatSelectionHint } from './BeatSelectionHint';
|
import { BeatSelectionHint } from './BeatSelectionHint';
|
||||||
import { CategoryLegend } from './CategoryLegend';
|
import { SampleLegend } from './CategoryLegend';
|
||||||
import { CategoryRingSelector } from './CategoryRingSelector';
|
|
||||||
import { CircularTimeline } from './CircularTimeline';
|
import { CircularTimeline } from './CircularTimeline';
|
||||||
|
import { PitchControl } from './PitchControl';
|
||||||
|
import { SoundRingSelector } from './SoundRingSelector';
|
||||||
import { TempoControl } from './TempoControl';
|
import { TempoControl } from './TempoControl';
|
||||||
import { TimeSignatureSelector } from './TimeSignatureSelector';
|
import { TimeSignatureSelector } from './TimeSignatureSelector';
|
||||||
import {
|
import {
|
||||||
INSTRUMENT_BY_ID,
|
INSTRUMENT_BY_ID,
|
||||||
INSTRUMENT_CATEGORIES,
|
INSTRUMENT_CATALOG,
|
||||||
INSTRUMENT_CATEGORY_BY_ID,
|
|
||||||
} from '../domain/instruments';
|
} from '../domain/instruments';
|
||||||
import type { InstrumentCategoryId } from '../domain/instruments';
|
|
||||||
import type { BeatSequencer } from '../hooks/useBeatSequencer';
|
import type { BeatSequencer } from '../hooks/useBeatSequencer';
|
||||||
import type { SoundPalette } from '../hooks/useSoundPalette';
|
import type { SoundPalette } from '../hooks/useSoundPalette';
|
||||||
import type { CategoryLabels } from '../hooks/useCategoryLabels';
|
|
||||||
|
|
||||||
interface BeatLoopPanelProps {
|
interface BeatLoopPanelProps {
|
||||||
sequencer: BeatSequencer;
|
sequencer: BeatSequencer;
|
||||||
soundPalette: SoundPalette;
|
soundPalette: SoundPalette;
|
||||||
categoryLabels: CategoryLabels;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function BeatLoopPanel({ sequencer, soundPalette, categoryLabels }: BeatLoopPanelProps) {
|
export function BeatLoopPanel({ sequencer, soundPalette }: BeatLoopPanelProps) {
|
||||||
const categoryIdsInLoop = useMemo(() => {
|
const soundIdsInLoop = useMemo(() => {
|
||||||
const categoryIds = new Set<InstrumentCategoryId>(
|
const soundIds = new Set(sequencer.beats.map((beat) => beat.soundId));
|
||||||
sequencer.beats.map((beat) => INSTRUMENT_BY_ID[beat.soundId].categoryId),
|
return INSTRUMENT_CATALOG
|
||||||
);
|
.filter((instrument) => soundIds.has(instrument.id))
|
||||||
return INSTRUMENT_CATEGORIES
|
.map((instrument) => instrument.id);
|
||||||
.filter((category) => categoryIds.has(category.id))
|
|
||||||
.map((category) => category.id);
|
|
||||||
}, [sequencer.beats]);
|
}, [sequencer.beats]);
|
||||||
const focusedRingCategoryId = sequencer.focusedCategoryId
|
const focusedRingSoundId = sequencer.focusedSoundId
|
||||||
&& categoryIdsInLoop.includes(sequencer.focusedCategoryId)
|
&& soundIdsInLoop.includes(sequencer.focusedSoundId)
|
||||||
? sequencer.focusedCategoryId
|
? sequencer.focusedSoundId
|
||||||
: null;
|
: null;
|
||||||
const hasDeleteTarget = Boolean(sequencer.selectedBeat || focusedRingCategoryId);
|
const hasDeleteTarget = Boolean(sequencer.selectedBeat || focusedRingSoundId);
|
||||||
const deleteLabel = sequencer.selectedBeat
|
const deleteLabel = sequencer.selectedBeat
|
||||||
? `Remove ${INSTRUMENT_BY_ID[sequencer.selectedBeat.soundId].label}`
|
? `Remove ${INSTRUMENT_BY_ID[sequencer.selectedBeat.soundId].label}`
|
||||||
: focusedRingCategoryId
|
: focusedRingSoundId
|
||||||
? `Remove ${categoryLabels.labelByCategoryId[focusedRingCategoryId] ?? INSTRUMENT_CATEGORY_BY_ID[focusedRingCategoryId].label} category`
|
? `Remove ${INSTRUMENT_BY_ID[focusedRingSoundId].label} ring`
|
||||||
: 'Remove sound';
|
: 'Remove sound';
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -51,28 +46,26 @@ export function BeatLoopPanel({ sequencer, soundPalette, categoryLabels }: BeatL
|
|||||||
beatsPerBar={sequencer.beatsPerBar}
|
beatsPerBar={sequencer.beatsPerBar}
|
||||||
onChange={sequencer.setBeatsPerBar}
|
onChange={sequencer.setBeatsPerBar}
|
||||||
/>
|
/>
|
||||||
<CategoryRingSelector
|
<SoundRingSelector
|
||||||
categoryIds={categoryIdsInLoop}
|
soundIds={soundIdsInLoop}
|
||||||
focusedCategoryId={sequencer.focusedCategoryId}
|
focusedSoundId={sequencer.focusedSoundId}
|
||||||
colorByCategoryId={soundPalette.colorByCategoryId}
|
colorBySoundId={soundPalette.colorBySoundId}
|
||||||
labelByCategoryId={categoryLabels.labelByCategoryId}
|
onSelectSound={sequencer.selectSound}
|
||||||
onSelectCategory={sequencer.selectCategory}
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="timeline-wrap">
|
<div className="timeline-wrap">
|
||||||
<CircularTimeline
|
<CircularTimeline
|
||||||
beats={sequencer.beats}
|
beats={sequencer.beats}
|
||||||
categoryIds={categoryIdsInLoop}
|
soundIds={soundIdsInLoop}
|
||||||
colorByCategoryId={soundPalette.colorByCategoryId}
|
colorBySoundId={soundPalette.colorBySoundId}
|
||||||
labelByCategoryId={categoryLabels.labelByCategoryId}
|
|
||||||
currentStep={sequencer.currentStep}
|
currentStep={sequencer.currentStep}
|
||||||
totalSteps={sequencer.totalSteps}
|
totalSteps={sequencer.totalSteps}
|
||||||
focusedCategoryId={sequencer.focusedCategoryId}
|
focusedSoundId={sequencer.focusedSoundId}
|
||||||
selectedBeatId={sequencer.selectedBeat?.id ?? null}
|
selectedBeatId={sequencer.selectedBeat?.id ?? null}
|
||||||
onMoveBeat={sequencer.moveBeat}
|
onMoveBeat={sequencer.moveBeat}
|
||||||
onSelectBeat={sequencer.selectBeat}
|
onSelectBeat={sequencer.selectBeat}
|
||||||
onSelectCategory={sequencer.selectCategory}
|
onSelectSound={sequencer.selectSound}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -85,9 +78,8 @@ export function BeatLoopPanel({ sequencer, soundPalette, categoryLabels }: BeatL
|
|||||||
</div>
|
</div>
|
||||||
<BeatSelectionHint
|
<BeatSelectionHint
|
||||||
selectedBeat={sequencer.selectedBeat}
|
selectedBeat={sequencer.selectedBeat}
|
||||||
focusedCategoryId={focusedRingCategoryId}
|
focusedSoundId={focusedRingSoundId}
|
||||||
categoryLabelById={categoryLabels.labelByCategoryId}
|
colorBySoundId={soundPalette.colorBySoundId}
|
||||||
colorByCategoryId={soundPalette.colorByCategoryId}
|
|
||||||
totalSteps={sequencer.totalSteps}
|
totalSteps={sequencer.totalSteps}
|
||||||
/>
|
/>
|
||||||
<div className="timeline-hint-actions">
|
<div className="timeline-hint-actions">
|
||||||
@@ -98,7 +90,7 @@ export function BeatLoopPanel({ sequencer, soundPalette, categoryLabels }: BeatL
|
|||||||
aria-label={deleteLabel}
|
aria-label={deleteLabel}
|
||||||
onClick={sequencer.selectedBeat
|
onClick={sequencer.selectedBeat
|
||||||
? sequencer.removeSelectedBeat
|
? sequencer.removeSelectedBeat
|
||||||
: sequencer.removeFocusedCategory}
|
: sequencer.removeFocusedSound}
|
||||||
>
|
>
|
||||||
<IonIcon icon={trash} />
|
<IonIcon icon={trash} />
|
||||||
</IonButton>
|
</IonButton>
|
||||||
@@ -107,14 +99,15 @@ export function BeatLoopPanel({ sequencer, soundPalette, categoryLabels }: BeatL
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<PitchControl
|
||||||
|
selectedBeat={sequencer.selectedBeat}
|
||||||
|
onChangePitch={sequencer.changeBeatPitch}
|
||||||
|
/>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<CategoryLegend
|
<SampleLegend
|
||||||
beats={sequencer.beats}
|
soundIds={soundIdsInLoop}
|
||||||
categoryIds={categoryIdsInLoop}
|
colorBySoundId={soundPalette.colorBySoundId}
|
||||||
colorByCategoryId={soundPalette.colorByCategoryId}
|
|
||||||
labelByCategoryId={categoryLabels.labelByCategoryId}
|
|
||||||
onRenameCategory={categoryLabels.renameCategory}
|
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,43 +1,36 @@
|
|||||||
import { memo } from 'react';
|
import { memo } from 'react';
|
||||||
import { getLoopPositionPercent } from '../domain/timeline';
|
import { getLoopPositionPercent } from '../domain/timeline';
|
||||||
import { INSTRUMENT_BY_ID, INSTRUMENT_CATEGORY_BY_ID } from '../domain/instruments';
|
import { INSTRUMENT_BY_ID } from '../domain/instruments';
|
||||||
import type { BeatPoint } from '../domain/sequencer';
|
import type { BeatPoint } from '../domain/sequencer';
|
||||||
import type { InstrumentCategoryId } from '../domain/instruments';
|
import type { InstrumentId } from '../domain/instruments';
|
||||||
import type { CategoryLabelOverrides } from '../hooks/useCategoryLabels';
|
|
||||||
|
|
||||||
interface BeatSelectionHintProps {
|
interface BeatSelectionHintProps {
|
||||||
selectedBeat: BeatPoint | undefined;
|
selectedBeat: BeatPoint | undefined;
|
||||||
focusedCategoryId: InstrumentCategoryId | null;
|
focusedSoundId: InstrumentId | null;
|
||||||
categoryLabelById: CategoryLabelOverrides;
|
colorBySoundId: Partial<Record<InstrumentId, string>>;
|
||||||
colorByCategoryId: Partial<Record<InstrumentCategoryId, string>>;
|
|
||||||
totalSteps: number;
|
totalSteps: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const BeatSelectionHint = memo(function BeatSelectionHint({
|
export const BeatSelectionHint = memo(function BeatSelectionHint({
|
||||||
selectedBeat,
|
selectedBeat,
|
||||||
focusedCategoryId,
|
focusedSoundId,
|
||||||
categoryLabelById,
|
colorBySoundId,
|
||||||
colorByCategoryId,
|
|
||||||
totalSteps,
|
totalSteps,
|
||||||
}: BeatSelectionHintProps) {
|
}: BeatSelectionHintProps) {
|
||||||
const selectedInstrument = selectedBeat ? INSTRUMENT_BY_ID[selectedBeat.soundId] : undefined;
|
const soundId = selectedBeat?.soundId ?? focusedSoundId;
|
||||||
const categoryId = selectedInstrument?.categoryId ?? focusedCategoryId;
|
if (!soundId) return <p className="timeline-hint" aria-live="polite" />;
|
||||||
if (!categoryId) return <p className="timeline-hint" aria-live="polite" />;
|
|
||||||
|
|
||||||
const category = INSTRUMENT_CATEGORY_BY_ID[categoryId];
|
const sound = INSTRUMENT_BY_ID[soundId];
|
||||||
const categoryLabel = categoryLabelById[categoryId] ?? category.label;
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<p className="timeline-hint" aria-live="polite">
|
<p className="timeline-hint" aria-live="polite">
|
||||||
<span
|
<span
|
||||||
className="hint-swatch"
|
className="hint-swatch"
|
||||||
style={{ backgroundColor: colorByCategoryId[categoryId] }}
|
style={{ backgroundColor: colorBySoundId[soundId] }}
|
||||||
/>
|
/>
|
||||||
{category.letter} · {categoryLabel}
|
{sound.label}
|
||||||
{selectedBeat && (
|
{selectedBeat && (
|
||||||
<>
|
<>
|
||||||
<span className="hint-separator">·</span>
|
|
||||||
{selectedBeat.letter} · {selectedInstrument?.label}
|
|
||||||
<span className="hint-separator">·</span>
|
<span className="hint-separator">·</span>
|
||||||
Step {getLoopPositionPercent(selectedBeat.step, totalSteps)}% selected
|
Step {getLoopPositionPercent(selectedBeat.step, totalSteps)}% selected
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ export const BeatTemplateSelector = memo(function BeatTemplateSelector({
|
|||||||
return (
|
return (
|
||||||
<div className="beat-template-selector">
|
<div className="beat-template-selector">
|
||||||
<IonButton
|
<IonButton
|
||||||
id="beat-template-trigger"
|
id={popover.triggerId}
|
||||||
className="beat-template-trigger"
|
className="beat-template-trigger"
|
||||||
fill="solid"
|
fill="solid"
|
||||||
aria-label={`Dance template: ${selectedTemplate?.label ?? 'Select a template'}`}
|
aria-label={`Dance template: ${selectedTemplate?.label ?? 'Select a template'}`}
|
||||||
@@ -39,8 +39,9 @@ export const BeatTemplateSelector = memo(function BeatTemplateSelector({
|
|||||||
|
|
||||||
<IonPopover
|
<IonPopover
|
||||||
className="beat-template-popover"
|
className="beat-template-popover"
|
||||||
trigger="beat-template-trigger"
|
trigger={popover.triggerId}
|
||||||
triggerAction="click"
|
reference="trigger"
|
||||||
|
size="cover"
|
||||||
side="bottom"
|
side="bottom"
|
||||||
alignment="center"
|
alignment="center"
|
||||||
dismissOnSelect
|
dismissOnSelect
|
||||||
|
|||||||
@@ -1,124 +1,27 @@
|
|||||||
import { useEffect, useRef, useState } from 'react';
|
import { INSTRUMENT_BY_ID } from '../domain/instruments';
|
||||||
import { IonAlert, IonButton } from '@ionic/react';
|
import type { InstrumentId } from '../domain/instruments';
|
||||||
import { INSTRUMENT_BY_ID, INSTRUMENT_CATEGORY_BY_ID } from '../domain/instruments';
|
|
||||||
import type { InstrumentCategoryId } from '../domain/instruments';
|
|
||||||
import type { BeatPoint } from '../domain/sequencer';
|
|
||||||
import type { CategoryLabelOverrides } from '../hooks/useCategoryLabels';
|
|
||||||
|
|
||||||
interface CategoryLegendProps {
|
interface SampleLegendProps {
|
||||||
beats: readonly BeatPoint[];
|
soundIds: readonly InstrumentId[];
|
||||||
categoryIds: readonly InstrumentCategoryId[];
|
colorBySoundId: Partial<Record<InstrumentId, string>>;
|
||||||
colorByCategoryId: Partial<Record<InstrumentCategoryId, string>>;
|
|
||||||
labelByCategoryId: CategoryLabelOverrides;
|
|
||||||
onRenameCategory: (categoryId: InstrumentCategoryId, label: string) => void;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function CategoryLegend({
|
export function SampleLegend({ soundIds, colorBySoundId }: SampleLegendProps) {
|
||||||
beats,
|
|
||||||
categoryIds,
|
|
||||||
colorByCategoryId,
|
|
||||||
labelByCategoryId,
|
|
||||||
onRenameCategory,
|
|
||||||
}: CategoryLegendProps) {
|
|
||||||
const [editingCategoryId, setEditingCategoryId] = useState<InstrumentCategoryId | null>(null);
|
|
||||||
const longPressTimerRef = useRef<number | null>(null);
|
|
||||||
const editingCategory = editingCategoryId
|
|
||||||
? INSTRUMENT_CATEGORY_BY_ID[editingCategoryId]
|
|
||||||
: undefined;
|
|
||||||
const editingLabel = editingCategory
|
|
||||||
? labelByCategoryId[editingCategory.id] ?? editingCategory.label
|
|
||||||
: '';
|
|
||||||
|
|
||||||
function clearLongPressTimer(): void {
|
|
||||||
if (longPressTimerRef.current === null) return;
|
|
||||||
window.clearTimeout(longPressTimerRef.current);
|
|
||||||
longPressTimerRef.current = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
function beginRename(categoryId: InstrumentCategoryId): void {
|
|
||||||
clearLongPressTimer();
|
|
||||||
setEditingCategoryId(categoryId);
|
|
||||||
}
|
|
||||||
|
|
||||||
function saveRename(value: unknown): void {
|
|
||||||
if (!editingCategoryId || typeof value !== 'object' || value === null) return;
|
|
||||||
const label = (value as Record<string, unknown>).categoryName;
|
|
||||||
if (typeof label === 'string') onRenameCategory(editingCategoryId, label);
|
|
||||||
}
|
|
||||||
|
|
||||||
useEffect(() => () => {
|
|
||||||
if (longPressTimerRef.current !== null) window.clearTimeout(longPressTimerRef.current);
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<div className="sound-legend" aria-label="Samples in this loop" aria-live="polite">
|
||||||
<div className="sound-legend" aria-label="Instrument categories in this loop" aria-live="polite">
|
{soundIds.length > 0 ? (
|
||||||
{categoryIds.length > 0 ? (
|
soundIds.map((soundId) => (
|
||||||
categoryIds.map((categoryId) => {
|
<span className="legend-sample" key={soundId}>
|
||||||
const category = INSTRUMENT_CATEGORY_BY_ID[categoryId];
|
|
||||||
const label = labelByCategoryId[categoryId] ?? category.label;
|
|
||||||
const categoryBeats = beats.filter(
|
|
||||||
(beat) => INSTRUMENT_BY_ID[beat.soundId].categoryId === categoryId,
|
|
||||||
);
|
|
||||||
return (
|
|
||||||
<div className="legend-category-entry" key={categoryId}>
|
|
||||||
<IonButton
|
|
||||||
className="legend-category"
|
|
||||||
fill="clear"
|
|
||||||
aria-label={`Press and hold to rename ${label}`}
|
|
||||||
onPointerDown={() => {
|
|
||||||
clearLongPressTimer();
|
|
||||||
longPressTimerRef.current = window.setTimeout(
|
|
||||||
() => beginRename(categoryId),
|
|
||||||
550,
|
|
||||||
);
|
|
||||||
}}
|
|
||||||
onPointerUp={clearLongPressTimer}
|
|
||||||
onPointerLeave={clearLongPressTimer}
|
|
||||||
onPointerCancel={clearLongPressTimer}
|
|
||||||
onContextMenu={(event) => {
|
|
||||||
event.preventDefault();
|
|
||||||
beginRename(categoryId);
|
|
||||||
}}
|
|
||||||
onKeyDown={(event) => {
|
|
||||||
if (event.key !== 'Enter' && event.key !== ' ') return;
|
|
||||||
event.preventDefault();
|
|
||||||
beginRename(categoryId);
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<span
|
<span
|
||||||
className="legend-swatch"
|
className="legend-swatch"
|
||||||
style={{ backgroundColor: colorByCategoryId[categoryId] }}
|
style={{ backgroundColor: colorBySoundId[soundId] }}
|
||||||
/>
|
/>
|
||||||
<span className="legend-category-letter">{category.letter}</span>
|
{INSTRUMENT_BY_ID[soundId].label}
|
||||||
<span>{label}</span>
|
|
||||||
</IonButton>
|
|
||||||
<span className="legend-beat-list">
|
|
||||||
{categoryBeats.map((beat) => (
|
|
||||||
<span key={beat.id}>
|
|
||||||
<strong>{beat.letter}</strong> {INSTRUMENT_BY_ID[beat.soundId].label}
|
|
||||||
</span>
|
</span>
|
||||||
))}
|
))
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
})
|
|
||||||
) : (
|
) : (
|
||||||
<span className="legend-empty">Added instrument categories will appear here.</span>
|
<span className="legend-empty">Added samples will appear here.</span>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<IonAlert
|
|
||||||
isOpen={editingCategory !== undefined}
|
|
||||||
header={`Rename ${editingLabel || 'category'}`}
|
|
||||||
message="This name is shown in the loop legend."
|
|
||||||
inputs={[{ name: 'categoryName', type: 'text', value: editingLabel, placeholder: 'Category name' }]}
|
|
||||||
buttons={[
|
|
||||||
{ text: 'Cancel', role: 'cancel' },
|
|
||||||
{ text: 'Save', handler: (value: unknown) => saveRename(value) },
|
|
||||||
]}
|
|
||||||
onDidDismiss={() => setEditingCategoryId(null)}
|
|
||||||
/>
|
|
||||||
</>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -1,96 +1 @@
|
|||||||
import { memo } from 'react';
|
export { SoundRingSelector as CategoryRingSelector } from './SoundRingSelector';
|
||||||
import { IonButton, IonIcon, IonPopover } from '@ionic/react';
|
|
||||||
import { chevronDown } from 'ionicons/icons';
|
|
||||||
import { INSTRUMENT_CATEGORY_BY_ID } from '../domain/instruments';
|
|
||||||
import type { InstrumentCategoryId } from '../domain/instruments';
|
|
||||||
import type { CategoryLabelOverrides } from '../hooks/useCategoryLabels';
|
|
||||||
import { usePopoverDisclosure } from '../hooks/usePopoverDisclosure';
|
|
||||||
|
|
||||||
interface CategoryRingSelectorProps {
|
|
||||||
categoryIds: readonly InstrumentCategoryId[];
|
|
||||||
focusedCategoryId: InstrumentCategoryId | null;
|
|
||||||
colorByCategoryId: Partial<Record<InstrumentCategoryId, string>>;
|
|
||||||
labelByCategoryId: CategoryLabelOverrides;
|
|
||||||
onSelectCategory: (categoryId: InstrumentCategoryId) => void;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const CategoryRingSelector = memo(function CategoryRingSelector({
|
|
||||||
categoryIds,
|
|
||||||
focusedCategoryId,
|
|
||||||
colorByCategoryId,
|
|
||||||
labelByCategoryId,
|
|
||||||
onSelectCategory,
|
|
||||||
}: CategoryRingSelectorProps) {
|
|
||||||
const popover = usePopoverDisclosure();
|
|
||||||
const focusedCategory = focusedCategoryId
|
|
||||||
? INSTRUMENT_CATEGORY_BY_ID[focusedCategoryId]
|
|
||||||
: undefined;
|
|
||||||
const focusedLabel = focusedCategory
|
|
||||||
? labelByCategoryId[focusedCategory.id] ?? focusedCategory.label
|
|
||||||
: undefined;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<IonButton
|
|
||||||
id="category-ring-selector-trigger"
|
|
||||||
className="sound-ring-selector-trigger"
|
|
||||||
fill="clear"
|
|
||||||
disabled={categoryIds.length === 0}
|
|
||||||
aria-label={focusedCategory ? `Selected ring: ${focusedLabel}` : 'Select a category ring'}
|
|
||||||
aria-haspopup="dialog"
|
|
||||||
aria-expanded={popover.isOpen}
|
|
||||||
>
|
|
||||||
<span className="sound-ring-trigger-content">
|
|
||||||
{focusedCategory && (
|
|
||||||
<>
|
|
||||||
<span
|
|
||||||
className="ring-selector-swatch"
|
|
||||||
style={{ backgroundColor: colorByCategoryId[focusedCategory.id] ?? '#b8b4e0' }}
|
|
||||||
/>
|
|
||||||
<span className="category-letter-badge">{focusedCategory.letter}</span>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
<span>{focusedLabel ? `${focusedLabel} ring` : 'Category rings'}</span>
|
|
||||||
<IonIcon icon={chevronDown} />
|
|
||||||
</span>
|
|
||||||
</IonButton>
|
|
||||||
|
|
||||||
<IonPopover
|
|
||||||
className="sound-ring-popover"
|
|
||||||
trigger="category-ring-selector-trigger"
|
|
||||||
triggerAction="click"
|
|
||||||
side="bottom"
|
|
||||||
alignment="end"
|
|
||||||
dismissOnSelect
|
|
||||||
onDidPresent={popover.onDidPresent}
|
|
||||||
onDidDismiss={popover.onDidDismiss}
|
|
||||||
>
|
|
||||||
<div className="sound-ring-options" role="group" aria-label="Category rings">
|
|
||||||
{categoryIds.map((categoryId) => {
|
|
||||||
const category = INSTRUMENT_CATEGORY_BY_ID[categoryId];
|
|
||||||
const label = labelByCategoryId[categoryId] ?? category.label;
|
|
||||||
const selected = categoryId === focusedCategoryId;
|
|
||||||
return (
|
|
||||||
<IonButton
|
|
||||||
key={categoryId}
|
|
||||||
className="sound-ring-option"
|
|
||||||
fill={selected ? 'solid' : 'clear'}
|
|
||||||
aria-pressed={selected}
|
|
||||||
onClick={() => onSelectCategory(categoryId)}
|
|
||||||
>
|
|
||||||
<span className="sound-ring-option-content">
|
|
||||||
<span
|
|
||||||
className="ring-selector-swatch"
|
|
||||||
style={{ backgroundColor: colorByCategoryId[categoryId] ?? '#b8b4e0' }}
|
|
||||||
/>
|
|
||||||
<span className="category-letter-badge">{category.letter}</span>
|
|
||||||
<span>{label} ring</span>
|
|
||||||
</span>
|
|
||||||
</IonButton>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</div>
|
|
||||||
</IonPopover>
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
});
|
|
||||||
@@ -8,7 +8,7 @@ import {
|
|||||||
import {
|
import {
|
||||||
getPointForStep,
|
getPointForStep,
|
||||||
getLoopPositionPercent,
|
getLoopPositionPercent,
|
||||||
getCategoryOrbitRadius,
|
getSoundOrbitRadius,
|
||||||
getStepFromPosition,
|
getStepFromPosition,
|
||||||
ORBIT_RADIUS,
|
ORBIT_RADIUS,
|
||||||
SVG_CENTER,
|
SVG_CENTER,
|
||||||
@@ -16,22 +16,20 @@ import {
|
|||||||
getStackedPosition,
|
getStackedPosition,
|
||||||
wrapStepPosition,
|
wrapStepPosition,
|
||||||
} from '../domain/timeline';
|
} from '../domain/timeline';
|
||||||
import { INSTRUMENT_BY_ID, INSTRUMENT_CATEGORY_BY_ID } from '../domain/instruments';
|
import { INSTRUMENT_BY_ID } from '../domain/instruments';
|
||||||
import type { InstrumentCategoryId } from '../domain/instruments';
|
import type { InstrumentId } from '../domain/instruments';
|
||||||
import type { CategoryLabelOverrides } from '../hooks/useCategoryLabels';
|
|
||||||
|
|
||||||
interface CircularTimelineProps {
|
interface CircularTimelineProps {
|
||||||
beats: BeatPoint[];
|
beats: BeatPoint[];
|
||||||
categoryIds: readonly InstrumentCategoryId[];
|
soundIds: readonly InstrumentId[];
|
||||||
colorByCategoryId: Partial<Record<InstrumentCategoryId, string>>;
|
colorBySoundId: Partial<Record<InstrumentId, string>>;
|
||||||
labelByCategoryId: CategoryLabelOverrides;
|
|
||||||
currentStep: number;
|
currentStep: number;
|
||||||
totalSteps: number;
|
totalSteps: number;
|
||||||
focusedCategoryId: InstrumentCategoryId | null;
|
focusedSoundId: InstrumentId | null;
|
||||||
selectedBeatId: string | null;
|
selectedBeatId: string | null;
|
||||||
onMoveBeat: (beatId: string, step: number) => void;
|
onMoveBeat: (beatId: string, step: number) => void;
|
||||||
onSelectBeat: (beatId: string) => void;
|
onSelectBeat: (beatId: string) => void;
|
||||||
onSelectCategory: (categoryId: InstrumentCategoryId) => void;
|
onSelectSound: (soundId: InstrumentId) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getPointerCoordinates(event: ReactPointerEvent<SVGSVGElement>) {
|
function getPointerCoordinates(event: ReactPointerEvent<SVGSVGElement>) {
|
||||||
@@ -44,29 +42,25 @@ function getPointerCoordinates(event: ReactPointerEvent<SVGSVGElement>) {
|
|||||||
|
|
||||||
export function CircularTimeline({
|
export function CircularTimeline({
|
||||||
beats,
|
beats,
|
||||||
categoryIds,
|
soundIds,
|
||||||
colorByCategoryId,
|
colorBySoundId,
|
||||||
labelByCategoryId,
|
|
||||||
currentStep,
|
currentStep,
|
||||||
totalSteps,
|
totalSteps,
|
||||||
focusedCategoryId,
|
focusedSoundId,
|
||||||
selectedBeatId,
|
selectedBeatId,
|
||||||
onMoveBeat,
|
onMoveBeat,
|
||||||
onSelectBeat,
|
onSelectBeat,
|
||||||
onSelectCategory,
|
onSelectSound,
|
||||||
}: CircularTimelineProps) {
|
}: CircularTimelineProps) {
|
||||||
const draggingBeatIdRef = useRef<string | null>(null);
|
const draggingBeatIdRef = useRef<string | null>(null);
|
||||||
const selectedBeatSoundId = beats.find((beat) => beat.id === selectedBeatId)?.soundId;
|
const selectedBeatSoundId = beats.find((beat) => beat.id === selectedBeatId)?.soundId;
|
||||||
const selectedBeatCategoryId = selectedBeatSoundId
|
const activeSoundId = selectedBeatSoundId ?? focusedSoundId;
|
||||||
? INSTRUMENT_BY_ID[selectedBeatSoundId].categoryId
|
const orderedSoundIds = activeSoundId
|
||||||
: null;
|
|
||||||
const activeCategoryId = selectedBeatCategoryId ?? focusedCategoryId;
|
|
||||||
const orderedCategoryIds = activeCategoryId
|
|
||||||
? [
|
? [
|
||||||
...categoryIds.filter((categoryId) => categoryId === activeCategoryId),
|
...soundIds.filter((soundId) => soundId === activeSoundId),
|
||||||
...categoryIds.filter((categoryId) => categoryId !== activeCategoryId),
|
...soundIds.filter((soundId) => soundId !== activeSoundId),
|
||||||
]
|
]
|
||||||
: categoryIds;
|
: soundIds;
|
||||||
|
|
||||||
function handlePointerDown(event: ReactPointerEvent<SVGGElement>, beatId: string): void {
|
function handlePointerDown(event: ReactPointerEvent<SVGGElement>, beatId: string): void {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
@@ -102,11 +96,11 @@ export function CircularTimeline({
|
|||||||
|
|
||||||
function handleOrbitKeyDown(
|
function handleOrbitKeyDown(
|
||||||
event: ReactKeyboardEvent<SVGCircleElement>,
|
event: ReactKeyboardEvent<SVGCircleElement>,
|
||||||
categoryId: InstrumentCategoryId,
|
soundId: InstrumentId,
|
||||||
): void {
|
): void {
|
||||||
if (event.key !== 'Enter' && event.key !== ' ') return;
|
if (event.key !== 'Enter' && event.key !== ' ') return;
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
onSelectCategory(categoryId);
|
onSelectSound(soundId);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -114,42 +108,26 @@ export function CircularTimeline({
|
|||||||
className="circular-timeline"
|
className="circular-timeline"
|
||||||
viewBox={`0 0 ${SVG_SIZE} ${SVG_SIZE}`}
|
viewBox={`0 0 ${SVG_SIZE} ${SVG_SIZE}`}
|
||||||
role="group"
|
role="group"
|
||||||
aria-label={`${totalSteps}-step circular beat timeline with one orbit per instrument category. Drag beat points to move them.`}
|
aria-label={`${totalSteps}-step circular beat timeline with one orbit per sound. Drag beat points to move them.`}
|
||||||
onPointerMove={handlePointerMove}
|
onPointerMove={handlePointerMove}
|
||||||
onPointerUp={() => { draggingBeatIdRef.current = null; }}
|
onPointerUp={() => { draggingBeatIdRef.current = null; }}
|
||||||
onPointerCancel={() => { draggingBeatIdRef.current = null; }}
|
onPointerCancel={() => { draggingBeatIdRef.current = null; }}
|
||||||
>
|
>
|
||||||
{orderedCategoryIds.map((categoryId, categoryIndex) => {
|
{orderedSoundIds.map((soundId, soundIndex) => {
|
||||||
const category = INSTRUMENT_CATEGORY_BY_ID[categoryId];
|
const focused = soundId === activeSoundId;
|
||||||
const color = colorByCategoryId[categoryId] ?? '#b8b4e0';
|
|
||||||
const radius = getCategoryOrbitRadius(categoryIndex, orderedCategoryIds.length);
|
|
||||||
const letterPosition = getPointForStep(totalSteps * 0.12, radius, SVG_CENTER, totalSteps);
|
|
||||||
const focused = categoryId === activeCategoryId;
|
|
||||||
return (
|
return (
|
||||||
<g key={categoryId}>
|
|
||||||
<circle
|
<circle
|
||||||
|
key={soundId}
|
||||||
cx={SVG_CENTER}
|
cx={SVG_CENTER}
|
||||||
cy={SVG_CENTER}
|
cy={SVG_CENTER}
|
||||||
r={radius}
|
r={getSoundOrbitRadius(soundIndex, orderedSoundIds.length)}
|
||||||
className={`timeline-orbit${focused ? ' is-focused' : ''}`}
|
className={`timeline-orbit${focused ? ' is-focused' : ''}`}
|
||||||
style={{
|
style={{
|
||||||
stroke: color,
|
stroke: colorBySoundId[soundId] ?? '#b8b4e0',
|
||||||
opacity: focused ? 0.55 : 0.32,
|
opacity: focused ? 0.55 : 0.32,
|
||||||
strokeWidth: focused ? 2.2 : 1.5,
|
strokeWidth: focused ? 2.2 : 1.5,
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<g className="timeline-category-letter" style={{ color }} aria-hidden="true">
|
|
||||||
<circle cx={letterPosition.x} cy={letterPosition.y} r="9" />
|
|
||||||
<text
|
|
||||||
x={letterPosition.x}
|
|
||||||
y={letterPosition.y}
|
|
||||||
textAnchor="middle"
|
|
||||||
dominantBaseline="middle"
|
|
||||||
>
|
|
||||||
{category.letter}
|
|
||||||
</text>
|
|
||||||
</g>
|
|
||||||
</g>
|
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
|
|
||||||
@@ -180,12 +158,12 @@ export function CircularTimeline({
|
|||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
|
|
||||||
{orderedCategoryIds.map((categoryId, categoryIndex) => (
|
{orderedSoundIds.map((soundId, soundIndex) => (
|
||||||
<circle
|
<circle
|
||||||
key={categoryId}
|
key={soundId}
|
||||||
cx={SVG_CENTER}
|
cx={SVG_CENTER}
|
||||||
cy={SVG_CENTER}
|
cy={SVG_CENTER}
|
||||||
r={getCategoryOrbitRadius(categoryIndex, orderedCategoryIds.length)}
|
r={getSoundOrbitRadius(soundIndex, orderedSoundIds.length)}
|
||||||
className="timeline-orbit-hit-area"
|
className="timeline-orbit-hit-area"
|
||||||
fill="none"
|
fill="none"
|
||||||
stroke="transparent"
|
stroke="transparent"
|
||||||
@@ -193,11 +171,11 @@ export function CircularTimeline({
|
|||||||
pointerEvents="stroke"
|
pointerEvents="stroke"
|
||||||
role="button"
|
role="button"
|
||||||
tabIndex={0}
|
tabIndex={0}
|
||||||
aria-label={`Select ${INSTRUMENT_CATEGORY_BY_ID[categoryId].letter} ${labelByCategoryId[categoryId] ?? INSTRUMENT_CATEGORY_BY_ID[categoryId].label} ring`}
|
aria-label={`Select ${INSTRUMENT_BY_ID[soundId].label} ring`}
|
||||||
aria-pressed={categoryId === activeCategoryId}
|
aria-pressed={soundId === activeSoundId}
|
||||||
onClick={() => onSelectCategory(categoryId)}
|
onClick={() => onSelectSound(soundId)}
|
||||||
onKeyDown={(event) => handleOrbitKeyDown(event, categoryId)}
|
onKeyDown={(event) => handleOrbitKeyDown(event, soundId)}
|
||||||
onFocus={() => onSelectCategory(categoryId)}
|
onFocus={() => onSelectSound(soundId)}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
|
|
||||||
@@ -213,23 +191,22 @@ export function CircularTimeline({
|
|||||||
|
|
||||||
{beats.map((beat) => {
|
{beats.map((beat) => {
|
||||||
const instrument = INSTRUMENT_BY_ID[beat.soundId];
|
const instrument = INSTRUMENT_BY_ID[beat.soundId];
|
||||||
const category = INSTRUMENT_CATEGORY_BY_ID[instrument.categoryId];
|
const soundIndex = orderedSoundIds.indexOf(beat.soundId);
|
||||||
const categoryIndex = orderedCategoryIds.indexOf(instrument.categoryId);
|
|
||||||
const point = getStackedPosition(
|
const point = getStackedPosition(
|
||||||
beat,
|
beat,
|
||||||
beats,
|
beats,
|
||||||
totalSteps,
|
totalSteps,
|
||||||
getCategoryOrbitRadius(categoryIndex, orderedCategoryIds.length),
|
getSoundOrbitRadius(soundIndex, orderedSoundIds.length),
|
||||||
);
|
);
|
||||||
const selected = selectedBeatId === beat.id;
|
const selected = selectedBeatId === beat.id;
|
||||||
return (
|
return (
|
||||||
<g
|
<g
|
||||||
key={beat.id}
|
key={beat.id}
|
||||||
className={`sound-point${selected ? ' is-selected' : ''}`}
|
className={`sound-point${selected ? ' is-selected' : ''}`}
|
||||||
style={{ color: colorByCategoryId[instrument.categoryId] ?? '#f4f1ed' }}
|
style={{ color: colorBySoundId[beat.soundId] ?? '#f4f1ed' }}
|
||||||
role="button"
|
role="button"
|
||||||
tabIndex={0}
|
tabIndex={0}
|
||||||
aria-label={`${category.letter} ${labelByCategoryId[category.id] ?? category.label}, beat ${beat.letter}, ${instrument.label}, ${getLoopPositionPercent(beat.step, totalSteps)}% around the loop. Drag to move freely, or use arrow keys for small steps.`}
|
aria-label={`${instrument.label}, beat ${beat.letter}, ${getLoopPositionPercent(beat.step, totalSteps)}% around the loop. Drag to move freely, or use arrow keys for small steps.`}
|
||||||
aria-pressed={selected}
|
aria-pressed={selected}
|
||||||
onPointerDown={(event) => handlePointerDown(event, beat.id)}
|
onPointerDown={(event) => handlePointerDown(event, beat.id)}
|
||||||
onClick={() => onSelectBeat(beat.id)}
|
onClick={() => onSelectBeat(beat.id)}
|
||||||
|
|||||||
@@ -1,5 +1,15 @@
|
|||||||
import { useRef, useState } from 'react';
|
import { useMemo, useRef, useState } from 'react';
|
||||||
import { IonButton, IonIcon, IonPopover, IonSelect, IonSelectOption } from '@ionic/react';
|
import {
|
||||||
|
IonAccordion,
|
||||||
|
IonAccordionGroup,
|
||||||
|
IonButton,
|
||||||
|
IonContent,
|
||||||
|
IonIcon,
|
||||||
|
IonItem,
|
||||||
|
IonLabel,
|
||||||
|
IonModal,
|
||||||
|
IonSearchbar,
|
||||||
|
} from '@ionic/react';
|
||||||
import { add } from 'ionicons/icons';
|
import { add } from 'ionicons/icons';
|
||||||
import {
|
import {
|
||||||
INSTRUMENT_BY_ID,
|
INSTRUMENT_BY_ID,
|
||||||
@@ -7,91 +17,163 @@ import {
|
|||||||
isInstrumentId,
|
isInstrumentId,
|
||||||
} from '../domain/instruments';
|
} from '../domain/instruments';
|
||||||
import type { InstrumentId } from '../domain/instruments';
|
import type { InstrumentId } from '../domain/instruments';
|
||||||
import { usePopoverDisclosure } from '../hooks/usePopoverDisclosure';
|
|
||||||
|
const PICKER_SHEET_BREAKPOINTS = [0, 0.82, 1];
|
||||||
|
|
||||||
interface InstrumentSelectorProps {
|
interface InstrumentSelectorProps {
|
||||||
onSelectInstrument: (instrumentId: InstrumentId) => void;
|
onSelectInstrument: (instrumentId: InstrumentId) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function InstrumentSelector({ onSelectInstrument }: InstrumentSelectorProps) {
|
export function InstrumentSelector({ onSelectInstrument }: InstrumentSelectorProps) {
|
||||||
const [selectedCategoryId, setSelectedCategoryId] = useState('drums');
|
const [searchQuery, setSearchQuery] = useState('');
|
||||||
const popoverRef = useRef<HTMLIonPopoverElement>(null);
|
const [expandedCategoryIds, setExpandedCategoryIds] = useState<string[]>([]);
|
||||||
const popover = usePopoverDisclosure();
|
const [isPickerOpen, setIsPickerOpen] = useState(false);
|
||||||
const selectedCategory = INSTRUMENT_CATEGORIES.find(
|
const modalRef = useRef<HTMLIonModalElement>(null);
|
||||||
(category) => category.id === selectedCategoryId,
|
|
||||||
) ?? INSTRUMENT_CATEGORIES[0];
|
|
||||||
|
|
||||||
function handleCategoryChange(value: unknown): void {
|
const filteredCategories = useMemo(() => {
|
||||||
if (typeof value !== 'string') return;
|
const query = searchQuery.trim().toLowerCase();
|
||||||
const category = INSTRUMENT_CATEGORIES.find((candidate) => candidate.id === value);
|
return INSTRUMENT_CATEGORIES.flatMap((category) => {
|
||||||
if (category) setSelectedCategoryId(category.id);
|
const categoryMatches = category.label.toLowerCase().includes(query);
|
||||||
|
const instruments = category.instrumentIds
|
||||||
|
.map((instrumentId) => INSTRUMENT_BY_ID[instrumentId])
|
||||||
|
.filter((instrument) => (
|
||||||
|
!query
|
||||||
|
|| categoryMatches
|
||||||
|
|| `${instrument.label} ${instrument.description}`.toLowerCase().includes(query)
|
||||||
|
));
|
||||||
|
|
||||||
|
return instruments.length > 0 ? [{ category, instruments }] : [];
|
||||||
|
});
|
||||||
|
}, [searchQuery]);
|
||||||
|
|
||||||
|
function handleSearchInput(value: string | null | undefined): void {
|
||||||
|
const nextQuery = value ?? '';
|
||||||
|
const normalizedQuery = nextQuery.trim().toLowerCase();
|
||||||
|
setSearchQuery(nextQuery);
|
||||||
|
|
||||||
|
if (!normalizedQuery) {
|
||||||
|
setExpandedCategoryIds([]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
setExpandedCategoryIds(
|
||||||
|
INSTRUMENT_CATEGORIES
|
||||||
|
.filter((category) => (
|
||||||
|
category.label.toLowerCase().includes(normalizedQuery)
|
||||||
|
|| category.instrumentIds.some((instrumentId) => {
|
||||||
|
const instrument = INSTRUMENT_BY_ID[instrumentId];
|
||||||
|
return `${instrument.label} ${instrument.description}`
|
||||||
|
.toLowerCase()
|
||||||
|
.includes(normalizedQuery);
|
||||||
|
})
|
||||||
|
))
|
||||||
|
.map((category) => category.id),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleAccordionChange(value: unknown): void {
|
||||||
|
if (Array.isArray(value)) {
|
||||||
|
setExpandedCategoryIds(value.filter((categoryId): categoryId is string => (
|
||||||
|
typeof categoryId === 'string'
|
||||||
|
)));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
setExpandedCategoryIds(typeof value === 'string' ? [value] : []);
|
||||||
|
}
|
||||||
|
|
||||||
|
function handlePickerDidDismiss(): void {
|
||||||
|
setIsPickerOpen(false);
|
||||||
|
setSearchQuery('');
|
||||||
|
setExpandedCategoryIds([]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function addInstrument(value: unknown): void {
|
function addInstrument(value: unknown): void {
|
||||||
if (!isInstrumentId(value)) return;
|
if (!isInstrumentId(value)) return;
|
||||||
|
|
||||||
void popoverRef.current?.dismiss();
|
void modalRef.current?.dismiss();
|
||||||
onSelectInstrument(value);
|
onSelectInstrument(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="instrument-selector-group">
|
<div className="instrument-selector-group">
|
||||||
<IonSelect
|
|
||||||
className="instrument-selector"
|
|
||||||
fill="solid"
|
|
||||||
interface="popover"
|
|
||||||
aria-label="Choose an instrument category"
|
|
||||||
value={selectedCategoryId}
|
|
||||||
onIonChange={(event) => handleCategoryChange(event.detail.value)}
|
|
||||||
>
|
|
||||||
{INSTRUMENT_CATEGORIES.map((category) => (
|
|
||||||
<IonSelectOption key={category.id} value={category.id}>
|
|
||||||
{category.label}
|
|
||||||
</IonSelectOption>
|
|
||||||
))}
|
|
||||||
</IonSelect>
|
|
||||||
|
|
||||||
<IonButton
|
<IonButton
|
||||||
id="instrument-add-trigger"
|
id="instrument-add-trigger"
|
||||||
className="instrument-add-button"
|
className="instrument-add-button"
|
||||||
fill="solid"
|
fill="solid"
|
||||||
aria-label={`Show ${selectedCategory.label} instruments`}
|
onClick={() => setIsPickerOpen(true)}
|
||||||
|
aria-label="Open samples"
|
||||||
aria-haspopup="dialog"
|
aria-haspopup="dialog"
|
||||||
aria-expanded={popover.isOpen}
|
aria-expanded={isPickerOpen}
|
||||||
>
|
>
|
||||||
<IonIcon icon={add} />
|
<IonIcon icon={add} slot="start" />
|
||||||
|
Samples
|
||||||
</IonButton>
|
</IonButton>
|
||||||
|
|
||||||
<IonPopover
|
<IonModal
|
||||||
ref={popoverRef}
|
ref={modalRef}
|
||||||
className="instrument-picker-popover"
|
className="instrument-picker-modal"
|
||||||
trigger="instrument-add-trigger"
|
isOpen={isPickerOpen}
|
||||||
triggerAction="click"
|
breakpoints={PICKER_SHEET_BREAKPOINTS}
|
||||||
side="top"
|
initialBreakpoint={1}
|
||||||
alignment="start"
|
expandToScroll={false}
|
||||||
onDidPresent={popover.onDidPresent}
|
handle
|
||||||
onDidDismiss={popover.onDidDismiss}
|
onDidDismiss={handlePickerDidDismiss}
|
||||||
>
|
>
|
||||||
<div className="instrument-picker-menu" role="group" aria-label={`${selectedCategory.label} instruments`}>
|
<IonContent className="instrument-picker-content" scrollY={false}>
|
||||||
{selectedCategory.instrumentIds.map((instrumentId) => {
|
<div className="instrument-picker-menu">
|
||||||
const instrument = INSTRUMENT_BY_ID[instrumentId];
|
<IonSearchbar
|
||||||
return (
|
className="instrument-picker-search"
|
||||||
|
aria-label="Search samples"
|
||||||
|
placeholder="Search samples"
|
||||||
|
value={searchQuery}
|
||||||
|
debounce={0}
|
||||||
|
showClearButton="always"
|
||||||
|
onIonInput={(event) => handleSearchInput(event.detail.value)}
|
||||||
|
onIonClear={() => handleSearchInput('')}
|
||||||
|
/>
|
||||||
|
|
||||||
|
{filteredCategories.length > 0 ? (
|
||||||
|
<IonAccordionGroup
|
||||||
|
className="instrument-picker-accordion-group"
|
||||||
|
multiple
|
||||||
|
value={expandedCategoryIds}
|
||||||
|
onIonChange={(event) => handleAccordionChange(event.detail.value)}
|
||||||
|
>
|
||||||
|
{filteredCategories.map(({ category, instruments }) => (
|
||||||
|
<IonAccordion
|
||||||
|
className="instrument-picker-category"
|
||||||
|
key={category.id}
|
||||||
|
value={category.id}
|
||||||
|
>
|
||||||
|
<IonItem className="instrument-category-header" slot="header" lines="none">
|
||||||
|
<IonLabel>{category.label}</IonLabel>
|
||||||
|
</IonItem>
|
||||||
|
<div className="instrument-category-content" slot="content">
|
||||||
|
{instruments.map((instrument) => (
|
||||||
<IonButton
|
<IonButton
|
||||||
className="instrument-picker-option"
|
className="instrument-picker-option"
|
||||||
fill="clear"
|
fill="solid"
|
||||||
key={instrumentId}
|
key={instrument.id}
|
||||||
aria-label={`Add ${instrument.label}`}
|
aria-label={`Add ${instrument.label}`}
|
||||||
onClick={() => addInstrument(instrumentId)}
|
onClick={() => addInstrument(instrument.id)}
|
||||||
>
|
>
|
||||||
<span className="instrument-picker-option-copy">
|
<span className="instrument-picker-option-copy">
|
||||||
<span>{instrument.label}</span>
|
<span>{instrument.label}</span>
|
||||||
<span>{instrument.description}</span>
|
<span>{instrument.description}</span>
|
||||||
</span>
|
</span>
|
||||||
</IonButton>
|
</IonButton>
|
||||||
);
|
))}
|
||||||
})}
|
|
||||||
</div>
|
</div>
|
||||||
</IonPopover>
|
</IonAccordion>
|
||||||
|
))}
|
||||||
|
</IonAccordionGroup>
|
||||||
|
) : (
|
||||||
|
<p className="instrument-picker-empty" role="status">No matching samples.</p>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</IonContent>
|
||||||
|
</IonModal>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -1 +1,85 @@
|
|||||||
export { CategoryRingSelector as SoundRingSelector } from './CategoryRingSelector';
|
import { memo } from 'react';
|
||||||
|
import { IonButton, IonIcon, IonPopover } from '@ionic/react';
|
||||||
|
import { chevronDown } from 'ionicons/icons';
|
||||||
|
import { INSTRUMENT_BY_ID } from '../domain/instruments';
|
||||||
|
import type { InstrumentId } from '../domain/instruments';
|
||||||
|
import { usePopoverDisclosure } from '../hooks/usePopoverDisclosure';
|
||||||
|
|
||||||
|
interface SoundRingSelectorProps {
|
||||||
|
soundIds: readonly InstrumentId[];
|
||||||
|
focusedSoundId: InstrumentId | null;
|
||||||
|
colorBySoundId: Partial<Record<InstrumentId, string>>;
|
||||||
|
onSelectSound: (soundId: InstrumentId) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const SoundRingSelector = memo(function SoundRingSelector({
|
||||||
|
soundIds,
|
||||||
|
focusedSoundId,
|
||||||
|
colorBySoundId,
|
||||||
|
onSelectSound,
|
||||||
|
}: SoundRingSelectorProps) {
|
||||||
|
const popover = usePopoverDisclosure();
|
||||||
|
const focusedSound = focusedSoundId ? INSTRUMENT_BY_ID[focusedSoundId] : undefined;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<IonButton
|
||||||
|
id={popover.triggerId}
|
||||||
|
className="sound-ring-selector-trigger"
|
||||||
|
fill="clear"
|
||||||
|
disabled={soundIds.length === 0}
|
||||||
|
aria-label={focusedSound ? `Selected ring: ${focusedSound.label}` : 'Select a sound ring'}
|
||||||
|
aria-haspopup="dialog"
|
||||||
|
aria-expanded={popover.isOpen}
|
||||||
|
>
|
||||||
|
<span className="sound-ring-trigger-content">
|
||||||
|
{focusedSoundId && (
|
||||||
|
<span
|
||||||
|
className="ring-selector-swatch"
|
||||||
|
style={{ backgroundColor: colorBySoundId[focusedSoundId] ?? '#b8b4e0' }}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
<span>{focusedSound ? `${focusedSound.label} ring` : 'Sound rings'}</span>
|
||||||
|
<IonIcon icon={chevronDown} />
|
||||||
|
</span>
|
||||||
|
</IonButton>
|
||||||
|
|
||||||
|
<IonPopover
|
||||||
|
className="sound-ring-popover"
|
||||||
|
trigger={popover.triggerId}
|
||||||
|
reference="trigger"
|
||||||
|
size="cover"
|
||||||
|
side="bottom"
|
||||||
|
alignment="end"
|
||||||
|
dismissOnSelect
|
||||||
|
onDidPresent={popover.onDidPresent}
|
||||||
|
onDidDismiss={popover.onDidDismiss}
|
||||||
|
>
|
||||||
|
<div className="sound-ring-options" role="group" aria-label="Sound rings">
|
||||||
|
{soundIds.map((soundId) => {
|
||||||
|
const selected = soundId === focusedSoundId;
|
||||||
|
return (
|
||||||
|
<IonButton
|
||||||
|
key={soundId}
|
||||||
|
className="sound-ring-option"
|
||||||
|
fill={selected ? 'solid' : 'clear'}
|
||||||
|
aria-pressed={selected}
|
||||||
|
onClick={() => {
|
||||||
|
onSelectSound(soundId);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<span className="sound-ring-option-content">
|
||||||
|
<span
|
||||||
|
className="ring-selector-swatch"
|
||||||
|
style={{ backgroundColor: colorBySoundId[soundId] ?? '#b8b4e0' }}
|
||||||
|
/>
|
||||||
|
<span>{INSTRUMENT_BY_ID[soundId].label} ring</span>
|
||||||
|
</span>
|
||||||
|
</IonButton>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
</IonPopover>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
});
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
import { memo } from 'react';
|
import { memo } from 'react';
|
||||||
import { IonButton, IonIcon, IonPopover, IonRange } from '@ionic/react';
|
import type { CSSProperties } from 'react';
|
||||||
|
import { IonButton, IonIcon, IonPopover } from '@ionic/react';
|
||||||
import { chevronDown } from 'ionicons/icons';
|
import { chevronDown } from 'ionicons/icons';
|
||||||
import { MAX_TEMPO_BPM, MIN_TEMPO_BPM } from '../domain/sequencer';
|
import { MAX_TEMPO_BPM, MIN_TEMPO_BPM } from '../domain/sequencer';
|
||||||
import { usePopoverDisclosure } from '../hooks/usePopoverDisclosure';
|
import { usePopoverDisclosure } from '../hooks/usePopoverDisclosure';
|
||||||
@@ -9,13 +10,19 @@ interface TempoControlProps {
|
|||||||
onTempoChange: (tempoBpm: number) => void;
|
onTempoChange: (tempoBpm: number) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const TEMPO_TRACK_HEIGHT = 164;
|
||||||
|
const TEMPO_THUMB_SIZE = 18;
|
||||||
|
|
||||||
export const TempoControl = memo(function TempoControl({ tempoBpm, onTempoChange }: TempoControlProps) {
|
export const TempoControl = memo(function TempoControl({ tempoBpm, onTempoChange }: TempoControlProps) {
|
||||||
const popover = usePopoverDisclosure();
|
const popover = usePopoverDisclosure();
|
||||||
|
const tempoProgress = ((tempoBpm - MIN_TEMPO_BPM) / (MAX_TEMPO_BPM - MIN_TEMPO_BPM)) * 100;
|
||||||
|
const tempoThumbCenter = TEMPO_THUMB_SIZE / 2
|
||||||
|
+ ((100 - tempoProgress) / 100) * (TEMPO_TRACK_HEIGHT - TEMPO_THUMB_SIZE);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<IonButton
|
<IonButton
|
||||||
id="main-tempo-control-trigger"
|
id={popover.triggerId}
|
||||||
className="tempo-trigger"
|
className="tempo-trigger"
|
||||||
fill="solid"
|
fill="solid"
|
||||||
aria-label={`Change tempo, currently ${tempoBpm} BPM`}
|
aria-label={`Change tempo, currently ${tempoBpm} BPM`}
|
||||||
@@ -30,8 +37,9 @@ export const TempoControl = memo(function TempoControl({ tempoBpm, onTempoChange
|
|||||||
|
|
||||||
<IonPopover
|
<IonPopover
|
||||||
className="tempo-popover"
|
className="tempo-popover"
|
||||||
trigger="main-tempo-control-trigger"
|
trigger={popover.triggerId}
|
||||||
triggerAction="click"
|
reference="trigger"
|
||||||
|
size="cover"
|
||||||
side="top"
|
side="top"
|
||||||
alignment="start"
|
alignment="start"
|
||||||
onDidPresent={popover.onDidPresent}
|
onDidPresent={popover.onDidPresent}
|
||||||
@@ -39,18 +47,24 @@ export const TempoControl = memo(function TempoControl({ tempoBpm, onTempoChange
|
|||||||
>
|
>
|
||||||
<div className="tempo-popover-content">
|
<div className="tempo-popover-content">
|
||||||
<output className="tempo-value" aria-live="polite">{tempoBpm} BPM</output>
|
<output className="tempo-value" aria-live="polite">{tempoBpm} BPM</output>
|
||||||
<div className="tempo-range-track">
|
<div
|
||||||
<IonRange
|
className="tempo-range-track"
|
||||||
|
style={{
|
||||||
|
'--tempo-progress': `${tempoProgress}%`,
|
||||||
|
'--tempo-thumb-center': `${tempoThumbCenter}px`,
|
||||||
|
} as CSSProperties}
|
||||||
|
>
|
||||||
|
<input
|
||||||
className="tempo-range"
|
className="tempo-range"
|
||||||
|
type="range"
|
||||||
aria-label="Tempo in beats per minute"
|
aria-label="Tempo in beats per minute"
|
||||||
min={MIN_TEMPO_BPM}
|
min={MIN_TEMPO_BPM}
|
||||||
max={MAX_TEMPO_BPM}
|
max={MAX_TEMPO_BPM}
|
||||||
step={1}
|
step={1}
|
||||||
value={tempoBpm}
|
value={tempoBpm}
|
||||||
onIonInput={(event) => {
|
onChange={(event) => onTempoChange(event.currentTarget.valueAsNumber)}
|
||||||
if (typeof event.detail.value === 'number') onTempoChange(event.detail.value);
|
|
||||||
}}
|
|
||||||
/>
|
/>
|
||||||
|
<span className="tempo-range-thumb" aria-hidden="true" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</IonPopover>
|
</IonPopover>
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ export const TimeSignatureSelector = memo(function TimeSignatureSelector({
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<IonButton
|
<IonButton
|
||||||
id="time-signature-trigger"
|
id={popover.triggerId}
|
||||||
className="meter-trigger"
|
className="meter-trigger"
|
||||||
fill="solid"
|
fill="solid"
|
||||||
aria-label={`Change time signature, currently ${beatsPerBar}/4`}
|
aria-label={`Change time signature, currently ${beatsPerBar}/4`}
|
||||||
@@ -34,8 +34,9 @@ export const TimeSignatureSelector = memo(function TimeSignatureSelector({
|
|||||||
|
|
||||||
<IonPopover
|
<IonPopover
|
||||||
className="meter-popover"
|
className="meter-popover"
|
||||||
trigger="time-signature-trigger"
|
trigger={popover.triggerId}
|
||||||
triggerAction="click"
|
reference="trigger"
|
||||||
|
size="cover"
|
||||||
side="bottom"
|
side="bottom"
|
||||||
alignment="start"
|
alignment="start"
|
||||||
dismissOnSelect
|
dismissOnSelect
|
||||||
@@ -49,7 +50,9 @@ export const TimeSignatureSelector = memo(function TimeSignatureSelector({
|
|||||||
className="meter-option"
|
className="meter-option"
|
||||||
fill={option === beatsPerBar ? 'solid' : 'clear'}
|
fill={option === beatsPerBar ? 'solid' : 'clear'}
|
||||||
aria-pressed={option === beatsPerBar}
|
aria-pressed={option === beatsPerBar}
|
||||||
onClick={() => onChange(option)}
|
onClick={() => {
|
||||||
|
onChange(option);
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<span className="meter-option-content">{option}/4</span>
|
<span className="meter-option-content">{option}/4</span>
|
||||||
</IonButton>
|
</IonButton>
|
||||||
|
|||||||
@@ -2,28 +2,22 @@ import { memo } from 'react';
|
|||||||
import { IonButton, IonFooter, IonIcon, IonToolbar } from '@ionic/react';
|
import { IonButton, IonFooter, IonIcon, IonToolbar } from '@ionic/react';
|
||||||
import { pause, play } from 'ionicons/icons';
|
import { pause, play } from 'ionicons/icons';
|
||||||
import type { InstrumentId } from '../domain/instruments';
|
import type { InstrumentId } from '../domain/instruments';
|
||||||
import type { BeatPoint } from '../domain/sequencer';
|
|
||||||
import { InstrumentSelector } from './InstrumentSelector';
|
import { InstrumentSelector } from './InstrumentSelector';
|
||||||
import { PitchControl } from './PitchControl';
|
|
||||||
|
|
||||||
interface TransportBarProps {
|
interface TransportBarProps {
|
||||||
isPlaying: boolean;
|
isPlaying: boolean;
|
||||||
isStarting: boolean;
|
isStarting: boolean;
|
||||||
hasBeats: boolean;
|
hasBeats: boolean;
|
||||||
selectedBeat: BeatPoint | undefined;
|
|
||||||
onTogglePlayback: () => Promise<void>;
|
onTogglePlayback: () => Promise<void>;
|
||||||
onAddInstrument: (instrumentId: InstrumentId) => void;
|
onAddInstrument: (instrumentId: InstrumentId) => void;
|
||||||
onChangeBeatPitch: (beatId: string, pitchSemitones: number) => void;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const TransportBar = memo(function TransportBar({
|
export const TransportBar = memo(function TransportBar({
|
||||||
isPlaying,
|
isPlaying,
|
||||||
isStarting,
|
isStarting,
|
||||||
hasBeats,
|
hasBeats,
|
||||||
selectedBeat,
|
|
||||||
onTogglePlayback,
|
onTogglePlayback,
|
||||||
onAddInstrument,
|
onAddInstrument,
|
||||||
onChangeBeatPitch,
|
|
||||||
}: TransportBarProps) {
|
}: TransportBarProps) {
|
||||||
return (
|
return (
|
||||||
<IonFooter className="transport-footer">
|
<IonFooter className="transport-footer">
|
||||||
@@ -38,7 +32,6 @@ export const TransportBar = memo(function TransportBar({
|
|||||||
{isStarting ? 'Starting' : isPlaying ? 'Pause' : 'Play'}
|
{isStarting ? 'Starting' : isPlaying ? 'Pause' : 'Play'}
|
||||||
</IonButton>
|
</IonButton>
|
||||||
<InstrumentSelector onSelectInstrument={onAddInstrument} />
|
<InstrumentSelector onSelectInstrument={onAddInstrument} />
|
||||||
<PitchControl selectedBeat={selectedBeat} onChangePitch={onChangeBeatPitch} />
|
|
||||||
</div>
|
</div>
|
||||||
</IonToolbar>
|
</IonToolbar>
|
||||||
</IonFooter>
|
</IonFooter>
|
||||||
|
|||||||
@@ -8,8 +8,8 @@ export const BEATS_PER_BAR_OPTIONS = [2, 3, 4, 5, 6, 7, 8] as const;
|
|||||||
export type BeatsPerBar = (typeof BEATS_PER_BAR_OPTIONS)[number];
|
export type BeatsPerBar = (typeof BEATS_PER_BAR_OPTIONS)[number];
|
||||||
export const TOTAL_STEPS = DEFAULT_BEATS_PER_BAR * STEPS_PER_BEAT;
|
export const TOTAL_STEPS = DEFAULT_BEATS_PER_BAR * STEPS_PER_BEAT;
|
||||||
export const TEMPO_BPM = 112;
|
export const TEMPO_BPM = 112;
|
||||||
export const MIN_TEMPO_BPM = 60;
|
export const MIN_TEMPO_BPM = 30;
|
||||||
export const MAX_TEMPO_BPM = 180;
|
export const MAX_TEMPO_BPM = 260;
|
||||||
|
|
||||||
export function getTotalSteps(beatsPerBar: BeatsPerBar): number {
|
export function getTotalSteps(beatsPerBar: BeatsPerBar): number {
|
||||||
return beatsPerBar * STEPS_PER_BEAT;
|
return beatsPerBar * STEPS_PER_BEAT;
|
||||||
|
|||||||
@@ -5,13 +5,13 @@ import {
|
|||||||
TEMPO_BPM,
|
TEMPO_BPM,
|
||||||
} from './sequencer';
|
} from './sequencer';
|
||||||
import type { BeatsPerBar, BeatPoint } from './sequencer';
|
import type { BeatsPerBar, BeatPoint } from './sequencer';
|
||||||
import { clampPitchSemitones, INSTRUMENT_BY_ID } from './instruments';
|
import { clampPitchSemitones } from './instruments';
|
||||||
import type { InstrumentCategoryId } from './instruments';
|
import type { InstrumentId } from './instruments';
|
||||||
|
|
||||||
export interface SequencerState {
|
export interface SequencerState {
|
||||||
beats: BeatPoint[];
|
beats: BeatPoint[];
|
||||||
selectedBeatId: string | null;
|
selectedBeatId: string | null;
|
||||||
focusedCategoryId: InstrumentCategoryId | null;
|
focusedSoundId: InstrumentId | null;
|
||||||
tempoBpm: number;
|
tempoBpm: number;
|
||||||
beatsPerBar: BeatsPerBar;
|
beatsPerBar: BeatsPerBar;
|
||||||
}
|
}
|
||||||
@@ -21,9 +21,9 @@ export type SequencerAction =
|
|||||||
| { type: 'beat-moved'; beatId: string; step: number }
|
| { type: 'beat-moved'; beatId: string; step: number }
|
||||||
| { type: 'beat-pitch-changed'; beatId: string; pitchSemitones: number }
|
| { type: 'beat-pitch-changed'; beatId: string; pitchSemitones: number }
|
||||||
| { type: 'beat-selected'; beatId: string }
|
| { type: 'beat-selected'; beatId: string }
|
||||||
| { type: 'category-selected'; categoryId: InstrumentCategoryId }
|
| { type: 'sound-selected'; soundId: InstrumentId }
|
||||||
| { type: 'selected-beat-removed' }
|
| { type: 'selected-beat-removed' }
|
||||||
| { type: 'focused-category-removed' }
|
| { type: 'focused-sound-removed' }
|
||||||
| { type: 'tempo-changed'; tempoBpm: number }
|
| { type: 'tempo-changed'; tempoBpm: number }
|
||||||
| { type: 'time-signature-changed'; beatsPerBar: BeatsPerBar }
|
| { type: 'time-signature-changed'; beatsPerBar: BeatsPerBar }
|
||||||
| { type: 'template-loaded'; beats: BeatPoint[]; tempoBpm: number; beatsPerBar: BeatsPerBar };
|
| { type: 'template-loaded'; beats: BeatPoint[]; tempoBpm: number; beatsPerBar: BeatsPerBar };
|
||||||
@@ -32,7 +32,7 @@ export function createInitialSequencerState(): SequencerState {
|
|||||||
return {
|
return {
|
||||||
beats: [],
|
beats: [],
|
||||||
selectedBeatId: null,
|
selectedBeatId: null,
|
||||||
focusedCategoryId: null,
|
focusedSoundId: null,
|
||||||
tempoBpm: TEMPO_BPM,
|
tempoBpm: TEMPO_BPM,
|
||||||
beatsPerBar: DEFAULT_BEATS_PER_BAR,
|
beatsPerBar: DEFAULT_BEATS_PER_BAR,
|
||||||
};
|
};
|
||||||
@@ -49,7 +49,7 @@ export function sequencerReducer(state: SequencerState, action: SequencerAction)
|
|||||||
...state,
|
...state,
|
||||||
beats: [...state.beats, action.beat],
|
beats: [...state.beats, action.beat],
|
||||||
selectedBeatId: action.beat.id,
|
selectedBeatId: action.beat.id,
|
||||||
focusedCategoryId: INSTRUMENT_BY_ID[action.beat.soundId].categoryId,
|
focusedSoundId: action.beat.soundId,
|
||||||
};
|
};
|
||||||
case 'beat-moved':
|
case 'beat-moved':
|
||||||
return {
|
return {
|
||||||
@@ -73,40 +73,35 @@ export function sequencerReducer(state: SequencerState, action: SequencerAction)
|
|||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
selectedBeatId: beat.id,
|
selectedBeatId: beat.id,
|
||||||
focusedCategoryId: INSTRUMENT_BY_ID[beat.soundId].categoryId,
|
focusedSoundId: beat.soundId,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
case 'category-selected':
|
case 'sound-selected':
|
||||||
return { ...state, focusedCategoryId: action.categoryId, selectedBeatId: null };
|
return { ...state, focusedSoundId: action.soundId, selectedBeatId: null };
|
||||||
case 'selected-beat-removed': {
|
case 'selected-beat-removed': {
|
||||||
if (!state.selectedBeatId) return state;
|
if (!state.selectedBeatId) return state;
|
||||||
const removedBeat = state.beats.find((beat) => beat.id === state.selectedBeatId);
|
const removedBeat = state.beats.find((beat) => beat.id === state.selectedBeatId);
|
||||||
if (!removedBeat) return { ...state, selectedBeatId: null };
|
if (!removedBeat) return { ...state, selectedBeatId: null };
|
||||||
|
|
||||||
const beats = state.beats.filter((beat) => beat.id !== removedBeat.id);
|
const beats = state.beats.filter((beat) => beat.id !== removedBeat.id);
|
||||||
const removedCategoryId = INSTRUMENT_BY_ID[removedBeat.soundId].categoryId;
|
const soundRemains = beats.some((beat) => beat.soundId === removedBeat.soundId);
|
||||||
const categoryRemains = beats.some(
|
|
||||||
(beat) => INSTRUMENT_BY_ID[beat.soundId].categoryId === removedCategoryId,
|
|
||||||
);
|
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
beats,
|
beats,
|
||||||
selectedBeatId: null,
|
selectedBeatId: null,
|
||||||
focusedCategoryId: state.focusedCategoryId === removedCategoryId && !categoryRemains
|
focusedSoundId: state.focusedSoundId === removedBeat.soundId && !soundRemains
|
||||||
? beats[0] ? INSTRUMENT_BY_ID[beats[0].soundId].categoryId : null
|
? beats[0]?.soundId ?? null
|
||||||
: state.focusedCategoryId,
|
: state.focusedSoundId,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
case 'focused-category-removed': {
|
case 'focused-sound-removed': {
|
||||||
if (!state.focusedCategoryId) return state;
|
if (!state.focusedSoundId) return state;
|
||||||
const beats = state.beats.filter(
|
const beats = state.beats.filter((beat) => beat.soundId !== state.focusedSoundId);
|
||||||
(beat) => INSTRUMENT_BY_ID[beat.soundId].categoryId !== state.focusedCategoryId,
|
|
||||||
);
|
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
beats,
|
beats,
|
||||||
selectedBeatId: null,
|
selectedBeatId: null,
|
||||||
focusedCategoryId: beats[0] ? INSTRUMENT_BY_ID[beats[0].soundId].categoryId : null,
|
focusedSoundId: beats[0]?.soundId ?? null,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
case 'tempo-changed':
|
case 'tempo-changed':
|
||||||
@@ -115,16 +110,16 @@ export function sequencerReducer(state: SequencerState, action: SequencerAction)
|
|||||||
const totalSteps = getTotalSteps(action.beatsPerBar);
|
const totalSteps = getTotalSteps(action.beatsPerBar);
|
||||||
const visibleBeats = state.beats.filter((beat) => beat.step < totalSteps);
|
const visibleBeats = state.beats.filter((beat) => beat.step < totalSteps);
|
||||||
const selectedBeat = visibleBeats.find((beat) => beat.id === state.selectedBeatId);
|
const selectedBeat = visibleBeats.find((beat) => beat.id === state.selectedBeatId);
|
||||||
const focusedCategoryRemains = visibleBeats.some(
|
const focusedSoundRemains = visibleBeats.some(
|
||||||
(beat) => INSTRUMENT_BY_ID[beat.soundId].categoryId === state.focusedCategoryId,
|
(beat) => beat.soundId === state.focusedSoundId,
|
||||||
);
|
);
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
beatsPerBar: action.beatsPerBar,
|
beatsPerBar: action.beatsPerBar,
|
||||||
selectedBeatId: selectedBeat?.id ?? null,
|
selectedBeatId: selectedBeat?.id ?? null,
|
||||||
focusedCategoryId: focusedCategoryRemains
|
focusedSoundId: focusedSoundRemains
|
||||||
? state.focusedCategoryId
|
? state.focusedSoundId
|
||||||
: visibleBeats[0] ? INSTRUMENT_BY_ID[visibleBeats[0].soundId].categoryId : null,
|
: visibleBeats[0]?.soundId ?? null,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
case 'template-loaded': {
|
case 'template-loaded': {
|
||||||
@@ -133,7 +128,7 @@ export function sequencerReducer(state: SequencerState, action: SequencerAction)
|
|||||||
...state,
|
...state,
|
||||||
beats: action.beats,
|
beats: action.beats,
|
||||||
selectedBeatId: firstBeat?.id ?? null,
|
selectedBeatId: firstBeat?.id ?? null,
|
||||||
focusedCategoryId: firstBeat ? INSTRUMENT_BY_ID[firstBeat.soundId].categoryId : null,
|
focusedSoundId: firstBeat?.soundId ?? null,
|
||||||
tempoBpm: clampTempoBpm(action.tempoBpm),
|
tempoBpm: clampTempoBpm(action.tempoBpm),
|
||||||
beatsPerBar: action.beatsPerBar,
|
beatsPerBar: action.beatsPerBar,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import type { BeatPoint } from './sequencer';
|
import type { BeatPoint } from './sequencer';
|
||||||
import { INSTRUMENT_BY_ID } from './instruments';
|
|
||||||
import {
|
import {
|
||||||
PLAYBACK_SUBSTEPS_PER_STEP,
|
PLAYBACK_SUBSTEPS_PER_STEP,
|
||||||
TOTAL_STEPS,
|
TOTAL_STEPS,
|
||||||
@@ -48,12 +47,10 @@ export function wrapStepPosition(step: number, totalSteps: number): number {
|
|||||||
return ((step % totalSteps) + totalSteps) % totalSteps;
|
return ((step % totalSteps) + totalSteps) % totalSteps;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getCategoryOrbitRadius(categoryIndex: number, categoryCount: number): number {
|
export function getSoundOrbitRadius(soundIndex: number, soundCount: number): number {
|
||||||
return ORBIT_RADIUS * (categoryCount + 1 - categoryIndex) / (categoryCount + 1);
|
return ORBIT_RADIUS * (soundCount + 1 - soundIndex) / (soundCount + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getSoundOrbitRadius = getCategoryOrbitRadius;
|
|
||||||
|
|
||||||
export function getPlaybackTick(step: number, totalSteps: number): number {
|
export function getPlaybackTick(step: number, totalSteps: number): number {
|
||||||
const totalPlaybackTicks = totalSteps * PLAYBACK_SUBSTEPS_PER_STEP;
|
const totalPlaybackTicks = totalSteps * PLAYBACK_SUBSTEPS_PER_STEP;
|
||||||
return Math.round(step * PLAYBACK_SUBSTEPS_PER_STEP) % totalPlaybackTicks;
|
return Math.round(step * PLAYBACK_SUBSTEPS_PER_STEP) % totalPlaybackTicks;
|
||||||
@@ -67,8 +64,7 @@ export function getStackedPosition(
|
|||||||
): CirclePoint {
|
): CirclePoint {
|
||||||
const siblings = beats
|
const siblings = beats
|
||||||
.filter((candidate) => (
|
.filter((candidate) => (
|
||||||
INSTRUMENT_BY_ID[candidate.soundId].categoryId
|
candidate.soundId === beat.soundId
|
||||||
=== INSTRUMENT_BY_ID[beat.soundId].categoryId
|
|
||||||
&& getPlaybackTick(candidate.step, totalSteps) === getPlaybackTick(beat.step, totalSteps)
|
&& getPlaybackTick(candidate.step, totalSteps) === getPlaybackTick(beat.step, totalSteps)
|
||||||
))
|
))
|
||||||
.sort((first, second) => first.id.localeCompare(second.id));
|
.sort((first, second) => first.id.localeCompare(second.id));
|
||||||
|
|||||||
@@ -22,15 +22,15 @@ export interface BeatSequencer {
|
|||||||
tempoBpm: number;
|
tempoBpm: number;
|
||||||
beatsPerBar: BeatsPerBar;
|
beatsPerBar: BeatsPerBar;
|
||||||
totalSteps: number;
|
totalSteps: number;
|
||||||
focusedCategoryId: InstrumentCategoryId | null;
|
focusedSoundId: InstrumentId | null;
|
||||||
selectedBeat: BeatPoint | undefined;
|
selectedBeat: BeatPoint | undefined;
|
||||||
addBeat: (soundId: InstrumentId) => void;
|
addBeat: (soundId: InstrumentId) => void;
|
||||||
moveBeat: (beatId: string, step: number) => void;
|
moveBeat: (beatId: string, step: number) => void;
|
||||||
changeBeatPitch: (beatId: string, pitchSemitones: number) => void;
|
changeBeatPitch: (beatId: string, pitchSemitones: number) => void;
|
||||||
selectBeat: (beatId: string) => void;
|
selectBeat: (beatId: string) => void;
|
||||||
selectCategory: (categoryId: InstrumentCategoryId) => void;
|
selectSound: (soundId: InstrumentId) => void;
|
||||||
removeSelectedBeat: () => void;
|
removeSelectedBeat: () => void;
|
||||||
removeFocusedCategory: () => void;
|
removeFocusedSound: () => void;
|
||||||
setTempoBpm: (tempoBpm: number) => void;
|
setTempoBpm: (tempoBpm: number) => void;
|
||||||
setBeatsPerBar: (beatsPerBar: BeatsPerBar) => void;
|
setBeatsPerBar: (beatsPerBar: BeatsPerBar) => void;
|
||||||
loadTemplate: (template: BeatTemplate) => void;
|
loadTemplate: (template: BeatTemplate) => void;
|
||||||
@@ -43,7 +43,7 @@ export function useBeatSequencer(): BeatSequencer {
|
|||||||
undefined,
|
undefined,
|
||||||
createInitialSequencerState,
|
createInitialSequencerState,
|
||||||
);
|
);
|
||||||
const { beats, beatsPerBar, focusedCategoryId, selectedBeatId, tempoBpm } = state;
|
const { beats, beatsPerBar, focusedSoundId, selectedBeatId, tempoBpm } = state;
|
||||||
const totalSteps = getTotalSteps(beatsPerBar);
|
const totalSteps = getTotalSteps(beatsPerBar);
|
||||||
|
|
||||||
const nextBeatIdRef = useRef(1);
|
const nextBeatIdRef = useRef(1);
|
||||||
@@ -83,16 +83,16 @@ export function useBeatSequencer(): BeatSequencer {
|
|||||||
dispatch({ type: 'beat-selected', beatId });
|
dispatch({ type: 'beat-selected', beatId });
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const selectCategory = useCallback((categoryId: InstrumentCategoryId): void => {
|
const selectSound = useCallback((soundId: InstrumentId): void => {
|
||||||
dispatch({ type: 'category-selected', categoryId });
|
dispatch({ type: 'sound-selected', soundId });
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const removeSelectedBeat = useCallback((): void => {
|
const removeSelectedBeat = useCallback((): void => {
|
||||||
dispatch({ type: 'selected-beat-removed' });
|
dispatch({ type: 'selected-beat-removed' });
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const removeFocusedCategory = useCallback((): void => {
|
const removeFocusedSound = useCallback((): void => {
|
||||||
dispatch({ type: 'focused-category-removed' });
|
dispatch({ type: 'focused-sound-removed' });
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const setTempoBpm = useCallback((tempo: number): void => {
|
const setTempoBpm = useCallback((tempo: number): void => {
|
||||||
@@ -137,15 +137,15 @@ export function useBeatSequencer(): BeatSequencer {
|
|||||||
tempoBpm,
|
tempoBpm,
|
||||||
beatsPerBar,
|
beatsPerBar,
|
||||||
totalSteps,
|
totalSteps,
|
||||||
focusedCategoryId,
|
focusedSoundId,
|
||||||
selectedBeat,
|
selectedBeat,
|
||||||
addBeat,
|
addBeat,
|
||||||
moveBeat,
|
moveBeat,
|
||||||
changeBeatPitch,
|
changeBeatPitch,
|
||||||
selectBeat,
|
selectBeat,
|
||||||
selectCategory,
|
selectSound,
|
||||||
removeSelectedBeat,
|
removeSelectedBeat,
|
||||||
removeFocusedCategory,
|
removeFocusedSound,
|
||||||
setTempoBpm,
|
setTempoBpm,
|
||||||
setBeatsPerBar,
|
setBeatsPerBar,
|
||||||
loadTemplate,
|
loadTemplate,
|
||||||
|
|||||||
@@ -5,13 +5,10 @@ import type { BeatSequencer } from './useBeatSequencer';
|
|||||||
import { useBeatSequencer } from './useBeatSequencer';
|
import { useBeatSequencer } from './useBeatSequencer';
|
||||||
import type { SoundPalette } from './useSoundPalette';
|
import type { SoundPalette } from './useSoundPalette';
|
||||||
import { useSoundPalette } from './useSoundPalette';
|
import { useSoundPalette } from './useSoundPalette';
|
||||||
import type { CategoryLabels } from './useCategoryLabels';
|
|
||||||
import { useCategoryLabels } from './useCategoryLabels';
|
|
||||||
|
|
||||||
export interface BeatStudio {
|
export interface BeatStudio {
|
||||||
sequencer: BeatSequencer;
|
sequencer: BeatSequencer;
|
||||||
soundPalette: SoundPalette;
|
soundPalette: SoundPalette;
|
||||||
categoryLabels: CategoryLabels;
|
|
||||||
addSound: (soundId: InstrumentId) => void;
|
addSound: (soundId: InstrumentId) => void;
|
||||||
applyTemplate: (template: BeatTemplate) => void;
|
applyTemplate: (template: BeatTemplate) => void;
|
||||||
}
|
}
|
||||||
@@ -19,7 +16,6 @@ export interface BeatStudio {
|
|||||||
export function useBeatStudio(): BeatStudio {
|
export function useBeatStudio(): BeatStudio {
|
||||||
const sequencer = useBeatSequencer();
|
const sequencer = useBeatSequencer();
|
||||||
const soundPalette = useSoundPalette();
|
const soundPalette = useSoundPalette();
|
||||||
const categoryLabels = useCategoryLabels();
|
|
||||||
const { addBeat, loadTemplate } = sequencer;
|
const { addBeat, loadTemplate } = sequencer;
|
||||||
const { activateSounds } = soundPalette;
|
const { activateSounds } = soundPalette;
|
||||||
|
|
||||||
@@ -33,5 +29,5 @@ export function useBeatStudio(): BeatStudio {
|
|||||||
activateSounds(template.beats.map((beat) => beat.soundId));
|
activateSounds(template.beats.map((beat) => beat.soundId));
|
||||||
}, [activateSounds, loadTemplate]);
|
}, [activateSounds, loadTemplate]);
|
||||||
|
|
||||||
return { sequencer, soundPalette, categoryLabels, addSound, applyTemplate };
|
return { sequencer, soundPalette, addSound, applyTemplate };
|
||||||
}
|
}
|
||||||
@@ -1,16 +1,17 @@
|
|||||||
import { useCallback, useState } from 'react';
|
import { useCallback, useId, useState } from 'react';
|
||||||
|
|
||||||
export interface PopoverDisclosure {
|
export interface PopoverDisclosure {
|
||||||
|
triggerId: string;
|
||||||
isOpen: boolean;
|
isOpen: boolean;
|
||||||
onDidPresent: () => void;
|
onDidPresent: () => void;
|
||||||
onDidDismiss: () => void;
|
onDidDismiss: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function usePopoverDisclosure(): PopoverDisclosure {
|
export function usePopoverDisclosure(): PopoverDisclosure {
|
||||||
|
const triggerId = useId();
|
||||||
const [isOpen, setIsOpen] = useState(false);
|
const [isOpen, setIsOpen] = useState(false);
|
||||||
|
|
||||||
const onDidPresent = useCallback(() => setIsOpen(true), []);
|
const onDidPresent = useCallback(() => setIsOpen(true), []);
|
||||||
const onDidDismiss = useCallback(() => setIsOpen(false), []);
|
const onDidDismiss = useCallback(() => setIsOpen(false), []);
|
||||||
|
|
||||||
return { isOpen, onDidPresent, onDidDismiss };
|
return { triggerId, isOpen, onDidPresent, onDidDismiss };
|
||||||
}
|
}
|
||||||
@@ -1,50 +1,54 @@
|
|||||||
import { useCallback, useMemo, useState } from 'react';
|
import { useCallback, useMemo, useState } from 'react';
|
||||||
import { INSTRUMENT_BY_ID, INSTRUMENT_CATEGORIES } from '../domain/instruments';
|
import { INSTRUMENT_BY_ID } from '../domain/instruments';
|
||||||
import type { InstrumentCategoryId, InstrumentId } from '../domain/instruments';
|
import type { InstrumentCategoryId, InstrumentId } from '../domain/instruments';
|
||||||
import { generateUniqueSoundColor } from '../domain/soundColors';
|
import { generateUniqueSoundColor } from '../domain/soundColors';
|
||||||
|
|
||||||
export interface PaletteCategory {
|
export interface PaletteSound {
|
||||||
id: InstrumentCategoryId;
|
id: InstrumentId;
|
||||||
color: string;
|
color: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface SoundPalette {
|
export interface SoundPalette {
|
||||||
activeCategories: PaletteCategory[];
|
activeSounds: PaletteSound[];
|
||||||
|
colorBySoundId: Partial<Record<InstrumentId, string>>;
|
||||||
colorByCategoryId: Partial<Record<InstrumentCategoryId, string>>;
|
colorByCategoryId: Partial<Record<InstrumentCategoryId, string>>;
|
||||||
activateSounds: (instrumentIds: readonly InstrumentId[]) => void;
|
activateSounds: (instrumentIds: readonly InstrumentId[]) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function useSoundPalette(): SoundPalette {
|
export function useSoundPalette(): SoundPalette {
|
||||||
const [activeCategories, setActiveCategories] = useState<PaletteCategory[]>([]);
|
const [activeSounds, setActiveSounds] = useState<PaletteSound[]>([]);
|
||||||
|
|
||||||
const activateSounds = useCallback((instrumentIds: readonly InstrumentId[]): void => {
|
const activateSounds = useCallback((instrumentIds: readonly InstrumentId[]): void => {
|
||||||
setActiveCategories((currentCategories) => {
|
setActiveSounds((currentSounds) => {
|
||||||
const nextCategories = [...currentCategories];
|
const nextSounds = [...currentSounds];
|
||||||
const currentCount = nextCategories.length;
|
instrumentIds.forEach((instrumentId) => {
|
||||||
const categoryIds = instrumentIds.map(
|
if (nextSounds.some((sound) => sound.id === instrumentId)) return;
|
||||||
(instrumentId) => INSTRUMENT_BY_ID[instrumentId].categoryId,
|
|
||||||
);
|
|
||||||
INSTRUMENT_CATEGORIES
|
|
||||||
.filter((category) => categoryIds.includes(category.id))
|
|
||||||
.forEach((category) => {
|
|
||||||
if (nextCategories.some((active) => active.id === category.id)) return;
|
|
||||||
|
|
||||||
nextCategories.push({
|
nextSounds.push({
|
||||||
id: category.id,
|
id: instrumentId,
|
||||||
color: generateUniqueSoundColor(nextCategories.map((active) => active.color)),
|
color: generateUniqueSoundColor(nextSounds.map((sound) => sound.color)),
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
return nextCategories.length === currentCount ? currentCategories : nextCategories;
|
return nextSounds.length === currentSounds.length ? currentSounds : nextSounds;
|
||||||
});
|
});
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const colorByCategoryId = useMemo(() => {
|
const colorBySoundId = useMemo(() => {
|
||||||
const colors: Partial<Record<InstrumentCategoryId, string>> = {};
|
const colors: Partial<Record<InstrumentId, string>> = {};
|
||||||
activeCategories.forEach((category) => {
|
activeSounds.forEach((sound) => {
|
||||||
colors[category.id] = category.color;
|
colors[sound.id] = sound.color;
|
||||||
});
|
});
|
||||||
return colors;
|
return colors;
|
||||||
}, [activeCategories]);
|
}, [activeSounds]);
|
||||||
|
|
||||||
return { activeCategories, colorByCategoryId, activateSounds };
|
const colorByCategoryId = useMemo(() => {
|
||||||
|
const colors: Partial<Record<InstrumentCategoryId, string>> = {};
|
||||||
|
activeSounds.forEach((sound) => {
|
||||||
|
const categoryId = INSTRUMENT_BY_ID[sound.id].categoryId;
|
||||||
|
if (colors[categoryId] === undefined) colors[categoryId] = sound.color;
|
||||||
|
});
|
||||||
|
return colors;
|
||||||
|
}, [activeSounds]);
|
||||||
|
|
||||||
|
return { activeSounds, colorBySoundId, colorByCategoryId, activateSounds };
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
declare module 'ionicons/icons' {
|
declare module 'ionicons/icons' {
|
||||||
export const add: string;
|
export const add: string;
|
||||||
|
export const arrowBack: string;
|
||||||
export const chevronDown: string;
|
export const chevronDown: string;
|
||||||
export const ellipsisVertical: string;
|
export const ellipsisVertical: string;
|
||||||
export const musicalNotes: string;
|
export const musicalNotes: string;
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ import {
|
|||||||
TEMPO_BPM,
|
TEMPO_BPM,
|
||||||
} from './sequencer';
|
} from './sequencer';
|
||||||
import type { BeatPoint } from './sequencer';
|
import type { BeatPoint } from './sequencer';
|
||||||
import { getStackedPosition } from './domain/timeline';
|
import { getSoundOrbitRadius, getStackedPosition } from './domain/timeline';
|
||||||
|
|
||||||
describe('circular step positions', () => {
|
describe('circular step positions', () => {
|
||||||
it('derives playback timing from tempo and fine-grained subdivisions', () => {
|
it('derives playback timing from tempo and fine-grained subdivisions', () => {
|
||||||
@@ -76,15 +76,16 @@ describe('circular step positions', () => {
|
|||||||
expect(getStepFromPosition(point.x, point.y)).toBeCloseTo(fractionalStep, 8);
|
expect(getStepFromPosition(point.x, point.y)).toBeCloseTo(fractionalStep, 8);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('visually separates same-category instruments at the same beat tick', () => {
|
it('gives each sound its own orbit and stacks repeated beats of that sound', () => {
|
||||||
const beats: BeatPoint[] = [
|
const beats: BeatPoint[] = [
|
||||||
{ id: 'kick-a', soundId: 'kick', letter: 'a', step: 4 },
|
{ id: 'kick-a', soundId: 'kick', letter: 'a', step: 4 },
|
||||||
{ id: 'snare-b', soundId: 'snare', letter: 'b', step: 4 },
|
{ id: 'kick-b', soundId: 'kick', letter: 'b', step: 4 },
|
||||||
];
|
];
|
||||||
const kickPosition = getStackedPosition(beats[0], beats, TOTAL_STEPS, 180);
|
const kickPosition = getStackedPosition(beats[0], beats, TOTAL_STEPS, 180);
|
||||||
const snarePosition = getStackedPosition(beats[1], beats, TOTAL_STEPS, 180);
|
const secondKickPosition = getStackedPosition(beats[1], beats, TOTAL_STEPS, 180);
|
||||||
|
|
||||||
expect(kickPosition).not.toEqual(snarePosition);
|
expect(kickPosition).not.toEqual(secondKickPosition);
|
||||||
|
expect(getSoundOrbitRadius(0, 2)).not.toBe(getSoundOrbitRadius(1, 2));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('wraps fractional positions and reports loop percentages', () => {
|
it('wraps fractional positions and reports loop percentages', () => {
|
||||||
@@ -175,7 +176,7 @@ describe('instrument catalog and pitch', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('sequencer state transitions', () => {
|
describe('sequencer state transitions', () => {
|
||||||
it('loads a template and removes every instrument in the focused category ring', () => {
|
it('loads a template and removes every beat in the focused sound ring', () => {
|
||||||
const templateBeats: BeatPoint[] = [
|
const templateBeats: BeatPoint[] = [
|
||||||
{ id: 'kick-1', soundId: 'kick', letter: 'a', step: 0 },
|
{ id: 'kick-1', soundId: 'kick', letter: 'a', step: 0 },
|
||||||
{ id: 'snare-1', soundId: 'snare', letter: 'b', step: 4 },
|
{ id: 'snare-1', soundId: 'snare', letter: 'b', step: 4 },
|
||||||
@@ -189,12 +190,12 @@ describe('sequencer state transitions', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
expect(loaded.selectedBeatId).toBe('kick-1');
|
expect(loaded.selectedBeatId).toBe('kick-1');
|
||||||
expect(loaded.focusedCategoryId).toBe('drums');
|
expect(loaded.focusedSoundId).toBe('kick');
|
||||||
|
|
||||||
const afterRingRemoval = sequencerReducer(loaded, { type: 'focused-category-removed' });
|
const afterRingRemoval = sequencerReducer(loaded, { type: 'focused-sound-removed' });
|
||||||
expect(afterRingRemoval.beats).toEqual([templateBeats[2]]);
|
expect(afterRingRemoval.beats).toEqual([templateBeats[1], templateBeats[2]]);
|
||||||
expect(afterRingRemoval.selectedBeatId).toBeNull();
|
expect(afterRingRemoval.selectedBeatId).toBeNull();
|
||||||
expect(afterRingRemoval.focusedCategoryId).toBe('keys');
|
expect(afterRingRemoval.focusedSoundId).toBe('snare');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('clears out-of-range selections when the time signature gets shorter', () => {
|
it('clears out-of-range selections when the time signature gets shorter', () => {
|
||||||
@@ -216,14 +217,15 @@ describe('sequencer state transitions', () => {
|
|||||||
|
|
||||||
expect(shortened.beats).toEqual(beats);
|
expect(shortened.beats).toEqual(beats);
|
||||||
expect(shortened.selectedBeatId).toBeNull();
|
expect(shortened.selectedBeatId).toBeNull();
|
||||||
expect(shortened.focusedCategoryId).toBe('drums');
|
expect(shortened.focusedSoundId).toBe('hi-hat');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('removes one category ring and focuses a remaining category', () => {
|
it('removes one sound ring without removing other sounds in the same category', () => {
|
||||||
const beats: BeatPoint[] = [
|
const beats: BeatPoint[] = [
|
||||||
{ id: 'kick-1', soundId: 'kick', letter: 'a', step: 0 },
|
{ id: 'kick-1', soundId: 'kick', letter: 'a', step: 0 },
|
||||||
{ id: 'hat-1', soundId: 'hi-hat', letter: 'b', step: 4 },
|
{ id: 'hat-1', soundId: 'hi-hat', letter: 'b', step: 4 },
|
||||||
{ id: 'bass-1', soundId: 'bass', letter: 'a', step: 8 },
|
{ id: 'bass-1', soundId: 'bass', letter: 'a', step: 8 },
|
||||||
|
{ id: 'bass-2', soundId: 'bass', letter: 'b', step: 12 },
|
||||||
];
|
];
|
||||||
const loaded = sequencerReducer(createInitialSequencerState(), {
|
const loaded = sequencerReducer(createInitialSequencerState(), {
|
||||||
type: 'template-loaded',
|
type: 'template-loaded',
|
||||||
@@ -232,13 +234,13 @@ describe('sequencer state transitions', () => {
|
|||||||
beatsPerBar: 4,
|
beatsPerBar: 4,
|
||||||
});
|
});
|
||||||
const bassSelected = sequencerReducer(loaded, {
|
const bassSelected = sequencerReducer(loaded, {
|
||||||
type: 'category-selected',
|
type: 'sound-selected',
|
||||||
categoryId: 'bass',
|
soundId: 'bass',
|
||||||
});
|
});
|
||||||
const removed = sequencerReducer(bassSelected, { type: 'focused-category-removed' });
|
const removed = sequencerReducer(bassSelected, { type: 'focused-sound-removed' });
|
||||||
|
|
||||||
expect(removed.beats).toEqual([beats[0], beats[1]]);
|
expect(removed.beats).toEqual([beats[0], beats[1]]);
|
||||||
expect(removed.focusedCategoryId).toBe('drums');
|
expect(removed.focusedSoundId).toBe('kick');
|
||||||
expect(removed.selectedBeatId).toBeNull();
|
expect(removed.selectedBeatId).toBeNull();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -247,6 +249,8 @@ describe('sequencer state transitions', () => {
|
|||||||
const tooSlow = sequencerReducer(initial, { type: 'tempo-changed', tempoBpm: 10 });
|
const tooSlow = sequencerReducer(initial, { type: 'tempo-changed', tempoBpm: 10 });
|
||||||
const tooFast = sequencerReducer(initial, { type: 'tempo-changed', tempoBpm: 300 });
|
const tooFast = sequencerReducer(initial, { type: 'tempo-changed', tempoBpm: 300 });
|
||||||
|
|
||||||
|
expect(MIN_TEMPO_BPM).toBe(30);
|
||||||
|
expect(MAX_TEMPO_BPM).toBe(260);
|
||||||
expect(tooSlow.tempoBpm).toBe(MIN_TEMPO_BPM);
|
expect(tooSlow.tempoBpm).toBe(MIN_TEMPO_BPM);
|
||||||
expect(tooFast.tempoBpm).toBe(MAX_TEMPO_BPM);
|
expect(tooFast.tempoBpm).toBe(MAX_TEMPO_BPM);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -41,6 +41,7 @@
|
|||||||
--accent: #ff8a3d;
|
--accent: #ff8a3d;
|
||||||
--accent-hover: #ff9b5c;
|
--accent-hover: #ff9b5c;
|
||||||
--accent-pressed: #e07936;
|
--accent-pressed: #e07936;
|
||||||
|
--tempo-control-width: 94px;
|
||||||
--primary-rgb: 244, 241, 237;
|
--primary-rgb: 244, 241, 237;
|
||||||
--accent-rgb: 255, 138, 61;
|
--accent-rgb: 255, 138, 61;
|
||||||
--mono: 'DM Mono', monospace;
|
--mono: 'DM Mono', monospace;
|
||||||
@@ -70,6 +71,10 @@ ion-content.app-content {
|
|||||||
color: var(--ink);
|
color: var(--ink);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ion-content.app-content-studio {
|
||||||
|
--overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
/* Application shell and studio heading */
|
/* Application shell and studio heading */
|
||||||
.app-shell {
|
.app-shell {
|
||||||
min-height: 100%;
|
min-height: 100%;
|
||||||
@@ -290,26 +295,24 @@ ion-content.app-content {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.about-return-row {
|
.about-return-row {
|
||||||
margin-top: 24px;
|
margin: 0 12px 24px;
|
||||||
text-align: center;
|
text-align: left;
|
||||||
}
|
}
|
||||||
|
|
||||||
.about-return-button {
|
.about-return-button {
|
||||||
--background: var(--accent);
|
--background: transparent;
|
||||||
--background-hover: var(--accent-hover);
|
--background-hover: rgba(var(--primary-rgb), 0.08);
|
||||||
--background-activated: var(--accent-pressed);
|
--background-activated: rgba(var(--primary-rgb), 0.12);
|
||||||
--color: #111116;
|
--border-radius: 8px;
|
||||||
--border-radius: 9px;
|
--color: var(--muted);
|
||||||
margin: 0;
|
margin: 0;
|
||||||
font-size: 12px;
|
font-size: 11px;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
text-transform: none;
|
text-transform: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.about-return-row p {
|
.about-return-button ion-icon {
|
||||||
margin: 12px 0 0;
|
font-size: 17px;
|
||||||
color: var(--soft);
|
|
||||||
font-size: 10px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.studio-heading {
|
.studio-heading {
|
||||||
@@ -320,8 +323,8 @@ ion-content.app-content {
|
|||||||
.studio-heading h1 {
|
.studio-heading h1 {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
color: var(--ink);
|
color: var(--ink);
|
||||||
font: 500 clamp(24px, 6vw, 40px)/1.1 var(--display);
|
font: 500 clamp(22px, 5vw, 34px)/1.1 var(--display);
|
||||||
letter-spacing: -1.1px;
|
letter-spacing: -0.9px;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -344,6 +347,7 @@ ion-content.app-content {
|
|||||||
--background-activated: #3b3944;
|
--background-activated: #3b3944;
|
||||||
--border-radius: 9px;
|
--border-radius: 9px;
|
||||||
--border-width: 0;
|
--border-width: 0;
|
||||||
|
width: min(230px, calc(100vw - 32px));
|
||||||
height: 40px;
|
height: 40px;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
font-size: 11px;
|
font-size: 11px;
|
||||||
@@ -369,7 +373,6 @@ ion-content.app-content {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.beat-template-popover {
|
.beat-template-popover {
|
||||||
--width: 230px;
|
|
||||||
--background: var(--surface);
|
--background: var(--surface);
|
||||||
--backdrop-opacity: 0;
|
--backdrop-opacity: 0;
|
||||||
--box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
|
--box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
|
||||||
@@ -468,6 +471,7 @@ ion-content.app-content {
|
|||||||
--color: var(--muted);
|
--color: var(--muted);
|
||||||
--border-radius: 7px;
|
--border-radius: 7px;
|
||||||
height: 30px;
|
height: 30px;
|
||||||
|
min-width: 160px;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
font-family: var(--mono);
|
font-family: var(--mono);
|
||||||
font-size: 8px;
|
font-size: 8px;
|
||||||
@@ -503,7 +507,6 @@ ion-content.app-content {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.sound-ring-popover {
|
.sound-ring-popover {
|
||||||
--width: 160px;
|
|
||||||
--background: var(--surface);
|
--background: var(--surface);
|
||||||
--backdrop-opacity: 0;
|
--backdrop-opacity: 0;
|
||||||
--box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
|
--box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
|
||||||
@@ -582,20 +585,11 @@ ion-content.app-content {
|
|||||||
|
|
||||||
.timeline-orbit-hit-area {
|
.timeline-orbit-hit-area {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
outline: none;
|
||||||
|
-webkit-tap-highlight-color: transparent;
|
||||||
transition: r 720ms cubic-bezier(0.22, 1.15, 0.36, 1);
|
transition: r 720ms cubic-bezier(0.22, 1.15, 0.36, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
.timeline-category-letter circle {
|
|
||||||
fill: var(--base);
|
|
||||||
stroke: currentColor;
|
|
||||||
stroke-width: 1.5;
|
|
||||||
}
|
|
||||||
|
|
||||||
.timeline-category-letter text {
|
|
||||||
fill: currentColor;
|
|
||||||
font: 700 9px var(--mono);
|
|
||||||
}
|
|
||||||
|
|
||||||
.timeline-tick line {
|
.timeline-tick line {
|
||||||
stroke: rgba(var(--primary-rgb), 0.34);
|
stroke: rgba(var(--primary-rgb), 0.34);
|
||||||
stroke-width: 1;
|
stroke-width: 1;
|
||||||
@@ -613,7 +607,7 @@ ion-content.app-content {
|
|||||||
|
|
||||||
.timeline-tick text {
|
.timeline-tick text {
|
||||||
fill: var(--muted);
|
fill: var(--muted);
|
||||||
font: 9px var(--mono);
|
font: 14px var(--mono);
|
||||||
}
|
}
|
||||||
|
|
||||||
.timeline-playhead line {
|
.timeline-playhead line {
|
||||||
@@ -733,13 +727,13 @@ ion-content.app-content {
|
|||||||
|
|
||||||
.hint-swatch,
|
.hint-swatch,
|
||||||
.legend-swatch {
|
.legend-swatch {
|
||||||
width: 8px;
|
|
||||||
height: 8px;
|
|
||||||
flex: 0 0 auto;
|
flex: 0 0 auto;
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.hint-swatch {
|
.hint-swatch {
|
||||||
|
width: 8px;
|
||||||
|
height: 8px;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
margin-right: 7px;
|
margin-right: 7px;
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
@@ -755,41 +749,20 @@ ion-content.app-content {
|
|||||||
display: flex;
|
display: flex;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: flex-start;
|
align-items: center;
|
||||||
gap: 8px 12px;
|
gap: 8px 14px;
|
||||||
padding-top: 17px;
|
padding-top: 17px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.legend-category-entry {
|
.legend-sample {
|
||||||
display: flex;
|
|
||||||
max-width: 220px;
|
|
||||||
flex-direction: column;
|
|
||||||
align-items: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.legend-category {
|
|
||||||
display: inline-flex;
|
display: inline-flex;
|
||||||
height: 30px;
|
|
||||||
align-items: center;
|
align-items: center;
|
||||||
margin: 0;
|
|
||||||
--color: var(--muted);
|
|
||||||
--background: transparent;
|
|
||||||
--background-hover: rgba(var(--primary-rgb), 0.08);
|
|
||||||
--background-activated: rgba(var(--primary-rgb), 0.12);
|
|
||||||
--border-radius: 7px;
|
|
||||||
font-size: 10px;
|
|
||||||
text-transform: none;
|
|
||||||
touch-action: manipulation;
|
|
||||||
user-select: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.legend-category::part(native) {
|
|
||||||
gap: 6px;
|
gap: 6px;
|
||||||
min-height: 30px;
|
color: var(--soft);
|
||||||
padding: 0 8px;
|
font-size: 10px;
|
||||||
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
.legend-category-letter,
|
|
||||||
.category-letter-badge {
|
.category-letter-badge {
|
||||||
display: inline-flex;
|
display: inline-flex;
|
||||||
width: 17px;
|
width: 17px;
|
||||||
@@ -803,29 +776,9 @@ ion-content.app-content {
|
|||||||
font: 600 9px var(--mono);
|
font: 600 9px var(--mono);
|
||||||
}
|
}
|
||||||
|
|
||||||
.legend-category .legend-category-letter {
|
.legend-swatch {
|
||||||
color: var(--muted);
|
width: 7px;
|
||||||
}
|
height: 7px;
|
||||||
|
|
||||||
.legend-beat-list {
|
|
||||||
display: flex;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
justify-content: center;
|
|
||||||
gap: 2px 7px;
|
|
||||||
padding: 0 4px;
|
|
||||||
color: var(--soft);
|
|
||||||
font-size: 9px;
|
|
||||||
line-height: 1.5;
|
|
||||||
}
|
|
||||||
|
|
||||||
.legend-beat-list span {
|
|
||||||
white-space: nowrap;
|
|
||||||
}
|
|
||||||
|
|
||||||
.legend-beat-list strong {
|
|
||||||
color: var(--ink);
|
|
||||||
font-family: var(--mono);
|
|
||||||
text-transform: lowercase;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.legend-empty {
|
.legend-empty {
|
||||||
@@ -833,11 +786,6 @@ ion-content.app-content {
|
|||||||
font-size: 11px;
|
font-size: 11px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.legend-swatch {
|
|
||||||
width: 7px;
|
|
||||||
height: 7px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.audio-error {
|
.audio-error {
|
||||||
margin: 13px auto 0;
|
margin: 13px auto 0;
|
||||||
color: #ffad8b;
|
color: #ffad8b;
|
||||||
@@ -890,85 +838,140 @@ ion-content.app-content {
|
|||||||
font-size: 17px;
|
font-size: 17px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.instrument-selector {
|
|
||||||
width: 170px;
|
|
||||||
min-width: 140px;
|
|
||||||
height: 44px;
|
|
||||||
flex: 1 1 150px;
|
|
||||||
margin: 0;
|
|
||||||
--background: var(--surface-raised);
|
|
||||||
--border-radius: 9px;
|
|
||||||
--color: var(--ink);
|
|
||||||
--padding-start: 11px;
|
|
||||||
--padding-end: 9px;
|
|
||||||
--placeholder-color: var(--ink);
|
|
||||||
--placeholder-opacity: 1;
|
|
||||||
font-size: 11px;
|
|
||||||
font-weight: 600;
|
|
||||||
}
|
|
||||||
|
|
||||||
.instrument-selector::part(icon) {
|
|
||||||
color: var(--muted);
|
|
||||||
opacity: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
.instrument-selector-group {
|
.instrument-selector-group {
|
||||||
display: flex;
|
display: flex;
|
||||||
min-width: 0;
|
min-width: 0;
|
||||||
flex: 0 1 auto;
|
flex: 0 0 auto;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 6px;
|
margin-left: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
.instrument-add-button {
|
.instrument-add-button {
|
||||||
width: 44px;
|
min-width: 104px;
|
||||||
height: 44px;
|
height: 44px;
|
||||||
flex: 0 0 44px;
|
flex: 0 0 auto;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
--background: var(--surface-raised);
|
--background: var(--surface-raised);
|
||||||
--background-hover: #33323b;
|
--background-hover: #33323b;
|
||||||
--background-activated: #3b3944;
|
--background-activated: #3b3944;
|
||||||
--border-radius: 9px;
|
--border-radius: 9px;
|
||||||
--color: var(--ink);
|
--color: var(--ink);
|
||||||
--padding-start: 0;
|
--padding-start: 12px;
|
||||||
--padding-end: 0;
|
--padding-end: 12px;
|
||||||
|
font-size: 11px;
|
||||||
|
font-weight: 600;
|
||||||
|
text-transform: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.instrument-add-button::part(native) {
|
.instrument-add-button::part(native) {
|
||||||
width: 44px;
|
width: 100%;
|
||||||
height: 44px;
|
height: 44px;
|
||||||
|
gap: 6px;
|
||||||
|
padding-inline: 12px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.instrument-add-button ion-icon {
|
.instrument-add-button ion-icon {
|
||||||
font-size: 19px;
|
font-size: 19px;
|
||||||
}
|
}
|
||||||
|
|
||||||
ion-popover.instrument-picker-popover {
|
ion-modal.instrument-picker-modal {
|
||||||
--width: min(250px, calc(100vw - 24px));
|
--width: min(420px, calc(100vw - 24px));
|
||||||
|
--height: min(620px, calc(100% - (var(--ion-modal-offset-top, 0px) + 10px)));
|
||||||
|
--max-height: calc(100% - (var(--ion-modal-offset-top, 0px) + 10px));
|
||||||
--background: var(--surface);
|
--background: var(--surface);
|
||||||
--backdrop-opacity: 0;
|
--border-radius: 18px 18px 0 0;
|
||||||
--box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
|
--box-shadow: 0 -10px 28px rgba(0, 0, 0, 0.45);
|
||||||
|
}
|
||||||
|
|
||||||
|
ion-content.instrument-picker-content {
|
||||||
|
--background: var(--surface);
|
||||||
|
--overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
.instrument-picker-menu {
|
.instrument-picker-menu {
|
||||||
display: flex;
|
display: flex;
|
||||||
max-height: min(60vh, 420px);
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
max-height: 100%;
|
||||||
|
min-height: 0;
|
||||||
|
box-sizing: border-box;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: 4px;
|
gap: 6px;
|
||||||
overflow-y: auto;
|
overflow: hidden;
|
||||||
overscroll-behavior: contain;
|
overscroll-behavior: contain;
|
||||||
padding: 8px;
|
padding: 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.instrument-picker-search {
|
||||||
|
width: 100%;
|
||||||
|
flex: 0 0 auto;
|
||||||
|
min-height: 40px;
|
||||||
|
padding: 0;
|
||||||
|
--background: var(--surface-raised);
|
||||||
|
--border-radius: 8px;
|
||||||
|
--box-shadow: none;
|
||||||
|
--color: var(--ink);
|
||||||
|
--icon-color: var(--muted);
|
||||||
|
--placeholder-color: var(--soft);
|
||||||
|
}
|
||||||
|
|
||||||
|
.instrument-picker-accordion-group {
|
||||||
|
width: 100%;
|
||||||
|
flex: 1 1 auto;
|
||||||
|
min-height: 0;
|
||||||
|
overflow-y: auto;
|
||||||
|
overscroll-behavior: contain;
|
||||||
|
}
|
||||||
|
|
||||||
|
.instrument-picker-category {
|
||||||
|
display: block;
|
||||||
|
width: 100%;
|
||||||
|
margin-bottom: 4px;
|
||||||
|
overflow: hidden;
|
||||||
|
border-radius: 8px;
|
||||||
|
background: var(--surface-raised);
|
||||||
|
}
|
||||||
|
|
||||||
|
.instrument-category-header {
|
||||||
|
--background: var(--surface-raised);
|
||||||
|
--color: var(--ink);
|
||||||
|
--min-height: 40px;
|
||||||
|
font-size: 11px;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.instrument-category-header::part(native) {
|
||||||
|
min-height: 40px;
|
||||||
|
padding-inline: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.instrument-category-content {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 6px;
|
||||||
|
padding: 6px 8px 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.instrument-picker-empty {
|
||||||
|
margin: 0;
|
||||||
|
padding: 12px 6px;
|
||||||
|
color: var(--soft);
|
||||||
|
font-size: 11px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
.instrument-picker-option {
|
.instrument-picker-option {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 48px;
|
height: 52px;
|
||||||
flex: 0 0 48px;
|
flex: 0 0 52px;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
--background: var(--surface-raised);
|
--background: var(--surface);
|
||||||
--background-hover: #33323b;
|
--background-hover: var(--surface-raised);
|
||||||
--background-activated: #3b3944;
|
--background-activated: #3b3944;
|
||||||
--border-radius: 8px;
|
--border-color: rgba(var(--primary-rgb), 0.12);
|
||||||
|
--border-style: solid;
|
||||||
|
--border-width: 1px;
|
||||||
|
--border-radius: 10px;
|
||||||
--color: var(--ink);
|
--color: var(--ink);
|
||||||
font-size: 11px;
|
font-size: 11px;
|
||||||
text-transform: none;
|
text-transform: none;
|
||||||
@@ -999,12 +1002,12 @@ ion-popover.instrument-picker-popover {
|
|||||||
|
|
||||||
.pitch-control {
|
.pitch-control {
|
||||||
display: flex;
|
display: flex;
|
||||||
min-width: 145px;
|
width: 100%;
|
||||||
max-width: 230px;
|
min-width: 0;
|
||||||
flex: 1 1 160px;
|
max-width: none;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: 1px;
|
gap: 1px;
|
||||||
margin-left: auto;
|
margin: 8px 0 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.pitch-control-heading {
|
.pitch-control-heading {
|
||||||
@@ -1040,6 +1043,8 @@ ion-popover.instrument-picker-popover {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.tempo-trigger {
|
.tempo-trigger {
|
||||||
|
width: var(--tempo-control-width);
|
||||||
|
flex: 0 0 var(--tempo-control-width);
|
||||||
--color: var(--ink);
|
--color: var(--ink);
|
||||||
--background: var(--surface-raised);
|
--background: var(--surface-raised);
|
||||||
--background-hover: #33323b;
|
--background-hover: #33323b;
|
||||||
@@ -1096,6 +1101,7 @@ ion-popover.instrument-picker-popover {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.tempo-value {
|
.tempo-value {
|
||||||
|
align-self: center;
|
||||||
color: var(--ink);
|
color: var(--ink);
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
@@ -1105,7 +1111,6 @@ ion-popover.instrument-picker-popover {
|
|||||||
|
|
||||||
/* Popover contents */
|
/* Popover contents */
|
||||||
.tempo-popover {
|
.tempo-popover {
|
||||||
--width: 94px;
|
|
||||||
--height: 226px;
|
--height: 226px;
|
||||||
--background: var(--surface);
|
--background: var(--surface);
|
||||||
--backdrop-opacity: 0;
|
--backdrop-opacity: 0;
|
||||||
@@ -1125,9 +1130,30 @@ ion-popover.instrument-picker-popover {
|
|||||||
|
|
||||||
.tempo-range-track {
|
.tempo-range-track {
|
||||||
position: relative;
|
position: relative;
|
||||||
width: 28px;
|
display: flex;
|
||||||
|
width: 44px;
|
||||||
height: 164px;
|
height: 164px;
|
||||||
flex: 0 0 164px;
|
flex: 0 0 164px;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tempo-range-track::before {
|
||||||
|
position: absolute;
|
||||||
|
top: 9px;
|
||||||
|
bottom: 9px;
|
||||||
|
left: 50%;
|
||||||
|
width: 3px;
|
||||||
|
border-radius: 999px;
|
||||||
|
background: linear-gradient(
|
||||||
|
to top,
|
||||||
|
var(--accent) 0%,
|
||||||
|
var(--accent) var(--tempo-progress),
|
||||||
|
#58537d var(--tempo-progress),
|
||||||
|
#58537d 100%
|
||||||
|
);
|
||||||
|
content: '';
|
||||||
|
transform: translateX(-50%);
|
||||||
}
|
}
|
||||||
|
|
||||||
.tempo-range {
|
.tempo-range {
|
||||||
@@ -1135,29 +1161,53 @@ ion-popover.instrument-picker-popover {
|
|||||||
top: 50%;
|
top: 50%;
|
||||||
left: 50%;
|
left: 50%;
|
||||||
width: 164px;
|
width: 164px;
|
||||||
height: 28px;
|
height: 44px;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
border: 0;
|
||||||
|
appearance: none;
|
||||||
|
-webkit-appearance: none;
|
||||||
|
z-index: 1;
|
||||||
transform: translate(-50%, -50%) rotate(-90deg);
|
transform: translate(-50%, -50%) rotate(-90deg);
|
||||||
--bar-background: #58537d;
|
background: transparent;
|
||||||
--bar-background-active: var(--accent);
|
cursor: ns-resize;
|
||||||
--bar-height: 3px;
|
opacity: 0;
|
||||||
--height: 28px;
|
touch-action: none;
|
||||||
--knob-background: var(--accent);
|
}
|
||||||
--knob-size: 12px;
|
|
||||||
--padding-top: 2px;
|
.tempo-range-thumb {
|
||||||
--padding-bottom: 2px;
|
position: absolute;
|
||||||
--padding-start: 2px;
|
top: var(--tempo-thumb-center);
|
||||||
--padding-end: 2px;
|
left: 50%;
|
||||||
|
width: 18px;
|
||||||
|
height: 18px;
|
||||||
|
border-radius: 50%;
|
||||||
|
background: var(--accent);
|
||||||
|
box-shadow: 0 0 0 2px rgba(var(--accent-rgb), 0.18);
|
||||||
|
pointer-events: none;
|
||||||
|
transform: translate(-50%, -50%);
|
||||||
|
}
|
||||||
|
|
||||||
|
.tempo-range-track:focus-within .tempo-range-thumb {
|
||||||
|
box-shadow: 0 0 0 2px var(--base), 0 0 0 4px var(--accent);
|
||||||
|
}
|
||||||
|
|
||||||
|
.tempo-range-track:focus-within {
|
||||||
|
outline: 2px solid var(--accent);
|
||||||
|
outline-offset: 4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.meter-popover {
|
.meter-popover {
|
||||||
--width: 96px;
|
--height: 250px;
|
||||||
--height: 224px;
|
|
||||||
--background: var(--surface);
|
--background: var(--surface);
|
||||||
--backdrop-opacity: 0;
|
--backdrop-opacity: 0;
|
||||||
--box-shadow: 0 10px 28px rgba(var(--primary-rgb), 0.2);
|
--box-shadow: 0 10px 28px rgba(var(--primary-rgb), 0.2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.meter-popover::part(content) {
|
||||||
|
overflow-y: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
.meter-popover-content {
|
.meter-popover-content {
|
||||||
display: flex;
|
display: flex;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
@@ -1176,6 +1226,7 @@ ion-popover.instrument-picker-popover {
|
|||||||
--border-radius: 7px;
|
--border-radius: 7px;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 31px;
|
height: 31px;
|
||||||
|
min-height: 31px;
|
||||||
flex: 0 0 31px;
|
flex: 0 0 31px;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
font-size: 11px;
|
font-size: 11px;
|
||||||
@@ -1227,6 +1278,10 @@ ion-popover.instrument-picker-popover {
|
|||||||
padding: 31px 0 24px;
|
padding: 31px 0 24px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.about-return-row {
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
.about-heading h1 {
|
.about-heading h1 {
|
||||||
font-size: 36px;
|
font-size: 36px;
|
||||||
}
|
}
|
||||||
@@ -1262,8 +1317,8 @@ ion-popover.instrument-picker-popover {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.studio-heading h1 {
|
.studio-heading h1 {
|
||||||
font-size: clamp(20px, 5.5vw, 32px);
|
font-size: clamp(18px, 4.5vw, 26px);
|
||||||
letter-spacing: -0.75px;
|
letter-spacing: -0.6px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.template-prompt {
|
.template-prompt {
|
||||||
@@ -1301,14 +1356,9 @@ ion-popover.instrument-picker-popover {
|
|||||||
min-width: 98px;
|
min-width: 98px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.instrument-selector {
|
|
||||||
min-width: 130px;
|
|
||||||
font-size: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.instrument-selector-group {
|
.instrument-selector-group {
|
||||||
min-width: 182px;
|
min-width: 0;
|
||||||
flex: 1 1 182px;
|
flex: 0 0 auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
.pitch-control {
|
.pitch-control {
|
||||||
@@ -1326,6 +1376,46 @@ ion-popover.instrument-picker-popover {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@media (max-height: 1100px) {
|
||||||
|
.app-shell {
|
||||||
|
padding-bottom: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.studio {
|
||||||
|
padding-bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.studio-heading {
|
||||||
|
padding: 14px 0 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.studio-heading h1 {
|
||||||
|
font-size: clamp(17px, 4.2vw, 25px);
|
||||||
|
letter-spacing: -0.5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.template-prompt {
|
||||||
|
margin-top: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.intro-copy {
|
||||||
|
margin-top: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.orbit-card {
|
||||||
|
padding: 12px 10px 9px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.timeline-wrap {
|
||||||
|
width: min(100%, max(180px, calc(100dvh - 390px)));
|
||||||
|
}
|
||||||
|
|
||||||
|
.sound-legend {
|
||||||
|
gap: 6px 10px;
|
||||||
|
padding-top: 8px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@media (max-width: 360px) {
|
@media (max-width: 360px) {
|
||||||
.transport-inner {
|
.transport-inner {
|
||||||
gap: 5px;
|
gap: 5px;
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { IonButton } from '@ionic/react';
|
import { IonButton, IonIcon } from '@ionic/react';
|
||||||
|
import { arrowBack } from 'ionicons/icons';
|
||||||
import { PROJECT_INFO } from '../config/projectInfo';
|
import { PROJECT_INFO } from '../config/projectInfo';
|
||||||
|
|
||||||
interface AboutViewProps {
|
interface AboutViewProps {
|
||||||
@@ -8,6 +9,18 @@ interface AboutViewProps {
|
|||||||
export function AboutView({ onReturnToStudio }: AboutViewProps) {
|
export function AboutView({ onReturnToStudio }: AboutViewProps) {
|
||||||
return (
|
return (
|
||||||
<main className="about-view">
|
<main className="about-view">
|
||||||
|
<div className="about-return-row">
|
||||||
|
<IonButton
|
||||||
|
className="about-return-button"
|
||||||
|
fill="clear"
|
||||||
|
aria-label="Back to the beat studio"
|
||||||
|
onClick={onReturnToStudio}
|
||||||
|
>
|
||||||
|
<IonIcon icon={arrowBack} slot="start" />
|
||||||
|
Back to the beat studio
|
||||||
|
</IonButton>
|
||||||
|
</div>
|
||||||
|
|
||||||
<header className="about-heading">
|
<header className="about-heading">
|
||||||
<p className="about-eyebrow">Project details</p>
|
<p className="about-eyebrow">Project details</p>
|
||||||
<h1>About BeatHound</h1>
|
<h1>About BeatHound</h1>
|
||||||
@@ -102,11 +115,6 @@ export function AboutView({ onReturnToStudio }: AboutViewProps) {
|
|||||||
</section>
|
</section>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="about-return-row">
|
|
||||||
<IonButton className="about-return-button" onClick={onReturnToStudio}>
|
|
||||||
Back to the beat studio
|
|
||||||
</IonButton>
|
|
||||||
</div>
|
|
||||||
</main>
|
</main>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -24,7 +24,6 @@ export function StudioView({ studio }: StudioViewProps) {
|
|||||||
<BeatLoopPanel
|
<BeatLoopPanel
|
||||||
sequencer={studio.sequencer}
|
sequencer={studio.sequencer}
|
||||||
soundPalette={studio.soundPalette}
|
soundPalette={studio.soundPalette}
|
||||||
categoryLabels={studio.categoryLabels}
|
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{studio.sequencer.audioError && (
|
{studio.sequencer.audioError && (
|
||||||
|
|||||||