@pepperhorn/sound-module 0.0.0-stage → 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 +118 -2
- package/dist/fonts.css +15 -0
- package/dist/index.js +5946 -0
- package/dist/patches/poly-bass/C2.wav +0 -0
- package/dist/patches/poly-bass/C3-a.wav +0 -0
- package/dist/patches/poly-bass/C3-b.wav +0 -0
- package/dist/patches/poly-bass/C4-hard-a.wav +0 -0
- package/dist/patches/poly-bass/C4-hard-b.wav +0 -0
- package/dist/patches/poly-bass/C4-soft.wav +0 -0
- package/dist/patches/sine-key/C3.wav +0 -0
- package/dist/patches/sine-key/C4.wav +0 -0
- package/dist/patches/sine-key/C5.wav +0 -0
- package/dist/styles.css +2019 -0
- package/dist/types/audio/AudioEngine.d.ts +147 -0
- package/dist/types/audio/customSampler.d.ts +43 -0
- package/dist/types/audio/effects.d.ts +111 -0
- package/dist/types/audio/fetchSlots.d.ts +4 -0
- package/dist/types/audio/loadPatch.d.ts +25 -0
- package/dist/types/audio/loggedStorage.d.ts +46 -0
- package/dist/types/audio/preview.d.ts +16 -0
- package/dist/types/components/Knob.d.ts +22 -0
- package/dist/types/components/LiveTouchKeyboard.d.ts +11 -0
- package/dist/types/components/LoadErrorToast.d.ts +14 -0
- package/dist/types/components/LoadingOverlay.d.ts +3 -0
- package/dist/types/components/MidiPanel.d.ts +17 -0
- package/dist/types/components/MidiStatus.d.ts +4 -0
- package/dist/types/components/PatchCard.d.ts +20 -0
- package/dist/types/components/PatchPicker.d.ts +13 -0
- package/dist/types/components/PatchStrip.d.ts +17 -0
- package/dist/types/components/PowerOnOverlay.d.ts +8 -0
- package/dist/types/components/TouchKeyboard.d.ts +17 -0
- package/dist/types/components/overlayEscape.d.ts +8 -0
- package/dist/types/embed/SoundModule.d.ts +16 -0
- package/dist/types/embed/catalog.d.ts +6 -0
- package/dist/types/embed/index.d.ts +2 -0
- package/dist/types/input/breath.d.ts +79 -0
- package/dist/types/input/midiAccess.d.ts +14 -0
- package/dist/types/input/midiMonitor.d.ts +10 -0
- package/dist/types/input/midiProfile.d.ts +77 -0
- package/dist/types/input/useComputerKeyboard.d.ts +19 -0
- package/dist/types/input/useWebMidi.d.ts +10 -0
- package/dist/types/patches/builtin.d.ts +2 -0
- package/dist/types/patches/catalog.d.ts +3 -0
- package/dist/types/patches/types.d.ts +51 -0
- package/dist/types/state/activeNotes.d.ts +4 -0
- package/dist/types/state/useFullCatalog.d.ts +19 -0
- package/dist/types/state/useSoundEngine.d.ts +41 -0
- package/dist/types/state/useStore.d.ts +131 -0
- package/package.json +44 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 PepperHorn
|
|
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
CHANGED
|
@@ -1,3 +1,119 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @pepperhorn/sound-module
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
An embeddable React sound module: a sampled-instrument rack with an LCD patch
|
|
4
|
+
strip, a patch browser, a labelled on-screen piano, computer-keyboard play and
|
|
5
|
+
Web MIDI input. It is the same engine as the standalone PepperHorn Module app,
|
|
6
|
+
without any of the app's offline/PWA machinery.
|
|
7
|
+
|
|
8
|
+
## Install
|
|
9
|
+
|
|
10
|
+
```sh
|
|
11
|
+
npm install @pepperhorn/sound-module
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
`react` and `react-dom` (18 or 19) are peer dependencies.
|
|
15
|
+
|
|
16
|
+
## Usage
|
|
17
|
+
|
|
18
|
+
```tsx
|
|
19
|
+
import { SoundModule } from '@pepperhorn/sound-module'
|
|
20
|
+
import '@pepperhorn/sound-module/fonts.css' // optional
|
|
21
|
+
import '@pepperhorn/sound-module/styles.css' // required
|
|
22
|
+
|
|
23
|
+
export function Synth() {
|
|
24
|
+
return (
|
|
25
|
+
<div className="my-synth-wrapper mx-auto max-w-3xl">
|
|
26
|
+
<SoundModule assetBaseUrl="" theme="dark" octaves={2} />
|
|
27
|
+
</div>
|
|
28
|
+
)
|
|
29
|
+
}
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
The component must be rendered client-side only (in Astro, `client:only="react"`).
|
|
33
|
+
|
|
34
|
+
### Stylesheets
|
|
35
|
+
|
|
36
|
+
- **`@pepperhorn/sound-module/styles.css` (required).** Precompiled, scoped to
|
|
37
|
+
`.sound-module`, with no global resets. Its rules sit in `sm-*` cascade layers
|
|
38
|
+
(`sm-properties`, `sm-theme`, `sm-base`, `sm-utilities`) plus unlayered
|
|
39
|
+
component rules. **Load it after the host's global CSS**, so the `sm-*` layers
|
|
40
|
+
are declared after the host's own layers. Note that unlayered host element
|
|
41
|
+
rules (for example a bare `button { … }` outside any `@layer`) beat layered
|
|
42
|
+
rules and can still leak in; keep host element styles layered or scoped.
|
|
43
|
+
- **`@pepperhorn/sound-module/fonts.css` (optional).** `@fontsource` imports for
|
|
44
|
+
Michroma, Chakra Petch, Inter and JetBrains Mono. Skip it if the host already
|
|
45
|
+
loads these fonts.
|
|
46
|
+
|
|
47
|
+
### Props
|
|
48
|
+
|
|
49
|
+
| Prop | Type | Default | |
|
|
50
|
+
|---|---|---|---|
|
|
51
|
+
| `assetBaseUrl` | `string` | — | Base URL that serves `/patches/**`. Pass `""` for same-origin. Omit it to hide the patches that need these files (the CST bank). |
|
|
52
|
+
| `theme` | `'dark' \| 'light'` | `'dark'` | Applied to the component root only (`data-theme`); `<html>` is not touched. |
|
|
53
|
+
| `octaves` | `number` | `2` | On-screen piano octaves (2 = 25 keys). |
|
|
54
|
+
| `className` | `string` | — | Extra classes on the root element. |
|
|
55
|
+
|
|
56
|
+
### Root element and theming
|
|
57
|
+
|
|
58
|
+
The root renders as
|
|
59
|
+
`<div class="sound-module sm-root …" data-theme="dark|light" tabindex="0">`.
|
|
60
|
+
The module sets its own typography on the root and has no box reset, so put
|
|
61
|
+
host spacing, sizing and typography classes **on a wrapper element**, not on
|
|
62
|
+
`className`. Use `className` only for hooks that do not fight the module's own
|
|
63
|
+
styles.
|
|
64
|
+
|
|
65
|
+
Theme tokens (`--color-*`, `--face-bg`, `--card-bg`, …) can be overridden with a
|
|
66
|
+
selector of specificity at least `(0,2,0)`; this holds for both themes, as the
|
|
67
|
+
module's own theme rules are `(0,1,0)`:
|
|
68
|
+
|
|
69
|
+
```css
|
|
70
|
+
.my-page .sound-module { --color-coral: #ff6f61; }
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Keyboard focus
|
|
74
|
+
|
|
75
|
+
The computer keyboard plays only while focus is inside the module; clicking or
|
|
76
|
+
pressing the on-screen piano focuses it. MIDI and breath input play regardless
|
|
77
|
+
of focus.
|
|
78
|
+
|
|
79
|
+
## Patch audio
|
|
80
|
+
|
|
81
|
+
Some patches play audio files shipped with the package at
|
|
82
|
+
`dist/patches/<folder>/<file>.wav` (currently `poly-bass/` and `sine-key/`).
|
|
83
|
+
Copy the **contents** of that folder into your public `patches/` directory so
|
|
84
|
+
that, with `assetBaseUrl=""`, `/patches/sine-key/C4.wav` resolves on your own
|
|
85
|
+
origin. Locate the package directory with:
|
|
86
|
+
|
|
87
|
+
```js
|
|
88
|
+
import { createRequire } from 'node:module'
|
|
89
|
+
import { dirname, join } from 'node:path'
|
|
90
|
+
const require = createRequire(import.meta.url)
|
|
91
|
+
const patchesDir = join(dirname(require.resolve('@pepperhorn/sound-module/package.json')), 'dist/patches')
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
The files are also exported individually as `@pepperhorn/sound-module/patches/*`.
|
|
95
|
+
|
|
96
|
+
## Host requirements
|
|
97
|
+
|
|
98
|
+
- **CSP:** `connect-src` must allow `https://smpldsnds.github.io`,
|
|
99
|
+
`https://gleitz.github.io` and `https://goldst.dev` (sample CDNs), plus your
|
|
100
|
+
own origin (or `assetBaseUrl`) for the patch audio.
|
|
101
|
+
- **Permissions-Policy:** `midi=(self)` on pages that host the module, for Web
|
|
102
|
+
MIDI input.
|
|
103
|
+
- **One instance per page.** The module shares one audio engine and one store.
|
|
104
|
+
|
|
105
|
+
## Storage keys
|
|
106
|
+
|
|
107
|
+
The module uses `localStorage` on the host origin:
|
|
108
|
+
|
|
109
|
+
| Key | Contents |
|
|
110
|
+
|---|---|
|
|
111
|
+
| `module:state:v1` | Current patch, octave and velocity only |
|
|
112
|
+
| `module:midi-map:v1` | MIDI mappings |
|
|
113
|
+
| `module:midi-enabled:v1` | Whether MIDI input is enabled |
|
|
114
|
+
| `module:favourites:v1` | Favourite patches |
|
|
115
|
+
| `module:ui:v1` | Read only, ignored |
|
|
116
|
+
|
|
117
|
+
## License
|
|
118
|
+
|
|
119
|
+
MIT © 2026 PepperHorn
|
package/dist/fonts.css
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The web fonts the sound module uses (the same weights as the standalone
|
|
3
|
+
* app). Import once, next to styles.css; a host that already loads these
|
|
4
|
+
* families can skip it.
|
|
5
|
+
*/
|
|
6
|
+
@import '@fontsource/michroma/400.css';
|
|
7
|
+
@import '@fontsource/chakra-petch/400.css';
|
|
8
|
+
@import '@fontsource/chakra-petch/500.css';
|
|
9
|
+
@import '@fontsource/chakra-petch/600.css';
|
|
10
|
+
@import '@fontsource/chakra-petch/700.css';
|
|
11
|
+
@import '@fontsource/inter/400.css';
|
|
12
|
+
@import '@fontsource/inter/500.css';
|
|
13
|
+
@import '@fontsource/inter/600.css';
|
|
14
|
+
@import '@fontsource/jetbrains-mono/400.css';
|
|
15
|
+
@import '@fontsource/jetbrains-mono/500.css';
|