AudioSpectralTransformation[f,audio]
returns a modified version of audio by applying a time-frequency transformation f to its short-time Fourier transform.
AudioSpectralTransformation[f,video]
transforms the first audio track in video.
AudioSpectralTransformation
AudioSpectralTransformation[f,audio]
returns a modified version of audio by applying a time-frequency transformation f to its short-time Fourier transform.
AudioSpectralTransformation[f,video]
transforms the first audio track in video.
Details and Options
- Applying an arbitrary time-frequency transformation to the short-time Fourier transform of audio signals can create interesting audio modifications and effects for creative use.
- AudioSpectralTransformation computes the short-time Fourier transform of audio, maps every value at position f[{time,freq}] to {time,freq}, and computes the inverse using the overlap-add method.
- The following options can be given:
-
DataRange Automatic ranges to assume for time and frequency Padding 0 padding scheme to use PartitionGranularity Automatic audio partitioning specification Resampling Automatic resampling method - By default, DataRange->{{0,dur},{0,sr/2}} is used, where dur and sr are duration and sample rate of audio.
Examples
open all close allBasic Examples (1)
Scope (4)
Transform only along the time axis:
a = ExampleData[{"Audio", "Apollo11SmallStep"}, "Audio"];f[{time_, frequency_}] := {time * .5, frequency};
AudioSpectralTransformation[f, a]Transform only along the frequency axis:
a = ExampleData[{"Audio", "Apollo11SmallStep"}, "Audio"];f[{time_, frequency_}] := {time, frequency * .5}
AudioSpectralTransformation[f, a]Transform along both time and frequency axes:
a = ExampleData[{"Audio", "Apollo11SmallStep"}, "Audio"]dur = QuantityMagnitude[Duration[a]];f[{time_, frequency_}] := {Tanh[time / dur]dur + frequency / 10000, frequency - time ^ 3}AudioSpectralTransformation[f, a]Spectrogram[%]Process the audio track of a video:
f[{time_, frequency_}] := {time * .5, frequency};
AudioSpectralTransformation[f, \!\(\*VideoBox[""]\)]Options (2)
DataRange (1)
By default, the data range is {{0,duration},{0,samplerate/2}}:
a = ExampleData[{"Audio", "Apollo11SmallStep"}, "Audio"];AudioSpectralTransformation[# - {1, 0}&, a]Spectrogram[%]Specify a different data range for the function:
AudioSpectralTransformation[# - {.5, 0}&, a, DataRange -> {{0, 1}, {0, 11025}}]Spectrogram[%]PartitionGranularity (1)
Use the PartitionGranularity option to change the quality of the result:
a = ExampleData[{"Sound", "Apollo11SmallStep"}, "Audio"];f[x_] := x / 2;
AudioSpectralTransformation[f, a]AudioSpectralTransformation[f, a, PartitionGranularity -> {.05, .008, BlackmanWindow}]Applications (5)
Compress the time and do a time-dependent frequency stretching:
a = ExampleData[{"Audio", "Apollo11SmallStep"}, "Audio"]f[{time_, frequency_}] := {time * 1.2, frequency + time * frequency ^ .5};
AudioSpectralTransformation[f, a]Spectrogram[%, 1024, 2048, ImageSize -> Medium]Apply a curvilinear distortion to the spectrogram:
a = ExampleData[{"Audio", "Apollo11SmallStep"}, "Audio"];f[pt_] := With[{s = {.5, .1}}, Module[{r, a, an},
r = Norm[pt - s];a = ArcTan@@(pt - s);an = a + 2r;
s + r{Cos[an], Sin[an]}]]
AudioSpectralTransformation[f, a, DataRange -> {{0, 1}, {0, 1}}]Spectrogram[%, 1024, 2048, ImageSize -> Medium]Quantize the spectrogram both in frequency and time:
a = ExampleData[{"Audio", "Apollo11SmallStep"}, "Audio"];f[{time_, frequency_}] := {.05Floor[time / .05], 100Floor[frequency / 100] + 1};
AudioSpectralTransformation[f, a]Spectrogram[%, 1024, 2048, ImageSize -> Medium]Create a time-dependent frequency shift:
a = ExampleData[{"Audio", "Apollo11SmallStep"}, "Audio"];f[{time_, frequency_}] := {time, frequency + 400Sin[2 Pi time]};
AudioSpectralTransformation[f, a]Spectrogram[%, 1024, 2048, ImageSize -> Medium]Apply a fisheye transformation to the spectrogram:
a = ExampleData[{"Audio", "Apollo11SmallStep"}, "Audio"];f[pt_] := With[{s = {2, 10000}}, Module[{r, a},
r = Norm[pt - s]^2 / Norm[s];a = ArcTan@@(pt - s);
s + r{Cos[a], Sin[a]}]];
AudioSpectralTransformation[f, a]Spectrogram[%, 1024, 2048, ImageSize -> Medium]Properties & Relations (4)
Performing an identity operation does not return the input sample values:
a = ExampleData[{"Audio", "Apollo11SmallStep"}, "Audio"];AudioSpectralTransformation[Identity, a] == aEven in the case of an identity, a short-time Fourier transform followed by an overlap add operation is performed. The result only has minor discrepancies with the input:
{Mean[#], StandardDeviation[#]}&[AudioSpectralTransformation[Identity, a] - a]Create a crude pitch-shifting effect:
a = ExampleData[{"Audio", "Apollo11SmallStep"}, "Audio"];f[{time_, frequency_}] := {time, frequency * .5}
AudioSpectralTransformation[f, a]Compare to AudioPitchShift:
AudioPitchShift[a, 2]Create a crude time-stretching effect:
a = ExampleData[{"Audio", "Apollo11SmallStep"}, "Audio"];f[{time_, frequency_}] := {time * .5, frequency}
AudioSpectralTransformation[f, a]Compare to AudioTimeStretch:
AudioTimeStretch[a, 2]Create a crude frequency-shifting effect:
a = ExampleData[{"Audio", "Apollo11SmallStep"}, "Audio"];f[{time_, frequency_}] := {time, 200 + frequency}
AudioSpectralTransformation[f, a]Compare to AudioFrequencyShift:
AudioFrequencyShift[a, 200]Related Guides
Text
Wolfram Research (2017), AudioSpectralTransformation, Wolfram Language function, https://reference.wolfram.com/language/ref/AudioSpectralTransformation.html (updated 2024).
CMS
Wolfram Language. 2017. "AudioSpectralTransformation." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2024. https://reference.wolfram.com/language/ref/AudioSpectralTransformation.html.
APA
Wolfram Language. (2017). AudioSpectralTransformation. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/AudioSpectralTransformation.html
BibTeX
@misc{reference.wolfram_2026_audiospectraltransformation, author="Wolfram Research", title="{AudioSpectralTransformation}", year="2024", howpublished="\url{https://reference.wolfram.com/language/ref/AudioSpectralTransformation.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_audiospectraltransformation, organization={Wolfram Research}, title={AudioSpectralTransformation}, year={2024}, url={https://reference.wolfram.com/language/ref/AudioSpectralTransformation.html}, note=[Accessed: 13-June-2026]}