@waveform-playlist/recording 9.5.2 → 10.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/dist/index.d.mts +41 -91
- package/dist/index.d.ts +41 -91
- package/dist/index.js +188 -366
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +195 -354
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -4
- package/dist/worklet/recording-processor.worklet.js +0 -76
- package/dist/worklet/recording-processor.worklet.js.map +0 -1
- package/dist/worklet/recording-processor.worklet.mjs +0 -74
- package/dist/worklet/recording-processor.worklet.mjs.map +0 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { ClipTrack } from '@waveform-playlist/core';
|
|
2
|
-
import React from 'react';
|
|
3
2
|
|
|
4
3
|
/**
|
|
5
4
|
* Types for the recording package
|
|
@@ -89,7 +88,8 @@ declare function useMicrophoneAccess(): UseMicrophoneAccessReturn;
|
|
|
89
88
|
/**
|
|
90
89
|
* Hook for monitoring microphone input levels
|
|
91
90
|
*
|
|
92
|
-
* Uses
|
|
91
|
+
* Uses an AudioWorklet-based meter processor for sample-accurate
|
|
92
|
+
* peak and RMS metering without requestAnimationFrame overhead.
|
|
93
93
|
*/
|
|
94
94
|
interface UseMicrophoneLevelOptions {
|
|
95
95
|
/**
|
|
@@ -98,45 +98,61 @@ interface UseMicrophoneLevelOptions {
|
|
|
98
98
|
*/
|
|
99
99
|
updateRate?: number;
|
|
100
100
|
/**
|
|
101
|
-
*
|
|
102
|
-
* Default:
|
|
101
|
+
* Number of channels to meter (1 = mono, 2 = stereo)
|
|
102
|
+
* Default: 1
|
|
103
103
|
*/
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* Smoothing time constant (0-1)
|
|
107
|
-
* Higher values = smoother but slower response
|
|
108
|
-
* Default: 0.8
|
|
109
|
-
*/
|
|
110
|
-
smoothingTimeConstant?: number;
|
|
104
|
+
channelCount?: number;
|
|
111
105
|
}
|
|
112
106
|
interface UseMicrophoneLevelReturn {
|
|
113
107
|
/**
|
|
114
|
-
* Current audio level (0-1)
|
|
115
|
-
*
|
|
108
|
+
* Current peak audio level (0-1)
|
|
109
|
+
* For single channel: channel 0 level
|
|
110
|
+
* For multi-channel: max across all channels
|
|
116
111
|
*/
|
|
117
112
|
level: number;
|
|
118
113
|
/**
|
|
119
|
-
*
|
|
114
|
+
* Held peak level since last reset (0-1)
|
|
115
|
+
* For single channel: channel 0 peak
|
|
116
|
+
* For multi-channel: max across all channels
|
|
120
117
|
*/
|
|
121
118
|
peakLevel: number;
|
|
122
119
|
/**
|
|
123
|
-
* Reset the peak level
|
|
120
|
+
* Reset the held peak level
|
|
124
121
|
*/
|
|
125
122
|
resetPeak: () => void;
|
|
123
|
+
/**
|
|
124
|
+
* Per-channel peak levels (0-1). Array length matches channelCount.
|
|
125
|
+
* True peak: max absolute sample value per analysis frame.
|
|
126
|
+
*/
|
|
127
|
+
levels: number[];
|
|
128
|
+
/**
|
|
129
|
+
* Per-channel held peak levels (0-1). Array length matches channelCount.
|
|
130
|
+
*/
|
|
131
|
+
peakLevels: number[];
|
|
132
|
+
/**
|
|
133
|
+
* Per-channel RMS levels (0-1). Array length matches channelCount.
|
|
134
|
+
* RMS: root mean square of samples per analysis frame.
|
|
135
|
+
*/
|
|
136
|
+
rmsLevels: number[];
|
|
137
|
+
/**
|
|
138
|
+
* Error from meter setup (worklet load failure, context issues, etc.)
|
|
139
|
+
* Null when metering is working normally.
|
|
140
|
+
*/
|
|
141
|
+
error: Error | null;
|
|
126
142
|
}
|
|
127
143
|
/**
|
|
128
144
|
* Monitor microphone input levels in real-time
|
|
129
145
|
*
|
|
130
146
|
* @param stream - MediaStream from getUserMedia
|
|
131
147
|
* @param options - Configuration options
|
|
132
|
-
* @returns Object with current level and peak level
|
|
148
|
+
* @returns Object with current peak level, RMS level, and held peak level
|
|
133
149
|
*
|
|
134
150
|
* @example
|
|
135
151
|
* ```typescript
|
|
136
152
|
* const { stream } = useMicrophoneAccess();
|
|
137
|
-
* const {
|
|
153
|
+
* const { levels, rmsLevels, peakLevels } = useMicrophoneLevel(stream, { channelCount: 2 });
|
|
138
154
|
*
|
|
139
|
-
* return <
|
|
155
|
+
* return <SegmentedVUMeter levels={levels} peakLevels={peakLevels} />;
|
|
140
156
|
* ```
|
|
141
157
|
*/
|
|
142
158
|
declare function useMicrophoneLevel(stream: MediaStream | null, options?: UseMicrophoneLevelOptions): UseMicrophoneLevelReturn;
|
|
@@ -174,6 +190,12 @@ interface UseIntegratedRecordingReturn {
|
|
|
174
190
|
duration: number;
|
|
175
191
|
level: number;
|
|
176
192
|
peakLevel: number;
|
|
193
|
+
/** Per-channel peak levels (0-1). Array length matches channelCount. */
|
|
194
|
+
levels: number[];
|
|
195
|
+
/** Per-channel held peak levels (0-1). Array length matches channelCount. */
|
|
196
|
+
peakLevels: number[];
|
|
197
|
+
/** Per-channel RMS levels (0-1). Array length matches channelCount. */
|
|
198
|
+
rmsLevels: number[];
|
|
177
199
|
error: Error | null;
|
|
178
200
|
stream: MediaStream | null;
|
|
179
201
|
devices: MicrophoneDevice[];
|
|
@@ -189,78 +211,6 @@ interface UseIntegratedRecordingReturn {
|
|
|
189
211
|
}
|
|
190
212
|
declare function useIntegratedRecording(tracks: ClipTrack[], setTracks: (tracks: ClipTrack[]) => void, selectedTrackId: string | null, options?: IntegratedRecordingOptions): UseIntegratedRecordingReturn;
|
|
191
213
|
|
|
192
|
-
/**
|
|
193
|
-
* RecordButton - Control button for starting/stopping recording
|
|
194
|
-
*/
|
|
195
|
-
|
|
196
|
-
interface RecordButtonProps {
|
|
197
|
-
isRecording: boolean;
|
|
198
|
-
onClick: () => void;
|
|
199
|
-
disabled?: boolean;
|
|
200
|
-
className?: string;
|
|
201
|
-
}
|
|
202
|
-
declare const RecordButton: React.FC<RecordButtonProps>;
|
|
203
|
-
|
|
204
|
-
/**
|
|
205
|
-
* MicrophoneSelector - Dropdown for selecting microphone input device
|
|
206
|
-
*/
|
|
207
|
-
|
|
208
|
-
interface MicrophoneSelectorProps {
|
|
209
|
-
devices: MicrophoneDevice[];
|
|
210
|
-
selectedDeviceId?: string;
|
|
211
|
-
onDeviceChange: (deviceId: string) => void;
|
|
212
|
-
disabled?: boolean;
|
|
213
|
-
className?: string;
|
|
214
|
-
}
|
|
215
|
-
declare const MicrophoneSelector: React.FC<MicrophoneSelectorProps>;
|
|
216
|
-
|
|
217
|
-
/**
|
|
218
|
-
* RecordingIndicator - Shows recording status, duration, and visual indicator
|
|
219
|
-
*/
|
|
220
|
-
|
|
221
|
-
interface RecordingIndicatorProps {
|
|
222
|
-
isRecording: boolean;
|
|
223
|
-
isPaused?: boolean;
|
|
224
|
-
duration: number;
|
|
225
|
-
formatTime?: (seconds: number) => string;
|
|
226
|
-
className?: string;
|
|
227
|
-
}
|
|
228
|
-
declare const RecordingIndicator: React.FC<RecordingIndicatorProps>;
|
|
229
|
-
|
|
230
|
-
/**
|
|
231
|
-
* VU Meter Component
|
|
232
|
-
*
|
|
233
|
-
* Displays real-time audio input levels with color-coded zones
|
|
234
|
-
* and peak indicator.
|
|
235
|
-
*/
|
|
236
|
-
|
|
237
|
-
interface VUMeterProps {
|
|
238
|
-
/**
|
|
239
|
-
* Current audio level (0-1)
|
|
240
|
-
*/
|
|
241
|
-
level: number;
|
|
242
|
-
/**
|
|
243
|
-
* Peak level (0-1)
|
|
244
|
-
* Optional - if provided, shows peak indicator
|
|
245
|
-
*/
|
|
246
|
-
peakLevel?: number;
|
|
247
|
-
/**
|
|
248
|
-
* Width of the meter in pixels
|
|
249
|
-
* Default: 200
|
|
250
|
-
*/
|
|
251
|
-
width?: number;
|
|
252
|
-
/**
|
|
253
|
-
* Height of the meter in pixels
|
|
254
|
-
* Default: 20
|
|
255
|
-
*/
|
|
256
|
-
height?: number;
|
|
257
|
-
/**
|
|
258
|
-
* Additional CSS class name
|
|
259
|
-
*/
|
|
260
|
-
className?: string;
|
|
261
|
-
}
|
|
262
|
-
declare const VUMeter: React.NamedExoticComponent<VUMeterProps>;
|
|
263
|
-
|
|
264
214
|
/**
|
|
265
215
|
* Peak generation for real-time waveform visualization during recording
|
|
266
216
|
* Matches the format used by webaudio-peaks: min/max pairs with bit depth
|
|
@@ -288,4 +238,4 @@ declare function concatenateAudioData(chunks: Float32Array[]): Float32Array;
|
|
|
288
238
|
*/
|
|
289
239
|
declare function createAudioBuffer(audioContext: AudioContext, channelData: Float32Array[] | Float32Array, sampleRate: number, channelCount?: number): AudioBuffer;
|
|
290
240
|
|
|
291
|
-
export { type IntegratedRecordingOptions, type MicrophoneDevice,
|
|
241
|
+
export { type IntegratedRecordingOptions, type MicrophoneDevice, type RecordingData, type RecordingOptions, type RecordingState, type UseIntegratedRecordingReturn, type UseMicrophoneAccessReturn, type UseMicrophoneLevelOptions, type UseMicrophoneLevelReturn, type UseRecordingReturn, concatenateAudioData, createAudioBuffer, generatePeaks, useIntegratedRecording, useMicrophoneAccess, useMicrophoneLevel, useRecording };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { ClipTrack } from '@waveform-playlist/core';
|
|
2
|
-
import React from 'react';
|
|
3
2
|
|
|
4
3
|
/**
|
|
5
4
|
* Types for the recording package
|
|
@@ -89,7 +88,8 @@ declare function useMicrophoneAccess(): UseMicrophoneAccessReturn;
|
|
|
89
88
|
/**
|
|
90
89
|
* Hook for monitoring microphone input levels
|
|
91
90
|
*
|
|
92
|
-
* Uses
|
|
91
|
+
* Uses an AudioWorklet-based meter processor for sample-accurate
|
|
92
|
+
* peak and RMS metering without requestAnimationFrame overhead.
|
|
93
93
|
*/
|
|
94
94
|
interface UseMicrophoneLevelOptions {
|
|
95
95
|
/**
|
|
@@ -98,45 +98,61 @@ interface UseMicrophoneLevelOptions {
|
|
|
98
98
|
*/
|
|
99
99
|
updateRate?: number;
|
|
100
100
|
/**
|
|
101
|
-
*
|
|
102
|
-
* Default:
|
|
101
|
+
* Number of channels to meter (1 = mono, 2 = stereo)
|
|
102
|
+
* Default: 1
|
|
103
103
|
*/
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* Smoothing time constant (0-1)
|
|
107
|
-
* Higher values = smoother but slower response
|
|
108
|
-
* Default: 0.8
|
|
109
|
-
*/
|
|
110
|
-
smoothingTimeConstant?: number;
|
|
104
|
+
channelCount?: number;
|
|
111
105
|
}
|
|
112
106
|
interface UseMicrophoneLevelReturn {
|
|
113
107
|
/**
|
|
114
|
-
* Current audio level (0-1)
|
|
115
|
-
*
|
|
108
|
+
* Current peak audio level (0-1)
|
|
109
|
+
* For single channel: channel 0 level
|
|
110
|
+
* For multi-channel: max across all channels
|
|
116
111
|
*/
|
|
117
112
|
level: number;
|
|
118
113
|
/**
|
|
119
|
-
*
|
|
114
|
+
* Held peak level since last reset (0-1)
|
|
115
|
+
* For single channel: channel 0 peak
|
|
116
|
+
* For multi-channel: max across all channels
|
|
120
117
|
*/
|
|
121
118
|
peakLevel: number;
|
|
122
119
|
/**
|
|
123
|
-
* Reset the peak level
|
|
120
|
+
* Reset the held peak level
|
|
124
121
|
*/
|
|
125
122
|
resetPeak: () => void;
|
|
123
|
+
/**
|
|
124
|
+
* Per-channel peak levels (0-1). Array length matches channelCount.
|
|
125
|
+
* True peak: max absolute sample value per analysis frame.
|
|
126
|
+
*/
|
|
127
|
+
levels: number[];
|
|
128
|
+
/**
|
|
129
|
+
* Per-channel held peak levels (0-1). Array length matches channelCount.
|
|
130
|
+
*/
|
|
131
|
+
peakLevels: number[];
|
|
132
|
+
/**
|
|
133
|
+
* Per-channel RMS levels (0-1). Array length matches channelCount.
|
|
134
|
+
* RMS: root mean square of samples per analysis frame.
|
|
135
|
+
*/
|
|
136
|
+
rmsLevels: number[];
|
|
137
|
+
/**
|
|
138
|
+
* Error from meter setup (worklet load failure, context issues, etc.)
|
|
139
|
+
* Null when metering is working normally.
|
|
140
|
+
*/
|
|
141
|
+
error: Error | null;
|
|
126
142
|
}
|
|
127
143
|
/**
|
|
128
144
|
* Monitor microphone input levels in real-time
|
|
129
145
|
*
|
|
130
146
|
* @param stream - MediaStream from getUserMedia
|
|
131
147
|
* @param options - Configuration options
|
|
132
|
-
* @returns Object with current level and peak level
|
|
148
|
+
* @returns Object with current peak level, RMS level, and held peak level
|
|
133
149
|
*
|
|
134
150
|
* @example
|
|
135
151
|
* ```typescript
|
|
136
152
|
* const { stream } = useMicrophoneAccess();
|
|
137
|
-
* const {
|
|
153
|
+
* const { levels, rmsLevels, peakLevels } = useMicrophoneLevel(stream, { channelCount: 2 });
|
|
138
154
|
*
|
|
139
|
-
* return <
|
|
155
|
+
* return <SegmentedVUMeter levels={levels} peakLevels={peakLevels} />;
|
|
140
156
|
* ```
|
|
141
157
|
*/
|
|
142
158
|
declare function useMicrophoneLevel(stream: MediaStream | null, options?: UseMicrophoneLevelOptions): UseMicrophoneLevelReturn;
|
|
@@ -174,6 +190,12 @@ interface UseIntegratedRecordingReturn {
|
|
|
174
190
|
duration: number;
|
|
175
191
|
level: number;
|
|
176
192
|
peakLevel: number;
|
|
193
|
+
/** Per-channel peak levels (0-1). Array length matches channelCount. */
|
|
194
|
+
levels: number[];
|
|
195
|
+
/** Per-channel held peak levels (0-1). Array length matches channelCount. */
|
|
196
|
+
peakLevels: number[];
|
|
197
|
+
/** Per-channel RMS levels (0-1). Array length matches channelCount. */
|
|
198
|
+
rmsLevels: number[];
|
|
177
199
|
error: Error | null;
|
|
178
200
|
stream: MediaStream | null;
|
|
179
201
|
devices: MicrophoneDevice[];
|
|
@@ -189,78 +211,6 @@ interface UseIntegratedRecordingReturn {
|
|
|
189
211
|
}
|
|
190
212
|
declare function useIntegratedRecording(tracks: ClipTrack[], setTracks: (tracks: ClipTrack[]) => void, selectedTrackId: string | null, options?: IntegratedRecordingOptions): UseIntegratedRecordingReturn;
|
|
191
213
|
|
|
192
|
-
/**
|
|
193
|
-
* RecordButton - Control button for starting/stopping recording
|
|
194
|
-
*/
|
|
195
|
-
|
|
196
|
-
interface RecordButtonProps {
|
|
197
|
-
isRecording: boolean;
|
|
198
|
-
onClick: () => void;
|
|
199
|
-
disabled?: boolean;
|
|
200
|
-
className?: string;
|
|
201
|
-
}
|
|
202
|
-
declare const RecordButton: React.FC<RecordButtonProps>;
|
|
203
|
-
|
|
204
|
-
/**
|
|
205
|
-
* MicrophoneSelector - Dropdown for selecting microphone input device
|
|
206
|
-
*/
|
|
207
|
-
|
|
208
|
-
interface MicrophoneSelectorProps {
|
|
209
|
-
devices: MicrophoneDevice[];
|
|
210
|
-
selectedDeviceId?: string;
|
|
211
|
-
onDeviceChange: (deviceId: string) => void;
|
|
212
|
-
disabled?: boolean;
|
|
213
|
-
className?: string;
|
|
214
|
-
}
|
|
215
|
-
declare const MicrophoneSelector: React.FC<MicrophoneSelectorProps>;
|
|
216
|
-
|
|
217
|
-
/**
|
|
218
|
-
* RecordingIndicator - Shows recording status, duration, and visual indicator
|
|
219
|
-
*/
|
|
220
|
-
|
|
221
|
-
interface RecordingIndicatorProps {
|
|
222
|
-
isRecording: boolean;
|
|
223
|
-
isPaused?: boolean;
|
|
224
|
-
duration: number;
|
|
225
|
-
formatTime?: (seconds: number) => string;
|
|
226
|
-
className?: string;
|
|
227
|
-
}
|
|
228
|
-
declare const RecordingIndicator: React.FC<RecordingIndicatorProps>;
|
|
229
|
-
|
|
230
|
-
/**
|
|
231
|
-
* VU Meter Component
|
|
232
|
-
*
|
|
233
|
-
* Displays real-time audio input levels with color-coded zones
|
|
234
|
-
* and peak indicator.
|
|
235
|
-
*/
|
|
236
|
-
|
|
237
|
-
interface VUMeterProps {
|
|
238
|
-
/**
|
|
239
|
-
* Current audio level (0-1)
|
|
240
|
-
*/
|
|
241
|
-
level: number;
|
|
242
|
-
/**
|
|
243
|
-
* Peak level (0-1)
|
|
244
|
-
* Optional - if provided, shows peak indicator
|
|
245
|
-
*/
|
|
246
|
-
peakLevel?: number;
|
|
247
|
-
/**
|
|
248
|
-
* Width of the meter in pixels
|
|
249
|
-
* Default: 200
|
|
250
|
-
*/
|
|
251
|
-
width?: number;
|
|
252
|
-
/**
|
|
253
|
-
* Height of the meter in pixels
|
|
254
|
-
* Default: 20
|
|
255
|
-
*/
|
|
256
|
-
height?: number;
|
|
257
|
-
/**
|
|
258
|
-
* Additional CSS class name
|
|
259
|
-
*/
|
|
260
|
-
className?: string;
|
|
261
|
-
}
|
|
262
|
-
declare const VUMeter: React.NamedExoticComponent<VUMeterProps>;
|
|
263
|
-
|
|
264
214
|
/**
|
|
265
215
|
* Peak generation for real-time waveform visualization during recording
|
|
266
216
|
* Matches the format used by webaudio-peaks: min/max pairs with bit depth
|
|
@@ -288,4 +238,4 @@ declare function concatenateAudioData(chunks: Float32Array[]): Float32Array;
|
|
|
288
238
|
*/
|
|
289
239
|
declare function createAudioBuffer(audioContext: AudioContext, channelData: Float32Array[] | Float32Array, sampleRate: number, channelCount?: number): AudioBuffer;
|
|
290
240
|
|
|
291
|
-
export { type IntegratedRecordingOptions, type MicrophoneDevice,
|
|
241
|
+
export { type IntegratedRecordingOptions, type MicrophoneDevice, type RecordingData, type RecordingOptions, type RecordingState, type UseIntegratedRecordingReturn, type UseMicrophoneAccessReturn, type UseMicrophoneLevelOptions, type UseMicrophoneLevelReturn, type UseRecordingReturn, concatenateAudioData, createAudioBuffer, generatePeaks, useIntegratedRecording, useMicrophoneAccess, useMicrophoneLevel, useRecording };
|