Plot Audio Wave in Time and Frequency domain by MATLAB

Tutorial #1

Jarvus
Audio Processing by MATLAB
2 min readMar 30, 2019

--

Download Source Code

MATLAB — File Exchange

Description

1. Plot signal wave in time or frequency domain
2. Choose x-axis as time or samples
3. Remove spectral energy under a value when show the spectrogram

Online Version

Online Analysis For Audio Time & Frequency Domain

Function

plotWave_YW(newFig, signal, fs, type, x_axis, name, removeFreq, frame)
  • Required Input Parameters
newFig      Create in a new figure window ( 0:No, 1:Yes )
signal Speech data
fs Sampling frequency (Hz)
type 'time' or 'freq'
  • Optional Input Parameters
x_axis      0: samples, 1: time
name Figure title
removeFreq Threshold for spectral energy
frame Frame size for spectrogram (ms)

Before plot the figure, read audio first.

[ clean, fs ] = audioread( 'sp10.wav' );

Example 1:

Show time domain with samples in x-axis.

plotWave_YW(1, clean, fs, 'time', 0, 'clean speech');

Example 2:

Show time domain with time in x-axis.

plotWave_YW(1, clean, fs, 'time', 1, 'clean speech');

Example 3:

Show frequency domain.

plotWave_YW(1, clean, fs, 'freq', 1, 'clean speech');

Example 4:

Show frequency domain but remove weak energy.

plotWave_YW(1, clean, fs, 'freq', 1, 'clean speech',0);

Example 5:

By using subplot.

figure;
subplot(2,1,1);
plotWave_YW(0, clean, fs, 'time', 1, 'clean speech');
subplot(2,1,2);
plotWave_YW(0, clean, fs, 'freq', 1, 'clean speech');

👉 Tutorial Outline 👈

--

--

Jarvus
Audio Processing by MATLAB

A diverse software developer, focus on Audio Processing, Deep learning and Blockchain.