MATLAB: Help me pls about the homework

homework

Firtly, sorry for my bad english. I want to write a program that has 20 seconds sound (called x) and program will choose 1 sec a part of sound randomly (called y) and will say us this 1 sec part is which part of sound. How can i write this fuction related to x and y ? Then we will add a noise to y. what is the differences between with noise and without noise? Thanks!

Best Answer

Here's a start:
% Read in standard MATLAB demo sound:
filename = 'guitartune.wav';
[y,Fs] = audioread(filename,'native');
whos y
% Find starting point for the 1 second chunk.
randomStartingIndex = randi(length(y) - Fs)
% Extract a 1 second chunk.
yExtracted = y(........
% Add noise to that chunk:
yNoisy = yExtracted + amplitude * rand(......
% Play the sound:
sound(yNoisy);
I trust you can finish it.