1-bit Audio and the Arduino - Duke
Transcript of 1-bit Audio and the Arduino - Duke
![Page 1: 1-bit Audio and the Arduino - Duke](https://reader030.fdocuments.net/reader030/viewer/2022032817/620618a98c2f7b1730048e0c/html5/thumbnails/1.jpg)
1-bit Audio and the Arduino
David J. Zielinski
![Page 2: 1-bit Audio and the Arduino - Duke](https://reader030.fdocuments.net/reader030/viewer/2022032817/620618a98c2f7b1730048e0c/html5/thumbnails/2.jpg)
Overview1. Terminology of Sound2. Atari 2600
a. clock division frequenciesb. linear feedback shift registers
3. Arduino Unoa. Specificationsb. Audio Generation Methodsc. Code Examples and Demosd. Arduino Duee. Future Work
![Page 3: 1-bit Audio and the Arduino - Duke](https://reader030.fdocuments.net/reader030/viewer/2022032817/620618a98c2f7b1730048e0c/html5/thumbnails/3.jpg)
sound waves are oscillations in air pressure. The amplitude (viewed on y axis) is proportional to the change in pressure
1 = Peak amplitude2 = Peak-to-peak amp3 = RMS amplitude 4 = Wave period
![Page 4: 1-bit Audio and the Arduino - Duke](https://reader030.fdocuments.net/reader030/viewer/2022032817/620618a98c2f7b1730048e0c/html5/thumbnails/4.jpg)
loudness is the perceptual sense of amplitude.
quiet vs loud
frequency is the number of repeating events per unit time.
pitch is the perceptual sense of frequency.
![Page 5: 1-bit Audio and the Arduino - Duke](https://reader030.fdocuments.net/reader030/viewer/2022032817/620618a98c2f7b1730048e0c/html5/thumbnails/5.jpg)
bit depth is seen as quantization on the y axis
![Page 6: 1-bit Audio and the Arduino - Duke](https://reader030.fdocuments.net/reader030/viewer/2022032817/620618a98c2f7b1730048e0c/html5/thumbnails/6.jpg)
Retail availability 1977Introductory price 199 USDUnits sold 30 millionCPU MOS 6507 @ 1.19 MHzMemory 128 bytes RAM, 4 kB ROM
Atari 2600
![Page 7: 1-bit Audio and the Arduino - Duke](https://reader030.fdocuments.net/reader030/viewer/2022032817/620618a98c2f7b1730048e0c/html5/thumbnails/7.jpg)
● MOS 6532 (RIOT) Ram-I/O-Timer● MOS 6507. Smaller/Cheaper version of the 6502
(used in Apple, Atari, Commodore)● Television Interface Adaptor (TIA)
![Page 8: 1-bit Audio and the Arduino - Duke](https://reader030.fdocuments.net/reader030/viewer/2022032817/620618a98c2f7b1730048e0c/html5/thumbnails/8.jpg)
AtariTIA Chip
● non-frame buffer design!● reading input controllers● sound effects
○ 2 independent noise generators
○ 5-bit frequency divider○ 4-bit audio control (sets
waveform)○ 4-bit volume control
Jay Glenn Miner (May 31, 1932 – June 20, 1994) was a famous American integrated circuit designer, known primarily for his work in multimedia chips and as the "father of the Amiga". Lead developer of the TIA chip.
![Page 9: 1-bit Audio and the Arduino - Duke](https://reader030.fdocuments.net/reader030/viewer/2022032817/620618a98c2f7b1730048e0c/html5/thumbnails/9.jpg)
![Page 10: 1-bit Audio and the Arduino - Duke](https://reader030.fdocuments.net/reader030/viewer/2022032817/620618a98c2f7b1730048e0c/html5/thumbnails/10.jpg)
String/TubeResonance Pitch Perception
100 hz - root200 hz - octave300 hz - 5th400 hz - octave500 hz - Major 3rd600 hz - minor 3rd
octave: 200/100 2 25th: 300/200 3/2 1.54th: 400/300 4/3 1.33_Maj3: 500/400 5/4 1.25min3: 600/500 6/5 1.26th: 500/300 5/3 1.66_
![Page 11: 1-bit Audio and the Arduino - Duke](https://reader030.fdocuments.net/reader030/viewer/2022032817/620618a98c2f7b1730048e0c/html5/thumbnails/11.jpg)
C C# D D# E F F# G G# A A# B C
blue = equal temperamentred = just intonation
pitch
freqratio
![Page 12: 1-bit Audio and the Arduino - Duke](https://reader030.fdocuments.net/reader030/viewer/2022032817/620618a98c2f7b1730048e0c/html5/thumbnails/12.jpg)
one reason classic video games sound distinctive is the utilization of the clock division technique which results in a scale based on the undertone series.
![Page 13: 1-bit Audio and the Arduino - Duke](https://reader030.fdocuments.net/reader030/viewer/2022032817/620618a98c2f7b1730048e0c/html5/thumbnails/13.jpg)
blue = just intonationred = harmonic undertone
cents
Pitch
![Page 14: 1-bit Audio and the Arduino - Duke](https://reader030.fdocuments.net/reader030/viewer/2022032817/620618a98c2f7b1730048e0c/html5/thumbnails/14.jpg)
Gioseffo Zarlino (1517-1590) was an Italian music theorist and composer of the Renaissance.
First proposed the idea of the undertone series.
Hermann Ludwig Ferdinand von Helmholtz(1821 – 1894) was a German physician and physicist who made significant contributions to several widely varied areas of modern science.
Argued that sympathetic resonance is at least as active in under partials as in over partials
![Page 15: 1-bit Audio and the Arduino - Duke](https://reader030.fdocuments.net/reader030/viewer/2022032817/620618a98c2f7b1730048e0c/html5/thumbnails/15.jpg)
Harmonic Undertone Demo
http://jackaudio.org/
![Page 16: 1-bit Audio and the Arduino - Duke](https://reader030.fdocuments.net/reader030/viewer/2022032817/620618a98c2f7b1730048e0c/html5/thumbnails/16.jpg)
4 bit poly, 5 bit poly, 9 bit poly
![Page 17: 1-bit Audio and the Arduino - Duke](https://reader030.fdocuments.net/reader030/viewer/2022032817/620618a98c2f7b1730048e0c/html5/thumbnails/17.jpg)
XOR (exclusive or)
A B Output
0 0 0
0 1 1
1 0 1
1 1 0
![Page 18: 1-bit Audio and the Arduino - Duke](https://reader030.fdocuments.net/reader030/viewer/2022032817/620618a98c2f7b1730048e0c/html5/thumbnails/18.jpg)
Linear Feedback Shift RegisterPoly4: Taps at 2 and 3
1 0 0 1 output: 1Now
1 1 0 0Future
![Page 19: 1-bit Audio and the Arduino - Duke](https://reader030.fdocuments.net/reader030/viewer/2022032817/620618a98c2f7b1730048e0c/html5/thumbnails/19.jpg)
Demo of LFSR
Poly4: taps at 2,3Poly5: taps at 2,4Poly9: taps at 4,8
![Page 20: 1-bit Audio and the Arduino - Duke](https://reader030.fdocuments.net/reader030/viewer/2022032817/620618a98c2f7b1730048e0c/html5/thumbnails/20.jpg)
Arduino UnoFlash / Program Memory32 KB
SRAM / Variable Memory2 KB
Clock Speed16 MHz
5v $30
![Page 21: 1-bit Audio and the Arduino - Duke](https://reader030.fdocuments.net/reader030/viewer/2022032817/620618a98c2f7b1730048e0c/html5/thumbnails/21.jpg)
Why arduino?● low cost. leave installed for installation. ● input: knobs, switches, pressure sensors,
accelerometers, ultrasonic distance, temperature, capacitive sensing.
● output: usb, control motors, lights, and audio● making things is more fun then buying things● open source hardware/software● manufactured in Italy ● subset of C++
![Page 22: 1-bit Audio and the Arduino - Duke](https://reader030.fdocuments.net/reader030/viewer/2022032817/620618a98c2f7b1730048e0c/html5/thumbnails/22.jpg)
Where can you get it(and components)?
In Person: Radio Shack [northgate mall]
Hobbyist: sparkfun.comadafruit.com
Pro: digikey.comnewark.com
![Page 23: 1-bit Audio and the Arduino - Duke](https://reader030.fdocuments.net/reader030/viewer/2022032817/620618a98c2f7b1730048e0c/html5/thumbnails/23.jpg)
Methods of Running
● With a computer. Use arduino to read input, then send via serial message (via USB cable) to computer for further action.
● Stand alone. Arduino reads input and does any processing on board.
![Page 24: 1-bit Audio and the Arduino - Duke](https://reader030.fdocuments.net/reader030/viewer/2022032817/620618a98c2f7b1730048e0c/html5/thumbnails/24.jpg)
Methods to Generate AudioType Pro Con
tone function call ● part of standard libraries. ● pitch is accurate.
● monophonic (1 pitch at a time).
● square wave only.
add on shield ● actual audio output (24bit, 44k). ● arduino uno processor is too slow.
● shield costs $$
pin toggle in main loop
● generate arbitrary 1-bit waveforms. ● polyphonic (multiple pitches).● simple programming
● 1-bit waveforms● pitch not accurate● highest pitch limited by
amount of processing
pin toggle in interrupt
● generate arbitrary 1-bit waveforms. ● polyphonic (multiple pitches).● pitch is accurate
● 1-bit waveforms● complicated programming● need buffer = latency
![Page 25: 1-bit Audio and the Arduino - Duke](https://reader030.fdocuments.net/reader030/viewer/2022032817/620618a98c2f7b1730048e0c/html5/thumbnails/25.jpg)
Things you will need:
![Page 26: 1-bit Audio and the Arduino - Duke](https://reader030.fdocuments.net/reader030/viewer/2022032817/620618a98c2f7b1730048e0c/html5/thumbnails/26.jpg)
How does electricity work?
![Page 27: 1-bit Audio and the Arduino - Duke](https://reader030.fdocuments.net/reader030/viewer/2022032817/620618a98c2f7b1730048e0c/html5/thumbnails/27.jpg)
How to convert 5v to 0.45v ?Solution: voltage divider
![Page 28: 1-bit Audio and the Arduino - Duke](https://reader030.fdocuments.net/reader030/viewer/2022032817/620618a98c2f7b1730048e0c/html5/thumbnails/28.jpg)
What does this look like?
![Page 29: 1-bit Audio and the Arduino - Duke](https://reader030.fdocuments.net/reader030/viewer/2022032817/620618a98c2f7b1730048e0c/html5/thumbnails/29.jpg)
Pitch Linear
void loop(){ int v = analogRead(A0); int v_half=v/2; if(current_sample<v_half) digitalWrite(2,HIGH); else digitalWrite(2,LOW); current_sample=(current_sample+1)%v;}
![Page 30: 1-bit Audio and the Arduino - Duke](https://reader030.fdocuments.net/reader030/viewer/2022032817/620618a98c2f7b1730048e0c/html5/thumbnails/30.jpg)
Pitch Expvoid loop(){ int v = analogRead(A0); int vp=int(pow(v,2.0)/5000.0); int v_half=vp/2;
if(current_sample<v_half) digitalWrite(2,HIGH); else digitalWrite(2,LOW); current_sample=(current_sample+1)%vp;}
![Page 31: 1-bit Audio and the Arduino - Duke](https://reader030.fdocuments.net/reader030/viewer/2022032817/620618a98c2f7b1730048e0c/html5/thumbnails/31.jpg)
samples
input value
![Page 32: 1-bit Audio and the Arduino - Duke](https://reader030.fdocuments.net/reader030/viewer/2022032817/620618a98c2f7b1730048e0c/html5/thumbnails/32.jpg)
Noisevoid loop(){ int v = analogRead(A0); int vp=int(pow(v,2.0)/5000.0); if(current_sample==0) { int val=random(2); if(val==1) digitalWrite(2,HIGH); else digitalWrite(2,LOW); } current_sample=(current_sample+1)%vp;}
![Page 33: 1-bit Audio and the Arduino - Duke](https://reader030.fdocuments.net/reader030/viewer/2022032817/620618a98c2f7b1730048e0c/html5/thumbnails/33.jpg)
Dual Pitch
void loop(){ int v = analogRead(A0); int v2 = analogRead(A1); s1.set_freq(v); s1.tick(); s2.set_freq(v2); s2.tick();}
![Page 34: 1-bit Audio and the Arduino - Duke](https://reader030.fdocuments.net/reader030/viewer/2022032817/620618a98c2f7b1730048e0c/html5/thumbnails/34.jpg)
AND aka Ring Modvoid loop(){ int v = analogRead(A0); int v2 = analogRead(A1); s1.set_freq(v); s2.set_freq(v2); int d=s1.get_val(); int d2=s2.get_val(); byte f=d&d2; digitalWrite(2,f); }
A B Output0 0 00 1 01 0 01 1 1
![Page 35: 1-bit Audio and the Arduino - Duke](https://reader030.fdocuments.net/reader030/viewer/2022032817/620618a98c2f7b1730048e0c/html5/thumbnails/35.jpg)
XOR aka Korg MS-20 Ring Modvoid loop(){ int v = analogRead(A0); int v2 = analogRead(A1); s1.set_freq(v); s2.set_freq(v2); int d=s1.get_val(); int d2=s2.get_val(); byte f=d^d2; digitalWrite(2,f); }
A B Output0 0 00 1 11 0 11 1 0
![Page 36: 1-bit Audio and the Arduino - Duke](https://reader030.fdocuments.net/reader030/viewer/2022032817/620618a98c2f7b1730048e0c/html5/thumbnails/36.jpg)
byte val=pgm_read_byte_near(pos); if(val>128) digitalWrite(2,HIGH); else digitalWrite(2,LOW); pos++; if(pos>pos_end) pos=start_pos;
Program Material
![Page 37: 1-bit Audio and the Arduino - Duke](https://reader030.fdocuments.net/reader030/viewer/2022032817/620618a98c2f7b1730048e0c/html5/thumbnails/37.jpg)
Decimation Delay
byte val=delay_array[d_pos]; int prob=random(0,1024);
dv=(val>0 && prob<decay) || pbyte; delay_array[d_pos]=dv; d_pos=(d_pos+1)%dtime;
digitalWrite(3,val); digitalWrite(2,pbyte);
![Page 38: 1-bit Audio and the Arduino - Duke](https://reader030.fdocuments.net/reader030/viewer/2022032817/620618a98c2f7b1730048e0c/html5/thumbnails/38.jpg)
Looper
if (sensorVal>0) {pbyte=pitch_sample<phalf;triggered=true;
} pitch_sample=(pitch_sample+1)%pmax; byte val=delay_array[d_pos]; if(triggered) delay_array[d_pos]=pbyte; else delay_array[d_pos]=val; d_pos=(d_pos+1)%dtime;
digitalWrite(2,pbyte); digitalWrite(3,val);
![Page 39: 1-bit Audio and the Arduino - Duke](https://reader030.fdocuments.net/reader030/viewer/2022032817/620618a98c2f7b1730048e0c/html5/thumbnails/39.jpg)
Arpeggiation
byte notes[6]={1,2,4,8,4,2};int vpn=sensor_val*notes[current_note];int v_half=vpn/2;digitalWrite(2,current_sample<v_half);
current_sample=(current_sample+1)%vpn;note_sample++; if(note_sample>samples_per_note){ note_sample=0; current_note=(current_note+1)%6; }
![Page 40: 1-bit Audio and the Arduino - Duke](https://reader030.fdocuments.net/reader030/viewer/2022032817/620618a98c2f7b1730048e0c/html5/thumbnails/40.jpg)
Arduino Due
Due Uno
Clock Speed 84 Mhz 16 Mhz
SRAM (Variables) 96 KB 2 KB
Flash (Program) 512 KB 32 KB
Voltage 3.3v 5v
Analog Input 12 [12 bit] 6 [10 bit]
Analog Output (D/A) 2 0
Digital Pins 54 14
Price $50 $30
![Page 41: 1-bit Audio and the Arduino - Duke](https://reader030.fdocuments.net/reader030/viewer/2022032817/620618a98c2f7b1730048e0c/html5/thumbnails/41.jpg)
Guitar Effect Pedal
![Page 42: 1-bit Audio and the Arduino - Duke](https://reader030.fdocuments.net/reader030/viewer/2022032817/620618a98c2f7b1730048e0c/html5/thumbnails/42.jpg)
Active Paintings
![Page 43: 1-bit Audio and the Arduino - Duke](https://reader030.fdocuments.net/reader030/viewer/2022032817/620618a98c2f7b1730048e0c/html5/thumbnails/43.jpg)
Skull Drum and Leg-Tar
![Page 44: 1-bit Audio and the Arduino - Duke](https://reader030.fdocuments.net/reader030/viewer/2022032817/620618a98c2f7b1730048e0c/html5/thumbnails/44.jpg)
P10 Project 100, 1k, 10k, ... channel installation
![Page 45: 1-bit Audio and the Arduino - Duke](https://reader030.fdocuments.net/reader030/viewer/2022032817/620618a98c2f7b1730048e0c/html5/thumbnails/45.jpg)
Thank You!
![Page 46: 1-bit Audio and the Arduino - Duke](https://reader030.fdocuments.net/reader030/viewer/2022032817/620618a98c2f7b1730048e0c/html5/thumbnails/46.jpg)
Wet Ink Ensemble@ Casbah8pmfeaturing Kenneth Stewart's "Make It Opaque"
![Page 47: 1-bit Audio and the Arduino - Duke](https://reader030.fdocuments.net/reader030/viewer/2022032817/620618a98c2f7b1730048e0c/html5/thumbnails/47.jpg)