Académique Documents
Professionnel Documents
Culture Documents
Arduino
David J. Zielinski
Overview
1. Terminology of Sound
2. Atari 2600
a. clock division frequencies
b. linear feedback shift registers
3. Arduino Uno
a. Specifications
b. Audio Generation Methods
c. Code Examples and Demos
d. Arduino Due
e. Future Work
sound waves are oscillations in air
pressure. The amplitude (viewed on y axis)
is proportional to the change in pressure
1 = Peak amplitude
2 = Peak-to-peak amp
3 = RMS amplitude
4 = Wave period
loudness is the perceptual sense of amplitude.
quiet vs loud
freq
ratio
C C# D D# E F F# G G# A A# B C
pitch
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.
blue = just intonation
red = harmonic undertone
cents
Pitch
Hermann Ludwig Ferdinand von Helmholtz
Gioseffo Zarlino (1517-1590) was an (1821 – 1894) was a German physician and
Italian music theorist and composer of the physicist who made significant contributions to
Renaissance. several widely varied areas of modern science.
http://jackaudio.org/
4 bit poly, 5 bit poly, 9 bit poly
XOR (exclusive or)
A B Output
0 0 0
0 1 1
1 0 1
1 1 0
Linear Feedback Shift Register
Poly4: Taps at 2 and 3
Now
1 0 0 1 output: 1
Future
1 1 0 0
Demo of LFSR
Clock Speed
16 MHz
5v $30
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++
Where can you get it
(and components)?
In Person: Radio Shack
[northgate mall]
Hobbyist: sparkfun.com
adafruit.com
Pro: digikey.com
newark.com
Methods of Running
● With a computer. Use arduino to read input,
then send via serial message (via USB
cable) to computer for further action.
add on shield ● actual audio output (24bit, 44k). ● arduino uno processor is
too slow.
● shield costs $$
if(current_sample<v_half)
digitalWrite(2,HIGH);
else
digitalWrite(2,LOW);
current_sample=(current_sample+1)%v;
}
Pitch Exp
void 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;
}
samples
input value
Noise
void 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;
}
Dual Pitch
void loop()
{
int v = analogRead(A0);
int v2 = analogRead(A1);
s1.set_freq(v);
s1.tick();
s2.set_freq(v2);
s2.tick();
}
AND aka Ring Mod
void loop(){
int v = analogRead(A0);
int v2 = analogRead(A1);
A B Output
s1.set_freq(v); 0 0 0
s2.set_freq(v2);
0 1 0
int d=s1.get_val(); 1 0 0
int d2=s2.get_val();
1 1 1
byte f=d&d2;
digitalWrite(2,f);
}
XOR aka Korg MS-20 Ring Mod
void loop(){
int v = analogRead(A0);
int v2 = analogRead(A1);
A B Output
s1.set_freq(v); 0 0 0
s2.set_freq(v2);
0 1 1
int d=s1.get_val(); 1 0 1
int d2=s2.get_val();
1 1 0
byte f=d^d2;
digitalWrite(2,f);
}
Program Material
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;
Decimation Delay
byte val=delay_array[d_pos];
int prob=random(0,1024);
digitalWrite(3,val);
digitalWrite(2,pbyte);
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);
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; }
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
Guitar Effect Pedal
Active Paintings
Skull Drum and Leg-
Tar
P10 Project
100, 1k, 10k, ... channel installation
Thank You!
Wet Ink Ensemble
@ Casbah
8pm
featuring Kenneth Stewart's "Make It Opaque"