0% found this document useful (0 votes)
30 views

Code For Read Sound (.Wav) in Matlab: All 'Bass - Wav' 'Guita - Wav' 'Drum - Wav'

This Matlab code reads in three .wav audio files (bass, guitar, and drums), and demonstrates how to combine and manipulate the sound signals in four steps: 1) Playing each individual file, 2) Attempting a simple addition which fails due to different lengths, 3) Segmenting each to 3 seconds and adding successfully, 4) Increasing the amplitude of some signals to make them louder before combining and playing.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views

Code For Read Sound (.Wav) in Matlab: All 'Bass - Wav' 'Guita - Wav' 'Drum - Wav'

This Matlab code reads in three .wav audio files (bass, guitar, and drums), and demonstrates how to combine and manipulate the sound signals in four steps: 1) Playing each individual file, 2) Attempting a simple addition which fails due to different lengths, 3) Segmenting each to 3 seconds and adding successfully, 4) Increasing the amplitude of some signals to make them louder before combining and playing.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Code for read sound(.

wav) in Matlab

clear all;
%make sure that you have this 3 files in the same directory
[bass, fs1] = audioread('bass.wav');
[guita, fs2] = audioread('guita.wav');
[drum, fs3] = audioread('drum.wav');
%---------- step1, we can play the sound -------------
sound(bass, fs1); %listen to the sound
length(bass)/ fs1; %get the length of the sound in t(s)

%---------- step2, lets combine sound together --------


y=bass+guita+drum; % it will error since it has difference length

%-----------step3, we can take all signals only 3s each ----

drum_seg=drum(44100*1:44100*4);
bass_seg=bass(44100*1:44100*4);
guita_seg=guita(44100*1:44100*4);

y= drum_seg + bass_seg + guita_seg;


sound(y,44100); %listen to the sound with sampling rate 44,1khz

%-----------step4, you want to make some signals louder------


y_amp=drum_seg*2 + bass_seg*3 + guita_seg;
sound(y_amp,44100);

Note:
1. Please do it from one step to one step
2. If you run one step please put comment (%) for other steps
Ex. If you run step1, make sure that step2,step3,step4 are all place with comments (%) in
front.

You might also like