Clear Filters
Clear Filters

given a speech signal(.wav) file, we are required to plot cosine waves over it like cos(k1*x),cos(k2*x).I tried using dct function but to unable to proceedd

6 views (last 30 days)
clc; clear;
syms m;
syms n;
[x, fs] = audioread('sample.wav');
x = x(:, 1);
xlen = length(x);
subplot(311)
plot(x)
subplot(312)
t=[-xlen:0.01:xlen];
plot(cos(2*pi*t/xlen));
y=dct(x);
y1=y*cos(2*pi/xlen);
y2=idct(y1);
subplot(313)
plot(y2) % i am required to plot cos waves around the .wav file but unable to proceed

Answers (1)

Chandra
Chandra on 4 Apr 2022
Hi,
By multiplying the cosine signal over the sound signal we can get the required signal
Use the following code to generate the plot
//Matlab code
>>[x, fs] = audioread('sample.wav');
>>t = linspace(0,length(x),length(x)); % or we can use t =0:length(x)-1;
>>n = x'.*cos(2*pi*fs*t);%multiplication is done using dot multiplication, the frequency value
%can be used depending on user values
>>plot(n);

Categories

Find more on Audio I/O and Waveform Generation in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!