SlideShare ist ein Scribd-Unternehmen logo
1 von 14
Sound in Matlab & Cogent
Tobias Overath
Sound
• sound = pressure wave
)2sin()( φπ +⋅⋅⋅= tfAty
Overview
• play sound in Matlab/Cogent
• create a sound
• things you can do with sound:
– louder/quieter
– higher/lower
– combine sounds
• compose & play a melody
Playing a sound in Matlab
• load wavfile
– y = wavread(‘filename.wav’);
• play wavfile
– sound(y,Fs)
• if unsure which Fs
– [y, Fs, nbits, opts] = wavread(‘filename.wav’)
• write to disk
– wavwrite(y,Fs,’filename.wav’)
Playing a sound in Cogent
• config_sound(nchannels,nbits,Fs,nbuffs)
– nchannels: 1 = mono, 2 = stereo
– nbits: e.g. 16
– Fs: sampling frequency (e.g. 44100)
– nbuffs: number of buffers
• wavfilename = [‘filename.wav’];
• loadsound(wavfilename, buffer number)
• playsound(buffer number)
• waitsound(buffer number)
– otherwise next command will be executed
immediately)
creating a sound in Matlab
• Fs = 44100;
• t = [0:1/Fs:1-1/Fs]; %1 second, length 44100
• freq = 400; % Hz
• f1 = sin(2*pi*freq*t);
– sound(f1,Fs)
• f2 = sin(2*pi*(2*freq)*t);
– sound(f2,Fs)
• period: 1/freq (*Fs)
• figure(1);plot(f1)
• figure(2);plot(f1(1:round(1/freq*Fs+1)))
• play consecutively
– f12 = [f1 f2];
– sound(f12,Fs)
• play together/superimposed:
– f_12 = [f1+f2];
• or:
– f_12 = sum([f1;f2]);
– sound(f_12,Fs);
making a sound louder/quieter
• f = sin(2*pi*freq*t)
– standardise sound
• f = f-mean(f);
• f = f/std(f);
• scale sound
– amplitude = .2;
– f = amplitude * f;
• 10^±0.5 for every 10dB
– e.g. 10^1.0  20 dB louder
– e.g. 10^-1.5  30 dB quieter
• do not be put off by warning ‘data clipped’ message. Wavwrite
needs an input vector in the range –1 to +1, else it will clip. The
warning means that you have sounds that are 1 or –1 but the
clipping will leave them unaltered
create noise
• y = .2*randn(1,Fs);
• sound(y,Fs)
FM sweep
• f = chirp(t1,f1,t2,f2);
– t1 = vector t = [0:1/Fs:1-1/fs];
– f1 = initial frequency
– f2 = final frequency
– t2 = time at which f2 is reached
• f = chirp(t,freq,1,2*freq);
• sound(f,Fs)
AM sound
• freq = 400; % carrier frequency
• fm = 10; % modulation frequency
• f_c = sin(2*pi*freq*t);
• f_m = sin(2*pi*fm*t);
• f_mod = [f_c .* f_m];
• sound(f_mod,Fs)
square wave
• x = square(t,duty cycle)
– duty cycle = % of signal that’s positive
• freq = 10;
• fsq = square(2*pi*freq*t);
• fsq = square(2*pi*freq*t, 80);
plot signal
• plot(t,f)
scale
• 12-split equitempered octave
– f(n) = sin(2*pi*freq*2^(n/12)*t)
– for example
n=[0:12]; % 12 semitones
for i=1:length(n)
f(i,:) = sin(2*pi*freq*2^(n(i)/12)*t);
end
fs=[];
for i=1:13
fs = [fs f(i,:)];
end
fs=fs-mean(fs);
fs=fs/std(fs);
fs=.2*fs;
sound(fs,Fs)

Weitere ähnliche Inhalte

Was ist angesagt?

Digital Signal Processing in Hadoop
Digital Signal Processing in HadoopDigital Signal Processing in Hadoop
Digital Signal Processing in HadoopAdam Laiacano
 
Natural language processing open seminar For Tensorflow usage
Natural language processing open seminar For Tensorflow usageNatural language processing open seminar For Tensorflow usage
Natural language processing open seminar For Tensorflow usagehyunyoung Lee
 
A Simple Communication System Design Lab #4 with MATLAB Simulink
A Simple Communication System Design Lab #4 with MATLAB SimulinkA Simple Communication System Design Lab #4 with MATLAB Simulink
A Simple Communication System Design Lab #4 with MATLAB SimulinkJaewook. Kang
 
Introduction to TensorFlow 2
Introduction to TensorFlow 2Introduction to TensorFlow 2
Introduction to TensorFlow 2Oswald Campesato
 
Statistical inference for (Python) Data Analysis. An introduction.
Statistical inference for (Python) Data Analysis. An introduction.Statistical inference for (Python) Data Analysis. An introduction.
Statistical inference for (Python) Data Analysis. An introduction.Piotr Milanowski
 
3 instantiating an object in c# (1)
3  instantiating an object in c# (1)3  instantiating an object in c# (1)
3 instantiating an object in c# (1)abdullah619
 
A Simple Communication System Design Lab #3 with MATLAB Simulink
A Simple Communication System Design Lab #3 with MATLAB SimulinkA Simple Communication System Design Lab #3 with MATLAB Simulink
A Simple Communication System Design Lab #3 with MATLAB SimulinkJaewook. Kang
 
Introduction to TensorFlow 2.0
Introduction to TensorFlow 2.0Introduction to TensorFlow 2.0
Introduction to TensorFlow 2.0Databricks
 
TensorFlow example for AI Ukraine2016
TensorFlow example  for AI Ukraine2016TensorFlow example  for AI Ukraine2016
TensorFlow example for AI Ukraine2016Andrii Babii
 
機械学習によるデータ分析 実践編
機械学習によるデータ分析 実践編機械学習によるデータ分析 実践編
機械学習によるデータ分析 実践編Ryota Kamoshida
 
Dsp gcu lab11
Dsp gcu lab11Dsp gcu lab11
Dsp gcu lab11Jannat41
 
The Joy of SciPy
The Joy of SciPyThe Joy of SciPy
The Joy of SciPykammeyer
 
Introduction to TensorFlow, by Machine Learning at Berkeley
Introduction to TensorFlow, by Machine Learning at BerkeleyIntroduction to TensorFlow, by Machine Learning at Berkeley
Introduction to TensorFlow, by Machine Learning at BerkeleyTed Xiao
 
Project session part_I
Project  session part_IProject  session part_I
Project session part_IMina Yonan
 
Machine Learning - Introduction to Tensorflow
Machine Learning - Introduction to TensorflowMachine Learning - Introduction to Tensorflow
Machine Learning - Introduction to TensorflowAndrew Ferlitsch
 

Was ist angesagt? (20)

Digital Signal Processing in Hadoop
Digital Signal Processing in HadoopDigital Signal Processing in Hadoop
Digital Signal Processing in Hadoop
 
Natural language processing open seminar For Tensorflow usage
Natural language processing open seminar For Tensorflow usageNatural language processing open seminar For Tensorflow usage
Natural language processing open seminar For Tensorflow usage
 
H2 o berkeleydltf
H2 o berkeleydltfH2 o berkeleydltf
H2 o berkeleydltf
 
A Simple Communication System Design Lab #4 with MATLAB Simulink
A Simple Communication System Design Lab #4 with MATLAB SimulinkA Simple Communication System Design Lab #4 with MATLAB Simulink
A Simple Communication System Design Lab #4 with MATLAB Simulink
 
Introduction to TensorFlow 2
Introduction to TensorFlow 2Introduction to TensorFlow 2
Introduction to TensorFlow 2
 
Statistical inference for (Python) Data Analysis. An introduction.
Statistical inference for (Python) Data Analysis. An introduction.Statistical inference for (Python) Data Analysis. An introduction.
Statistical inference for (Python) Data Analysis. An introduction.
 
Fourier image
Fourier imageFourier image
Fourier image
 
3 instantiating an object in c# (1)
3  instantiating an object in c# (1)3  instantiating an object in c# (1)
3 instantiating an object in c# (1)
 
A Simple Communication System Design Lab #3 with MATLAB Simulink
A Simple Communication System Design Lab #3 with MATLAB SimulinkA Simple Communication System Design Lab #3 with MATLAB Simulink
A Simple Communication System Design Lab #3 with MATLAB Simulink
 
Introduction to TensorFlow 2.0
Introduction to TensorFlow 2.0Introduction to TensorFlow 2.0
Introduction to TensorFlow 2.0
 
About RNN
About RNNAbout RNN
About RNN
 
About RNN
About RNNAbout RNN
About RNN
 
TensorFlow example for AI Ukraine2016
TensorFlow example  for AI Ukraine2016TensorFlow example  for AI Ukraine2016
TensorFlow example for AI Ukraine2016
 
機械学習によるデータ分析 実践編
機械学習によるデータ分析 実践編機械学習によるデータ分析 実践編
機械学習によるデータ分析 実践編
 
Dsp gcu lab11
Dsp gcu lab11Dsp gcu lab11
Dsp gcu lab11
 
The Joy of SciPy
The Joy of SciPyThe Joy of SciPy
The Joy of SciPy
 
Music as data
Music as dataMusic as data
Music as data
 
Introduction to TensorFlow, by Machine Learning at Berkeley
Introduction to TensorFlow, by Machine Learning at BerkeleyIntroduction to TensorFlow, by Machine Learning at Berkeley
Introduction to TensorFlow, by Machine Learning at Berkeley
 
Project session part_I
Project  session part_IProject  session part_I
Project session part_I
 
Machine Learning - Introduction to Tensorflow
Machine Learning - Introduction to TensorflowMachine Learning - Introduction to Tensorflow
Machine Learning - Introduction to Tensorflow
 

Ähnlich wie Sound Analysis and Synthesis in Matlab and Cogent

It's so quiet. Let's make music.
It's so quiet. Let's make music.It's so quiet. Let's make music.
It's so quiet. Let's make music.Loren Segal
 
orfanidis-solutions-book-2nd-edition-pdf
orfanidis-solutions-book-2nd-edition-pdforfanidis-solutions-book-2nd-edition-pdf
orfanidis-solutions-book-2nd-edition-pdfmavim69186
 
Introduction to Signal Processing Orfanidis [Solution Manual]
Introduction to Signal Processing Orfanidis [Solution Manual]Introduction to Signal Processing Orfanidis [Solution Manual]
Introduction to Signal Processing Orfanidis [Solution Manual]slyhamm
 
Lectures on digital communication by prof.dr.a.abbas
Lectures on digital communication by prof.dr.a.abbasLectures on digital communication by prof.dr.a.abbas
Lectures on digital communication by prof.dr.a.abbasProfArshadAbbas
 
Lectures on Digital Dommunication by Prof.Dr.A.Abbas Khan
Lectures on Digital Dommunication by Prof.Dr.A.Abbas KhanLectures on Digital Dommunication by Prof.Dr.A.Abbas Khan
Lectures on Digital Dommunication by Prof.Dr.A.Abbas KhanProfArshadAbbas
 
The method of comparing two audio files
The method of comparing two audio filesThe method of comparing two audio files
The method of comparing two audio filesMinh Anh Nguyen
 
NoiseGen at Arlington Ruby 2012
NoiseGen at Arlington Ruby 2012NoiseGen at Arlington Ruby 2012
NoiseGen at Arlington Ruby 2012awwaiid
 
12 Narrow_band_and_Wide_band_FM.pdf
12 Narrow_band_and_Wide_band_FM.pdf12 Narrow_band_and_Wide_band_FM.pdf
12 Narrow_band_and_Wide_band_FM.pdfMohamedshabana38
 
The method of comparing two audio files
The method of comparing two audio filesThe method of comparing two audio files
The method of comparing two audio filesMinh Anh Nguyen
 
Digital signal processing through speech, hearing, and Python
Digital signal processing through speech, hearing, and PythonDigital signal processing through speech, hearing, and Python
Digital signal processing through speech, hearing, and PythonMel Chua
 
Lecture 09 interference for sound waves. beats. doppler effect
Lecture 09   interference for sound waves. beats. doppler effectLecture 09   interference for sound waves. beats. doppler effect
Lecture 09 interference for sound waves. beats. doppler effectAlbania Energy Association
 

Ähnlich wie Sound Analysis and Synthesis in Matlab and Cogent (18)

It's so quiet. Let's make music.
It's so quiet. Let's make music.It's so quiet. Let's make music.
It's so quiet. Let's make music.
 
lec-4.ppt
lec-4.pptlec-4.ppt
lec-4.ppt
 
lec-4.ppt
lec-4.pptlec-4.ppt
lec-4.ppt
 
lec-4.ppt
lec-4.pptlec-4.ppt
lec-4.ppt
 
orfanidis-solutions-book-2nd-edition-pdf
orfanidis-solutions-book-2nd-edition-pdforfanidis-solutions-book-2nd-edition-pdf
orfanidis-solutions-book-2nd-edition-pdf
 
Introduction to Signal Processing Orfanidis [Solution Manual]
Introduction to Signal Processing Orfanidis [Solution Manual]Introduction to Signal Processing Orfanidis [Solution Manual]
Introduction to Signal Processing Orfanidis [Solution Manual]
 
Lectures on digital communication by prof.dr.a.abbas
Lectures on digital communication by prof.dr.a.abbasLectures on digital communication by prof.dr.a.abbas
Lectures on digital communication by prof.dr.a.abbas
 
Lectures on Digital Dommunication by Prof.Dr.A.Abbas Khan
Lectures on Digital Dommunication by Prof.Dr.A.Abbas KhanLectures on Digital Dommunication by Prof.Dr.A.Abbas Khan
Lectures on Digital Dommunication by Prof.Dr.A.Abbas Khan
 
The method of comparing two audio files
The method of comparing two audio filesThe method of comparing two audio files
The method of comparing two audio files
 
NoiseGen at Arlington Ruby 2012
NoiseGen at Arlington Ruby 2012NoiseGen at Arlington Ruby 2012
NoiseGen at Arlington Ruby 2012
 
12 Narrow_band_and_Wide_band_FM.pdf
12 Narrow_band_and_Wide_band_FM.pdf12 Narrow_band_and_Wide_band_FM.pdf
12 Narrow_band_and_Wide_band_FM.pdf
 
The method of comparing two audio files
The method of comparing two audio filesThe method of comparing two audio files
The method of comparing two audio files
 
Digital signal processing through speech, hearing, and Python
Digital signal processing through speech, hearing, and PythonDigital signal processing through speech, hearing, and Python
Digital signal processing through speech, hearing, and Python
 
Lab Activity
Lab ActivityLab Activity
Lab Activity
 
Lecture 09 interference for sound waves. beats. doppler effect
Lecture 09   interference for sound waves. beats. doppler effectLecture 09   interference for sound waves. beats. doppler effect
Lecture 09 interference for sound waves. beats. doppler effect
 
Lecture22
Lecture22Lecture22
Lecture22
 
Lecture22
Lecture22Lecture22
Lecture22
 
Polyanna manual
Polyanna manualPolyanna manual
Polyanna manual
 

Mehr von umarjamil10000

Mehr von umarjamil10000 (8)

Galvanometer,wheatstone bridge,ohm law,
Galvanometer,wheatstone bridge,ohm  law,Galvanometer,wheatstone bridge,ohm  law,
Galvanometer,wheatstone bridge,ohm law,
 
Mechatronics, Embedded System,
Mechatronics, Embedded System,Mechatronics, Embedded System,
Mechatronics, Embedded System,
 
Electric Field
Electric FieldElectric Field
Electric Field
 
Image denoising
Image denoising Image denoising
Image denoising
 
Coding verilog
Coding verilogCoding verilog
Coding verilog
 
Matlab dsp examples
Matlab dsp examplesMatlab dsp examples
Matlab dsp examples
 
Pm project
Pm projectPm project
Pm project
 
Mechatronics systems
Mechatronics systemsMechatronics systems
Mechatronics systems
 

Kürzlich hochgeladen

4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptxmary850239
 
Indexing Structures in Database Management system.pdf
Indexing Structures in Database Management system.pdfIndexing Structures in Database Management system.pdf
Indexing Structures in Database Management system.pdfChristalin Nelson
 
4.11.24 Poverty and Inequality in America.pptx
4.11.24 Poverty and Inequality in America.pptx4.11.24 Poverty and Inequality in America.pptx
4.11.24 Poverty and Inequality in America.pptxmary850239
 
Oppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and FilmOppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and FilmStan Meyer
 
Narcotic and Non Narcotic Analgesic..pdf
Narcotic and Non Narcotic Analgesic..pdfNarcotic and Non Narcotic Analgesic..pdf
Narcotic and Non Narcotic Analgesic..pdfPrerana Jadhav
 
Active Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdfActive Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdfPatidar M
 
How to Make a Duplicate of Your Odoo 17 Database
How to Make a Duplicate of Your Odoo 17 DatabaseHow to Make a Duplicate of Your Odoo 17 Database
How to Make a Duplicate of Your Odoo 17 DatabaseCeline George
 
CHEST Proprioceptive neuromuscular facilitation.pptx
CHEST Proprioceptive neuromuscular facilitation.pptxCHEST Proprioceptive neuromuscular facilitation.pptx
CHEST Proprioceptive neuromuscular facilitation.pptxAneriPatwari
 
Team Lead Succeed – Helping you and your team achieve high-performance teamwo...
Team Lead Succeed – Helping you and your team achieve high-performance teamwo...Team Lead Succeed – Helping you and your team achieve high-performance teamwo...
Team Lead Succeed – Helping you and your team achieve high-performance teamwo...Association for Project Management
 
Scientific Writing :Research Discourse
Scientific  Writing :Research  DiscourseScientific  Writing :Research  Discourse
Scientific Writing :Research DiscourseAnita GoswamiGiri
 
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptx
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptxDecoding the Tweet _ Practical Criticism in the Age of Hashtag.pptx
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptxDhatriParmar
 
Congestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentationCongestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentationdeepaannamalai16
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptxmary850239
 
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...Nguyen Thanh Tu Collection
 
Sulphonamides, mechanisms and their uses
Sulphonamides, mechanisms and their usesSulphonamides, mechanisms and their uses
Sulphonamides, mechanisms and their usesVijayaLaxmi84
 
ClimART Action | eTwinning Project
ClimART Action    |    eTwinning ProjectClimART Action    |    eTwinning Project
ClimART Action | eTwinning Projectjordimapav
 
CLASSIFICATION OF ANTI - CANCER DRUGS.pptx
CLASSIFICATION OF ANTI - CANCER DRUGS.pptxCLASSIFICATION OF ANTI - CANCER DRUGS.pptx
CLASSIFICATION OF ANTI - CANCER DRUGS.pptxAnupam32727
 
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...DhatriParmar
 

Kürzlich hochgeladen (20)

4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx
 
Indexing Structures in Database Management system.pdf
Indexing Structures in Database Management system.pdfIndexing Structures in Database Management system.pdf
Indexing Structures in Database Management system.pdf
 
4.11.24 Poverty and Inequality in America.pptx
4.11.24 Poverty and Inequality in America.pptx4.11.24 Poverty and Inequality in America.pptx
4.11.24 Poverty and Inequality in America.pptx
 
Oppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and FilmOppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and Film
 
Narcotic and Non Narcotic Analgesic..pdf
Narcotic and Non Narcotic Analgesic..pdfNarcotic and Non Narcotic Analgesic..pdf
Narcotic and Non Narcotic Analgesic..pdf
 
Active Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdfActive Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdf
 
How to Make a Duplicate of Your Odoo 17 Database
How to Make a Duplicate of Your Odoo 17 DatabaseHow to Make a Duplicate of Your Odoo 17 Database
How to Make a Duplicate of Your Odoo 17 Database
 
CHEST Proprioceptive neuromuscular facilitation.pptx
CHEST Proprioceptive neuromuscular facilitation.pptxCHEST Proprioceptive neuromuscular facilitation.pptx
CHEST Proprioceptive neuromuscular facilitation.pptx
 
Team Lead Succeed – Helping you and your team achieve high-performance teamwo...
Team Lead Succeed – Helping you and your team achieve high-performance teamwo...Team Lead Succeed – Helping you and your team achieve high-performance teamwo...
Team Lead Succeed – Helping you and your team achieve high-performance teamwo...
 
Paradigm shift in nursing research by RS MEHTA
Paradigm shift in nursing research by RS MEHTAParadigm shift in nursing research by RS MEHTA
Paradigm shift in nursing research by RS MEHTA
 
Scientific Writing :Research Discourse
Scientific  Writing :Research  DiscourseScientific  Writing :Research  Discourse
Scientific Writing :Research Discourse
 
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptx
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptxDecoding the Tweet _ Practical Criticism in the Age of Hashtag.pptx
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptx
 
Congestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentationCongestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentation
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx
 
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
 
INCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptx
INCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptxINCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptx
INCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptx
 
Sulphonamides, mechanisms and their uses
Sulphonamides, mechanisms and their usesSulphonamides, mechanisms and their uses
Sulphonamides, mechanisms and their uses
 
ClimART Action | eTwinning Project
ClimART Action    |    eTwinning ProjectClimART Action    |    eTwinning Project
ClimART Action | eTwinning Project
 
CLASSIFICATION OF ANTI - CANCER DRUGS.pptx
CLASSIFICATION OF ANTI - CANCER DRUGS.pptxCLASSIFICATION OF ANTI - CANCER DRUGS.pptx
CLASSIFICATION OF ANTI - CANCER DRUGS.pptx
 
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
 

Sound Analysis and Synthesis in Matlab and Cogent

  • 1. Sound in Matlab & Cogent Tobias Overath
  • 2. Sound • sound = pressure wave )2sin()( φπ +⋅⋅⋅= tfAty
  • 3. Overview • play sound in Matlab/Cogent • create a sound • things you can do with sound: – louder/quieter – higher/lower – combine sounds • compose & play a melody
  • 4. Playing a sound in Matlab • load wavfile – y = wavread(‘filename.wav’); • play wavfile – sound(y,Fs) • if unsure which Fs – [y, Fs, nbits, opts] = wavread(‘filename.wav’) • write to disk – wavwrite(y,Fs,’filename.wav’)
  • 5. Playing a sound in Cogent • config_sound(nchannels,nbits,Fs,nbuffs) – nchannels: 1 = mono, 2 = stereo – nbits: e.g. 16 – Fs: sampling frequency (e.g. 44100) – nbuffs: number of buffers • wavfilename = [‘filename.wav’]; • loadsound(wavfilename, buffer number) • playsound(buffer number) • waitsound(buffer number) – otherwise next command will be executed immediately)
  • 6. creating a sound in Matlab • Fs = 44100; • t = [0:1/Fs:1-1/Fs]; %1 second, length 44100 • freq = 400; % Hz • f1 = sin(2*pi*freq*t); – sound(f1,Fs) • f2 = sin(2*pi*(2*freq)*t); – sound(f2,Fs) • period: 1/freq (*Fs) • figure(1);plot(f1) • figure(2);plot(f1(1:round(1/freq*Fs+1)))
  • 7. • play consecutively – f12 = [f1 f2]; – sound(f12,Fs) • play together/superimposed: – f_12 = [f1+f2]; • or: – f_12 = sum([f1;f2]); – sound(f_12,Fs);
  • 8. making a sound louder/quieter • f = sin(2*pi*freq*t) – standardise sound • f = f-mean(f); • f = f/std(f); • scale sound – amplitude = .2; – f = amplitude * f; • 10^±0.5 for every 10dB – e.g. 10^1.0  20 dB louder – e.g. 10^-1.5  30 dB quieter • do not be put off by warning ‘data clipped’ message. Wavwrite needs an input vector in the range –1 to +1, else it will clip. The warning means that you have sounds that are 1 or –1 but the clipping will leave them unaltered
  • 9. create noise • y = .2*randn(1,Fs); • sound(y,Fs)
  • 10. FM sweep • f = chirp(t1,f1,t2,f2); – t1 = vector t = [0:1/Fs:1-1/fs]; – f1 = initial frequency – f2 = final frequency – t2 = time at which f2 is reached • f = chirp(t,freq,1,2*freq); • sound(f,Fs)
  • 11. AM sound • freq = 400; % carrier frequency • fm = 10; % modulation frequency • f_c = sin(2*pi*freq*t); • f_m = sin(2*pi*fm*t); • f_mod = [f_c .* f_m]; • sound(f_mod,Fs)
  • 12. square wave • x = square(t,duty cycle) – duty cycle = % of signal that’s positive • freq = 10; • fsq = square(2*pi*freq*t); • fsq = square(2*pi*freq*t, 80);
  • 14. scale • 12-split equitempered octave – f(n) = sin(2*pi*freq*2^(n/12)*t) – for example n=[0:12]; % 12 semitones for i=1:length(n) f(i,:) = sin(2*pi*freq*2^(n(i)/12)*t); end fs=[]; for i=1:13 fs = [fs f(i,:)]; end fs=fs-mean(fs); fs=fs/std(fs); fs=.2*fs; sound(fs,Fs)