SlideShare ist ein Scribd-Unternehmen logo
1 von 57
Audible Objects
June 14, 2016
Leif Bloomquist – Inter/Access June 13-14, 2016
Overview
Day 1 (Theory)
• Introduction (15 minutes)
• Arduino Basics (30 minutes)
• Sensor Basics (15 minutes)
• Analog vs. Digital (15 minutes)
• Detecting Events (15 minutes)
• Programming Basics (30 minutes)
• MIDI (15 minutes)
• Set up and test Arduino IDE (30 minutes)
Day 2 (Practical)
• Hook up and test sensors (1 hour)
• Hook up and test MIDI (1 hour)
• Put it all together (1 hour)
A bit about me…
• “Classically trained” in clarinet and percussion
• Have been dabbling with music, composing, and technology since the 1980s
• Moved to Waterloo in 1992 to study Systems Design Engineering
• Moved to Toronto in 1997 and discovered the Ambient Ping, Riot Art and other
experimental music communities
• Occasional “live” gigs under the moniker Schema Factor
• Playing with the tech is half the fun!
• In general I release my tools and techniques open-source
• Enable other electronic musicians to build on ideas!
• “Day job” in software engineering at MDA, creators of the Canadarm
Demos
Introduction to Arduino
What is Arduino?
• An open-source electronics prototyping platform
based on flexible, easy-to-use hardware and
software. It’s intended for artists, designers,
hobbyists, and anyone interested in creating
interactive objects or environments.
• Named after a bar in Italy, where it was invented!
• The bar, in turn, was named after Arduin of Ivrea,
king of Italy 1002-1014
www.arduino.cc
Why Arduino?
• Comes in a variety of shapes and sizes (and cost).
• All programmed very similarly.
• Emphasis on ease of programming and connecting to the outside world.
• Arduino Uno is the most basic model (we will use for this course).
• Open-Source: All designs, code, and tools are freely available.
An Arduino is a computer!
• Technically, a “microcontroller.”
• Most run at 16 MHz – about the same power
as a ‘286 computer from the 1990s
(but with much less memory).
• No Operating System, just a “bootloader.”
Some Terminology
• Bit: The smallest unit a computer can represent (0 or 1)
• Byte: A collection of 8 bits (represents a whole number, 0 to 255)
• Baud: (Also bps): bits per second
• Serial: Method of transmitting data between computers (including Arduinos)
• Named because the bits flow one at a time
• Speed is represented in baud
• Pin: Connection point to an Arduino for connecting inputs or outputs
More Terminology
• USB: Universal Serial Bus
• Digital: An input or output that can be 0 or 1 (off or on)
• Analog: An input or output that can be a range of values – like a volume
control
• ADC: Analog to Digital Converter – converts an analog input into a numeric
whole number that the Arduino can work with
Arduino Uno Parts
Power Port
(If not using USB)
USB Port
(Power and Serial)
Digital Pins
(Input or Output)
Analog Pins
(Input Only)
Programming Pins
(For factory setup)
Microcontroller
Reset Button
(Reboots the Arduino)
Power Pins
Introduction to Sensors
June 14, 2016
Sensors
• Motion
• Acceleration
• Sound
• Light
• Touch
• Flex
• Switches / Buttons
• Moisture level
• Temperature
• Atmospheric pressure
• Etc, etc.
Detecting Digital Events
Rising Edge: 0 → 1 Falling Edge: 1 → 0
Image Credit: Manpreet Singh Minhas
• You need to remember the “previous” value
Debouncing
• In theory, the input signal from a perfect button looks like this
(negative logic):
1
0
Time →
Debouncing
• But in reality, it looks like this: (trace from an oscilloscope)
Debouncing Strategies
• Wait for the value to stabilize over a few milliseconds
• A simple delay timer works reasonably well
Analog inputs are still “digital”…kind of
• A typical analog sensor gives an output 0 volts to 5 volts, with infinite
precision
• To represent an analog input, the
Arduino’s ADC converts these into a
(typically) 10-bit value.
• This ranges 0 to 1023.
(Representing 0 volts to 5 volts)
Detecting Analog Events
• Set a “threshold” to trigger the event
0
1023
Time →
Threshold
Analog Inputs and Thresholds - Tips
• The threshold value can be determined by trial and error
• Print out the ADC value and note that happens when you activate the sensor
• You may have to define an “on” threshold and an “off” threshold to keep it from triggering over
and over again
• Your thermostat at home does this
• “Hysteresis”
• Each individual sensor is slightly different – always check the values if changing sensors
Arduino Programming
June 14, 2016
Arduino Programming Basics
• Arduino programs are called sketches.
• The Arduino programming language is based on the Wiring language,
which in turn is a simplified version of C++.
• Libraries are collections of functions that do various tasks.
• The Arduino Integrated Development Environment (IDE) includes
many libraries to help get you started.
A Very Simple Arduino Program
/*
* Hello World!
*
* This is the Hello World! for Arduino.
* It shows how to send data to the computer
*/
void setup() // run once, when the sketch starts
{
Serial.begin(9600); // set up Serial library at 9600 baud
}
void loop() // run over and over again
{
Serial.println("Hello world!"); // prints hello with ending line break
}
Arduino Programming Terminology
• Statements are individual instructions to the Arduino.
• Functions are a group of statements that do a single task.
• Variables are placeholders in memory that can store a value.
• Every variable has a data type (byte, integer, “float”, boolean, etc.)
• Comments are notes that stay inside the program to explain what’s going on
• The Arduino ignores these, they are for future you!
• Use // or /* */ to indicate a comment.
• Control structures are statements like if, for, while that let you direct the flow of the program
based on conditions.
Arduino Programming Continued…
• Arduino requires two functions at minimum: setup() and loop()
setup() is where you get everything ready (runs once at powerup or
reset)
loop() runs over and over infinitely until the power is turned off.
• You can create your own functions if you find you are doing
something over and over again
Anatomy of a Function
int AddTwoNumbers(int num1, int num2)
{
int sum = num1+num2;
return sum;
}
{ and } surround the
function statements
Inputs to the Function
aka “parameters”
Output of the Function
aka “return type”
Statements
Return this value back to
the main function
Using Functions
…
…
int answer = AddTwoNumbers(2,3);
…
…
<do something with the answer>
Inputs to the Function
aka “arguments”
Variable data type
(must match!)
Variable to hold the
returned value
Function “call”
Useful Built-In Arduino Functions
pinMode(): set a pin as input or output
digitalWrite() – set a digital pin high/low
digitalRead() – read a digital pin’s state
analogRead() – read an analog pin
delay() – wait an amount of time
millis() – get the current time in milliseconds
Using Comparison Operators
(3 == 2) FALSE
(3 > 2) TRUE
(3 < 2) FALSE
(answer < 5) FALSE
(answer <= 5) TRUE
• Potential gotcha: Off-by-one errors are very common
Control Statements – if / else
if (<condition is true>)
{
<do something>
}
else
{
<do something else>
}
Control Statements – while
while (<condition is true>)
{
<do something over and over>
}
…
• Potential gotcha: Your program will “freeze” inside the while loop while the condition is true
Control Statements – for
for (<initialization>, <condition>, <increment>)
{
<do something>
}
• Potential gotcha: Your program will “freeze” until the loop completes
Control Statements – for (Example)
for (int i=1; i<10; i++)
{
<do something 9 times>
}
A more complete Arduino program
// Analog Input Example with Control Structures
int sensorPin = A0; // select the input pin for the sensor
int ledPin = 13; // select the pin for the LED
int sensorValue = 0; // variable to store the value coming from the sensor
void setup()
{
pinMode(ledPin, OUTPUT); // declare the ledPin as an OUTPUT
}
void loop()
{
sensorValue = analogRead(sensorPin); // read the value from the sensor
Serial.println(sensorValue); // send the value to the PC
if (sensorValue > 2000) // Have we crossed the threshold?
{
// turn the ledPin on
digitalWrite(ledPin, HIGH);
}
else
{
// turn the ledPin off:
digitalWrite(ledPin, LOW);
}
}
“Global” variables –
shared by entire program
“setup” runs once
“loop” runs infinitely
Getting the Program into the Arduino
• The Arduino IDE needs to know the type of Arduino that is connected, and which Serial port it is
connected to.
• Windows: COMxx
• Mac: /dev/usbserialxx
• The process of converting your human-readable program into Arduino “machine code” (a series
of bytes) is called compiling.
• The Arduino IDE checks your code for “correctness” (typos etc.), then compiles it, then transmits
the program into the actual Arduino through USB.
• The program stays permanently inside the Arduino until you change it.
Musical Instrument Digital Interface (MIDI)
The MIDI Protocol
• Musical Instrument Digital Interface
• Defined in 1982.
• Serial Interface at 31250 baud (though this can be changed).
• Messages consist of a Status (command) byte followed by Data bytes
(usually two).
• 16 virtual “Channels”.
• Commands such as Note On, Note Off, Control Change, etc.
• The defacto standard for exchanging music between computers,
synthesizers, software, Arduinos…
Decimal vs. Hexadecimal Notation
• Most of the time, we use “decimal” (base 10) notation.
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13…
• In many cases in programming and data communications (including
MIDI), it is helpful to use “hexadecimal” (base 16)
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F, 10, 11, 12, 13…
Why Hexadecimal?
• Remember that a byte is 8 bits.
• A “nybble” is 4 bits, which is 0-15 decimal…or 0-F hexadecimal.
• Therefore, a byte can be conveniently represented in 2 hexadecimal digits.
• In MIDI the different digits may have different meanings – example next slide
• Hexadecimal is usually represented with the prefix 0x (other notations are
heresy)
• 0x00 = 0 decimal
• 0x10 = 16 decimal
• 0x64 = 100 decimal
• 0xFF = 255 decimal (maximum for 1 byte)
Typical MIDI Message
9 0 0x3C 0x64
Status
byte
Data
bytes
Channel
Command
0x
Example MIDI Message: Note On
9 1 0x45 0x7F
Status
byte
Channel 2
Command “Note On”
A440 Volume
(“Velocity”)
0x
Every Note On should be paired with a Note Off!
8 1 0x45 0x7F
Status
byte
Channel 2
Command “Note Off”
A440 “Velocity”
0x
MIDI Note Numbers
• Range from 0 (C in Octave 0) to 127 (G in Octave 10)
• Middle C is 60
• A440 is 69
• etc…
MIDI can also represent “continuous” values
B 1 20 100
Status
byte
Channel 2
Command “Controller”
Controller
Number
Controller
Value
• Useful for volume, pitch, filters, panning, other effects
0x
MIDI Gotchas to Watch Out For
• Remember to follow every Note On with a Note Off.
• Note numbers and commands are often cited in hexadecimal.
• Channel numbers are off by 1. A channel value of 3 refers to channel 4.
• The values can only be 0 to 127 (7 bits)
There is an Arduino MIDI Library
• However, the protocol is so simple we will do it “by hand.”
• The library is most useful for receiving+processing MIDI within the
Arduino itself (outside the scope of this course.)
http://playground.arduino.cc/Main/MIDILibrary
Arduino Function to Send MIDI
void sendMIDI(byte cmd, byte data1, byte data2)
{
Serial.write(cmd);
Serial.write(data1);
Serial.write(data2);
}
Receiving the Data: Hairless MIDI Bridge
http://projectgus.github.io/hairless-midiserial/
Putting It All Together
• We now have almost everything we need:
1. We can create Arduino Sketches.
2. We can read from a sensor.
3. We can detect events.
4. We can send MIDI data from the Arduino to a computer .
5. We can receive MIDI data on the computer.
Types of playback: Samples
Types of playback: Synthesized
• Additive and subtractive synthesis
• Generated algorithmically
• Many parameters you can adjust in “real time”
Digital Audio Workstations (DAWs)
Many to choose from!
Ableton, Logic Pro, GarageBand, Sonar, MAX, Reason, Cubase, Pro Tools,
Different strengths and weaknesses, some free, many cost
Concepts are similar
Browser based!! https://www.soundtrap.com/
What Next?
1. What MIDI data to send?
2. That depends on you!
Some Ideas…
1. Trigger a sample based on a sensor event
2. Change the volume of a sound based on a sensor input
3. Change the pitch of a sound based on a sensor input
4. Play a musical ditty when an event happens
5. …
Alternatives
A modern alternative to MIDI exists, called Open Sound Control:
http://opensoundcontrol.org/
(It’s complicated and hasn’t really caught on)
Making it Wireless
• Batteries
• Wireless
• Xbees (Serial to Serial)
• ESP8266 (Serial to Wifi)
Prep for tomorrow
• Arduino IDE Setup
• Hairless MIDI
• Soundtrap

Weitere ähnliche Inhalte

Was ist angesagt?

Hardware Hacking area: Make Cool Things with Microcontrollers (and learn to s...
Hardware Hacking area: Make Cool Things with Microcontrollers (and learn to s...Hardware Hacking area: Make Cool Things with Microcontrollers (and learn to s...
Hardware Hacking area: Make Cool Things with Microcontrollers (and learn to s...
codebits
 

Was ist angesagt? (20)

Asus Tinker Board
Asus Tinker BoardAsus Tinker Board
Asus Tinker Board
 
uRock @ Jserv Course Final
uRock @ Jserv Course Final uRock @ Jserv Course Final
uRock @ Jserv Course Final
 
Interacting with Intel Edison
Interacting with Intel EdisonInteracting with Intel Edison
Interacting with Intel Edison
 
ELC North America 2021 Introduction to pin muxing and gpio control under linux
ELC  North America 2021 Introduction to pin muxing and gpio control under linuxELC  North America 2021 Introduction to pin muxing and gpio control under linux
ELC North America 2021 Introduction to pin muxing and gpio control under linux
 
Beaglebone And Android
Beaglebone And AndroidBeaglebone And Android
Beaglebone And Android
 
Hardware Hacking area: Make Cool Things with Microcontrollers (and learn to s...
Hardware Hacking area: Make Cool Things with Microcontrollers (and learn to s...Hardware Hacking area: Make Cool Things with Microcontrollers (and learn to s...
Hardware Hacking area: Make Cool Things with Microcontrollers (and learn to s...
 
BKK16-211 Internet of Tiny Linux (io tl)- Status and Progress
BKK16-211 Internet of Tiny Linux (io tl)- Status and ProgressBKK16-211 Internet of Tiny Linux (io tl)- Status and Progress
BKK16-211 Internet of Tiny Linux (io tl)- Status and Progress
 
Scratch pcduino
Scratch pcduinoScratch pcduino
Scratch pcduino
 
New Commodore 64 Network Game Developments
New Commodore 64 Network Game DevelopmentsNew Commodore 64 Network Game Developments
New Commodore 64 Network Game Developments
 
A Quick Introduction to Programmable Logic
A Quick Introduction to Programmable LogicA Quick Introduction to Programmable Logic
A Quick Introduction to Programmable Logic
 
ELC-E 2019 Device tree, past, present, future
ELC-E 2019 Device tree, past, present, futureELC-E 2019 Device tree, past, present, future
ELC-E 2019 Device tree, past, present, future
 
Introduction to Arduino and Circuits
Introduction to Arduino and CircuitsIntroduction to Arduino and Circuits
Introduction to Arduino and Circuits
 
pcDuino tech talk at Carnegie Mellon University 10/14/2014
pcDuino tech talk at Carnegie Mellon University 10/14/2014pcDuino tech talk at Carnegie Mellon University 10/14/2014
pcDuino tech talk at Carnegie Mellon University 10/14/2014
 
Embedded Recipes 2019 - Pipewire a new foundation for embedded multimedia
Embedded Recipes 2019 - Pipewire a new foundation for embedded multimediaEmbedded Recipes 2019 - Pipewire a new foundation for embedded multimedia
Embedded Recipes 2019 - Pipewire a new foundation for embedded multimedia
 
Hardware hacking 101
Hardware hacking 101Hardware hacking 101
Hardware hacking 101
 
Linux Conference Australia 2018 : Device Tree, past, present, future
Linux Conference Australia 2018 : Device Tree, past, present, futureLinux Conference Australia 2018 : Device Tree, past, present, future
Linux Conference Australia 2018 : Device Tree, past, present, future
 
pcDuino Presentation at SparkFun
pcDuino Presentation at SparkFunpcDuino Presentation at SparkFun
pcDuino Presentation at SparkFun
 
Elc Europe 2020 : u-boot- porting and maintaining a bootloader for a multimed...
Elc Europe 2020 : u-boot- porting and maintaining a bootloader for a multimed...Elc Europe 2020 : u-boot- porting and maintaining a bootloader for a multimed...
Elc Europe 2020 : u-boot- porting and maintaining a bootloader for a multimed...
 
Lee 2020 what the clock !
Lee 2020  what the clock !Lee 2020  what the clock !
Lee 2020 what the clock !
 
Raspberry Pi Using Python
Raspberry Pi Using PythonRaspberry Pi Using Python
Raspberry Pi Using Python
 

Andere mochten auch (7)

Space Solutions
Space SolutionsSpace Solutions
Space Solutions
 
Software Requirements and Design Process in the Aerospace Industry
Software Requirements and Design Process in the Aerospace IndustrySoftware Requirements and Design Process in the Aerospace Industry
Software Requirements and Design Process in the Aerospace Industry
 
Canadian contributions
Canadian contributionsCanadian contributions
Canadian contributions
 
Marc Garneau Collegiate Institute
Marc Garneau Collegiate InstituteMarc Garneau Collegiate Institute
Marc Garneau Collegiate Institute
 
CANADA IN SPACE
CANADA IN SPACECANADA IN SPACE
CANADA IN SPACE
 
ISS Presentation
ISS PresentationISS Presentation
ISS Presentation
 
Slideshare ppt
Slideshare pptSlideshare ppt
Slideshare ppt
 

Ähnlich wie Audible Objects

teststststststLecture_3_2022_Arduino.pptx
teststststststLecture_3_2022_Arduino.pptxteststststststLecture_3_2022_Arduino.pptx
teststststststLecture_3_2022_Arduino.pptx
ethannguyen1618
 
arduinocourse-180308074529 (1).pdf
arduinocourse-180308074529 (1).pdfarduinocourse-180308074529 (1).pdf
arduinocourse-180308074529 (1).pdf
ssusere5db05
 
4 IOT 18ISDE712 MODULE 4 IoT Physical Devices and End Point-Aurdino Uno.pdf
4 IOT 18ISDE712  MODULE 4 IoT Physical Devices and End Point-Aurdino  Uno.pdf4 IOT 18ISDE712  MODULE 4 IoT Physical Devices and End Point-Aurdino  Uno.pdf
4 IOT 18ISDE712 MODULE 4 IoT Physical Devices and End Point-Aurdino Uno.pdf
Jayanthi Kannan MK
 

Ähnlich wie Audible Objects (20)

13223971.ppt
13223971.ppt13223971.ppt
13223971.ppt
 
teststststststLecture_3_2022_Arduino.pptx
teststststststLecture_3_2022_Arduino.pptxteststststststLecture_3_2022_Arduino.pptx
teststststststLecture_3_2022_Arduino.pptx
 
Arduino
ArduinoArduino
Arduino
 
Introduction to Arduino Hardware and Programming
Introduction to Arduino Hardware and ProgrammingIntroduction to Arduino Hardware and Programming
Introduction to Arduino Hardware and Programming
 
Arduino Slides With Neopixels
Arduino Slides With NeopixelsArduino Slides With Neopixels
Arduino Slides With Neopixels
 
Arduino course
Arduino courseArduino course
Arduino course
 
arduinocourse-180308074529 (1).pdf
arduinocourse-180308074529 (1).pdfarduinocourse-180308074529 (1).pdf
arduinocourse-180308074529 (1).pdf
 
IOT beginnners
IOT beginnnersIOT beginnners
IOT beginnners
 
IOT beginnners
IOT beginnnersIOT beginnners
IOT beginnners
 
4 IOT 18ISDE712 MODULE 4 IoT Physical Devices and End Point-Aurdino Uno.pdf
4 IOT 18ISDE712  MODULE 4 IoT Physical Devices and End Point-Aurdino  Uno.pdf4 IOT 18ISDE712  MODULE 4 IoT Physical Devices and End Point-Aurdino  Uno.pdf
4 IOT 18ISDE712 MODULE 4 IoT Physical Devices and End Point-Aurdino Uno.pdf
 
Introduction to Arduino Webinar
Introduction to Arduino WebinarIntroduction to Arduino Webinar
Introduction to Arduino Webinar
 
Arduino Programming Familiarization
Arduino Programming FamiliarizationArduino Programming Familiarization
Arduino Programming Familiarization
 
Introduction to Arduino Microcontroller
Introduction to Arduino MicrocontrollerIntroduction to Arduino Microcontroller
Introduction to Arduino Microcontroller
 
Arduino Workshop Slides
Arduino Workshop SlidesArduino Workshop Slides
Arduino Workshop Slides
 
Arduino slides
Arduino slidesArduino slides
Arduino slides
 
Arduino: Arduino starter kit
Arduino: Arduino starter kitArduino: Arduino starter kit
Arduino: Arduino starter kit
 
arduinoworkshop-160204051621.pdf
arduinoworkshop-160204051621.pdfarduinoworkshop-160204051621.pdf
arduinoworkshop-160204051621.pdf
 
Ardui no
Ardui no Ardui no
Ardui no
 
Arduino Workshop @ MSA University
Arduino Workshop @ MSA UniversityArduino Workshop @ MSA University
Arduino Workshop @ MSA University
 
Syed IoT - module 5
Syed  IoT - module 5Syed  IoT - module 5
Syed IoT - module 5
 

Mehr von Leif Bloomquist

Motion-Sensing Gaming Glove for the Commodore 64
Motion-Sensing Gaming Glove for the Commodore 64Motion-Sensing Gaming Glove for the Commodore 64
Motion-Sensing Gaming Glove for the Commodore 64
Leif Bloomquist
 

Mehr von Leif Bloomquist (15)

Tracking the International Space Station with Commodore Computers
Tracking the International Space Station with Commodore ComputersTracking the International Space Station with Commodore Computers
Tracking the International Space Station with Commodore Computers
 
Multiplayer Roguelike for the Commodore 64
Multiplayer Roguelike for the Commodore 64Multiplayer Roguelike for the Commodore 64
Multiplayer Roguelike for the Commodore 64
 
Multiplayer RogueLike Game for the Commodore 64
Multiplayer RogueLike Game for the Commodore 64Multiplayer RogueLike Game for the Commodore 64
Multiplayer RogueLike Game for the Commodore 64
 
VIC MIDI (World of Commodore 2015)
VIC MIDI (World of Commodore 2015)VIC MIDI (World of Commodore 2015)
VIC MIDI (World of Commodore 2015)
 
MIDI Mad Science and Mayhem (Soundhackers #5 "Controller Crazy")
MIDI Mad Science and Mayhem (Soundhackers #5 "Controller Crazy")MIDI Mad Science and Mayhem (Soundhackers #5 "Controller Crazy")
MIDI Mad Science and Mayhem (Soundhackers #5 "Controller Crazy")
 
Motion-Sensing Gaming Glove for the Commodore 64
Motion-Sensing Gaming Glove for the Commodore 64Motion-Sensing Gaming Glove for the Commodore 64
Motion-Sensing Gaming Glove for the Commodore 64
 
Wifi For the Commodore 64 (ECCC 2013)
Wifi For the Commodore 64 (ECCC 2013)Wifi For the Commodore 64 (ECCC 2013)
Wifi For the Commodore 64 (ECCC 2013)
 
TCP/IP For Engineers
TCP/IP For EngineersTCP/IP For Engineers
TCP/IP For Engineers
 
Real-Time Clock for Commodore PETs
Real-Time Clock for Commodore PETsReal-Time Clock for Commodore PETs
Real-Time Clock for Commodore PETs
 
Commodore 64 Telnet BBS Server
Commodore 64 Telnet BBS ServerCommodore 64 Telnet BBS Server
Commodore 64 Telnet BBS Server
 
Artillery Duel Network
Artillery Duel NetworkArtillery Duel Network
Artillery Duel Network
 
World of Commodore 2009 Posters
World of Commodore 2009 PostersWorld of Commodore 2009 Posters
World of Commodore 2009 Posters
 
Retrocomputers as Hacking Platforms
Retrocomputers as Hacking PlatformsRetrocomputers as Hacking Platforms
Retrocomputers as Hacking Platforms
 
NetRacer for the Commodore 64
NetRacer for the Commodore 64NetRacer for the Commodore 64
NetRacer for the Commodore 64
 
The Dancer From The Dance: Mapping Motion With Sound Via Radio Transmission
The Dancer From The Dance:  Mapping Motion With Sound Via Radio TransmissionThe Dancer From The Dance:  Mapping Motion With Sound Via Radio Transmission
The Dancer From The Dance: Mapping Motion With Sound Via Radio Transmission
 

Kürzlich hochgeladen

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Kürzlich hochgeladen (20)

GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 

Audible Objects

  • 1. Audible Objects June 14, 2016 Leif Bloomquist – Inter/Access June 13-14, 2016
  • 2. Overview Day 1 (Theory) • Introduction (15 minutes) • Arduino Basics (30 minutes) • Sensor Basics (15 minutes) • Analog vs. Digital (15 minutes) • Detecting Events (15 minutes) • Programming Basics (30 minutes) • MIDI (15 minutes) • Set up and test Arduino IDE (30 minutes) Day 2 (Practical) • Hook up and test sensors (1 hour) • Hook up and test MIDI (1 hour) • Put it all together (1 hour)
  • 3. A bit about me… • “Classically trained” in clarinet and percussion • Have been dabbling with music, composing, and technology since the 1980s • Moved to Waterloo in 1992 to study Systems Design Engineering • Moved to Toronto in 1997 and discovered the Ambient Ping, Riot Art and other experimental music communities • Occasional “live” gigs under the moniker Schema Factor • Playing with the tech is half the fun! • In general I release my tools and techniques open-source • Enable other electronic musicians to build on ideas! • “Day job” in software engineering at MDA, creators of the Canadarm
  • 6. What is Arduino? • An open-source electronics prototyping platform based on flexible, easy-to-use hardware and software. It’s intended for artists, designers, hobbyists, and anyone interested in creating interactive objects or environments. • Named after a bar in Italy, where it was invented! • The bar, in turn, was named after Arduin of Ivrea, king of Italy 1002-1014 www.arduino.cc
  • 7. Why Arduino? • Comes in a variety of shapes and sizes (and cost). • All programmed very similarly. • Emphasis on ease of programming and connecting to the outside world. • Arduino Uno is the most basic model (we will use for this course). • Open-Source: All designs, code, and tools are freely available.
  • 8. An Arduino is a computer! • Technically, a “microcontroller.” • Most run at 16 MHz – about the same power as a ‘286 computer from the 1990s (but with much less memory). • No Operating System, just a “bootloader.”
  • 9. Some Terminology • Bit: The smallest unit a computer can represent (0 or 1) • Byte: A collection of 8 bits (represents a whole number, 0 to 255) • Baud: (Also bps): bits per second • Serial: Method of transmitting data between computers (including Arduinos) • Named because the bits flow one at a time • Speed is represented in baud • Pin: Connection point to an Arduino for connecting inputs or outputs
  • 10. More Terminology • USB: Universal Serial Bus • Digital: An input or output that can be 0 or 1 (off or on) • Analog: An input or output that can be a range of values – like a volume control • ADC: Analog to Digital Converter – converts an analog input into a numeric whole number that the Arduino can work with
  • 11. Arduino Uno Parts Power Port (If not using USB) USB Port (Power and Serial) Digital Pins (Input or Output) Analog Pins (Input Only) Programming Pins (For factory setup) Microcontroller Reset Button (Reboots the Arduino) Power Pins
  • 13. Sensors • Motion • Acceleration • Sound • Light • Touch • Flex • Switches / Buttons • Moisture level • Temperature • Atmospheric pressure • Etc, etc.
  • 14. Detecting Digital Events Rising Edge: 0 → 1 Falling Edge: 1 → 0 Image Credit: Manpreet Singh Minhas • You need to remember the “previous” value
  • 15. Debouncing • In theory, the input signal from a perfect button looks like this (negative logic): 1 0 Time →
  • 16. Debouncing • But in reality, it looks like this: (trace from an oscilloscope)
  • 17. Debouncing Strategies • Wait for the value to stabilize over a few milliseconds • A simple delay timer works reasonably well
  • 18. Analog inputs are still “digital”…kind of • A typical analog sensor gives an output 0 volts to 5 volts, with infinite precision • To represent an analog input, the Arduino’s ADC converts these into a (typically) 10-bit value. • This ranges 0 to 1023. (Representing 0 volts to 5 volts)
  • 19. Detecting Analog Events • Set a “threshold” to trigger the event 0 1023 Time → Threshold
  • 20. Analog Inputs and Thresholds - Tips • The threshold value can be determined by trial and error • Print out the ADC value and note that happens when you activate the sensor • You may have to define an “on” threshold and an “off” threshold to keep it from triggering over and over again • Your thermostat at home does this • “Hysteresis” • Each individual sensor is slightly different – always check the values if changing sensors
  • 22. Arduino Programming Basics • Arduino programs are called sketches. • The Arduino programming language is based on the Wiring language, which in turn is a simplified version of C++. • Libraries are collections of functions that do various tasks. • The Arduino Integrated Development Environment (IDE) includes many libraries to help get you started.
  • 23. A Very Simple Arduino Program /* * Hello World! * * This is the Hello World! for Arduino. * It shows how to send data to the computer */ void setup() // run once, when the sketch starts { Serial.begin(9600); // set up Serial library at 9600 baud } void loop() // run over and over again { Serial.println("Hello world!"); // prints hello with ending line break }
  • 24. Arduino Programming Terminology • Statements are individual instructions to the Arduino. • Functions are a group of statements that do a single task. • Variables are placeholders in memory that can store a value. • Every variable has a data type (byte, integer, “float”, boolean, etc.) • Comments are notes that stay inside the program to explain what’s going on • The Arduino ignores these, they are for future you! • Use // or /* */ to indicate a comment. • Control structures are statements like if, for, while that let you direct the flow of the program based on conditions.
  • 25. Arduino Programming Continued… • Arduino requires two functions at minimum: setup() and loop() setup() is where you get everything ready (runs once at powerup or reset) loop() runs over and over infinitely until the power is turned off. • You can create your own functions if you find you are doing something over and over again
  • 26. Anatomy of a Function int AddTwoNumbers(int num1, int num2) { int sum = num1+num2; return sum; } { and } surround the function statements Inputs to the Function aka “parameters” Output of the Function aka “return type” Statements Return this value back to the main function
  • 27. Using Functions … … int answer = AddTwoNumbers(2,3); … … <do something with the answer> Inputs to the Function aka “arguments” Variable data type (must match!) Variable to hold the returned value Function “call”
  • 28. Useful Built-In Arduino Functions pinMode(): set a pin as input or output digitalWrite() – set a digital pin high/low digitalRead() – read a digital pin’s state analogRead() – read an analog pin delay() – wait an amount of time millis() – get the current time in milliseconds
  • 29. Using Comparison Operators (3 == 2) FALSE (3 > 2) TRUE (3 < 2) FALSE (answer < 5) FALSE (answer <= 5) TRUE • Potential gotcha: Off-by-one errors are very common
  • 30. Control Statements – if / else if (<condition is true>) { <do something> } else { <do something else> }
  • 31. Control Statements – while while (<condition is true>) { <do something over and over> } … • Potential gotcha: Your program will “freeze” inside the while loop while the condition is true
  • 32. Control Statements – for for (<initialization>, <condition>, <increment>) { <do something> } • Potential gotcha: Your program will “freeze” until the loop completes
  • 33. Control Statements – for (Example) for (int i=1; i<10; i++) { <do something 9 times> }
  • 34. A more complete Arduino program // Analog Input Example with Control Structures int sensorPin = A0; // select the input pin for the sensor int ledPin = 13; // select the pin for the LED int sensorValue = 0; // variable to store the value coming from the sensor void setup() { pinMode(ledPin, OUTPUT); // declare the ledPin as an OUTPUT } void loop() { sensorValue = analogRead(sensorPin); // read the value from the sensor Serial.println(sensorValue); // send the value to the PC if (sensorValue > 2000) // Have we crossed the threshold? { // turn the ledPin on digitalWrite(ledPin, HIGH); } else { // turn the ledPin off: digitalWrite(ledPin, LOW); } } “Global” variables – shared by entire program “setup” runs once “loop” runs infinitely
  • 35. Getting the Program into the Arduino • The Arduino IDE needs to know the type of Arduino that is connected, and which Serial port it is connected to. • Windows: COMxx • Mac: /dev/usbserialxx • The process of converting your human-readable program into Arduino “machine code” (a series of bytes) is called compiling. • The Arduino IDE checks your code for “correctness” (typos etc.), then compiles it, then transmits the program into the actual Arduino through USB. • The program stays permanently inside the Arduino until you change it.
  • 36. Musical Instrument Digital Interface (MIDI)
  • 37. The MIDI Protocol • Musical Instrument Digital Interface • Defined in 1982. • Serial Interface at 31250 baud (though this can be changed). • Messages consist of a Status (command) byte followed by Data bytes (usually two). • 16 virtual “Channels”. • Commands such as Note On, Note Off, Control Change, etc. • The defacto standard for exchanging music between computers, synthesizers, software, Arduinos…
  • 38. Decimal vs. Hexadecimal Notation • Most of the time, we use “decimal” (base 10) notation. 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13… • In many cases in programming and data communications (including MIDI), it is helpful to use “hexadecimal” (base 16) 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F, 10, 11, 12, 13…
  • 39. Why Hexadecimal? • Remember that a byte is 8 bits. • A “nybble” is 4 bits, which is 0-15 decimal…or 0-F hexadecimal. • Therefore, a byte can be conveniently represented in 2 hexadecimal digits. • In MIDI the different digits may have different meanings – example next slide • Hexadecimal is usually represented with the prefix 0x (other notations are heresy) • 0x00 = 0 decimal • 0x10 = 16 decimal • 0x64 = 100 decimal • 0xFF = 255 decimal (maximum for 1 byte)
  • 40. Typical MIDI Message 9 0 0x3C 0x64 Status byte Data bytes Channel Command 0x
  • 41. Example MIDI Message: Note On 9 1 0x45 0x7F Status byte Channel 2 Command “Note On” A440 Volume (“Velocity”) 0x
  • 42. Every Note On should be paired with a Note Off! 8 1 0x45 0x7F Status byte Channel 2 Command “Note Off” A440 “Velocity” 0x
  • 43. MIDI Note Numbers • Range from 0 (C in Octave 0) to 127 (G in Octave 10) • Middle C is 60 • A440 is 69 • etc…
  • 44. MIDI can also represent “continuous” values B 1 20 100 Status byte Channel 2 Command “Controller” Controller Number Controller Value • Useful for volume, pitch, filters, panning, other effects 0x
  • 45. MIDI Gotchas to Watch Out For • Remember to follow every Note On with a Note Off. • Note numbers and commands are often cited in hexadecimal. • Channel numbers are off by 1. A channel value of 3 refers to channel 4. • The values can only be 0 to 127 (7 bits)
  • 46. There is an Arduino MIDI Library • However, the protocol is so simple we will do it “by hand.” • The library is most useful for receiving+processing MIDI within the Arduino itself (outside the scope of this course.) http://playground.arduino.cc/Main/MIDILibrary
  • 47. Arduino Function to Send MIDI void sendMIDI(byte cmd, byte data1, byte data2) { Serial.write(cmd); Serial.write(data1); Serial.write(data2); }
  • 48. Receiving the Data: Hairless MIDI Bridge http://projectgus.github.io/hairless-midiserial/
  • 49. Putting It All Together • We now have almost everything we need: 1. We can create Arduino Sketches. 2. We can read from a sensor. 3. We can detect events. 4. We can send MIDI data from the Arduino to a computer . 5. We can receive MIDI data on the computer.
  • 51. Types of playback: Synthesized • Additive and subtractive synthesis • Generated algorithmically • Many parameters you can adjust in “real time”
  • 52. Digital Audio Workstations (DAWs) Many to choose from! Ableton, Logic Pro, GarageBand, Sonar, MAX, Reason, Cubase, Pro Tools, Different strengths and weaknesses, some free, many cost Concepts are similar Browser based!! https://www.soundtrap.com/
  • 53. What Next? 1. What MIDI data to send? 2. That depends on you!
  • 54. Some Ideas… 1. Trigger a sample based on a sensor event 2. Change the volume of a sound based on a sensor input 3. Change the pitch of a sound based on a sensor input 4. Play a musical ditty when an event happens 5. …
  • 55. Alternatives A modern alternative to MIDI exists, called Open Sound Control: http://opensoundcontrol.org/ (It’s complicated and hasn’t really caught on)
  • 56. Making it Wireless • Batteries • Wireless • Xbees (Serial to Serial) • ESP8266 (Serial to Wifi)
  • 57. Prep for tomorrow • Arduino IDE Setup • Hairless MIDI • Soundtrap