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?

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
 

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 noise removal in matlab

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
Mohamedshabana38
 

Ähnlich wie noise removal in matlab (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 (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

1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
QucHHunhnh
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
negromaestrong
 

Kürzlich hochgeladen (20)

2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural ResourcesEnergy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
Role Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptxRole Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptx
 

noise removal in matlab

  • 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)