@waveform-playlist/spectrogram 15.0.0-next.0 → 15.0.0-next.10
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/README.md +2 -2
- package/dist/index.d.mts +13 -3
- package/dist/index.d.ts +13 -3
- package/dist/index.js +213 -329
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +195 -307
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -6
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@ Wraps [`@dawcore/spectrogram`](https://www.npmjs.com/package/@dawcore/spectrogra
|
|
|
10
10
|
- **Render-mode switching** per track — `'waveform'`, `'spectrogram'`, or `'both'` (waveform on top, spectrogram below)
|
|
11
11
|
- **Six built-in color maps** (`viridis`, `magma`, `inferno`, `grayscale`, `igray`, `roseus`) plus custom `[r, g, b]` palettes
|
|
12
12
|
- **Five frequency scales** — linear, logarithmic, mel, bark, erb
|
|
13
|
-
- **Drop-in settings UI** — `<SpectrogramSettingsModal>` (FFT size, hop size, window function, gain/range, frequency bounds) and `
|
|
13
|
+
- **Drop-in settings UI** — `<SpectrogramSettingsModal>` (FFT size, hop size, window function, gain/range, frequency bounds) and `spectrogramMenuItems()`, a function that returns the render-mode and settings items for a `TrackMenu` (`@waveform-playlist/ui-components`). Under the provider, the default track controls of `@waveform-playlist/browser` show that menu already (`<TrackMenuButton />` in a panel you compose; `useTrack().setRenderMode()` and `.openSpectrogramSettings()` in your own)
|
|
14
14
|
- **Viewport-aware rendering** — a Web Worker pool computes the visible chunks first, then a scroll buffer, then the rest in the background, so long timelines stay responsive
|
|
15
15
|
|
|
16
16
|
## Installation
|
|
@@ -45,7 +45,7 @@ function MyEditor() {
|
|
|
45
45
|
}
|
|
46
46
|
```
|
|
47
47
|
|
|
48
|
-
`<SpectrogramProvider>` exposes one config + one color map at a time; per-track
|
|
48
|
+
`<SpectrogramProvider>` exposes one config + one color map at a time; per-track settings come from that track's own `renderMode`, `spectrogramConfig` and `spectrogramColorMap` fields. At runtime the track menu changes the render mode and the settings dialog it opens changes the config and colour map, in the arrangement (each change an undo step). `<SpectrogramSettingsModal>` used on its own changes nothing: it hands the result to its `onApply`.
|
|
49
49
|
|
|
50
50
|
## Examples & Documentation
|
|
51
51
|
|
package/dist/index.d.mts
CHANGED
|
@@ -5,7 +5,7 @@ import React, { ReactNode } from 'react';
|
|
|
5
5
|
/** The items browser's track menu asks the spectrogram integration for:
|
|
6
6
|
* ui-components' `TrackMenuItem[]`, named through the type that carries it. */
|
|
7
7
|
type MenuItems = ReturnType<NonNullable<SpectrogramIntegration['renderMenuItems']>>;
|
|
8
|
-
interface
|
|
8
|
+
interface SpectrogramMenuItemsOptions {
|
|
9
9
|
renderMode: RenderMode;
|
|
10
10
|
onRenderModeChange: (mode: RenderMode) => void;
|
|
11
11
|
onOpenSettings: () => void;
|
|
@@ -15,14 +15,24 @@ interface SpectrogramMenuItemsProps {
|
|
|
15
15
|
* Returns the track menu items (`TrackMenuItem[]` of ui-components) for the
|
|
16
16
|
* spectrogram display mode radios and settings button.
|
|
17
17
|
*/
|
|
18
|
-
declare function
|
|
18
|
+
declare function spectrogramMenuItems({ renderMode, onRenderModeChange, onOpenSettings, onClose, }: SpectrogramMenuItemsOptions): MenuItems;
|
|
19
19
|
|
|
20
20
|
interface SpectrogramSettingsModalProps {
|
|
21
21
|
open: boolean;
|
|
22
22
|
onClose: () => void;
|
|
23
23
|
config: SpectrogramConfig;
|
|
24
24
|
colorMap: ColorMapValue;
|
|
25
|
+
/**
|
|
26
|
+
* Called on Apply with the config it was given plus the fields the user
|
|
27
|
+
* changed, and the colour map (the one given unless the user picked one).
|
|
28
|
+
* Not called when nothing was changed: Apply then only closes.
|
|
29
|
+
*/
|
|
25
30
|
onApply: (config: SpectrogramConfig, colorMap: ColorMapValue) => void;
|
|
31
|
+
/**
|
|
32
|
+
* The sample rate of the audio. With a config that has no `maxFrequency`,
|
|
33
|
+
* the field shows half of it, the top the spectrogram is drawn to.
|
|
34
|
+
*/
|
|
35
|
+
sampleRate?: number;
|
|
26
36
|
}
|
|
27
37
|
declare const SpectrogramSettingsModal: React.FC<SpectrogramSettingsModalProps>;
|
|
28
38
|
|
|
@@ -35,4 +45,4 @@ interface SpectrogramProviderProps {
|
|
|
35
45
|
}
|
|
36
46
|
declare const SpectrogramProvider: React.FC<SpectrogramProviderProps>;
|
|
37
47
|
|
|
38
|
-
export {
|
|
48
|
+
export { type SpectrogramMenuItemsOptions, SpectrogramProvider, type SpectrogramProviderProps, SpectrogramSettingsModal, type SpectrogramSettingsModalProps, spectrogramMenuItems };
|
package/dist/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import React, { ReactNode } from 'react';
|
|
|
5
5
|
/** The items browser's track menu asks the spectrogram integration for:
|
|
6
6
|
* ui-components' `TrackMenuItem[]`, named through the type that carries it. */
|
|
7
7
|
type MenuItems = ReturnType<NonNullable<SpectrogramIntegration['renderMenuItems']>>;
|
|
8
|
-
interface
|
|
8
|
+
interface SpectrogramMenuItemsOptions {
|
|
9
9
|
renderMode: RenderMode;
|
|
10
10
|
onRenderModeChange: (mode: RenderMode) => void;
|
|
11
11
|
onOpenSettings: () => void;
|
|
@@ -15,14 +15,24 @@ interface SpectrogramMenuItemsProps {
|
|
|
15
15
|
* Returns the track menu items (`TrackMenuItem[]` of ui-components) for the
|
|
16
16
|
* spectrogram display mode radios and settings button.
|
|
17
17
|
*/
|
|
18
|
-
declare function
|
|
18
|
+
declare function spectrogramMenuItems({ renderMode, onRenderModeChange, onOpenSettings, onClose, }: SpectrogramMenuItemsOptions): MenuItems;
|
|
19
19
|
|
|
20
20
|
interface SpectrogramSettingsModalProps {
|
|
21
21
|
open: boolean;
|
|
22
22
|
onClose: () => void;
|
|
23
23
|
config: SpectrogramConfig;
|
|
24
24
|
colorMap: ColorMapValue;
|
|
25
|
+
/**
|
|
26
|
+
* Called on Apply with the config it was given plus the fields the user
|
|
27
|
+
* changed, and the colour map (the one given unless the user picked one).
|
|
28
|
+
* Not called when nothing was changed: Apply then only closes.
|
|
29
|
+
*/
|
|
25
30
|
onApply: (config: SpectrogramConfig, colorMap: ColorMapValue) => void;
|
|
31
|
+
/**
|
|
32
|
+
* The sample rate of the audio. With a config that has no `maxFrequency`,
|
|
33
|
+
* the field shows half of it, the top the spectrogram is drawn to.
|
|
34
|
+
*/
|
|
35
|
+
sampleRate?: number;
|
|
26
36
|
}
|
|
27
37
|
declare const SpectrogramSettingsModal: React.FC<SpectrogramSettingsModalProps>;
|
|
28
38
|
|
|
@@ -35,4 +45,4 @@ interface SpectrogramProviderProps {
|
|
|
35
45
|
}
|
|
36
46
|
declare const SpectrogramProvider: React.FC<SpectrogramProviderProps>;
|
|
37
47
|
|
|
38
|
-
export {
|
|
48
|
+
export { type SpectrogramMenuItemsOptions, SpectrogramProvider, type SpectrogramProviderProps, SpectrogramSettingsModal, type SpectrogramSettingsModalProps, spectrogramMenuItems };
|