![Page 1: Phun With Sound Basic Concepts For Hardware (and other) Hackers](https://reader036.vdocument.in/reader036/viewer/2022062322/56649cb95503460f9497fbd9/html5/thumbnails/1.jpg)
Phun With Sound
Basic ConceptsFor
Hardware (and other) Hackers
![Page 2: Phun With Sound Basic Concepts For Hardware (and other) Hackers](https://reader036.vdocument.in/reader036/viewer/2022062322/56649cb95503460f9497fbd9/html5/thumbnails/2.jpg)
You Don’t Know What This Is
But you want to!
![Page 3: Phun With Sound Basic Concepts For Hardware (and other) Hackers](https://reader036.vdocument.in/reader036/viewer/2022062322/56649cb95503460f9497fbd9/html5/thumbnails/3.jpg)
This Circuit Board
Made this famous riff
![Page 4: Phun With Sound Basic Concepts For Hardware (and other) Hackers](https://reader036.vdocument.in/reader036/viewer/2022062322/56649cb95503460f9497fbd9/html5/thumbnails/4.jpg)
Phun With Sound
• Combo talk, covering:– Intro to sound– Some basics of synthesizers– Making sounds with microcontrollers
![Page 5: Phun With Sound Basic Concepts For Hardware (and other) Hackers](https://reader036.vdocument.in/reader036/viewer/2022062322/56649cb95503460f9497fbd9/html5/thumbnails/5.jpg)
What is Sound?
• Modulated air pressure• Frequency of modulation is pitch• Amplitude is volume• Waveforms can be defined (and created) with
math
![Page 6: Phun With Sound Basic Concepts For Hardware (and other) Hackers](https://reader036.vdocument.in/reader036/viewer/2022062322/56649cb95503460f9497fbd9/html5/thumbnails/6.jpg)
More Sound Basics
• Unit of frequency is Hertz (Hz)• Unit of sound energy is decibel• Human hearing is around 20 Hz to 20 kHz
• Phreak bonus: who is the unit of sound level named for?
![Page 7: Phun With Sound Basic Concepts For Hardware (and other) Hackers](https://reader036.vdocument.in/reader036/viewer/2022062322/56649cb95503460f9497fbd9/html5/thumbnails/7.jpg)
Basic Waveforms
• Sine
• Triangle
• Square
![Page 8: Phun With Sound Basic Concepts For Hardware (and other) Hackers](https://reader036.vdocument.in/reader036/viewer/2022062322/56649cb95503460f9497fbd9/html5/thumbnails/8.jpg)
Some Math
• Sine is the “purest” waveform both in math and acoustical presentation: f(x) = sin(x)
• Square waves are an infinite summation of sine waves:
• All those terms beyond the fundamental frequency are “harmonics”
![Page 9: Phun With Sound Basic Concepts For Hardware (and other) Hackers](https://reader036.vdocument.in/reader036/viewer/2022062322/56649cb95503460f9497fbd9/html5/thumbnails/9.jpg)
More Square Wave
![Page 10: Phun With Sound Basic Concepts For Hardware (and other) Hackers](https://reader036.vdocument.in/reader036/viewer/2022062322/56649cb95503460f9497fbd9/html5/thumbnails/10.jpg)
Some Examples
• Using the SH101 analog synthesizer– Sine– Square– Triangle– PWM
• Microcontrollers driving motors often use PWM…
![Page 11: Phun With Sound Basic Concepts For Hardware (and other) Hackers](https://reader036.vdocument.in/reader036/viewer/2022062322/56649cb95503460f9497fbd9/html5/thumbnails/11.jpg)
Pulse Width Modulation
• PWM: fixed period, changing duty cycle• Used as motor drive, DAC, and in sound
synthesis (and others)• Back to the square wave function…
• …does changing duty cycle change harmonics? YES!
• Bonus: what’s a 100% duty cycle PWM called?
![Page 12: Phun With Sound Basic Concepts For Hardware (and other) Hackers](https://reader036.vdocument.in/reader036/viewer/2022062322/56649cb95503460f9497fbd9/html5/thumbnails/12.jpg)
Phun With Harmonics
• Subtractive Synthesis– Start with a signal with lots of harmonics– Filter it!
• Low pass filter
![Page 13: Phun With Sound Basic Concepts For Hardware (and other) Hackers](https://reader036.vdocument.in/reader036/viewer/2022062322/56649cb95503460f9497fbd9/html5/thumbnails/13.jpg)
More Filtering
• Traditional analog synths use voltage controlled filters VCF• Modern synths use digital filters running on DSPs
![Page 14: Phun With Sound Basic Concepts For Hardware (and other) Hackers](https://reader036.vdocument.in/reader036/viewer/2022062322/56649cb95503460f9497fbd9/html5/thumbnails/14.jpg)
The Filter Sweep
• Classic electronica music effect
![Page 15: Phun With Sound Basic Concepts For Hardware (and other) Hackers](https://reader036.vdocument.in/reader036/viewer/2022062322/56649cb95503460f9497fbd9/html5/thumbnails/15.jpg)
Triangle Man (Delta)
• Non-changing waveforms sound dull, even irritating
• ∆ Sounds more interesting • How to implement change?– LFO, repeatable change– “Random” change
![Page 16: Phun With Sound Basic Concepts For Hardware (and other) Hackers](https://reader036.vdocument.in/reader036/viewer/2022062322/56649cb95503460f9497fbd9/html5/thumbnails/16.jpg)
Art of Noise
• Noise is random• Pseudo-random isn’t random, nor noise• What does it sound like?– Noise on the SH101– Pseudo-random on the SH101– How the pros use pseudo-random influences
• InfoSec tie-in: see how limited pseudo-random is a bad choice for seeding crypto?
![Page 17: Phun With Sound Basic Concepts For Hardware (and other) Hackers](https://reader036.vdocument.in/reader036/viewer/2022062322/56649cb95503460f9497fbd9/html5/thumbnails/17.jpg)
Making Sound With Microcontrollers
• Two basic approaches:– Synthesis– Sample playback
• Two areas of concern:– Hardware– Firmware
![Page 18: Phun With Sound Basic Concepts For Hardware (and other) Hackers](https://reader036.vdocument.in/reader036/viewer/2022062322/56649cb95503460f9497fbd9/html5/thumbnails/18.jpg)
Making Sound With Microcontrollers: Firmware
• Synthesis options– Hardware based (waveform into VCF)– Math based (calculations in firmware)
• Sample option– Look up table– Can be waveform data (sine, triangle, DTMF)– Can also be “sample” in the sense of digital
recording
![Page 19: Phun With Sound Basic Concepts For Hardware (and other) Hackers](https://reader036.vdocument.in/reader036/viewer/2022062322/56649cb95503460f9497fbd9/html5/thumbnails/19.jpg)
Microcontrollers: Hardware
• Synthesis options– Output waveform and control of external
elements (VCF, VCA)– Heavily filtered square wave– DAC…
![Page 20: Phun With Sound Basic Concepts For Hardware (and other) Hackers](https://reader036.vdocument.in/reader036/viewer/2022062322/56649cb95503460f9497fbd9/html5/thumbnails/20.jpg)
Microcontrollers: Hardware
• Sampled sound needs DAC– Filtered PWM, single output pin, HW controlled– DAC Ladder, multiple output pins, simple interface– DAC hardware, multiple i/o pins, complex
interface
![Page 21: Phun With Sound Basic Concepts For Hardware (and other) Hackers](https://reader036.vdocument.in/reader036/viewer/2022062322/56649cb95503460f9497fbd9/html5/thumbnails/21.jpg)
Example: DEFCON 18Badge Hack
• What happens when you combine:– DC18 Badge– Beer– Pr0n– Top engineers from famous comm corp– And me?
• The Optimized Tomfoolery DC18 badge hack entry! (Kingpin approved!)
• The Hacker Jeopardy answer is: “Hey, what’s the input impedance of an LM386?”
![Page 22: Phun With Sound Basic Concepts For Hardware (and other) Hackers](https://reader036.vdocument.in/reader036/viewer/2022062322/56649cb95503460f9497fbd9/html5/thumbnails/22.jpg)
DEFCON Badge Hack
• Limited microcontroller code space…• …and limited hardware options (no PWM)• Sampled desired sound to get .wav• Edit .wav to get C #include• Crude R-2R ladder DAC (considered other
methods)• Play samples back from codespace• 4-bit low sample rate, was recognizable!
![Page 23: Phun With Sound Basic Concepts For Hardware (and other) Hackers](https://reader036.vdocument.in/reader036/viewer/2022062322/56649cb95503460f9497fbd9/html5/thumbnails/23.jpg)
DC18 Badge Hack
• Tools used:– Audacitiy: sound recording manipulation tool– Lame: mpg recorder option for Audacity– HxD: hex editor– Code Warrior: microcontroller IDE
• Search youtube for “DC18 Theater” for Kingpin’s video of our entry (NSFW!)
![Page 24: Phun With Sound Basic Concepts For Hardware (and other) Hackers](https://reader036.vdocument.in/reader036/viewer/2022062322/56649cb95503460f9497fbd9/html5/thumbnails/24.jpg)
¿Questions?