Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ stNode.pitch.value = 0.9;
source.start();
```

The audio-worklet package exposes wider real-time control ranges for `pitch`, `tempo`, `rate`, and `playbackRate` than earlier releases. Those controls are intentionally capped to balance flexibility with predictable real-time behavior: more extreme values can increase artifacts, reduce output quality, and make buffer behavior less stable on small AudioWorklet render blocks.

### PitchShifter (ScriptProcessorNode)

The `@soundtouchjs/core` package provides a higher-level `PitchShifter` class with built-in playback tracking. This uses `ScriptProcessorNode`, which is deprecated but widely supported.
Expand Down
16 changes: 9 additions & 7 deletions packages/audio-worklet/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,15 @@ stNode.pitchSemitones.value = -3;
stNode.pitch.linearRampToValueAtTime(2.0, audioCtx.currentTime + 5);
```

| Parameter | Default | Range | Description |
| ---------------- | ------- | ---------- | -------------------------------------------------- |
| `pitch` | 1.0 | 0.25 – 4.0 | Pitch multiplier (1.0 = original) |
| `tempo` | 1.0 | 0.25 – 4.0 | Tempo multiplier (1.0 = original) |
| `rate` | 1.0 | 0.25 – 4.0 | Playback rate (affects both pitch and tempo) |
| `pitchSemitones` | 0 | -24 – 24 | Pitch shift in semitones (combined with `pitch`) |
| `playbackRate` | 1.0 | 0.25 – 4.0 | Source playback rate (for auto pitch compensation) |
| Parameter | Default | Range | Description |
| ---------------- | ------- | --------- | -------------------------------------------------- |
| `pitch` | 1.0 | 0.1 – 8.0 | Pitch multiplier (1.0 = original) |
| `tempo` | 1.0 | 0.1 – 8.0 | Tempo multiplier (1.0 = original) |
| `rate` | 1.0 | 0.1 – 8.0 | Playback rate (affects both pitch and tempo) |
| `pitchSemitones` | 0 | -24 – 24 | Pitch shift in semitones (combined with `pitch`) |
| `playbackRate` | 1.0 | 0.1 – 8.0 | Source playback rate (for auto pitch compensation) |

These ranges are intentionally broader than the typical musical sweet spot, but still bounded for real-time stability. Values outside this window tend to produce more audible artifacts, less predictable output, and higher risk of buffer starvation or unnatural sounding results, especially in the AudioWorklet's small render blocks. For most material, settings closer to `1.0` will sound cleaner.

### Full example — AudioBuffer

Expand Down
16 changes: 8 additions & 8 deletions packages/audio-worklet/src/processor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,22 @@ class SoundTouchProcessor extends AudioWorkletProcessor {
{
name: 'pitch',
defaultValue: 1.0,
minValue: 0.25,
maxValue: 4.0,
minValue: 0.1,
maxValue: 8.0,
automationRate: 'k-rate',
},
{
name: 'tempo',
defaultValue: 1.0,
minValue: 0.25,
maxValue: 4.0,
minValue: 0.1,
maxValue: 8.0,
automationRate: 'k-rate',
},
{
name: 'rate',
defaultValue: 1.0,
minValue: 0.25,
maxValue: 4.0,
minValue: 0.1,
maxValue: 8.0,
automationRate: 'k-rate',
},
{
Expand All @@ -63,8 +63,8 @@ class SoundTouchProcessor extends AudioWorkletProcessor {
{
name: 'playbackRate',
defaultValue: 1.0,
minValue: 0.25,
maxValue: 4.0,
minValue: 0.1,
maxValue: 8.0,
automationRate: 'k-rate',
},
];
Expand Down
Loading