Phun With Sound Basic Concepts For Hardware (and other) Hackers

Preview:

Citation preview

Phun With Sound

Basic ConceptsFor

Hardware (and other) Hackers

You Don’t Know What This Is

But you want to!

This Circuit Board

Made this famous riff

Phun With Sound

• Combo talk, covering:– Intro to sound– Some basics of synthesizers– Making sounds with microcontrollers

What is Sound?

• Modulated air pressure• Frequency of modulation is pitch• Amplitude is volume• Waveforms can be defined (and created) with

math

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?

Basic Waveforms

• Sine

• Triangle

• Square

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”

More Square Wave

Some Examples

• Using the SH101 analog synthesizer– Sine– Square– Triangle– PWM

• Microcontrollers driving motors often use PWM…

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?

Phun With Harmonics

• Subtractive Synthesis– Start with a signal with lots of harmonics– Filter it!

• Low pass filter

More Filtering

• Traditional analog synths use voltage controlled filters VCF• Modern synths use digital filters running on DSPs

The Filter Sweep

• Classic electronica music effect

Triangle Man (Delta)

• Non-changing waveforms sound dull, even irritating

• ∆ Sounds more interesting • How to implement change?– LFO, repeatable change– “Random” change

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?

Making Sound With Microcontrollers

• Two basic approaches:– Synthesis– Sample playback

• Two areas of concern:– Hardware– Firmware

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

Microcontrollers: Hardware

• Synthesis options– Output waveform and control of external

elements (VCF, VCA)– Heavily filtered square wave– DAC…

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

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?”

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!

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

¿Questions?

Recommended