Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

1 Sound Synthesis and Analysis Using MATLAB: 1.1 Resources

Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

DRAFT UNDER CONSTRUCTION 8/11/2004.

Sound synthesis and analysis using MATLAB


Write programs to produce interesting sounds. Use MATLAB to analyse and visualize sounds.

Aims:

1.1

Resources

For a basic introduction to digital sound and other useful links point your web browser at http://www.bath.ac.uk/~eespjl/MATLAB/sound.html

1.2

Adding sines waves

Dierent timbres can be created by summing sinusoidal waves of dierent frequencies, i , Use x(t) = i is the phase of the sine sin(i t + i )

1.3

Sound in MATLAB
% % % % % % CD sampling rate. quite a high note to sing Try higher than 1.0 to see what happens ! CD quality what difference does it make if you change this ? how long ?

Here is a simple program to construct and play a sine wav Fs =44100; f = 400; A = 1.0; bits= 16; phi= 0.0; len = .2;

% create an array with the times of the samples t = [0:Fs*len]/Fs; % now generate the wave form x = A*sin(t*2*pi*f + phi); % plot it plot(t,x); % play it sound(x,Fs); MATLAB Sound Assignment 1 PJL 2004-5

1.4

Types of synthesis

There are other ways of synthesing sounds. Additive. e.g. summing sinwaves or other sources Subttractive. e.g. source lters (Vocoder) FM frequency modulation x(t) = sin(w*t) w = w1 + sin(w2*t) Physical modelling e.g. M x(t) 2 x(t) +C + Kx(t) = f (t) t2 t

Wave table. (Store sound in arrays and play them). You could try some of these and compare the results.

1.5

Visualising sound

MATLAB has got facilities to plot the wave forms (plot). You can also look a the frequency content of the sound. Try out the specgram function. t = 0:1/1000:2; y = chirp(t,0,1,150); specgram(y,256,1000,256,250);

1.6

Things to do

Write a program to construct a wave form by summing sine waves. Write a program that generates a wave that starts with a frequency of 50Hz and changes to a frequency of 5000Hz in 1sec. Most natural sounds vary in loudness during time. Try modulating the amplitude of your sounds with an envelope (the envelope must change a a slower rate compared to the frequency of the tone.) e.g. x(t) = A(t)sin(wt) Better still modulate each harmonic with its own envelope. Analyse some of the sounds at

http://www.bath.ac.uk/~eespjl/MATLAB/samples/ Investigate the parameters for specgram what is the eect of using dierent window lengths.

MATLAB Sound Assignment

PJL 2004-5

Do you think you could reproduce any of these sounds using your synthesiser? Look at the spectrograms / wave forms of the speech fragments. Can you see any recognisable patterns ? Generate some sounds using the source lter technique. The original synthsisers (Moog) used source envelopes and lters to generate sounds. The source is a sound which usually has a high spectral content. You could use a square wave (what is the spectral content of a square wave). Matlab has square (type help square for more info). Noise is an interesting source because it contains all the frequencies. You can generate noise using MATLABs random number generator rand() Put your source through a lter (see Web resources page for links to some digital lters). You may need to read up on digital lters! Ask Dr PJL for some help if you are stuck. Changing the lter parameters during the note produces some interesting sounds (wah wah) ! Look at the spectral content of your sounds.

1.7

More ?

Try physical modelling, generate sounds by modelling the physics of the instrument.

MATLAB Sound Assignment

PJL 2004-5

You might also like