@toneflix/studio 0.4.0 → 0.6.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/README.md +14 -6
- package/dist/import.d.ts +19 -0
- package/dist/import.js +32 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/recording.d.ts +13 -1
- package/dist/recording.js +70 -1
- package/package.json +10 -8
package/README.md
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
# Toneflix Studio
|
|
2
2
|
|
|
3
|
-

|
|
4
4
|
|
|
5
5
|
**The studio engine for the web.** Give any web app a real multitrack editor. Your users arrange, cut and shape audio as freely as in a desktop DAW, right in the browser.
|
|
6
6
|
|
|
7
7
|
- **Edit without limits.** Split anything, drag clips anywhere, layer them and move them between tracks. Nothing snaps back unless you ask it to.
|
|
8
8
|
- **Hear every edit.** Playback follows the timeline as you work, with a mixer, effects, loops, a metronome and mixdown to WAV.
|
|
9
|
+
- **Play instruments.** Instrument tracks play note clips through a built-in synth, drum kit or sampler, or any Web Audio Module instrument. Draw and edit their notes in a piano roll, or program beats in a step sequencer with swing, with a mouse or on a phone. Load your own samples onto drum pads and sampler keys. Play and record notes on on-screen keys, the computer keyboard or a MIDI device.
|
|
9
10
|
- **Record over the mix.** Arm a track and record a voice or instrument while the music plays. Takes land where they were performed, with the waveform drawn as you go.
|
|
10
11
|
- **Plugins, live.** Put Web Audio Module plugins on any track or the master and hear them as you play, with their own editors. They are saved with the project and printed into the mix.
|
|
11
12
|
- **Fast with big sessions.** Waveforms are drawn in the background and cached on the device, so long recordings open instantly the next time.
|
|
@@ -54,12 +55,17 @@ timeline.on('change', ({ state, final }) => final && save(state));
|
|
|
54
55
|
| Drag a clip edge | Trims it, up to the ends of its audio |
|
|
55
56
|
| Drag a corner handle | Fade in or out |
|
|
56
57
|
| Click, Shift or Ctrl/Cmd click | Select, add to or toggle the selection |
|
|
57
|
-
| Drag on an empty lane
|
|
58
|
+
| Drag on an empty lane | Selects the clips the box touches (Shift adds to the selection) |
|
|
59
|
+
| Drag on the ruler | Selects a time range across all tracks |
|
|
58
60
|
| Alt while dragging | Turns snapping off |
|
|
59
61
|
| Ctrl/Cmd + wheel | Zoom around the pointer |
|
|
60
62
|
| S, Delete, Ctrl+D, Ctrl+A | Split at the playhead, delete, duplicate, select all |
|
|
61
63
|
| Arrows | Nudge by the snap step, or move up and down a lane |
|
|
62
|
-
| + above the headers, click a track name | Add a track; rename, duplicate, move or delete one from its menu |
|
|
64
|
+
| + above the headers, click a track name | Add an empty audio track, audio from a file, or an instrument, drum or sampler track; rename, duplicate, move or delete one from its menu |
|
|
65
|
+
| Double-click an empty spot on an instrument track | Adds a one-bar note clip |
|
|
66
|
+
| Double-click a note clip | Opens it in the piano roll: click to draw notes, drag to move or resize them. Drum clips open as a step sequencer with swing |
|
|
67
|
+
| Markers and tempo in the ruler | Right-click the ruler to add a marker or tempo change, or double-click above the bar numbers for a marker; drag to move, click a marker to jump there, click a tempo to set it or the meter |
|
|
68
|
+
| Track menu, Show volume/pan automation | Opens a lane under the track: click to add points, drag to move, double-click to remove |
|
|
63
69
|
| Ctrl+Z, Ctrl+Shift+Z | Undo and redo |
|
|
64
70
|
|
|
65
71
|
Where clips overlap on a lane, the one that starts later is on top and is the one heard. `audibleRanges(clips)` gives the heard part of each clip, for players and mix renderers.
|
|
@@ -73,10 +79,12 @@ Install `@toneflix/studio` for everything, or only the parts your app uses. Ever
|
|
|
73
79
|
| [`@toneflix/studio`](packages/studio) | Everything below, from one import |
|
|
74
80
|
| [`@toneflix/studio-core`](packages/core) | Tracks, clips, pure edits (`splitClips`, `moveClips`, `trimStart`, `setFades`…), snapping, `TimelineModel` and `History`. No DOM or audio, so it also runs on servers and in tests |
|
|
75
81
|
| [`@toneflix/studio-waveforms`](packages/waveforms) | `Waveforms`, `PeaksWorker`, `PeaksCache` and `drawWaveform`: peaks off the main thread, cached on the device |
|
|
76
|
-
| [`@toneflix/studio-audio`](packages/audio) | `AudioEngine`: playback with a mixer, effects, loops, a metronome and offline mixdown |
|
|
77
|
-
| [`@toneflix/studio-recorder`](packages/recorder) | `Recorder`: records a microphone or line input onto a track, lined up with what was playing |
|
|
82
|
+
| [`@toneflix/studio-audio`](packages/audio) | `AudioEngine`: playback with a mixer, effects, volume and pan automation, loops, a metronome and offline mixdown |
|
|
83
|
+
| [`@toneflix/studio-recorder`](packages/recorder) | `Recorder`: records a microphone or line input onto a track, lined up with what was playing; `NoteRecorder` records notes played live |
|
|
78
84
|
| [`@toneflix/studio-plugins`](packages/plugins) | `PluginRack`: Web Audio Module (WAM 2) plugins on tracks and the master, live, with their editors, saved with the project and in the mixdown |
|
|
79
|
-
| [`@toneflix/studio-
|
|
85
|
+
| [`@toneflix/studio-wams`](packages/wams) | `curatedWams` and `curatedWamSource`: reviewed Web Audio Module effects, served pinned from jsDelivr |
|
|
86
|
+
| [`@toneflix/studio-exchange`](packages/exchange) | `saveProject` and `openProject`: sessions in the app's own format with plugins, or to and from REAPER, with tracks, clips, fades, automation, markers, tempo and the audio |
|
|
87
|
+
| [`@toneflix/studio-controls`](packages/controls) | `StudioToolbar`, `trackStrip`, `StudioMixer`, `StudioBrowser`, `StudioPianoRoll` and `StudioKeys`: playback, recording and editing buttons, track arm, mute, solo and volume, a mixer with plugin slots, a browser of sounds and plugins from any source, a piano roll and step sequencer, and keys with MIDI input, with Lucide icons you can replace |
|
|
80
88
|
| [`@toneflix/studio-timeline`](packages/timeline) | `StudioTimeline`, the editor view. Restyle it with the `--tfs-*` CSS variables or fill track headers with `renderHeader` |
|
|
81
89
|
|
|
82
90
|
## Develop
|
package/dist/import.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { AudioEngine } from '@toneflix/studio-audio';
|
|
2
|
+
import { type Clip } from '@toneflix/studio-core';
|
|
3
|
+
import type { StudioTimeline } from '@toneflix/studio-timeline';
|
|
4
|
+
export interface ImportAudioOptions {
|
|
5
|
+
/** Gets each file's audio once decoded, for example to draw its waveform */
|
|
6
|
+
onSource?: (id: string, buffer: AudioBuffer) => void;
|
|
7
|
+
/** Where the clips start; the playhead unless given */
|
|
8
|
+
time?: number;
|
|
9
|
+
}
|
|
10
|
+
export interface ImportedAudio {
|
|
11
|
+
clips: Clip[];
|
|
12
|
+
/** Files that could not be decoded as audio */
|
|
13
|
+
failed: File[];
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Put audio files from the device on new tracks, one track per file named after it,
|
|
17
|
+
* as one undo step. Nothing is uploaded. Made for the timeline's `importAudio` option.
|
|
18
|
+
*/
|
|
19
|
+
export declare const importAudioFiles: (timeline: StudioTimeline, engine: AudioEngine, files: Iterable<File>, options?: ImportAudioOptions) => Promise<ImportedAudio>;
|
package/dist/import.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { addClips, addTrack, makeClip, uid } from '@toneflix/studio-core';
|
|
2
|
+
/**
|
|
3
|
+
* Put audio files from the device on new tracks, one track per file named after it,
|
|
4
|
+
* as one undo step. Nothing is uploaded. Made for the timeline's `importAudio` option.
|
|
5
|
+
*/
|
|
6
|
+
export const importAudioFiles = async (timeline, engine, files, options = {}) => {
|
|
7
|
+
const start = Math.max(0, options.time ?? timeline.time);
|
|
8
|
+
const added = [];
|
|
9
|
+
const failed = [];
|
|
10
|
+
for (const file of files) {
|
|
11
|
+
let buffer;
|
|
12
|
+
try {
|
|
13
|
+
buffer = await engine.context.decodeAudioData(await file.arrayBuffer());
|
|
14
|
+
}
|
|
15
|
+
catch {
|
|
16
|
+
failed.push(file);
|
|
17
|
+
continue;
|
|
18
|
+
}
|
|
19
|
+
const id = uid('file');
|
|
20
|
+
const name = file.name.replace(/\.[^.]+$/, '') || file.name;
|
|
21
|
+
const track = { id: uid('t'), name };
|
|
22
|
+
engine.setBuffer(id, buffer);
|
|
23
|
+
timeline.setSource({ id, duration: buffer.duration });
|
|
24
|
+
options.onSource?.(id, buffer);
|
|
25
|
+
added.push({ track, clip: makeClip({ id: uid('c'), track: track.id, source: id, name, start, offset: 0, duration: buffer.duration }) });
|
|
26
|
+
}
|
|
27
|
+
if (added.length) {
|
|
28
|
+
timeline.model.apply('Import audio', (state) => addClips(added.reduce((next, { track }) => addTrack(next, track), state), added.map(({ clip }) => clip)));
|
|
29
|
+
timeline.select(added.map(({ clip }) => clip.id));
|
|
30
|
+
}
|
|
31
|
+
return { clips: added.map(({ clip }) => clip), failed };
|
|
32
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -4,6 +4,9 @@ export * from '@toneflix/studio-timeline';
|
|
|
4
4
|
export * from '@toneflix/studio-audio';
|
|
5
5
|
export * from '@toneflix/studio-plugins';
|
|
6
6
|
export * from '@toneflix/studio-recorder';
|
|
7
|
+
export * from '@toneflix/studio-exchange';
|
|
7
8
|
export * from '@toneflix/studio-controls';
|
|
9
|
+
export * from '@toneflix/studio-wams';
|
|
8
10
|
export * from './playback.ts';
|
|
9
11
|
export * from './recording.ts';
|
|
12
|
+
export * from './import.ts';
|
package/dist/index.js
CHANGED
|
@@ -4,6 +4,9 @@ export * from '@toneflix/studio-timeline';
|
|
|
4
4
|
export * from '@toneflix/studio-audio';
|
|
5
5
|
export * from '@toneflix/studio-plugins';
|
|
6
6
|
export * from '@toneflix/studio-recorder';
|
|
7
|
+
export * from '@toneflix/studio-exchange';
|
|
7
8
|
export * from '@toneflix/studio-controls';
|
|
9
|
+
export * from '@toneflix/studio-wams';
|
|
8
10
|
export * from './playback.js';
|
|
9
11
|
export * from './recording.js';
|
|
12
|
+
export * from './import.js';
|
package/dist/recording.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Recorder, Take } from '@toneflix/studio-recorder';
|
|
1
|
+
import type { NoteRecorder, NoteTakeResult, Recorder, Take } from '@toneflix/studio-recorder';
|
|
2
2
|
import type { StudioTimeline } from '@toneflix/studio-timeline';
|
|
3
3
|
import { type Waveforms } from '@toneflix/studio-waveforms';
|
|
4
4
|
export interface LinkRecorderOptions {
|
|
@@ -16,3 +16,15 @@ export interface LinkRecorderOptions {
|
|
|
16
16
|
* Returns a function that unlinks them.
|
|
17
17
|
*/
|
|
18
18
|
export declare const linkRecorder: (timeline: StudioTimeline, recorder: Recorder, options?: LinkRecorderOptions) => () => void;
|
|
19
|
+
export interface LinkNoteRecorderOptions {
|
|
20
|
+
/** Name of the clip a take makes, from its number in this session */
|
|
21
|
+
name?: (take: number) => string;
|
|
22
|
+
/** Called with each finished take */
|
|
23
|
+
onTake?: (take: NoteTakeResult) => void;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Shows note recording on a timeline: the take grows as a note clip in whole bars
|
|
27
|
+
* while recording, and lands as one undo step. Editing is paused while recording.
|
|
28
|
+
* Returns a function that unlinks them.
|
|
29
|
+
*/
|
|
30
|
+
export declare const linkNoteRecorder: (timeline: StudioTimeline, recorder: NoteRecorder, options?: LinkNoteRecorderOptions) => () => void;
|
package/dist/recording.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { addClips, makeClip } from '@toneflix/studio-core';
|
|
1
|
+
import { addClips, makeClip, makeNoteClip, uid } from '@toneflix/studio-core';
|
|
2
2
|
import { computePeakData, makePeaks } from '@toneflix/studio-waveforms';
|
|
3
3
|
/** Samples per peak of the waveform drawn while recording */
|
|
4
4
|
const LIVE_PEAK = 256;
|
|
@@ -78,3 +78,72 @@ export const linkRecorder = (timeline, recorder, options = {}) => {
|
|
|
78
78
|
off();
|
|
79
79
|
};
|
|
80
80
|
};
|
|
81
|
+
/** Whole bars around a stretch of time: from the bar `from` falls in to the end of the bar `to` falls in. */
|
|
82
|
+
const barsAround = (grid, from, to) => {
|
|
83
|
+
const first = grid.barTime(grid.position(from).bar);
|
|
84
|
+
const last = grid.position(Math.max(from, to - 1e-6)).bar;
|
|
85
|
+
return { start: first, end: grid.barTime(last + 1) };
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* Shows note recording on a timeline: the take grows as a note clip in whole bars
|
|
89
|
+
* while recording, and lands as one undo step. Editing is paused while recording.
|
|
90
|
+
* Returns a function that unlinks them.
|
|
91
|
+
*/
|
|
92
|
+
export const linkNoteRecorder = (timeline, recorder, options = {}) => {
|
|
93
|
+
const name = options.name ?? ((n) => `Take ${n}`);
|
|
94
|
+
let count = 0;
|
|
95
|
+
let live = null;
|
|
96
|
+
let frame = 0;
|
|
97
|
+
const draw = (notes, to) => {
|
|
98
|
+
if (!live)
|
|
99
|
+
return;
|
|
100
|
+
const { id, track, from } = live;
|
|
101
|
+
const end = Math.max(to, ...notes.map((n) => n.start + n.duration));
|
|
102
|
+
const bars = barsAround(timeline.grid, from, end);
|
|
103
|
+
const clip = makeNoteClip({
|
|
104
|
+
id,
|
|
105
|
+
track,
|
|
106
|
+
name: name(count),
|
|
107
|
+
start: bars.start,
|
|
108
|
+
duration: bars.end - bars.start,
|
|
109
|
+
notes: notes.map((n) => ({ ...n, start: n.start - bars.start })),
|
|
110
|
+
});
|
|
111
|
+
timeline.model.draft('Record notes', (state) => addClips(state, [clip]));
|
|
112
|
+
};
|
|
113
|
+
const tick = () => {
|
|
114
|
+
frame = requestAnimationFrame(tick);
|
|
115
|
+
if (live)
|
|
116
|
+
draw(recorder.notes(), recorder.engine.time);
|
|
117
|
+
};
|
|
118
|
+
const unlisten = [
|
|
119
|
+
recorder.on('start', ({ track, from }) => {
|
|
120
|
+
count++;
|
|
121
|
+
live = { id: uid('c'), track, from, readonly: timeline.readonly };
|
|
122
|
+
timeline.setOptions({ readonly: true });
|
|
123
|
+
frame = requestAnimationFrame(tick);
|
|
124
|
+
}),
|
|
125
|
+
recorder.on('stop', ({ take }) => {
|
|
126
|
+
cancelAnimationFrame(frame);
|
|
127
|
+
frame = 0;
|
|
128
|
+
const was = live;
|
|
129
|
+
live = null;
|
|
130
|
+
if (!was)
|
|
131
|
+
return;
|
|
132
|
+
timeline.setOptions({ readonly: was.readonly });
|
|
133
|
+
if (!take) {
|
|
134
|
+
timeline.model.cancel();
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
live = was;
|
|
138
|
+
draw(take.notes, take.to);
|
|
139
|
+
live = null;
|
|
140
|
+
timeline.model.commit('Record notes');
|
|
141
|
+
options.onTake?.(take);
|
|
142
|
+
}),
|
|
143
|
+
];
|
|
144
|
+
return () => {
|
|
145
|
+
cancelAnimationFrame(frame);
|
|
146
|
+
for (const off of unlisten)
|
|
147
|
+
off();
|
|
148
|
+
};
|
|
149
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@toneflix/studio",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "The studio engine for the web: multitrack audio editing that feels like a desktop DAW, in any browser app. Includes every Toneflix Studio package.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Toneflix <code@toneflix.com.ng>",
|
|
@@ -38,13 +38,15 @@
|
|
|
38
38
|
"LICENSE"
|
|
39
39
|
],
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@toneflix/studio-audio": "^0.
|
|
42
|
-
"@toneflix/studio-controls": "^0.
|
|
43
|
-
"@toneflix/studio-core": "^0.
|
|
44
|
-
"@toneflix/studio-
|
|
45
|
-
"@toneflix/studio-
|
|
46
|
-
"@toneflix/studio-
|
|
47
|
-
"@toneflix/studio-
|
|
41
|
+
"@toneflix/studio-audio": "^0.6.0",
|
|
42
|
+
"@toneflix/studio-controls": "^0.6.0",
|
|
43
|
+
"@toneflix/studio-core": "^0.6.0",
|
|
44
|
+
"@toneflix/studio-exchange": "^0.6.0",
|
|
45
|
+
"@toneflix/studio-plugins": "^0.6.0",
|
|
46
|
+
"@toneflix/studio-recorder": "^0.6.0",
|
|
47
|
+
"@toneflix/studio-timeline": "^0.6.0",
|
|
48
|
+
"@toneflix/studio-wams": "^0.6.0",
|
|
49
|
+
"@toneflix/studio-waveforms": "^0.6.0"
|
|
48
50
|
},
|
|
49
51
|
"engines": {
|
|
50
52
|
"node": ">=22.18"
|