@waveform-playlist/browser 10.1.2 → 10.3.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 CHANGED
@@ -254,6 +254,9 @@ interface MediaElementPlaylistProviderProps {
254
254
  timescale?: boolean;
255
255
  /** Initial playback rate (0.5 to 2.0) */
256
256
  playbackRate?: number;
257
+ /** Whether to preserve pitch when changing playback rate (default: true).
258
+ * Set to false when using an external pitch processor like SoundTouch. */
259
+ preservesPitch?: boolean;
257
260
  /** Enable automatic scroll to keep playhead centered */
258
261
  automaticScroll?: boolean;
259
262
  /** Theme configuration */
package/dist/index.d.ts CHANGED
@@ -254,6 +254,9 @@ interface MediaElementPlaylistProviderProps {
254
254
  timescale?: boolean;
255
255
  /** Initial playback rate (0.5 to 2.0) */
256
256
  playbackRate?: number;
257
+ /** Whether to preserve pitch when changing playback rate (default: true).
258
+ * Set to false when using an external pitch processor like SoundTouch. */
259
+ preservesPitch?: boolean;
257
260
  /** Enable automatic scroll to keep playhead centered */
258
261
  automaticScroll?: boolean;
259
262
  /** Theme configuration */
package/dist/index.js CHANGED
@@ -2791,7 +2791,6 @@ function useExportWav() {
2791
2791
  const [error, setError] = (0, import_react18.useState)(null);
2792
2792
  const exportWav = (0, import_react18.useCallback)(
2793
2793
  (_0, _1, ..._2) => __async(null, [_0, _1, ..._2], function* (tracks, trackStates, options = {}) {
2794
- var _a;
2795
2794
  const {
2796
2795
  filename = "export",
2797
2796
  mode = "master",
@@ -2813,7 +2812,7 @@ function useExportWav() {
2813
2812
  if (mode === "individual" && (trackIndex === void 0 || trackIndex < 0 || trackIndex >= tracks.length)) {
2814
2813
  throw new Error("Invalid track index for individual export");
2815
2814
  }
2816
- const sampleRate = ((_a = tracks[0].clips[0]) == null ? void 0 : _a.sampleRate) || 44100;
2815
+ const sampleRate = (0, import_playout.getGlobalAudioContext)().sampleRate;
2817
2816
  let totalDurationSamples = 0;
2818
2817
  for (const track of tracks) {
2819
2818
  for (const clip of track.clips) {
@@ -3741,7 +3740,7 @@ var WaveformPlaylistProvider = ({
3741
3740
  indefinitePlayback = false,
3742
3741
  children
3743
3742
  }) => {
3744
- var _a, _b, _c, _d, _e, _f, _g;
3743
+ var _a, _b, _c, _d;
3745
3744
  const progressBarWidth = progressBarWidthProp != null ? progressBarWidthProp : barWidth + barGap;
3746
3745
  const indefinitePlaybackRef = (0, import_react23.useRef)(indefinitePlayback);
3747
3746
  indefinitePlaybackRef.current = indefinitePlayback;
@@ -3802,7 +3801,9 @@ var WaveformPlaylistProvider = ({
3802
3801
  const isDraggingRef = (0, import_react23.useRef)(false);
3803
3802
  const prevTracksRef = (0, import_react23.useRef)([]);
3804
3803
  const samplesPerPixelRef = (0, import_react23.useRef)(initialSamplesPerPixel);
3805
- const sampleRateRef = (0, import_react23.useRef)(44100);
3804
+ const sampleRateRef = (0, import_react23.useRef)(
3805
+ typeof AudioContext !== "undefined" ? (0, import_playout4.getGlobalAudioContext)().sampleRate : 48e3
3806
+ );
3806
3807
  const { timeFormat, setTimeFormat, formatTime: formatTime2 } = useTimeFormat();
3807
3808
  const zoom = useZoomControls({ engineRef, initialSamplesPerPixel });
3808
3809
  const { samplesPerPixel, onEngineState: onZoomEngineState } = zoom;
@@ -3997,7 +3998,7 @@ var WaveformPlaylistProvider = ({
3997
3998
  pendingResumeRef.current = { position: resumePosition };
3998
3999
  }
3999
4000
  const loadAudio = () => __async(null, null, function* () {
4000
- var _a3, _b3, _c3, _d3, _e2;
4001
+ var _a3, _b3, _c3, _d3, _e;
4001
4002
  try {
4002
4003
  const buffers = [];
4003
4004
  tracks.forEach((track) => {
@@ -4047,7 +4048,7 @@ var WaveformPlaylistProvider = ({
4047
4048
  engine.setSelection((_a3 = selectionStartRef.current) != null ? _a3 : 0, (_b3 = selectionEndRef.current) != null ? _b3 : 0);
4048
4049
  engine.setLoopRegion((_c3 = loopStartRef.current) != null ? _c3 : 0, (_d3 = loopEndRef.current) != null ? _d3 : 0);
4049
4050
  if (isLoopEnabledRef.current) engine.setLoopEnabled(true);
4050
- engine.setMasterVolume((_e2 = masterVolumeRef.current) != null ? _e2 : 1);
4051
+ engine.setMasterVolume((_e = masterVolumeRef.current) != null ? _e : 1);
4051
4052
  if (selectedTrackIdRef.current) engine.selectTrack(selectedTrackIdRef.current);
4052
4053
  const currentTrackStates = trackStatesRef.current;
4053
4054
  const tracksWithState = tracks.map((track, index) => {
@@ -4336,7 +4337,7 @@ var WaveformPlaylistProvider = ({
4336
4337
  }, [tracks, startAnimationLoop, stopAnimationLoop]);
4337
4338
  const play = (0, import_react23.useCallback)(
4338
4339
  (startTime, playDuration) => __async(null, null, function* () {
4339
- if (!engineRef.current || duration === 0) return;
4340
+ if (!engineRef.current) return;
4340
4341
  const actualStartTime = startTime != null ? startTime : currentTimeRef.current;
4341
4342
  playStartPositionRef.current = actualStartTime;
4342
4343
  currentTimeRef.current = actualStartTime;
@@ -4363,7 +4364,7 @@ var WaveformPlaylistProvider = ({
4363
4364
  setIsPlaying(true);
4364
4365
  startAnimationLoop();
4365
4366
  }),
4366
- [duration, startAnimationLoop, stopAnimationLoop]
4367
+ [startAnimationLoop, stopAnimationLoop]
4367
4368
  );
4368
4369
  const pause = (0, import_react23.useCallback)(() => {
4369
4370
  if (!engineRef.current) return;
@@ -4483,8 +4484,7 @@ var WaveformPlaylistProvider = ({
4483
4484
  },
4484
4485
  []
4485
4486
  );
4486
- const sampleRate = ((_e = audioBuffers[0]) == null ? void 0 : _e.sampleRate) || ((_g = (_f = tracks[0]) == null ? void 0 : _f.clips[0]) == null ? void 0 : _g.sampleRate) || 44100;
4487
- sampleRateRef.current = sampleRate;
4487
+ const sampleRate = sampleRateRef.current;
4488
4488
  const timeScaleHeight = timescale ? 30 : 0;
4489
4489
  const minimumPlaylistHeight = tracks.length * waveHeight + timeScaleHeight;
4490
4490
  const animationValue = (0, import_react23.useMemo)(
@@ -4718,6 +4718,7 @@ var MediaElementPlaylistProvider = ({
4718
4718
  waveHeight = 100,
4719
4719
  timescale = false,
4720
4720
  playbackRate: initialPlaybackRate = 1,
4721
+ preservesPitch = true,
4721
4722
  automaticScroll = false,
4722
4723
  theme: userTheme,
4723
4724
  controls = { show: false, width: 0 },
@@ -4787,7 +4788,8 @@ var MediaElementPlaylistProvider = ({
4787
4788
  (0, import_react24.useEffect)(() => {
4788
4789
  var _a2, _b;
4789
4790
  const playout = new import_media_element_playout.MediaElementPlayout({
4790
- playbackRate: initialPlaybackRate
4791
+ playbackRate: initialPlaybackRate,
4792
+ preservesPitch
4791
4793
  });
4792
4794
  playout.addTrack({
4793
4795
  source: track.source,
@@ -4825,6 +4827,7 @@ var MediaElementPlaylistProvider = ({
4825
4827
  track.fadeOut,
4826
4828
  audioContext,
4827
4829
  initialPlaybackRate,
4830
+ preservesPitch,
4828
4831
  onReady,
4829
4832
  stopAnimationFrameLoop,
4830
4833
  setActiveAnnotationId