({{, (RefLink[AudioResample, paclet:ref/AudioResample])[audio,sr] 
resamples audio to have the sample rate of sr.}})

OpenersNotesSection(Spacer1)Details and Options

(RefLink[AudioResample, paclet:ref/AudioResample]) can be used to convert between any sampling rates, including the common ones, e.g. telephone, CD, and DVD.

The sample rate sr can be given as a positive integer, assumed to be in hertz, a quantity, or a (RefLink[Scaled, paclet:ref/Scaled]) parameter.

The following common sampling rates are also supported:

(RefLink[AudioResample, paclet:ref/AudioResample]) works with (RefLink[Audio, paclet:ref/Audio]) objects of any number of channels.

The following options can be given:

For possible settings for (RefLink[Padding, paclet:ref/Padding]), see the reference page for (RefLink[AudioPad, paclet:ref/AudioPad]).

OpenersPrimaryExamplesSection(Spacer1)Examples  (9)

OpenersExampleSection0(Spacer1)Basic Examples  (1)

Resample an audio object:

a=ExampleData[{"Sound","RollingCoin"},"Audio"];
AudioSampleRate[a]

ar=AudioResample[a,8000];
AudioSampleRate[ar]

OpenersExampleSection1(Spacer1)Scope  (3)

Specify the sample rate using a frequency (RefLink[Quantity, paclet:ref/Quantity]):

a=AudioGenerator["Sin"];

AudioResample[a,(Quantity[11025, "Hz", hertz, "Hertz"])]//AudioSampleRate

Specify the sample rate using a (RefLink[Scaled, paclet:ref/Scaled]) value:

a=AudioGenerator["Sin"];

AudioResample[a,Scaled[.25]]//AudioSampleRate

Specify the sample rate using a preset value:

a=AudioGenerator["Sin"];

AudioResample[a,"Telephone"]//AudioSampleRate

OpenersExampleSection2(Spacer1)Options  (3)

OpenersExampleSubsection0(Spacer1)Antialiasing  (1)

When resampling to a lower sample rate, an antialiasing filter is applied by default:

a=AudioGenerator[{"Sin",3500},SampleRate->8000]+AudioGenerator[{"Sin",1500},SampleRate->8000];
Spectrogram[a]

Resampling by a factor of .5 with antialiasing filter:

Spectrogram[AudioResample[a,4000]]

Use (RefLink[Antialiasing, paclet:ref/Antialiasing])->(RefLink[False, paclet:ref/False]):

Spectrogram[AudioResample[a,4000,Antialiasing->False]]

OpenersExampleSubsection1(Spacer1)Padding  (1)

The default padding value is 0:

a=Audio[{1,-1,1},SampleRate->1];
AudioResample[a,2]//AudioData

Specify a different padding:

AudioResample[a,2, Padding->"Periodic"]//AudioData

OpenersExampleSubsection2(Spacer1)Reasampling  (1)

By default, "Lanczos" resampling is used:

a=Audio[{1,2,3},SampleRate->1];
AudioResample[a,2]//AudioData

Use a different resampling scheme:

AudioResample[a,2, Resampling->"Linear"]//AudioData

OpenersExampleSection3(Spacer1)Applications  (2)

Convert an audio object in CD quality (44.1 KHz) to DVD quality (48 KHz):

a=ExampleData[{"Sound","RollingCoin"},"Audio"];
dvd=AudioResample[a,"DVD"]

AudioSampleRate/@{a,dvd}

Resampling to a lower sample rate reduces the memory used by the audio object:

a=ExampleData[{"Sound","RollingCoin"},"Audio"];
t=Table[AudioResample[a,sr],{sr,{48000,44100,32000,22050,11025,8000}}];

TableForm[{AudioSampleRate[#],Quantity[ByteCount[#],"Bytes"]}&/@t,TableHeadings->{None,{"sample rate", "memory"}}]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[Audio, paclet:ref/Audio])  ▪  (RefLink[AudioSampleRate, paclet:ref/AudioSampleRate])  ▪  (RefLink[AudioLength, paclet:ref/AudioLength])  ▪  (RefLink[AudioTrim, paclet:ref/AudioTrim])  ▪  (RefLink[ArrayResample, paclet:ref/ArrayResample])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Audio Processing, paclet:guide/AudioProcessing])}})}})