<< Chapter < Page | Chapter >> Page > |
There are many functions built into MATLAB. One that will be useful here is
fliplr
, which is a one step way of time reversing a signal. Try this with the bell sound.
Another function that we created for you is timescale.m , which you can use to speed up or slow down a signal. Download it and give it a try. Notice that it also changes the pitch of a sound -- why?
Download the function
fade.m , make sure you save it as
fade.m
. Start MATLAB, and go to the directory where you saved the function. You can see and change your current directory at the top of the MATLAB screen. Enter "help fade" at the MATLAB prompt. If you did everything correctly, you should see the help text (in the
.m
file) in response
to
help fade
. Notice that we've now added a new command to MATLAB
that can be used as if it were a built-in function.
Enter the following commands at the MATLAB prompt:
>>time = 0:.01:1;>>y = cos(time .* pi .* 25);>>plot(time, fade(y));
You can see in the plot that fade does indeed fade-out the cosine wave. You can use this function on audio signals as well.
level
(which is already in the parameter list for you in the function) to represent the strength of the fade as a decimal fraction. The function should make sure that the value is between 0 and 1.
for
loop for this. Inside the
for
loop you will need to concatenate sound signals. For example, if you have two vectors
x
and
y
, you can concatenate them like this:
>>x = [1 4 2 2 3];>>y = [5 8 3 9 0];>>x = [x y];
The first line of your function might look like this:
function [ out ] = repeat(in, N)
soundsc
function for a way to do this. What happens if you let the sounds go out of this range and you try to play them with the
sound
command?
type function_name
.In order to create a groove, you're going to need some instruments. The groove will be made up of some sound samples modified in any way you want and concatenated together to make one long sound vector. Use only the sound samples from the sound resources page.
wavwrite
command (Remember to specify the sample rate (Fs), which for the sounds on the resource page is 8000 Hz).Notification Switch
Would you like to follow the 'Continuous time linear systems laboratory (ee 235)' conversation and receive update notifications?