0

I am doing a mp3 decoder project and I have built a function to decode a song in mp3 format:

function [PCM_output,frequency] = decode(mp3song)

At the end of the code, I am adding a few lines to plot the PCM waveform:

t=0:0.01:120; 
plot(t,PCM_output);
title('PCM waveform');

But it shows error:

Vectors must be the same lengths.

How to solve the error? Besides, is it possible to output the decoded song in PCM format?

Additional Question: I want to compare the mp3 and PCM output as shown in the Figures below: MP3 - Amplitude vs Time

PCM - Amplitude vs Time

Why does the PCM has two output overlay together? Is it because of the left and right channel at the output?

Ralph
  • 19
  • 7

1 Answers1

0

If you try to plot your sound wave, you just need your t vector to be the same length as your PCM_output. So, instead of t=0:0.01:120 you need

t=linspace(0,120,length(PCM_output(1,:)));
brainkz
  • 1,335
  • 10
  • 16