@audiofab-io/easy-spin-ui 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +78 -0
- package/dist/assets/pedal.png +0 -0
- package/dist/audio/binary.d.ts +7 -0
- package/dist/components/ClipSelector.d.ts +20 -0
- package/dist/components/Knob.d.ts +11 -0
- package/dist/components/PedalFace.d.ts +47 -0
- package/dist/components/ProgramSelector.d.ts +15 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.js +764 -0
- package/dist/index.js.map +1 -0
- package/dist/simulator/useSimulator.d.ts +57 -0
- package/dist/styles.css +811 -0
- package/dist/worklet/fv1-processor.js +8 -0
- package/dist/worklet/fv1-processor.js.map +1 -0
- package/package.json +57 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Audiofab
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# @audiofab-io/easy-spin-ui
|
|
2
|
+
|
|
3
|
+
Shared React components and FV-1 simulation runtime for Audiofab's [Easy Spin](https://audiofab.com/products/easy-spin) pedal. Used by:
|
|
4
|
+
|
|
5
|
+
- **[easy-spin-web](https://easy-spin.audiofab.com)** — the browser-based effect loader and simulator.
|
|
6
|
+
- **[fv1-vscode](https://github.com/audiofab/fv1-vscode)** — the FV-1 VS Code extension's pedal-shaped simulator and bank editor.
|
|
7
|
+
|
|
8
|
+
The package keeps the two surfaces visually and behaviourally identical: the skeuomorphic pedal, the rotary knobs, the program-slot grid, and the audio worklet that runs FV-1 programs in real time all live here.
|
|
9
|
+
|
|
10
|
+
## Installation
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
npm install @audiofab-io/easy-spin-ui
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Peer dependencies: `react@^19`, `react-dom@^19`, `@audiofab-io/fv1-core@^0.4`.
|
|
17
|
+
|
|
18
|
+
## Usage
|
|
19
|
+
|
|
20
|
+
```tsx
|
|
21
|
+
import '@audiofab-io/easy-spin-ui/styles.css'
|
|
22
|
+
import { PedalFace, useSimulator } from '@audiofab-io/easy-spin-ui'
|
|
23
|
+
import workletUrl from '@audiofab-io/easy-spin-ui/worklet?url'
|
|
24
|
+
import pedalImage from '@audiofab-io/easy-spin-ui/assets/pedal.png?url'
|
|
25
|
+
|
|
26
|
+
function App() {
|
|
27
|
+
const simulator = useSimulator({ workletUrl })
|
|
28
|
+
return (
|
|
29
|
+
<PedalFace
|
|
30
|
+
pedalImageUrl={pedalImage}
|
|
31
|
+
pots={[0.5, 0.5, 0.5]}
|
|
32
|
+
onPotChange={simulator.setPot}
|
|
33
|
+
potLabels={['Decay', 'Tone', 'Mix']}
|
|
34
|
+
selectedSlot={0}
|
|
35
|
+
onSelectSlot={() => {}}
|
|
36
|
+
selectedClipId={null}
|
|
37
|
+
onSelectClip={() => {}}
|
|
38
|
+
playing={simulator.playing}
|
|
39
|
+
onPlay={simulator.play}
|
|
40
|
+
onPause={simulator.pause}
|
|
41
|
+
bypassed={simulator.bypassed}
|
|
42
|
+
onToggleBypass={() => simulator.setBypass(!simulator.bypassed)}
|
|
43
|
+
channelMode={simulator.channelMode}
|
|
44
|
+
onChannelModeChange={simulator.setChannelMode}
|
|
45
|
+
/>
|
|
46
|
+
)
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
The hook is intentionally headless — it doesn't know how to fetch effects or audio clips. Consumers compose their own loading conventions on top of `simulator.loadProgram(binary)` and `simulator.loadClipBuffer(arrayBuffer)`.
|
|
51
|
+
|
|
52
|
+
## Building
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
npm install
|
|
56
|
+
npm run build
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
The build produces:
|
|
60
|
+
|
|
61
|
+
- `dist/index.js` — main library entry (ESM)
|
|
62
|
+
- `dist/index.d.ts` — TypeScript declarations
|
|
63
|
+
- `dist/styles.css` — precompiled Tailwind stylesheet
|
|
64
|
+
- `dist/worklet/fv1-processor.js` — self-contained AudioWorklet (IIFE)
|
|
65
|
+
- `dist/assets/pedal.png` — pedal artwork
|
|
66
|
+
|
|
67
|
+
## Releasing
|
|
68
|
+
|
|
69
|
+
Releases are published to npm by GitHub Actions when a tag matching `v*` is pushed. The workflow uses [npm trusted publishing](https://docs.npmjs.com/trusted-publishers) (no `NPM_TOKEN` required).
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
npm version <patch|minor|major> # bumps package.json + creates a v* tag
|
|
73
|
+
git push --follow-tags
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## License
|
|
77
|
+
|
|
78
|
+
MIT — see [LICENSE](LICENSE).
|
|
Binary file
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts a compiled FV-1 binary (Uint8Array, big-endian) to an array of
|
|
3
|
+
* 32-bit machine code words suitable for FV1Simulator.loadProgram().
|
|
4
|
+
*
|
|
5
|
+
* An FV-1 program is 128 instructions × 4 bytes = 512 bytes.
|
|
6
|
+
*/
|
|
7
|
+
export declare function binaryToMachineCode(binary: Uint8Array): number[];
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export interface ClipInfo {
|
|
2
|
+
id: string;
|
|
3
|
+
name: string;
|
|
4
|
+
description?: string;
|
|
5
|
+
}
|
|
6
|
+
interface ClipSelectorProps {
|
|
7
|
+
/** List of clips the consumer wants to expose. */
|
|
8
|
+
clips: ClipInfo[];
|
|
9
|
+
selectedClipId: string | null;
|
|
10
|
+
onSelect: (clipId: string) => void;
|
|
11
|
+
/** When true, the selector is visually disabled (e.g. while a list is loading). */
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Pure presentational dropdown for picking an audio clip. The shared package
|
|
16
|
+
* has no opinion about where clips come from — consumers fetch / bundle their
|
|
17
|
+
* own list and pass it in.
|
|
18
|
+
*/
|
|
19
|
+
export declare function ClipSelector({ clips, selectedClipId, onSelect, disabled }: ClipSelectorProps): import("react/jsx-runtime").JSX.Element;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
interface KnobProps {
|
|
2
|
+
value: number;
|
|
3
|
+
label: string;
|
|
4
|
+
onChange: (value: number) => void;
|
|
5
|
+
size?: number;
|
|
6
|
+
/** When true, render without a visible body — just a pointer indicator
|
|
7
|
+
* (for overlaying on top of a pre-drawn dial graphic). */
|
|
8
|
+
overlay?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export declare function Knob({ value, label, onChange, size, overlay }: KnobProps): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { type ClipInfo } from './ClipSelector';
|
|
2
|
+
export type ChannelMode = 'mono' | 'stereo';
|
|
3
|
+
export interface PedalFaceProps {
|
|
4
|
+
/** URL of the pedal outline graphic. Required — see assets/pedal.png in
|
|
5
|
+
* this package, or bring your own. */
|
|
6
|
+
pedalImageUrl: string;
|
|
7
|
+
/** Current values of the three pots, normalised 0..1. */
|
|
8
|
+
pots: [number, number, number];
|
|
9
|
+
onPotChange: (index: number, value: number) => void;
|
|
10
|
+
/** Per-pot display labels — typically the effect's `controls[].name`,
|
|
11
|
+
* or `Pot 0/1/2` when the active program is unknown. */
|
|
12
|
+
potLabels?: [string, string, string];
|
|
13
|
+
/** Currently selected slot (0-based). */
|
|
14
|
+
selectedSlot: number;
|
|
15
|
+
onSelectSlot: (slot: number) => void;
|
|
16
|
+
/** Display labels for each of the 8 slots. Empty / undefined means empty. */
|
|
17
|
+
slotLabels?: string[];
|
|
18
|
+
/** Drop handler for slot N. The data string is the platform-specific
|
|
19
|
+
* payload (e.g. an effect id, a file URI). The consumer interprets it. */
|
|
20
|
+
onAssignSlot?: (slotIndex: number, payload: string) => void;
|
|
21
|
+
onUnassignSlot?: (slotIndex: number) => void;
|
|
22
|
+
onUnassignAllSlots?: () => void;
|
|
23
|
+
/** Called when the user clicks the per-slot "send to pedal" icon. */
|
|
24
|
+
onProgramSlot?: (slotIndex: number) => void;
|
|
25
|
+
/** Index of the slot currently being written to the pedal, or null. */
|
|
26
|
+
programmingSlot?: number | null;
|
|
27
|
+
/** Audio clip selection — pass an empty array to hide the selector. */
|
|
28
|
+
clips?: ClipInfo[];
|
|
29
|
+
selectedClipId: string | null;
|
|
30
|
+
onSelectClip: (clipId: string) => void;
|
|
31
|
+
playing: boolean;
|
|
32
|
+
onPlay: () => void;
|
|
33
|
+
onPause: () => void;
|
|
34
|
+
bypassed: boolean;
|
|
35
|
+
onToggleBypass: () => void;
|
|
36
|
+
channelMode: ChannelMode;
|
|
37
|
+
onChannelModeChange: (mode: ChannelMode) => void;
|
|
38
|
+
/** Pedal connection state — the I/O button cluster only renders when
|
|
39
|
+
* these are wired up. */
|
|
40
|
+
pedalConnected?: boolean;
|
|
41
|
+
onConnectPedal?: () => void;
|
|
42
|
+
onReadPedal?: () => void;
|
|
43
|
+
onWritePedal?: () => void;
|
|
44
|
+
pedalReading?: boolean;
|
|
45
|
+
pedalWriting?: boolean;
|
|
46
|
+
}
|
|
47
|
+
export declare function PedalFace({ pedalImageUrl, pots, onPotChange, potLabels, selectedSlot, onSelectSlot, slotLabels, onAssignSlot, onUnassignSlot, onUnassignAllSlots, onProgramSlot, programmingSlot, clips, selectedClipId, onSelectClip, playing, onPlay, onPause, bypassed, onToggleBypass, channelMode, onChannelModeChange, pedalConnected, onConnectPedal, onReadPedal, onWritePedal, pedalReading, pedalWriting, }: PedalFaceProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
interface ProgramSelectorProps {
|
|
2
|
+
selectedSlot: number;
|
|
3
|
+
onSelectSlot: (slot: number) => void;
|
|
4
|
+
slotLabels?: string[];
|
|
5
|
+
/** When true, render as a rotary dial with a pointer indicator (no visible body). */
|
|
6
|
+
overlay?: boolean;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Rotary program selector. In overlay mode it renders as a pot-style knob
|
|
10
|
+
* (black circular outline + pointer) that points at the currently selected
|
|
11
|
+
* slot. The knob can be dragged to change program — it snaps to the nearest
|
|
12
|
+
* of the 8 discrete positions.
|
|
13
|
+
*/
|
|
14
|
+
export declare function ProgramSelector({ selectedSlot, onSelectSlot, slotLabels, overlay, }: ProgramSelectorProps): import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
export {};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @audiofab-io/easy-spin-ui
|
|
3
|
+
*
|
|
4
|
+
* Shared React components and FV-1 simulation runtime for Audiofab's
|
|
5
|
+
* Easy Spin pedal. Used by:
|
|
6
|
+
* - easy-spin-web (browser-only)
|
|
7
|
+
* - fv1-vscode (VS Code extension webviews)
|
|
8
|
+
*
|
|
9
|
+
* Consumers must:
|
|
10
|
+
* 1. Import the bundled stylesheet: import '@audiofab-io/easy-spin-ui/styles.css'
|
|
11
|
+
* 2. Provide a worklet URL to useSimulator. In Vite consumers:
|
|
12
|
+
* import workletUrl from '@audiofab-io/easy-spin-ui/worklet?url'
|
|
13
|
+
* In VS Code webviews, copy the file to a webview-accessible path and
|
|
14
|
+
* pass the resulting `webview.asWebviewUri(...)`.
|
|
15
|
+
* 3. Provide a `pedalImageUrl` prop to <PedalFace />. Default asset is
|
|
16
|
+
* shipped at `@audiofab-io/easy-spin-ui/assets/pedal.png`.
|
|
17
|
+
*/
|
|
18
|
+
export { Knob } from './components/Knob';
|
|
19
|
+
export { ProgramSelector } from './components/ProgramSelector';
|
|
20
|
+
export { ClipSelector } from './components/ClipSelector';
|
|
21
|
+
export type { ClipInfo } from './components/ClipSelector';
|
|
22
|
+
export { PedalFace } from './components/PedalFace';
|
|
23
|
+
export type { PedalFaceProps, ChannelMode } from './components/PedalFace';
|
|
24
|
+
export { useSimulator } from './simulator/useSimulator';
|
|
25
|
+
export type { SimulatorState, UseSimulatorOptions, AssembleResult, } from './simulator/useSimulator';
|
|
26
|
+
export { binaryToMachineCode } from './audio/binary';
|
|
27
|
+
export { PROGRAM_SLOT_COUNT } from '@audiofab-io/fv1-core/pedal';
|