SlideShare a Scribd company logo
1 of 91
Download to read offline
It’s so quiet. 
Let’s make music. 
Loren Segal 
RubyConf 2014
@lsegal
WARNING: 
MUSIC 
AHEAD 
 
What is 
music 
even?
S + R = M 
ound 
hythm 
usic
S + R = M 
ound 
hythm 
usic
S + R = M 
ound 
uby 
usic
S + R = 
ound 
uby
S + R = 
ound 
uby 
This talk.
Sounddd beep. 
boop.
Analog 
Audio
Good Vibrations
Continuous Signal
DIGITAL 
AUDIO
 ? 
Discrete Signal (not continuous) 
187 
198 
-84 -84
not continuous, 
Just Samples
Discrete Signal (not continuous)
Discrete Signal (not continuous)
Discrete Signal (sampling)
Discrete Signal (sampling)
Discrete Signal (sampling)
Audio Vocabulary 
[Sample Rate]⇒ 
“Number of data values for 
each second of audio” 
Measured in Hertz (Hz)
20 Samples 
20.times.map {|i| (Math.sin(i) * 255).floor } 
[0, 214, 231, 35, -193, 
-245, -72, 167, 252, 105, 
-139, -255, -137, 107, 252, 
165, -74, -246, -192, 38]
Common Sample Rates 
44,100 Hz 
44,800 Hz 
96,000 Hz 
used by VHS, CDs
 
fundamental 
WAVES
SINE 
sin(x)
#math
f(t) = A sin(2πΩt) 
s
f(t) = A sin(2πΩt) 
Amplitude 
Frequency 
s
Amplitude 
Frequency* 
…ish
Audio Vocabulary 
[Amplitude]⇒ 
“Loudness” 
Measured in Decibels (dB)
Audio Vocabulary 
[Frequency]⇒ 
“Pitch” 
Measured in Hertz (Hz)
Ωs 
s = Sample Rate 
= e.g., 44100
Frequency?
Ω = 440 Hz [A3]
f(t) = sin(0.0627t)
SQUARE
f(t) = A ((Ωt) < 0.5 ? -1 : 1) s
Triangle
f(t) = A(1 - 4(Ωst - Ωst ))
SAW(tooth)
f(t) = 2A (Ωt - Ωt ) s s
NOISE
f(t) = A rand() 
rand() = some evenly distributed random fn
Show, 
Don’t Tell
Processing 
Audio
From 
synthesis
To 
analysis
Fourier 
Transform
It’s Complex
Literally.
SIDE VIEW OF f(t)!
thefouriertransform.com
“All waveforms, no matter what you 
scribble or observe in the universe, 
are actually just the sum of simple 
sinusoids of different frequencies.”
Analysis 
Applications
1. 
Pitch Detection: 
Instrument Tuner, 
Visualization
2. 
Wave Shaping: 
Equalizer, 
Autotune
Let’s see it.
RUBY 
TIME
ruby-audio $ gem install
libsndfile 
wrapper
Write a Sine Wave 
require 
'ruby-­‐audio' 
include 
RubyAudio 
sample_rate, 
len, 
freq, 
amp 
= 
48000, 
10, 
440, 
0.9 
buf 
= 
Buffer.float(sample_rate 
* 
len) 
buf.size.times 
do 
|i| 
sine_rad 
= 
((freq 
* 
Math::PI 
* 
2) 
/ 
sample_rate) 
* 
i 
buf[i] 
= 
amp 
* 
Math.sin(sine_rad) 
end 
format 
= 
FORMAT_WAV 
| 
FORMAT_PCM_16 
info 
= 
SoundInfo.new(channels: 
1, 
samplerate: 
sample_rate, 
format: 
format) 
snd 
= 
Sound.new('out.wav', 
'w', 
info) 
snd.write(buf) 
snd.close
easy_audio $ gem install
portaudio 
wrapper
Play a Sine Wave 
require 
'easy_audio' 
EasyAudio.easy_open(&EasyAudio::Waveforms::SINE) 
sleep 
2 
# 
play 
for 
2 
seconds
Increase Frequency / Time 
require 
'easy_audio' 
triangle 
= 
EasyAudio::Waveforms::TRIANGLE 
stream 
= 
EasyAudio.easy_open(freq: 
220, 
&triangle) 
Thread.new 
{ 
loop 
{ 
stream.frequency 
+= 
50; 
sleep 
0.2 
} 
} 
sleep 
3
Audio 
Plugins
VST
github.com/lsegal/ easy_vst
Embedding DRb - C++ 
AudioEffect* 
createEffectInstance(audioMasterCallback 
audioMaster) 
{ 
ruby_init(); 
ruby_init_loadpath(); 
rb_require("drb/drb"); 
rb_eval_string("DRb.start_service"); 
return 
new 
SampleVST(audioMaster); 
} 
// 
... 
server 
= 
rb_eval_string( 
"DRbObject.new_with_uri('druby://localhost:9090')");
Call Distributed Method 
rb_funcall( 
server, 
// 
the 
DRb 
object 
rb_intern(“process”), 
// 
the 
remote 
method 
1, 
// 
one 
argument 
INT2FIX(sampleFrames)); 
// 
number 
of 
samples
Fun 
Time!
Summary
1. Audio is samples!
2. Making waves! 
Sine, Square, 
Saw, Triangle, 
Noise
3. Fourier = analysis
4. Ruby libraries! 
ruby-audio 
easy_audio 
easy_vst
5. Music!
 
gnuu.org
github.com/lsegal
@lsegal
Thanks! Questions?

More Related Content

What's hot

Introduction of ToySynth
Introduction of ToySynthIntroduction of ToySynth
Introduction of ToySynthRansui Iso
 
Audio DSP in ReasonML
Audio DSP in ReasonMLAudio DSP in ReasonML
Audio DSP in ReasonMLKen Wheeler
 
USRP Implementation of Max-Min SNR Signal Energy based Spectrum Sensing Algor...
USRP Implementation of Max-Min SNR Signal Energy based Spectrum Sensing Algor...USRP Implementation of Max-Min SNR Signal Energy based Spectrum Sensing Algor...
USRP Implementation of Max-Min SNR Signal Energy based Spectrum Sensing Algor...T. E. BOGALE
 
Telecommunications: Motion Video
Telecommunications: Motion VideoTelecommunications: Motion Video
Telecommunications: Motion VideoNapier University
 
Forgent Inc. v. High-Tech Giants
Forgent Inc. v. High-Tech GiantsForgent Inc. v. High-Tech Giants
Forgent Inc. v. High-Tech GiantsVideoguy
 

What's hot (10)

Introduction of ToySynth
Introduction of ToySynthIntroduction of ToySynth
Introduction of ToySynth
 
Audio DSP in ReasonML
Audio DSP in ReasonMLAudio DSP in ReasonML
Audio DSP in ReasonML
 
USRP Implementation of Max-Min SNR Signal Energy based Spectrum Sensing Algor...
USRP Implementation of Max-Min SNR Signal Energy based Spectrum Sensing Algor...USRP Implementation of Max-Min SNR Signal Energy based Spectrum Sensing Algor...
USRP Implementation of Max-Min SNR Signal Energy based Spectrum Sensing Algor...
 
Lecture13
Lecture13Lecture13
Lecture13
 
Stream audio affects
Stream audio affectsStream audio affects
Stream audio affects
 
Lecture22
Lecture22Lecture22
Lecture22
 
Telecommunications: Motion Video
Telecommunications: Motion VideoTelecommunications: Motion Video
Telecommunications: Motion Video
 
Forgent Inc. v. High-Tech Giants
Forgent Inc. v. High-Tech GiantsForgent Inc. v. High-Tech Giants
Forgent Inc. v. High-Tech Giants
 
Ultrasonic with buzzer
Ultrasonic with buzzerUltrasonic with buzzer
Ultrasonic with buzzer
 
Presentazione
PresentazionePresentazione
Presentazione
 

Similar to It's so quiet. Let's make music.

noise removal in matlab
noise removal in matlabnoise removal in matlab
noise removal in matlabumarjamil10000
 
Fourier project presentation
Fourier project  presentationFourier project  presentation
Fourier project presentation志璿 楊
 
Vidyalankar final-essentials of communication systems
Vidyalankar final-essentials of communication systemsVidyalankar final-essentials of communication systems
Vidyalankar final-essentials of communication systemsanilkurhekar
 
Audio Signal Processing
Audio Signal Processing Audio Signal Processing
Audio Signal Processing Ahmed A. Arefin
 
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 Tuner
Digital TunerDigital Tuner
Digital Tunerplun
 
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
 
Beamforming and microphone arrays
Beamforming and microphone arraysBeamforming and microphone arrays
Beamforming and microphone arraysRamin Anushiravani
 
Audio Data Representation (NCGD009)
Audio Data Representation (NCGD009)Audio Data Representation (NCGD009)
Audio Data Representation (NCGD009)Adam Sporka
 
Tomas_IWAENC_keynote10.ppt
Tomas_IWAENC_keynote10.pptTomas_IWAENC_keynote10.ppt
Tomas_IWAENC_keynote10.pptRakesh Pogula
 
What Shazam doesn't want you to know
What Shazam doesn't want you to knowWhat Shazam doesn't want you to know
What Shazam doesn't want you to knowRoy van Rijn
 
Audio125 wk1-review-digital-audio-specs-and-acoustics
Audio125 wk1-review-digital-audio-specs-and-acousticsAudio125 wk1-review-digital-audio-specs-and-acoustics
Audio125 wk1-review-digital-audio-specs-and-acousticsRaffiel203
 
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
 
Digital Audio & Signal Processing (Elad Gariany)
Digital Audio & Signal Processing (Elad Gariany)Digital Audio & Signal Processing (Elad Gariany)
Digital Audio & Signal Processing (Elad Gariany)Ron Reiter
 
Chapter 02 audio recording - part i
Chapter 02   audio recording - part iChapter 02   audio recording - part i
Chapter 02 audio recording - part iNazihah Ahwan
 
Analog Communication fast mode material.pdf
Analog Communication fast mode material.pdfAnalog Communication fast mode material.pdf
Analog Communication fast mode material.pdfEngineering Funda
 

Similar to It's so quiet. Let's make music. (20)

noise removal in matlab
noise removal in matlabnoise removal in matlab
noise removal in matlab
 
Fourier project presentation
Fourier project  presentationFourier project  presentation
Fourier project presentation
 
Vidyalankar final-essentials of communication systems
Vidyalankar final-essentials of communication systemsVidyalankar final-essentials of communication systems
Vidyalankar final-essentials of communication systems
 
Audio Signal Processing
Audio Signal Processing Audio Signal Processing
Audio Signal Processing
 
Polyanna manual
Polyanna manualPolyanna manual
Polyanna manual
 
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
 
example based audio editing
example based audio editingexample based audio editing
example based audio editing
 
Digital Tuner
Digital TunerDigital Tuner
Digital Tuner
 
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
 
Beamforming and microphone arrays
Beamforming and microphone arraysBeamforming and microphone arrays
Beamforming and microphone arrays
 
Audio Data Representation (NCGD009)
Audio Data Representation (NCGD009)Audio Data Representation (NCGD009)
Audio Data Representation (NCGD009)
 
Tomas_IWAENC_keynote10.ppt
Tomas_IWAENC_keynote10.pptTomas_IWAENC_keynote10.ppt
Tomas_IWAENC_keynote10.ppt
 
DJ Workshop v.0.2b
DJ Workshop v.0.2bDJ Workshop v.0.2b
DJ Workshop v.0.2b
 
What Shazam doesn't want you to know
What Shazam doesn't want you to knowWhat Shazam doesn't want you to know
What Shazam doesn't want you to know
 
Session3
Session3Session3
Session3
 
Audio125 wk1-review-digital-audio-specs-and-acoustics
Audio125 wk1-review-digital-audio-specs-and-acousticsAudio125 wk1-review-digital-audio-specs-and-acoustics
Audio125 wk1-review-digital-audio-specs-and-acoustics
 
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
 
Digital Audio & Signal Processing (Elad Gariany)
Digital Audio & Signal Processing (Elad Gariany)Digital Audio & Signal Processing (Elad Gariany)
Digital Audio & Signal Processing (Elad Gariany)
 
Chapter 02 audio recording - part i
Chapter 02   audio recording - part iChapter 02   audio recording - part i
Chapter 02 audio recording - part i
 
Analog Communication fast mode material.pdf
Analog Communication fast mode material.pdfAnalog Communication fast mode material.pdf
Analog Communication fast mode material.pdf
 

Recently uploaded

Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 

Recently uploaded (20)

Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 

It's so quiet. Let's make music.