audiora 1.0.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/CHANGELOG.md +29 -0
- package/LICENSE +21 -0
- package/README.md +104 -0
- package/docs/API.md +343 -0
- package/package.json +39 -0
- package/src/Audiora.ts +293 -0
- package/src/core/AudioEngine.ts +108 -0
- package/src/core/ImageProcessor.ts +180 -0
- package/src/core/Scanner.ts +183 -0
- package/src/core/Scheduler.ts +105 -0
- package/src/core/State.ts +86 -0
- package/src/core/Synthesizer.ts +196 -0
- package/src/core/constants.ts +70 -0
- package/src/core/presets.ts +166 -0
- package/src/core/types.ts +54 -0
- package/src/core/utils.ts +47 -0
- package/src/core/wav.ts +60 -0
- package/src/index.ts +9 -0
- package/src/ui/Renderer.ts +145 -0
- package/src/ui/Tweener.ts +67 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
|
|
14
|
+
### Fixed
|
|
15
|
+
|
|
16
|
+
## [1.0.0] - 2026-07-15
|
|
17
|
+
|
|
18
|
+
### Added
|
|
19
|
+
|
|
20
|
+
- Initial public release of `audiora`.
|
|
21
|
+
- Picture-driven synthesis instrument with live playback and offline WAV render.
|
|
22
|
+
- Built-in presets: `Haze`, `Leap`, `Pulse`, `Bite`, `Spark`, `Raw`.
|
|
23
|
+
- Scan modes: `linear`, `vertical`, `zigzag`, `drift`, `spiral`.
|
|
24
|
+
- Timing modes: `expressive`, `stable`.
|
|
25
|
+
- Custom oscillator identities: `pulse`, `organ`, `bell` (plus native Web Audio types).
|
|
26
|
+
- UI helpers: `FORMAT`, `RANGE_KEYS`, `SELECT_KEYS`, `DEFAULT_PRESET`.
|
|
27
|
+
- API reference in `docs/API.md`.
|
|
28
|
+
|
|
29
|
+
[1.0.0]: https://github.com/whosramoss/audiora/releases/tag/v1.0.0
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 whosramoss
|
|
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,104 @@
|
|
|
1
|
+
<h1>
|
|
2
|
+
<p align="center">
|
|
3
|
+
<img src="https://raw.githubusercontent.com/whosramoss/audiora/main/www/assets/android-chrome-512x512.png" alt="logo" width="128">
|
|
4
|
+
<br>audiora
|
|
5
|
+
</p>
|
|
6
|
+
</h1>
|
|
7
|
+
|
|
8
|
+
<p align="center">
|
|
9
|
+
Picture-driven synthesis for the web. Maps color and light into pitch, timing, and texture through scanning and musical rules.
|
|
10
|
+
<br /> <br />
|
|
11
|
+
<a href="#how-to-install">Install</a>
|
|
12
|
+
·
|
|
13
|
+
<a href="#usage">Usage</a>
|
|
14
|
+
·
|
|
15
|
+
<a href="#mapping">Mapping</a>
|
|
16
|
+
</p>
|
|
17
|
+
|
|
18
|
+
## How to install
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
npm install audiora
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Usage
|
|
25
|
+
|
|
26
|
+
Import the instrument, load an image, and either play live or render offline:
|
|
27
|
+
|
|
28
|
+
```js
|
|
29
|
+
import { Audiora, PRESETS } from "audiora";
|
|
30
|
+
|
|
31
|
+
const audiora = new Audiora({
|
|
32
|
+
waveCanvas: document.getElementById("wave_canvas"),
|
|
33
|
+
mapCanvas: document.getElementById("map_canvas"),
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
await audiora.loadImage("/photo.jpg");
|
|
37
|
+
audiora.applyParams(PRESETS.Haze, { tween: false });
|
|
38
|
+
|
|
39
|
+
await audiora.play(); // needs a user gesture in most browsers
|
|
40
|
+
|
|
41
|
+
// offline WAV
|
|
42
|
+
const blob = await audiora.toBlob({
|
|
43
|
+
params: PRESETS.Bite,
|
|
44
|
+
duration: 12,
|
|
45
|
+
});
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Importing `audiora` has no side effects — it does not create an `AudioContext` or touch the DOM until you call methods.
|
|
49
|
+
|
|
50
|
+
See the **[API reference](https://github.com/whosramoss/audiora/blob/main/docs/API.md)** for constructors, params, presets, scan modes, and TypeScript types.
|
|
51
|
+
|
|
52
|
+
### Live shell (demo)
|
|
53
|
+
|
|
54
|
+
The `www/` folder is a Vite app (landing + instrument UI). It is **not** published to npm.
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
cd www
|
|
58
|
+
npm install
|
|
59
|
+
npm run dev
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Open the demo, load an image, tweak presets, and listen. Use `warmUp()` / Play after a click so the browser can resume audio.
|
|
63
|
+
|
|
64
|
+
## Mapping
|
|
65
|
+
|
|
66
|
+
Time is shaped by the image: bright areas slightly accelerate the system, darker areas slow it down. Each block is a musical event.
|
|
67
|
+
|
|
68
|
+
| Source | Maps to |
|
|
69
|
+
| ---------------- | --------------------------------------------------- |
|
|
70
|
+
| Hue | Scale degree (pitch), stereo position, micro-detune |
|
|
71
|
+
| Lightness | Octave, amplitude, subtle timing / duration |
|
|
72
|
+
| Saturation | Velocity weighting |
|
|
73
|
+
| Spatial position | Traversal path (`scan_mode`) |
|
|
74
|
+
|
|
75
|
+
The goal is coherence of behavior, not literal accuracy of translation. Small parameter changes matter; most adjustments are intentionally subtle.
|
|
76
|
+
|
|
77
|
+
Built-in scan modes: `linear`, `vertical`, `zigzag`, `drift`, `spiral`. Timing modes: `expressive`, `stable`.
|
|
78
|
+
|
|
79
|
+
## Presets
|
|
80
|
+
|
|
81
|
+
| Name | Role |
|
|
82
|
+
| ------------------------ | ----------------------------------------- |
|
|
83
|
+
| `Haze` | Default — soft, expressive, higher reverb |
|
|
84
|
+
| `Leap` / `Pulse` | Faster, stable phrasing |
|
|
85
|
+
| `Bite` / `Spark` / `Raw` | Sharper / drier identities |
|
|
86
|
+
|
|
87
|
+
```js
|
|
88
|
+
audiora.applyParams(PRESETS.Haze);
|
|
89
|
+
audiora.applyParams(PRESETS.Raw, { tween: false }); // hard cut
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## TypeScript
|
|
93
|
+
|
|
94
|
+
Types ship with the package source entry. No separate `@types` package required.
|
|
95
|
+
|
|
96
|
+
```ts
|
|
97
|
+
import { Audiora, type PresetData, type RenderOptions } from "audiora";
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## Notes
|
|
101
|
+
|
|
102
|
+
- First `play()` may show the scan cursor slightly ahead of audio while the context starts; later plays are stable.
|
|
103
|
+
- The visual cursor leads audio by a small lookahead window by design.
|
|
104
|
+
- At `reverb_mix = 1.0`, stereo pan spread is reduced (fully wet signal) — lower the mix to restore imaging.
|
package/docs/API.md
ADDED
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
# API Reference
|
|
2
|
+
|
|
3
|
+
## Package entry points
|
|
4
|
+
|
|
5
|
+
| Import | Description |
|
|
6
|
+
| --------- | ---------------------------------------------------------------------------------------------- |
|
|
7
|
+
| `audiora` | Main entry. Exports the `Audiora` class, presets, and helpers for live + offline picture-driven synthesis. |
|
|
8
|
+
|
|
9
|
+
There are no side-effectful subpaths. Importing `audiora` does not start AudioContext or scan the DOM.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## `audiora` exports
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import {
|
|
17
|
+
Audiora,
|
|
18
|
+
PRESETS,
|
|
19
|
+
DEFAULT_PRESET,
|
|
20
|
+
FORMAT,
|
|
21
|
+
RANGE_KEYS,
|
|
22
|
+
SELECT_KEYS,
|
|
23
|
+
type RenderOptions,
|
|
24
|
+
type ImageSource,
|
|
25
|
+
type LiveOptions,
|
|
26
|
+
type PresetData,
|
|
27
|
+
} from "audiora";
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
| Export | Type | Description |
|
|
31
|
+
| ---------------- | ---------------------------- | -------------------------------------------------------------------------------- |
|
|
32
|
+
| `Audiora` | `class` | Picture-driven synthesis instrument (live playback + offline render). |
|
|
33
|
+
| `PRESETS` | `Record<string, PresetData>` | Built-in parameter patches (`Haze`, `Leap`, `Pulse`, `Bite`, `Spark`, `Raw`). |
|
|
34
|
+
| `DEFAULT_PRESET` | `string` | Recommended starting preset name (`"Haze"`). |
|
|
35
|
+
| `FORMAT` | `Record<string, (v: number) => string>` | Display formatters for numeric params (UI labels). |
|
|
36
|
+
| `RANGE_KEYS` | `(keyof PresetData)[]` | Numeric param keys that use range controls. |
|
|
37
|
+
| `SELECT_KEYS` | `(keyof PresetData)[]` | String/select param keys (`osc_type`, `scale_name`, `scan_mode`, `timing_mode`). |
|
|
38
|
+
| `RenderOptions` | `type` | Options for `toAudioBuffer` / `toBlob`. |
|
|
39
|
+
| `ImageSource` | `type` | `string`, `File`, `Blob`, or `HTMLImageElement`. |
|
|
40
|
+
| `LiveOptions` | `type` | Optional canvases + tween callback for the constructor. |
|
|
41
|
+
| `PresetData` | `type` | Full parameter set that drives synthesis and traversal. |
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
## Picture → sound mapping
|
|
46
|
+
|
|
47
|
+
Each image is downsampled, split into blocks (`block_w` × `block_h`), and traversed by a scan strategy. Per-block HSL drives the musical event:
|
|
48
|
+
|
|
49
|
+
| Source | Maps to |
|
|
50
|
+
| ---------------- | ----------------------------------------------------------------------- |
|
|
51
|
+
| Hue | Scale degree (pitch), stereo pan, micro-detune |
|
|
52
|
+
| Lightness | Octave, primary velocity weight, filter tracking; timing / note duration when expressive |
|
|
53
|
+
| Saturation | Secondary velocity weight |
|
|
54
|
+
| Spatial position | Traversal path (`scan_mode`) |
|
|
55
|
+
|
|
56
|
+
Bright areas slightly accelerate the system; darker areas slow it down. Timing is intentionally restrained so the result stays coherent rather than mechanical. Filter cutoff follows `filter_base + brightness × filter_track` (when `filter_track ≠ 0`).
|
|
57
|
+
|
|
58
|
+
Cross-origin image URLs need CORS (`crossOrigin = "anonymous"` is set for string sources). Blobs/`File` use object URLs and do not set CORS.
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## `Audiora`
|
|
63
|
+
|
|
64
|
+
```js
|
|
65
|
+
import { Audiora, PRESETS } from "audiora";
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### Constructor
|
|
69
|
+
|
|
70
|
+
```js
|
|
71
|
+
new Audiora(options?)
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
- **options** — Partial `LiveOptions`. If both canvases are provided, visuals attach immediately.
|
|
75
|
+
|
|
76
|
+
```ts
|
|
77
|
+
interface LiveOptions {
|
|
78
|
+
waveCanvas?: HTMLCanvasElement; // waveform / analyzer view
|
|
79
|
+
mapCanvas?: HTMLCanvasElement; // image + scan cursor
|
|
80
|
+
onTweenTick?: (key: string, value: number) => void; // fired while params tween
|
|
81
|
+
}
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### Instance properties
|
|
85
|
+
|
|
86
|
+
| Property | Type | Description |
|
|
87
|
+
| --------- | ------------------ | -------------------------------- |
|
|
88
|
+
| `playing` | `boolean` (getter) | Whether live playback is active. |
|
|
89
|
+
|
|
90
|
+
### Instance methods
|
|
91
|
+
|
|
92
|
+
| Method | Returns | Description |
|
|
93
|
+
| -------------------------------------- | ---------------------- | --------------------------------------------------------------------- |
|
|
94
|
+
| `attachVisuals(waveCanvas, mapCanvas)` | `void` | Starts (or restarts) the render loop on the given canvases. |
|
|
95
|
+
| `resizeVisuals()` | `void` | Recomputes canvas sizes after layout/window resize. |
|
|
96
|
+
| `loadImage(image)` | `Promise<void>` | Loads an `ImageSource`, processes pixels, rebuilds the block grid. |
|
|
97
|
+
| `play()` | `Promise<void>` | Ensures AudioContext, resumes it, starts the live scheduler. No notes until an image grid exists. |
|
|
98
|
+
| `stop()` | `void` | Stops the scheduler, resets sequencer timing, suspends the context. |
|
|
99
|
+
| `warmUp()` | `Promise<void>` | Primes the audio graph (helpful before first gesture-driven `play`). |
|
|
100
|
+
| `getParam(key)` | `string \| number` | Reads one `PresetData` field from live state. |
|
|
101
|
+
| `setParam(key, value)` | `void` | Sets one param and applies side effects (volume, reverb, grid, etc.). |
|
|
102
|
+
| `applyParams(patch, options?)` | `void` | Merges a partial preset. Default tweens numeric UI keys (~1.5s). |
|
|
103
|
+
| `captureParams()` | `Partial<PresetData>` | Snapshot of current live params (for export / cloning). |
|
|
104
|
+
| `toAudioBuffer(options?)` | `Promise<AudioBuffer>` | Offline render via `OfflineAudioContext`. |
|
|
105
|
+
| `toBlob(options?)` | `Promise<Blob>` | Same as `toAudioBuffer`, encoded as WAV `Blob`. |
|
|
106
|
+
|
|
107
|
+
#### `applyParams(patch, options?)`
|
|
108
|
+
|
|
109
|
+
```ts
|
|
110
|
+
applyParams(patch: Partial<PresetData>, options?: { tween?: boolean })
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
- `tween: true` (default) — applies structural fields immediately, then smoothly interpolates `TWEEN_KEYS` (volume, filter, reverb, etc.).
|
|
114
|
+
- `tween: false` — cancels any running tween and applies the full patch immediately, syncing live audio nodes.
|
|
115
|
+
|
|
116
|
+
Changing `scan_mode` resets the read-head position and resyncs the scheduler.
|
|
117
|
+
|
|
118
|
+
#### `toAudioBuffer` / `toBlob`
|
|
119
|
+
|
|
120
|
+
```ts
|
|
121
|
+
interface RenderOptions {
|
|
122
|
+
image?: ImageSource; // required if loadImage was never called
|
|
123
|
+
params?: Partial<PresetData>; // defaults to current live capture
|
|
124
|
+
duration?: number; // seconds, default 10
|
|
125
|
+
sampleRate?: number; // default 44100
|
|
126
|
+
}
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
Throws if no image is available (`options.image` and prior `loadImage` both missing).
|
|
130
|
+
|
|
131
|
+
Stereo output: 2 channels.
|
|
132
|
+
|
|
133
|
+
### Example — live session
|
|
134
|
+
|
|
135
|
+
```js
|
|
136
|
+
const wave = document.getElementById("wave_canvas");
|
|
137
|
+
const map = document.getElementById("map_canvas");
|
|
138
|
+
|
|
139
|
+
const audiora = new Audiora({
|
|
140
|
+
waveCanvas: wave,
|
|
141
|
+
mapCanvas: map,
|
|
142
|
+
onTweenTick: (key, value) => {
|
|
143
|
+
// keep UI sliders in sync during preset morphs
|
|
144
|
+
},
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
await audiora.loadImage("/photo.jpg");
|
|
148
|
+
audiora.applyParams(PRESETS.Haze, { tween: false });
|
|
149
|
+
|
|
150
|
+
await audiora.warmUp(); // optional; after a user gesture
|
|
151
|
+
await audiora.play();
|
|
152
|
+
|
|
153
|
+
// later
|
|
154
|
+
audiora.setParam("bpm", 110);
|
|
155
|
+
audiora.stop();
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
### Example — offline WAV
|
|
159
|
+
|
|
160
|
+
```js
|
|
161
|
+
const blob = await audiora.toBlob({
|
|
162
|
+
image: fileFromInput,
|
|
163
|
+
params: PRESETS.Bite,
|
|
164
|
+
duration: 15,
|
|
165
|
+
sampleRate: 44100,
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
const url = URL.createObjectURL(blob);
|
|
169
|
+
// trigger download or upload
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
---
|
|
173
|
+
|
|
174
|
+
## `PresetData`
|
|
175
|
+
|
|
176
|
+
All live and offline synthesis is driven by this shape:
|
|
177
|
+
|
|
178
|
+
| Key | Type | Role |
|
|
179
|
+
| ------------------ | -------- | -------------------------------------------------------------- |
|
|
180
|
+
| `osc_type` | `string` | Waveform identity. |
|
|
181
|
+
| `scale_name` | `string` | Named scale for pitch quantization. |
|
|
182
|
+
| `base_note` | `number` | Root frequency (Hz). |
|
|
183
|
+
| `bpm` | `number` | Base tempo. |
|
|
184
|
+
| `speed` | `number` | Traversal / scheduling multiplier. |
|
|
185
|
+
| `note_mult` | `number` | Note duration multiplier. |
|
|
186
|
+
| `volume` | `number` | Master level (0–1; gain uses `volume²`). |
|
|
187
|
+
| `vibrato_rate` | `number` | Vibrato LFO rate (Hz). |
|
|
188
|
+
| `vibrato_depth` | `number` | Vibrato depth (cents). |
|
|
189
|
+
| `tremolo_rate` | `number` | Tremolo LFO rate (Hz). |
|
|
190
|
+
| `tremolo_depth` | `number` | Tremolo depth (0–1). |
|
|
191
|
+
| `fifth_lvl` | `number` | Level of fifth partial voice (0–1). |
|
|
192
|
+
| `oct_lvl` | `number` | Level of octave partial voice (0–1). |
|
|
193
|
+
| `filter_base` | `number` | Filter base cutoff (Hz). |
|
|
194
|
+
| `filter_track` | `number` | How strongly block brightness shifts cutoff (Hz; `0` = fixed). |
|
|
195
|
+
| `resonance` | `number` | Filter Q. |
|
|
196
|
+
| `reverb_mix` | `number` | Wet level (0–1). At `≥ 0.99`, dry path is muted (less stereo). |
|
|
197
|
+
| `reverb_time` | `number` | Convolution / decay time (s). |
|
|
198
|
+
| `bass_gain` | `number` | Bass shelf (dB). |
|
|
199
|
+
| `block_w` | `number` | Analysis block width (px). |
|
|
200
|
+
| `block_h` | `number` | Analysis block height (px). |
|
|
201
|
+
| `scan_mode` | `string` | Traversal strategy. |
|
|
202
|
+
| `pan_amount` | `number` | Stereo imaging strength (0–1). |
|
|
203
|
+
| `timing_mode` | `string` | `"expressive"` or `"stable"`. |
|
|
204
|
+
| `timing_intensity` | `number` | How strongly lightness bends timing when expressive (0–1). |
|
|
205
|
+
|
|
206
|
+
`FORMAT` / `RANGE_KEYS` cover the numeric rows above; `SELECT_KEYS` are the four string fields.
|
|
207
|
+
|
|
208
|
+
### `osc_type` values
|
|
209
|
+
|
|
210
|
+
| Value | Behavior |
|
|
211
|
+
| ------------------------------------------- | -------------------------------------------------------------------- |
|
|
212
|
+
| `sine` / `square` / `sawtooth` / `triangle` | Native Web Audio oscillator types. |
|
|
213
|
+
| `pulse` | Custom periodic wave (odd harmonics). |
|
|
214
|
+
| `organ` | Custom harmonic stack. |
|
|
215
|
+
| `bell` | Custom inharmonic-leaning stack; fifth/octave levels are attenuated. |
|
|
216
|
+
|
|
217
|
+
Unknown types fall back to `triangle`.
|
|
218
|
+
|
|
219
|
+
### `scale_name` values
|
|
220
|
+
|
|
221
|
+
Built-in scales (from `SCALES` in core constants):
|
|
222
|
+
|
|
223
|
+
`Major`, `Minor`, `Pentatonic`, `Blues`, `Chromatic`, `Whole Tone`, `Dorian`, `Phrygian`, `Lydian`, `Harmonic Minor`, `In Sen`.
|
|
224
|
+
|
|
225
|
+
### `scan_mode` values
|
|
226
|
+
|
|
227
|
+
| Value | Path |
|
|
228
|
+
| ---------- | ---------------------------------------------------- |
|
|
229
|
+
| `linear` | Left-to-right rows. |
|
|
230
|
+
| `vertical` | Top-to-bottom columns. |
|
|
231
|
+
| `zigzag` | Alternating row direction. |
|
|
232
|
+
| `drift` | Soft irregular walk. |
|
|
233
|
+
| `spiral` | Outward from near center along a precomputed spiral. |
|
|
234
|
+
|
|
235
|
+
Unknown modes fall back to `linear`.
|
|
236
|
+
|
|
237
|
+
### `timing_mode` values
|
|
238
|
+
|
|
239
|
+
| Value | Behavior |
|
|
240
|
+
| ------------ | ----------------------------------------------------------------------- |
|
|
241
|
+
| `expressive` | Lightness modulates interval / duration (scaled by `timing_intensity`). |
|
|
242
|
+
| `stable` | Fixed rhythmic grid; ignores lightness timing bend. |
|
|
243
|
+
|
|
244
|
+
---
|
|
245
|
+
|
|
246
|
+
## `PRESETS`
|
|
247
|
+
|
|
248
|
+
| Name | Character (summary) |
|
|
249
|
+
| ------- | ---------------------------------------------------------------------- |
|
|
250
|
+
| `Haze` | Soft triangle / pentatonic, expressive timing, higher reverb. Default. |
|
|
251
|
+
| `Leap` | Fast square / major, stable timing. |
|
|
252
|
+
| `Pulse` | Square with strong tremolo, stable. |
|
|
253
|
+
| `Bite` | Dark sawtooth / chromatic, high resonance & bass. |
|
|
254
|
+
| `Spark` | High square / chromatic, short notes, fast tempo. |
|
|
255
|
+
| `Raw` | Dry square, large blocks, no effects stack. |
|
|
256
|
+
|
|
257
|
+
Apply with:
|
|
258
|
+
|
|
259
|
+
```js
|
|
260
|
+
audiora.applyParams(PRESETS.Haze);
|
|
261
|
+
// or hard-cut without morph:
|
|
262
|
+
audiora.applyParams(PRESETS.Raw, { tween: false });
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
---
|
|
266
|
+
|
|
267
|
+
## Helpers for UI hosts
|
|
268
|
+
|
|
269
|
+
The demo app (`audiora/www`) uses these exports to bind controls without redefining param lists:
|
|
270
|
+
|
|
271
|
+
```js
|
|
272
|
+
import {
|
|
273
|
+
FORMAT,
|
|
274
|
+
RANGE_KEYS,
|
|
275
|
+
SELECT_KEYS,
|
|
276
|
+
DEFAULT_PRESET,
|
|
277
|
+
PRESETS,
|
|
278
|
+
} from "audiora";
|
|
279
|
+
|
|
280
|
+
for (const key of RANGE_KEYS) {
|
|
281
|
+
// range input id === key; label via FORMAT[key](value)
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
for (const key of SELECT_KEYS) {
|
|
285
|
+
// select id === key
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
audiora.applyParams(PRESETS[DEFAULT_PRESET], { tween: false });
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
| Helper | Use |
|
|
292
|
+
| -------------------- | ----------------------------------------------------- |
|
|
293
|
+
| `RANGE_KEYS` | Iterate numeric sliders. |
|
|
294
|
+
| `SELECT_KEYS` | Iterate `<select>` bindings. |
|
|
295
|
+
| `FORMAT[key](value)` | Human-readable label (`"92"`, `"×1.70"`, `"45%"`, …). |
|
|
296
|
+
| `DEFAULT_PRESET` | Initial highlight / first apply (`"Haze"`). |
|
|
297
|
+
|
|
298
|
+
---
|
|
299
|
+
|
|
300
|
+
## Browser / runtime requirements
|
|
301
|
+
|
|
302
|
+
- **Live playback**: Web Audio API (`AudioContext`), user gesture before `resume` in most browsers.
|
|
303
|
+
- **Offline render**: `OfflineAudioContext`.
|
|
304
|
+
- **Visuals** (optional): 2D canvas contexts for wave + map.
|
|
305
|
+
- **Images**: max analysis path is capped internally (pixel buffer ≤ 512px on the long side; display canvas ≤ 2048px).
|
|
306
|
+
|
|
307
|
+
### Known timing notes
|
|
308
|
+
|
|
309
|
+
- First `play()` may show the scan cursor slightly ahead of audio while the context starts; subsequent plays are stable.
|
|
310
|
+
- The visual cursor leads audio by a small lookahead window by design (avoids audible glitches).
|
|
311
|
+
- Live `play()` without a loaded image keeps the scheduler running but schedules no notes until `loadImage` builds a grid.
|
|
312
|
+
- `reverb_mix ≥ 0.99` mutes the dry path; reduce mix to restore pan spread.
|
|
313
|
+
|
|
314
|
+
---
|
|
315
|
+
|
|
316
|
+
## Import patterns
|
|
317
|
+
|
|
318
|
+
### Library-only (embed in your app)
|
|
319
|
+
|
|
320
|
+
```js
|
|
321
|
+
import { Audiora, PRESETS } from "audiora";
|
|
322
|
+
|
|
323
|
+
const audiora = new Audiora();
|
|
324
|
+
await audiora.loadImage(userFile);
|
|
325
|
+
const wav = await audiora.toBlob({ params: PRESETS.Pulse, duration: 12 });
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
### Live instrument shell
|
|
329
|
+
|
|
330
|
+
```js
|
|
331
|
+
import { Audiora, PRESETS, RANGE_KEYS, SELECT_KEYS } from "audiora";
|
|
332
|
+
|
|
333
|
+
const audiora = new Audiora({
|
|
334
|
+
waveCanvas: document.getElementById("wave_canvas"),
|
|
335
|
+
mapCanvas: document.getElementById("map_canvas"),
|
|
336
|
+
});
|
|
337
|
+
|
|
338
|
+
window.addEventListener("resize", () => audiora.resizeVisuals());
|
|
339
|
+
await audiora.loadImage("/assets/map.jpg");
|
|
340
|
+
audiora.applyParams(PRESETS.Haze, { tween: false });
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
Wire `RANGE_KEYS` / `SELECT_KEYS` to DOM controls calling `setParam` / `applyParams` as in `audiora/www`.
|
package/package.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "audiora",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Picture-driven synthesis for the web — maps color and light into pitch, timing, and texture.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"audio",
|
|
7
|
+
"web-audio",
|
|
8
|
+
"synthesis",
|
|
9
|
+
"picture-driven",
|
|
10
|
+
"canvas",
|
|
11
|
+
"typescript",
|
|
12
|
+
"music",
|
|
13
|
+
"instrument"
|
|
14
|
+
],
|
|
15
|
+
"license": "MIT",
|
|
16
|
+
"author": "whosramoss",
|
|
17
|
+
"type": "module",
|
|
18
|
+
"main": "src/index.ts",
|
|
19
|
+
"types": "src/index.ts",
|
|
20
|
+
"exports": {
|
|
21
|
+
".": "./src/index.ts"
|
|
22
|
+
},
|
|
23
|
+
"files": [
|
|
24
|
+
"src",
|
|
25
|
+
"docs",
|
|
26
|
+
"CHANGELOG.md"
|
|
27
|
+
],
|
|
28
|
+
"repository": {
|
|
29
|
+
"type": "git",
|
|
30
|
+
"url": "git+https://github.com/whosramoss/audiora.git"
|
|
31
|
+
},
|
|
32
|
+
"homepage": "https://github.com/whosramoss/audiora#readme",
|
|
33
|
+
"bugs": {
|
|
34
|
+
"url": "https://github.com/whosramoss/audiora/issues"
|
|
35
|
+
},
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"typescript": "^5.5.0"
|
|
38
|
+
}
|
|
39
|
+
}
|