---
title: "AudioPitchShift"
language: "en"
type: "Symbol"
summary: "AudioPitchShift[audio, r] applies pitch shifting to audio by the ratio r, shifting every frequency f to r f. AudioPitchShift[video, r] applies pitch shifting to the first audio track in video."
keywords: 
- Pitch Shift
- Phase Vocoder
- Pitch
- Frequency Shift
- audio pitch shift
- pitch shifting
- time stretch
- change audio pitch
canonical_url: "https://reference.wolfram.com/language/ref/AudioPitchShift.html"
source: "Wolfram Language Documentation"
related_guides: 
  - 
    title: "Audio Editing"
    link: "https://reference.wolfram.com/language/guide/AudioEditing.en.md"
  - 
    title: "Signal Processing"
    link: "https://reference.wolfram.com/language/guide/SignalProcessing.en.md"
  - 
    title: "Speech Computation"
    link: "https://reference.wolfram.com/language/guide/SpeechComputation.en.md"
  - 
    title: "Sound and Sonification"
    link: "https://reference.wolfram.com/language/guide/SoundAndSonification.en.md"
  - 
    title: "Video Editing"
    link: "https://reference.wolfram.com/language/guide/VideoEditing.en.md"
  - 
    title: "Video Computation: Update History"
    link: "https://reference.wolfram.com/language/guide/VideoComputation-UpdateHistory.en.md"
  - 
    title: "Audio Processing"
    link: "https://reference.wolfram.com/language/guide/AudioProcessing.en.md"
related_functions: 
  - 
    title: "AudioFrequencyShift"
    link: "https://reference.wolfram.com/language/ref/AudioFrequencyShift.en.md"
  - 
    title: "AudioTimeStretch"
    link: "https://reference.wolfram.com/language/ref/AudioTimeStretch.en.md"
  - 
    title: "PitchRecognize"
    link: "https://reference.wolfram.com/language/ref/PitchRecognize.en.md"
  - 
    title: "AudioResample"
    link: "https://reference.wolfram.com/language/ref/AudioResample.en.md"
  - 
    title: "AudioTrackApply"
    link: "https://reference.wolfram.com/language/ref/AudioTrackApply.en.md"
---
# AudioPitchShift

AudioPitchShift[audio, r] applies pitch shifting to audio by the ratio r, shifting every frequency $f$ to $r f$.

AudioPitchShift[video, r] applies pitch shifting to the first audio track in video.

## Details and Options

* ``AudioPitchShift`` shifts the pitch of the input audio signal without affecting the duration.

[image]

* The frequency ratio ``r`` can be given as a pitch interval, including:

|                            |                                                                             |
| -------------------------- | --------------------------------------------------------------------------- |
| Quantity[oct, "octaves"]   | correspond to $r=2^{\text{\textit{oct}}}$     |
| Quantity[sem, "semitones"] | correspond to $r=2^{\text{\textit{sem}}/12}$  |

* The following options are supported:

|                       |           |                                                                                       |
| --------------------- | --------- | ------------------------------------------------------------------------------------- |
| Method                | Automatic | the method to use                                                                     |
| PartitionGranularity  | Automatic | control the partitioning used for the computation of the short-time Fourier transform |

* By default, a phase vocoder algorithm is used. Use ``Method -> "Speech"`` for pitch shifting speech signals. In this case, while the fundamental frequency is changed, the formants of the signal are not modified.

---

## Examples (15)

### Basic Examples (2)

Shift the audio pitch by a factor of two:

```wl
In[1]:= AudioPitchShift[\!\(\*AudioBox["![Embedded Audio Player](audio://content-1il6e)"]\), 2]

Out[1]= \!\(\*AudioBox["![Embedded Audio Player](audio://content-x63r6)"]\)
```

---

Shift the audio pitch by a semitone:

```wl
In[1]:= AudioPitchShift[\!\(\*AudioBox["![Embedded Audio Player](audio://content-1il6e)"]\), Quantity[1, IndependentUnit["semitones"]]]

Out[1]= \!\(\*AudioBox["![Embedded Audio Player](audio://content-r326p)"]\)
```

### Scope (4)

A shift by ``n`` octaves corresponds to a frequency ratio of ``2^n`` :

```wl
In[1]:= a = Import["ExampleData/rule30.wav"];

In[2]:= AudioPitchShift[a, Quantity[1.5, IndependentUnit["octaves"]]] === AudioPitchShift[a, 2^1.5]

Out[2]= True
```

---

A shift by ``s`` semitones corresponds to a frequency ratio of ``2^s / 12`` :

```wl
In[1]:= a = Import["ExampleData/rule30.wav"];

In[2]:= AudioPitchShift[a, Quantity[10, IndependentUnit["semitones"]]] === AudioPitchShift[a, 2^10 / 12]

Out[2]= True
```

---

``AudioPitchShift`` can be used to change the pitch of a harmonically complex sound without altering its timbre and timing:

```wl
In[1]:= a = Mean[Table[AudioGenerator[{"Sin", 200 * i}, 2], {i, 1, 6}]]

Out[1]= \!\(\*AudioBox["![Embedded Audio Player](audio://content-eic2c)"]\)

In[2]:= Periodogram[a, ScalingFunctions -> "Absolute", PlotRange -> {{0, 3000}, All}]

Out[2]= [image]
```

The frequency ratio between the components of the audio signal is not changed:

```wl
In[3]:= AudioPitchShift[a, Quantity[12, IndependentUnit["semitones"]]]

Out[3]= \!\(\*AudioBox["![Embedded Audio Player](audio://content-xasji)"]\)

In[4]:= Periodogram[%, ScalingFunctions -> "Absolute", PlotRange -> {{0, 3000}, All}]

Out[4]= [image]
```

---

Process the audio track of a video:

```wl
In[1]:= AudioPitchShift[\!\(\*VideoBox["![Video Player: ExampleData/fish.mp4](video://content-2sfji)"]\), 2]

Out[1]= \!\(\*VideoBox[...]\)
```

### Options (4)

#### Method (1)

Use ``Method -> "Speech"`` for speech signals to shift the pitch while maintaining other voice characteristics:

```wl
In[1]:=
a = \!\(\*AudioBox["![Embedded Audio Player](audio://content-2pcu3)"]\);
AudioPitchShift[a, 1.8, Method -> "Speech"]

Out[1]= \!\(\*AudioBox["![Embedded Audio Player](audio://content-vv029)"]\)
```

Compare with the normal pitch shifting, which dramatically affects the timbre of the voice:

```wl
In[2]:= AudioPitchShift[a, 1.8]

Out[2]= \!\(\*AudioBox["![Embedded Audio Player](audio://content-578kf)"]\)
```

#### PartitionGranularity (3)

Using a bigger partition size will improve the frequency response but will smear the transient components:

```wl
In[1]:=
a = Import["ExampleData/rule30.wav"];
AudioPitchShift[a, 1.1, PartitionGranularity -> Quantity[46, "Milliseconds"]]

Out[1]= \!\(\*AudioBox["![Embedded Audio Player](audio://content-exgx5)"]\)

In[2]:= AudioPitchShift[a, 1.1, PartitionGranularity -> Quantity[150, "Milliseconds"]]

Out[2]= \!\(\*AudioBox["![Embedded Audio Player](audio://content-03whf)"]\)
```

---

Using a small offset value will in general increase the quality of the result at the cost of more computation time:

```wl
In[1]:=
a = Import["ExampleData/rule30.wav"];
AudioPitchShift[a, 1.1, PartitionGranularity -> {Quantity[46, "Milliseconds"], Quantity[20, "Milliseconds"]}]

Out[1]= \!\(\*AudioBox["![Embedded Audio Player](audio://content-fu1wc)"]\)

In[2]:= AudioPitchShift[a, 1.1, PartitionGranularity -> {Quantity[46, "Milliseconds"], Quantity[5, "Milliseconds"]}]

Out[2]= \!\(\*AudioBox["![Embedded Audio Player](audio://content-0vxuv)"]\)
```

If only the partition size is specified, the offset is calculated as 25% of the partition size.

---

Use a different window shape to change the quality of the result:

```wl
In[1]:=
a = Import["ExampleData/rule30.wav"];
AudioPitchShift[a, 1.1, 
	PartitionGranularity -> {Quantity[46, "Milliseconds"], Quantity[10, "Milliseconds"], DirichletWindow}]

Out[1]= \!\(\*AudioBox["![Embedded Audio Player](audio://content-925us)"]\)

In[2]:=
AudioPitchShift[a, 1.1, 
	PartitionGranularity -> {Quantity[46, "Milliseconds"], Quantity[10, "Milliseconds"], BlackmanWindow}]

Out[2]= \!\(\*AudioBox["![Embedded Audio Player](audio://content-925us)"]\)
```

By default, ``HannWindow`` is used.

### Applications (1)

Shift the pitch of an audio object to match a target frequency:

```wl
In[1]:= a = \!\(\*AudioBox["![Embedded Audio Player](audio://content-oxizp)"]\);
```

Extract the mean frequency with ``AudioLocalMeasurements`` :

```wl
In[2]:= meanFreq = DeleteMissing@TimeSeries[AudioLocalMeasurements[a, "FundamentalFrequency"]]["Values"]//Mean

Out[2]= 262.63
```

Shift the audio to reach the target frequency:

```wl
In[3]:= targetFreq = 1000;

In[4]:= AudioPitchShift[a, targetFreq / meanFreq]

Out[4]= \!\(\*AudioBox["![Embedded Audio Player](audio://content-izyh6)"]\)

In[5]:= Periodogram[{a, %}, 4000, PlotRange -> {{0, 4000}, All}]

Out[5]= [image]
```

### Properties & Relations (2)

``AudioPitchShift`` and ``AudioFrequencyShift`` modify the spectrum of the signal in different ways:

```wl
In[1]:= a = Mean[{AudioGenerator[{"Sin", 200}, SampleRate -> 16000], AudioGenerator[{"Sin", 400}, SampleRate -> 16000]}]

Out[1]= \!\(\*AudioBox["![Embedded Audio Player](audio://content-ggi7p)"]\)
```

``AudioPitchShift`` shifts each frequency ``f`` in the signal by an amount proportional to the frequency itself (``f^' = f×shift``), thus preserving the timbre in the shifted signal:

```wl
In[2]:= ps = AudioPitchShift[a, 4]

Out[2]= \!\(\*AudioBox["![Embedded Audio Player](audio://content-9gtjf)"]\)
```

``AudioFrequencyShift`` shifts every frequency ``f`` by the same amount (``f^' = f + shift``), changing dramatically the timbre in the shifted signal:

```wl
In[3]:= fs = AudioFrequencyShift[a, 800]

Out[3]= \!\(\*AudioBox["![Embedded Audio Player](audio://content-zci51)"]\)

In[4]:= Periodogram[{a, ps, fs}, PlotRange -> {{0, 2000}, All}, ScalingFunctions -> "Absolute", PlotLegends -> {"Original", "Pitch Shift", "Frequency Shift"}]

Out[4]= [image]
```

---

Change the pitch of a recording by using a different sample rate:

```wl
In[1]:= a = \!\(\*AudioBox["![Embedded Audio Player](audio://content-ctqtq)"]\);

In[2]:= Audio[a, SampleRate -> 44100]

Out[2]= \!\(\*AudioBox["![Embedded Audio Player](audio://content-gqwq2)"]\)
```

``AudioPitchShift`` changes the pitch without altering the timing:

```wl
In[3]:= AudioPitchShift[a, 44100 / 22050]

Out[3]= \!\(\*AudioBox["![Embedded Audio Player](audio://content-k17zo)"]\)
```

### Possible Issues (2)

The quality of the result degrades with large shift parameters:

```wl
In[1]:= AudioPitchShift[\!\(\*AudioBox["![Embedded Audio Player](audio://content-1il6e)"]\), 5.6]

Out[1]= \!\(\*AudioBox["![Embedded Audio Player](audio://content-ubfox)"]\)
```

---

Using ``Method -> "Speech"`` for non-speech signals may not sound as expected:

```wl
In[1]:= AudioPitchShift[\!\(\*AudioBox["![Embedded Audio Player](audio://content-3rb3d)"]\), 1.8, Method -> "Speech"]

Out[1]= \!\(\*AudioBox["![Embedded Audio Player](audio://content-re1cz)"]\)
```

## See Also

* [`AudioFrequencyShift`](https://reference.wolfram.com/language/ref/AudioFrequencyShift.en.md)
* [`AudioTimeStretch`](https://reference.wolfram.com/language/ref/AudioTimeStretch.en.md)
* [`PitchRecognize`](https://reference.wolfram.com/language/ref/PitchRecognize.en.md)
* [`AudioResample`](https://reference.wolfram.com/language/ref/AudioResample.en.md)
* [`AudioTrackApply`](https://reference.wolfram.com/language/ref/AudioTrackApply.en.md)

## Related Guides

* [Audio Editing](https://reference.wolfram.com/language/guide/AudioEditing.en.md)
* [Signal Processing](https://reference.wolfram.com/language/guide/SignalProcessing.en.md)
* [Speech Computation](https://reference.wolfram.com/language/guide/SpeechComputation.en.md)
* [Sound and Sonification](https://reference.wolfram.com/language/guide/SoundAndSonification.en.md)
* [Video Editing](https://reference.wolfram.com/language/guide/VideoEditing.en.md)
* [Video Computation: Update History](https://reference.wolfram.com/language/guide/VideoComputation-UpdateHistory.en.md)
* [Audio Processing](https://reference.wolfram.com/language/guide/AudioProcessing.en.md)

## History

* [Introduced in 2016 (11.0)](https://reference.wolfram.com/language/guide/SummaryOfNewFeaturesIn110.en.md) \| [Updated in 2020 (12.1)](https://reference.wolfram.com/language/guide/SummaryOfNewFeaturesIn121.en.md) ▪ [2024 (14.1)](https://reference.wolfram.com/language/guide/SummaryOfNewFeaturesIn141.en.md)