plotting pre-emphasis

Hello,
I am trying to plot the signal before and after the pre emphasis filter but I'm getting error "Dot indexing is not supported for variables of this type."
Any suggestions?
The full code:
waveFile='whatFood.wav';
au=myAudioRead(waveFile); y=au.signal; fs=au.fs
a=0.95;
y2 = filter([1, -a], 1, y);
time=(1:length(y))/fs;
au2=au; au2.signal=y2;
myAudioWrite(au2, 'whatFood_preEmphasis.wav');
subplot(2,1,1);
plot(time, y);
title('Original wave: s(n)');
subplot(2,1,2);
plot(time, y2);
title(sprintf('After pre-emphasis: s_2(n)=s(n)-a*s(n-1), a=%f', a));
subplot(2,1,1);
set(gca, 'unit', 'pixel');
axisPos=get(gca, 'position');
uicontrol('string', 'Play', 'position', [axisPos(1:2), 60, 20], 'callback', 'sound(y, fs)');
subplot(2,1,2);
set(gca, 'unit', 'pixel');
axisPos=get(gca, 'position');
uicontrol('string', 'Play', 'position', [axisPos(1:2), 60, 20], 'callback', 'sound(y2, fs)');

Risposte (2)

Image Analyst
Image Analyst il 25 Dic 2019
Why are you using those functions instead of the built-in ones? The code below works using the built-in functions:
waveFile='guitartune.wav';
[y, fs] = audioread(waveFile);
% [y, fs] = myAudioRead(waveFile);
% y=au.signal;
% fs=au.fs
a=0.95;
y2 = filter([1, -a], 1, y);
time=(1:length(y))/fs;
% au2=au;
% au2.signal=y2;
% myAudioWrite(au2, 'whatFood_preEmphasis.wav');
audiowrite('whatFood_preEmphasis.wav', y2, fs);
soundsc(y, fs);
subplot(2,1,1);
plot(time, y);
grid on;
title('Original wave: s(n)');
subplot(2,1,2);
plot(time, y2);
title(sprintf('After pre-emphasis: s_2(n)=s(n)-a*s(n-1), a=%f', a));
subplot(2,1,1);
set(gca, 'unit', 'pixel');
axisPos=get(gca, 'position');
uicontrol('string', 'Play', 'position', [axisPos(1:2), 60, 20], 'callback', 'sound(y, fs)');
subplot(2,1,2);
set(gca, 'unit', 'pixel');
axisPos=get(gca, 'position');
uicontrol('string', 'Play', 'position', [axisPos(1:2), 60, 20], 'callback', 'sound(y2, fs)');
grid on;
0000 Screenshot.png

3 Commenti

SAF
SAF il 25 Dic 2019
Thnak you so much for you help, i could not find the code for the built in one. tbh im not sure how to find it. im also looking for a function to apply hamming window on wav file and plot the outout, any idea how?
You could try to edit it
>> edit audioread.m
though I don't know why you need the source code for those built-in functions.
I'm not exactly sure if you want a sliding hamming window or one that covers the whole waveform. Please give the formula (so I don't have to look it up).
SAF
SAF il 25 Dic 2019
im looking for the one that covers the whole waveform, sorry i cant find it because its my first time using matlab.
also the code above worked thank you. may i ask how do i find built in codes to use in the future?

Accedi per commentare.

Star Strider
Star Strider il 25 Dic 2019

0 voti

I looked at your filter, and note that it is not actually doing any filtering. The output is essentially the same as the input, although with a 0.4455 dB attenuation.
To design a FIR filter that automatically uses a Hamming wndow, use the fir1 function.
You can also use the designfilt function.

Categorie

Scopri di più su Simulation, Tuning, and Visualization in Centro assistenza e File Exchange

Richiesto:

SAF
il 25 Dic 2019

Risposto:

il 25 Dic 2019

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by