AudioTools - Maple Help

AudioTools

Maple 2020 updates AudioTools with features that help you work with high precision audio, PCM WAV files, and more.

$\mathrm{restart}:$

$\mathrm{with}\left(\mathrm{AudioTools}\right):$

Read Part of an Audio File

You can now read part of an audio file with the new samples option for Read.

 ${\mathrm{violinNote_sub}}{≔}\left[\begin{array}{cc}{"Sample Rate"}& {44100}\\ {"File Format"}& {\mathrm{PCM}}\\ {"File Bit Depth"}& {16}\\ {"Channels"}& {2}\\ {"Samples/Channel"}& {59001}\\ {"Duration"}& {1.33789}{}{s}\end{array}\right]$ (1.1)



Fast Convolution of Audio and Convolution of Multi-Channel Audio

You can create many audio effects with convolution. For example, you can add reverb, or simulate how audio would sound in a specific room with its convolution with an impulse response.

For Maple 2020, AudioTools:-Convolution is significantly faster (for the default case) for those CPUs where the Intel IPP libraries can run optimized code.

Consider this violin note (to interact with the audio playback buttons below, open this page as a worksheet)

Read the kernel for the convolutiona "ding" sound.

Convolution of the violin note with the ding sound (on an i7-8650U processor, Maple 2019 takes 2.6 s, while Maple 2020 takes 0.02 s)

 ${0.079}$ (2.1)

$\mathrm{Preview}\left(\mathrm{violinNote_conv},\mathrm{output}=\mathrm{embed}\right)$

Moreover, AudioTools:-Convolution now supports multi-channel audio. For audio with M channels, the kernel can be specified as an M-column Matrix or Array. Each channel of the kernel is applied to the corresponding channel of the audio.

Floating-Point WAV Files

You can now create 32-bit and 64-bit WAV files.

 ${\mathrm{aud_float}}{≔}\left[\begin{array}{cc}{"Sample Rate"}& {11025}\\ {"File Format"}& {\mathrm{IEEE_FLOAT}}\\ {"File Bit Depth"}& {32}\\ {"Channels"}& {1}\\ {"Samples/Channel"}& {55125}\\ {"Duration"}& {5.00000}{}{s}\end{array}\right]$ (3.1)

$#\mathrm{Write}\left("aud_float.wav",\mathrm{aud_float}\right)\phantom{\rule[-0.0ex]{0.0em}{0.0ex}}$

High Sample Rates

You can now write audio files with sample rates of up to 232 - 1 Hz = 4.29 GHz.

 ${\mathrm{aud_high_sample_rate}}{≔}\left[\begin{array}{cc}{"Sample Rate"}& {2097152}\\ {"File Format"}& {\mathrm{PCM}}\\ {"File Bit Depth"}& {16}\\ {"Channels"}& {1}\\ {"Samples/Channel"}& {2097152}\\ {"Duration"}& {1.00000}{}{s}\end{array}\right]$ (4.1)

$#\mathrm{Write}\left("aud_high_sample_rate.wav",\mathrm{aud_high_sample_rate}\right)$

Efficient White Noise Generator

You can now quickly generate audio filled with white noise.

 ${\mathrm{aud_noise}}{≔}\left[\begin{array}{cc}{"Sample Rate"}& {44100}\\ {"File Format"}& {\mathrm{PCM}}\\ {"File Bit Depth"}& {16}\\ {"Channels"}& {1}\\ {"Samples/Channel"}& {44100}\\ {"Duration"}& {1.00000}{}{s}\end{array}\right]$ (5.1)

$\mathrm{Preview}\left(\mathrm{aud_noise},\mathrm{output}=\mathrm{embed}\right)$



Asymmetric Mapping from Internal Signal Values to External File

PCM audio is asymmetricthe highest possible value is not equal in magnitude to the lowest possible value. For example, 16-bit audio ranges in value from -32768 to +32767. This means that positive half-cycles of a waveform are compressed compared to negative ones.

AudioTools:-Write and AudioTools:-Read now offer new options to change the mapping of minimum and maximum values in the internal representation of an audio file to external values when written to a PCM WAV file. This now reflects the reality of working with PCM audio.

 ${\mathrm{aud_sym}}{≔}\left[\begin{array}{cc}{"Sample Rate"}& {44100}\\ {"File Format"}& {\mathrm{PCM}}\\ {"File Bit Depth"}& {16}\\ {"Channels"}& {1}\\ {"Samples/Channel"}& {1000}\\ {"Duration"}& {0.02268}{}{s}\end{array}\right]$ (6.1)

$\mathrm{min}\left(\mathrm{aud_sym}\right);\mathrm{max}\left(\mathrm{aud_sym}\right)$

 ${1.}$ (6.2)

$\mathrm{aud_path}≔\mathrm{FileTools}:-\mathrm{JoinPath}\left(\left[\mathrm{FileTools}:-\mathrm{TemporaryDirectory}\left(\right),"foo.wav"\right]\right)$

 ${\mathrm{aud_path}}{≔}{"C:\Users\skhan\AppData\Local\Temp\foo.wav"}$ (6.3)

 ${0.999969482421875}$ (6.4)