SlideShare a Scribd company logo
Università degli studi di
Roma Tor Vergata
Facoltà di Ingegneria
Roma2LUG
Linux User Group
Roma2LUG Incontra
Music On Linux
Speaker Speaker
Giulia Cassarà Emanuele Savo
Raspberry Pi
Introduction to the Raspberry Pi 3 Model B Board
General features
• Born as a MiniPC
• Can play HD movies
• Pi is versatile, you can use it in many ways: web servers, print
servers, robot, camera... We have use it as a speaker :)
Raspberry Pi
Specs of the Raspberry Pi 3 Model B Board
GPIO (General Purpose Input Output)
GPIO ports mapping of the Raspberry Pi 3 Model B Board
• The main difference between Raspberry Pi and a normal PC
are GPIO pins.
• These pins are a physical interface between the Pi and the
outside world. Raspberry can take an input from ouside (input
mode) or the Pi can "generate" something outside (output
mode)
• Be aware! GPIO pins don’t tolerate more than 3.3 V!
Raspbian OS installation
Download and unzip OS
• Download Raspbian OS lite version for the Raspberry Pi
$ wget https :// downloads.raspberrypi.org/
raspbian_lite_latest
• Unzip Raspbian OS for the Raspberry Pi
$ unzip xxxx -xx -xx -raspbian -jessie -lite.zip
After Download
Prepare SD card from Linux
• Insert SD card into the PC
• Search for device name of the SD card with this command:
$ sudo fdisk -l
• Search for info about your SD card. Warning, be careful!
Disk /dev/mmcblk0: 14,5 GiB , 15523119104 bytes , 30318592 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytesa
Disklabel type: dos
Disk identifier: 0x6f92008e
• Replace mmcblk0 with device name of your SD
$ sudo dd 
if=/xxxx -xx -xx -raspbian -jessie -lite.img 
of=/dev/mmcblk0
Boot
Boot the system and update packages
• Connect ethernet cable to the Raspberry Pi
• Connect HDMI cable to the Raspberry Pi
• Connect micro USB power cable to the Raspberry Pi
• Waiting for complete boot...
• Login
• user: pi
• password: raspberry
• Repository update:
$ sudo apt -get update
$ sudo apt -get dist -upgrade -y
$ sudo apt -get install rpi -update -y
Configuration
Expand filesystem and configure your raspberry
• Config Raspbian OS with this tool
$ sudo raspi -config
• Expand Filesystem
• Internationalisation Options
• Change Locale
• Change Timezone
• Change Keyboard Layout
• Change wifi Country
$ sudo reboot
• Update Raspberry Pi firmware
$ sudo rpi -update
$ sudo reboot
WiringPi and GIT
Install necessary software
• Install library for gpio and other tools
$ sudo apt -get install -y wiringpi git vim
• Download the scripts
$ git clone https :// github.com/Roma2Lug -
Projects/MusicOnLinux.git
• Open the script
$ cd MusicOnLinux/Scripts
$ vim keyboard.sh
$ vim smario.sh
Final steps
Script’s permission and execution
• Give execute permission
$ chmod +x keyboard.sh
$ chmod +x smario.sh
• Execute the scripts!
$ ./ keyboard.sh
$ ./ smario.sh
Tone function
#! /bin/bash
tone () {
local note="$1"
local duration="$2"
if test "$note" -eq 0; then
gpio -g mode 18 in
else
local frequency=$(python -c "print ’{0:.0f
}’. format (600000.0/440.0/2**(( $note -69)
/12.0))")
gpio -g mode 18 pwm
gpio pwmr "$(( frequency ))"
gpio -g pwm 18 "$(( frequency /2 ))"
gpio pwm -ms
sleep $duration
tone 0
fi
}
Tone function in details (1)
tone () {
local note="$1"
local duration="$2"
if test "$note" -eq 0; then
gpio -g mode 18 in
...
• First parameter: note.
• Second parameter: duration of the note.
• Test if the note is 0 then put the GPIO in input mode, so the
speaker doesn’t make any sound.
Tone function in details (2)
...
else
local frequency=$(python -c "print ’{0:.0f
}’. format (600000.0/440.0/2**(( $note -69)
/12.0))")
...
• We use the formula below to obtain the frequency of the
speaker
K · 440
2
X−69
12
• K = 19.2MHz
32 = 600kHz is the base frequency on which the
notes are calculated. It is dependent to the hardware of Pi.
• The so called twelfth root of two or 12
√
2 is an algebraic
irrational number. It is most important in music theory, where
it represents the frequency ratio of a semitone in twelve-tone
equal temperament.
• X is the range of the note, encoded in ASCII.
Tone function in details (3)
...
gpio -g mode 18 pwm
gpio pwmr "$(( frequency ))"
gpio -g pwm 18 "$(( frequency /2 ))"
gpio pwm -ms
sleep $duration
tone 0
fi
}
• These lines of code tell to Pi to give HIGH signal through
GPIO port 18 at a rate frequency to the connected speaker
with a modulation algorithm called Pulse Width Modulation
(PWM).
• The speaker beeps the "note" for a time "duration".
• Finally the last command mute the sound by recalling the
tone function with 0. Without this line the speaker will sound
indefinitily(!!!).
[DEMO]
Grazie per l’attenzione!

More Related Content

What's hot

Guitar Tone Analyzer and Note Plotter Presentation
Guitar Tone Analyzer and Note Plotter PresentationGuitar Tone Analyzer and Note Plotter Presentation
Guitar Tone Analyzer and Note Plotter Presentation
William Fackelman
 
Linux Shell Scripting Presantion
Linux Shell Scripting PresantionLinux Shell Scripting Presantion
Linux Shell Scripting Presantion
SameerNimkar
 
Background Audio Playback
Background Audio PlaybackBackground Audio Playback
Background Audio Playback
Korhan Bircan
 
Stdout
StdoutStdout
Stdout
Annu Gone
 
noise removal in matlab
noise removal in matlabnoise removal in matlab
noise removal in matlab
umarjamil10000
 
今日から始めるPlan 9 from Bell Labs
今日から始めるPlan 9 from Bell Labs今日から始めるPlan 9 from Bell Labs
今日から始めるPlan 9 from Bell Labs
Ryousei Takano
 
Lab1 dhcp-server
Lab1 dhcp-serverLab1 dhcp-server
Lab1 dhcp-server
Hudson Gwambe
 
Raspberry pi's gpio programming with go
Raspberry pi's gpio programming with goRaspberry pi's gpio programming with go
Raspberry pi's gpio programming with go
Konstantin Shamko
 
Pry at the Ruby Drink-up of Sophia, February 2012
Pry at the Ruby Drink-up of Sophia, February 2012Pry at the Ruby Drink-up of Sophia, February 2012
Pry at the Ruby Drink-up of Sophia, February 2012
rivierarb
 
Linux Device Tree
Linux Device TreeLinux Device Tree
Linux Device Tree
艾鍗科技
 
Making Open Source Hardware for Retrogaming on Raspberry Pi
Making Open Source Hardware for Retrogaming on Raspberry PiMaking Open Source Hardware for Retrogaming on Raspberry Pi
Making Open Source Hardware for Retrogaming on Raspberry Pi
Leon Anavi
 
Drumwavy VST VST3 Audio Unit: Orchestral and Ethnic Percussion VST, VST3 and ...
Drumwavy VST VST3 Audio Unit: Orchestral and Ethnic Percussion VST, VST3 and ...Drumwavy VST VST3 Audio Unit: Orchestral and Ethnic Percussion VST, VST3 and ...
Drumwavy VST VST3 Audio Unit: Orchestral and Ethnic Percussion VST, VST3 and ...
Syntheway Virtual Musical Instruments
 
Exploring the Internet of Things Using Ruby
Exploring the Internet of Things Using RubyExploring the Internet of Things Using Ruby
Exploring the Internet of Things Using Ruby
Mike Hagedorn
 
Music Trackers - Linux Usergroup Nijmegen 2014
Music Trackers - Linux Usergroup Nijmegen 2014Music Trackers - Linux Usergroup Nijmegen 2014
Music Trackers - Linux Usergroup Nijmegen 2014
Peter Martin
 
Sound analysis and processing with MATLAB
Sound analysis and processing with MATLABSound analysis and processing with MATLAB
Sound analysis and processing with MATLAB
Tan Hoang Luu
 
Sample Jarvis(desktop assistant)
Sample Jarvis(desktop assistant)Sample Jarvis(desktop assistant)
Sample Jarvis(desktop assistant)
Shivaji SV
 
Tiny ML for spark Fun Edge
Tiny ML for spark Fun EdgeTiny ML for spark Fun Edge
Tiny ML for spark Fun Edge
艾鍗科技
 
Getting started with ubuntu
Getting started with ubuntuGetting started with ubuntu
Getting started with ubuntu
Abhinav Upadhyay
 
Ultimate Unix Meetup Presentation
Ultimate Unix Meetup PresentationUltimate Unix Meetup Presentation
Ultimate Unix Meetup Presentation
JacobMenke1
 
Sup intro
Sup introSup intro
Sup intro
chase pettet
 

What's hot (20)

Guitar Tone Analyzer and Note Plotter Presentation
Guitar Tone Analyzer and Note Plotter PresentationGuitar Tone Analyzer and Note Plotter Presentation
Guitar Tone Analyzer and Note Plotter Presentation
 
Linux Shell Scripting Presantion
Linux Shell Scripting PresantionLinux Shell Scripting Presantion
Linux Shell Scripting Presantion
 
Background Audio Playback
Background Audio PlaybackBackground Audio Playback
Background Audio Playback
 
Stdout
StdoutStdout
Stdout
 
noise removal in matlab
noise removal in matlabnoise removal in matlab
noise removal in matlab
 
今日から始めるPlan 9 from Bell Labs
今日から始めるPlan 9 from Bell Labs今日から始めるPlan 9 from Bell Labs
今日から始めるPlan 9 from Bell Labs
 
Lab1 dhcp-server
Lab1 dhcp-serverLab1 dhcp-server
Lab1 dhcp-server
 
Raspberry pi's gpio programming with go
Raspberry pi's gpio programming with goRaspberry pi's gpio programming with go
Raspberry pi's gpio programming with go
 
Pry at the Ruby Drink-up of Sophia, February 2012
Pry at the Ruby Drink-up of Sophia, February 2012Pry at the Ruby Drink-up of Sophia, February 2012
Pry at the Ruby Drink-up of Sophia, February 2012
 
Linux Device Tree
Linux Device TreeLinux Device Tree
Linux Device Tree
 
Making Open Source Hardware for Retrogaming on Raspberry Pi
Making Open Source Hardware for Retrogaming on Raspberry PiMaking Open Source Hardware for Retrogaming on Raspberry Pi
Making Open Source Hardware for Retrogaming on Raspberry Pi
 
Drumwavy VST VST3 Audio Unit: Orchestral and Ethnic Percussion VST, VST3 and ...
Drumwavy VST VST3 Audio Unit: Orchestral and Ethnic Percussion VST, VST3 and ...Drumwavy VST VST3 Audio Unit: Orchestral and Ethnic Percussion VST, VST3 and ...
Drumwavy VST VST3 Audio Unit: Orchestral and Ethnic Percussion VST, VST3 and ...
 
Exploring the Internet of Things Using Ruby
Exploring the Internet of Things Using RubyExploring the Internet of Things Using Ruby
Exploring the Internet of Things Using Ruby
 
Music Trackers - Linux Usergroup Nijmegen 2014
Music Trackers - Linux Usergroup Nijmegen 2014Music Trackers - Linux Usergroup Nijmegen 2014
Music Trackers - Linux Usergroup Nijmegen 2014
 
Sound analysis and processing with MATLAB
Sound analysis and processing with MATLABSound analysis and processing with MATLAB
Sound analysis and processing with MATLAB
 
Sample Jarvis(desktop assistant)
Sample Jarvis(desktop assistant)Sample Jarvis(desktop assistant)
Sample Jarvis(desktop assistant)
 
Tiny ML for spark Fun Edge
Tiny ML for spark Fun EdgeTiny ML for spark Fun Edge
Tiny ML for spark Fun Edge
 
Getting started with ubuntu
Getting started with ubuntuGetting started with ubuntu
Getting started with ubuntu
 
Ultimate Unix Meetup Presentation
Ultimate Unix Meetup PresentationUltimate Unix Meetup Presentation
Ultimate Unix Meetup Presentation
 
Sup intro
Sup introSup intro
Sup intro
 

Similar to Musiconlinux

Up and running with Raspberry Pi
Up and running with Raspberry PiUp and running with Raspberry Pi
Up and running with Raspberry Pi
Shahed Mehbub
 
Intoduction to physical computing using Raspberry Pi, 18-02-2016
Intoduction to physical computing using Raspberry Pi, 18-02-2016Intoduction to physical computing using Raspberry Pi, 18-02-2016
Intoduction to physical computing using Raspberry Pi, 18-02-2016
Sebin Benjamin
 
Raspberry Pi Free Session - 20_09_2014
Raspberry Pi Free Session - 20_09_2014Raspberry Pi Free Session - 20_09_2014
Raspberry Pi Free Session - 20_09_2014
Mandeesh Singh
 
Introduction To Raspberry Pi with Simple GPIO pin Control
Introduction To Raspberry Pi with Simple GPIO pin ControlIntroduction To Raspberry Pi with Simple GPIO pin Control
Introduction To Raspberry Pi with Simple GPIO pin Control
Pradip Bhandari
 
My presentation raspberry pi
My presentation raspberry piMy presentation raspberry pi
My presentation raspberry pi
HusainBhaldar21
 
Getting Started with Raspberry Pi
Getting Started with Raspberry PiGetting Started with Raspberry Pi
Getting Started with Raspberry Pi
yeokm1
 
[5]投影片 futurewad樹莓派研習會 141218
[5]投影片 futurewad樹莓派研習會 141218[5]投影片 futurewad樹莓派研習會 141218
[5]投影片 futurewad樹莓派研習會 141218
CAVEDU Education
 
Raspberry pi
Raspberry pi Raspberry pi
Raspberry pi
ABHIJITPATRA23
 
Raspberry Pi introduction
Raspberry Pi introductionRaspberry Pi introduction
Raspberry Pi introduction
Lotfi Messaoudi
 
Raspberry Pi Session - 22_11_2014
Raspberry Pi Session - 22_11_2014Raspberry Pi Session - 22_11_2014
Raspberry Pi Session - 22_11_2014
Mandeesh Singh
 
Intro to the raspberry pi board
Intro to the raspberry pi boardIntro to the raspberry pi board
Intro to the raspberry pi board
Thierry Gayet
 
Raspberry Pi GPIO Tutorial - Make Your Own Game Console
Raspberry Pi GPIO Tutorial - Make Your Own Game ConsoleRaspberry Pi GPIO Tutorial - Make Your Own Game Console
Raspberry Pi GPIO Tutorial - Make Your Own Game Console
RICELEEIO
 
Internet of Things, refers to the network of interconnected devices that are ...
Internet of Things, refers to the network of interconnected devices that are ...Internet of Things, refers to the network of interconnected devices that are ...
Internet of Things, refers to the network of interconnected devices that are ...
tharunreddy999000
 
Python-in-Embedded-systems.pptx
Python-in-Embedded-systems.pptxPython-in-Embedded-systems.pptx
Python-in-Embedded-systems.pptx
TuynLCh
 
Introduction to the rapid prototyping with python and linux for embedded systems
Introduction to the rapid prototyping with python and linux for embedded systemsIntroduction to the rapid prototyping with python and linux for embedded systems
Introduction to the rapid prototyping with python and linux for embedded systems
Naohiko Shimizu
 
Raspberry Pi Technology
Raspberry Pi TechnologyRaspberry Pi Technology
Raspberry Pi Technology
Ravi Basil
 
Exploring the ABC's of Raspberry Pi with Python
Exploring the ABC's of Raspberry Pi with PythonExploring the ABC's of Raspberry Pi with Python
Exploring the ABC's of Raspberry Pi with Python
Shahed Mehbub
 
Raspberry pi basics
Raspberry pi  basicsRaspberry pi  basics
Raspberry pi basics
BHAWESH RAJPAL
 
2_RaspberryPi presentation.pptx
2_RaspberryPi presentation.pptx2_RaspberryPi presentation.pptx
2_RaspberryPi presentation.pptx
neelamsanjeevkumar
 
Raspberry Pi for IPRUG
Raspberry Pi for IPRUGRaspberry Pi for IPRUG
Raspberry Pi for IPRUG
Frank Carver
 

Similar to Musiconlinux (20)

Up and running with Raspberry Pi
Up and running with Raspberry PiUp and running with Raspberry Pi
Up and running with Raspberry Pi
 
Intoduction to physical computing using Raspberry Pi, 18-02-2016
Intoduction to physical computing using Raspberry Pi, 18-02-2016Intoduction to physical computing using Raspberry Pi, 18-02-2016
Intoduction to physical computing using Raspberry Pi, 18-02-2016
 
Raspberry Pi Free Session - 20_09_2014
Raspberry Pi Free Session - 20_09_2014Raspberry Pi Free Session - 20_09_2014
Raspberry Pi Free Session - 20_09_2014
 
Introduction To Raspberry Pi with Simple GPIO pin Control
Introduction To Raspberry Pi with Simple GPIO pin ControlIntroduction To Raspberry Pi with Simple GPIO pin Control
Introduction To Raspberry Pi with Simple GPIO pin Control
 
My presentation raspberry pi
My presentation raspberry piMy presentation raspberry pi
My presentation raspberry pi
 
Getting Started with Raspberry Pi
Getting Started with Raspberry PiGetting Started with Raspberry Pi
Getting Started with Raspberry Pi
 
[5]投影片 futurewad樹莓派研習會 141218
[5]投影片 futurewad樹莓派研習會 141218[5]投影片 futurewad樹莓派研習會 141218
[5]投影片 futurewad樹莓派研習會 141218
 
Raspberry pi
Raspberry pi Raspberry pi
Raspberry pi
 
Raspberry Pi introduction
Raspberry Pi introductionRaspberry Pi introduction
Raspberry Pi introduction
 
Raspberry Pi Session - 22_11_2014
Raspberry Pi Session - 22_11_2014Raspberry Pi Session - 22_11_2014
Raspberry Pi Session - 22_11_2014
 
Intro to the raspberry pi board
Intro to the raspberry pi boardIntro to the raspberry pi board
Intro to the raspberry pi board
 
Raspberry Pi GPIO Tutorial - Make Your Own Game Console
Raspberry Pi GPIO Tutorial - Make Your Own Game ConsoleRaspberry Pi GPIO Tutorial - Make Your Own Game Console
Raspberry Pi GPIO Tutorial - Make Your Own Game Console
 
Internet of Things, refers to the network of interconnected devices that are ...
Internet of Things, refers to the network of interconnected devices that are ...Internet of Things, refers to the network of interconnected devices that are ...
Internet of Things, refers to the network of interconnected devices that are ...
 
Python-in-Embedded-systems.pptx
Python-in-Embedded-systems.pptxPython-in-Embedded-systems.pptx
Python-in-Embedded-systems.pptx
 
Introduction to the rapid prototyping with python and linux for embedded systems
Introduction to the rapid prototyping with python and linux for embedded systemsIntroduction to the rapid prototyping with python and linux for embedded systems
Introduction to the rapid prototyping with python and linux for embedded systems
 
Raspberry Pi Technology
Raspberry Pi TechnologyRaspberry Pi Technology
Raspberry Pi Technology
 
Exploring the ABC's of Raspberry Pi with Python
Exploring the ABC's of Raspberry Pi with PythonExploring the ABC's of Raspberry Pi with Python
Exploring the ABC's of Raspberry Pi with Python
 
Raspberry pi basics
Raspberry pi  basicsRaspberry pi  basics
Raspberry pi basics
 
2_RaspberryPi presentation.pptx
2_RaspberryPi presentation.pptx2_RaspberryPi presentation.pptx
2_RaspberryPi presentation.pptx
 
Raspberry Pi for IPRUG
Raspberry Pi for IPRUGRaspberry Pi for IPRUG
Raspberry Pi for IPRUG
 

Recently uploaded

International Conference on NLP, Artificial Intelligence, Machine Learning an...
International Conference on NLP, Artificial Intelligence, Machine Learning an...International Conference on NLP, Artificial Intelligence, Machine Learning an...
International Conference on NLP, Artificial Intelligence, Machine Learning an...
gerogepatton
 
学校原版美国波士顿大学毕业证学历学位证书原版一模一样
学校原版美国波士顿大学毕业证学历学位证书原版一模一样学校原版美国波士顿大学毕业证学历学位证书原版一模一样
学校原版美国波士顿大学毕业证学历学位证书原版一模一样
171ticu
 
Manufacturing Process of molasses based distillery ppt.pptx
Manufacturing Process of molasses based distillery ppt.pptxManufacturing Process of molasses based distillery ppt.pptx
Manufacturing Process of molasses based distillery ppt.pptx
Madan Karki
 
CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURSCompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
RamonNovais6
 
Unit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
Unit-III-ELECTROCHEMICAL STORAGE DEVICES.pptUnit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
Unit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
KrishnaveniKrishnara1
 
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming PipelinesHarnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
Christina Lin
 
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
insn4465
 
官方认证美国密歇根州立大学毕业证学位证书原版一模一样
官方认证美国密歇根州立大学毕业证学位证书原版一模一样官方认证美国密歇根州立大学毕业证学位证书原版一模一样
官方认证美国密歇根州立大学毕业证学位证书原版一模一样
171ticu
 
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressionsKuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
Victor Morales
 
LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by AnantLLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
Anant Corporation
 
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
shadow0702a
 
john krisinger-the science and history of the alcoholic beverage.pptx
john krisinger-the science and history of the alcoholic beverage.pptxjohn krisinger-the science and history of the alcoholic beverage.pptx
john krisinger-the science and history of the alcoholic beverage.pptx
Madan Karki
 
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
Yasser Mahgoub
 
ISPM 15 Heat Treated Wood Stamps and why your shipping must have one
ISPM 15 Heat Treated Wood Stamps and why your shipping must have oneISPM 15 Heat Treated Wood Stamps and why your shipping must have one
ISPM 15 Heat Treated Wood Stamps and why your shipping must have one
Las Vegas Warehouse
 
Computational Engineering IITH Presentation
Computational Engineering IITH PresentationComputational Engineering IITH Presentation
Computational Engineering IITH Presentation
co23btech11018
 
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
IJECEIAES
 
一比一原版(CalArts毕业证)加利福尼亚艺术学院毕业证如何办理
一比一原版(CalArts毕业证)加利福尼亚艺术学院毕业证如何办理一比一原版(CalArts毕业证)加利福尼亚艺术学院毕业证如何办理
一比一原版(CalArts毕业证)加利福尼亚艺术学院毕业证如何办理
ecqow
 
Curve Fitting in Numerical Methods Regression
Curve Fitting in Numerical Methods RegressionCurve Fitting in Numerical Methods Regression
Curve Fitting in Numerical Methods Regression
Nada Hikmah
 
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdfBPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
MIGUELANGEL966976
 
Casting-Defect-inSlab continuous casting.pdf
Casting-Defect-inSlab continuous casting.pdfCasting-Defect-inSlab continuous casting.pdf
Casting-Defect-inSlab continuous casting.pdf
zubairahmad848137
 

Recently uploaded (20)

International Conference on NLP, Artificial Intelligence, Machine Learning an...
International Conference on NLP, Artificial Intelligence, Machine Learning an...International Conference on NLP, Artificial Intelligence, Machine Learning an...
International Conference on NLP, Artificial Intelligence, Machine Learning an...
 
学校原版美国波士顿大学毕业证学历学位证书原版一模一样
学校原版美国波士顿大学毕业证学历学位证书原版一模一样学校原版美国波士顿大学毕业证学历学位证书原版一模一样
学校原版美国波士顿大学毕业证学历学位证书原版一模一样
 
Manufacturing Process of molasses based distillery ppt.pptx
Manufacturing Process of molasses based distillery ppt.pptxManufacturing Process of molasses based distillery ppt.pptx
Manufacturing Process of molasses based distillery ppt.pptx
 
CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURSCompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
 
Unit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
Unit-III-ELECTROCHEMICAL STORAGE DEVICES.pptUnit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
Unit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
 
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming PipelinesHarnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
 
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
 
官方认证美国密歇根州立大学毕业证学位证书原版一模一样
官方认证美国密歇根州立大学毕业证学位证书原版一模一样官方认证美国密歇根州立大学毕业证学位证书原版一模一样
官方认证美国密歇根州立大学毕业证学位证书原版一模一样
 
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressionsKuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
 
LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by AnantLLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
 
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
 
john krisinger-the science and history of the alcoholic beverage.pptx
john krisinger-the science and history of the alcoholic beverage.pptxjohn krisinger-the science and history of the alcoholic beverage.pptx
john krisinger-the science and history of the alcoholic beverage.pptx
 
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
 
ISPM 15 Heat Treated Wood Stamps and why your shipping must have one
ISPM 15 Heat Treated Wood Stamps and why your shipping must have oneISPM 15 Heat Treated Wood Stamps and why your shipping must have one
ISPM 15 Heat Treated Wood Stamps and why your shipping must have one
 
Computational Engineering IITH Presentation
Computational Engineering IITH PresentationComputational Engineering IITH Presentation
Computational Engineering IITH Presentation
 
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
 
一比一原版(CalArts毕业证)加利福尼亚艺术学院毕业证如何办理
一比一原版(CalArts毕业证)加利福尼亚艺术学院毕业证如何办理一比一原版(CalArts毕业证)加利福尼亚艺术学院毕业证如何办理
一比一原版(CalArts毕业证)加利福尼亚艺术学院毕业证如何办理
 
Curve Fitting in Numerical Methods Regression
Curve Fitting in Numerical Methods RegressionCurve Fitting in Numerical Methods Regression
Curve Fitting in Numerical Methods Regression
 
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdfBPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
 
Casting-Defect-inSlab continuous casting.pdf
Casting-Defect-inSlab continuous casting.pdfCasting-Defect-inSlab continuous casting.pdf
Casting-Defect-inSlab continuous casting.pdf
 

Musiconlinux

  • 1. Università degli studi di Roma Tor Vergata Facoltà di Ingegneria Roma2LUG Linux User Group Roma2LUG Incontra Music On Linux Speaker Speaker Giulia Cassarà Emanuele Savo
  • 2. Raspberry Pi Introduction to the Raspberry Pi 3 Model B Board General features • Born as a MiniPC • Can play HD movies • Pi is versatile, you can use it in many ways: web servers, print servers, robot, camera... We have use it as a speaker :)
  • 3. Raspberry Pi Specs of the Raspberry Pi 3 Model B Board
  • 4. GPIO (General Purpose Input Output) GPIO ports mapping of the Raspberry Pi 3 Model B Board • The main difference between Raspberry Pi and a normal PC are GPIO pins. • These pins are a physical interface between the Pi and the outside world. Raspberry can take an input from ouside (input mode) or the Pi can "generate" something outside (output mode) • Be aware! GPIO pins don’t tolerate more than 3.3 V!
  • 5. Raspbian OS installation Download and unzip OS • Download Raspbian OS lite version for the Raspberry Pi $ wget https :// downloads.raspberrypi.org/ raspbian_lite_latest • Unzip Raspbian OS for the Raspberry Pi $ unzip xxxx -xx -xx -raspbian -jessie -lite.zip
  • 6. After Download Prepare SD card from Linux • Insert SD card into the PC • Search for device name of the SD card with this command: $ sudo fdisk -l • Search for info about your SD card. Warning, be careful! Disk /dev/mmcblk0: 14,5 GiB , 15523119104 bytes , 30318592 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytesa Disklabel type: dos Disk identifier: 0x6f92008e • Replace mmcblk0 with device name of your SD $ sudo dd if=/xxxx -xx -xx -raspbian -jessie -lite.img of=/dev/mmcblk0
  • 7. Boot Boot the system and update packages • Connect ethernet cable to the Raspberry Pi • Connect HDMI cable to the Raspberry Pi • Connect micro USB power cable to the Raspberry Pi • Waiting for complete boot... • Login • user: pi • password: raspberry • Repository update: $ sudo apt -get update $ sudo apt -get dist -upgrade -y $ sudo apt -get install rpi -update -y
  • 8. Configuration Expand filesystem and configure your raspberry • Config Raspbian OS with this tool $ sudo raspi -config • Expand Filesystem • Internationalisation Options • Change Locale • Change Timezone • Change Keyboard Layout • Change wifi Country $ sudo reboot • Update Raspberry Pi firmware $ sudo rpi -update $ sudo reboot
  • 9. WiringPi and GIT Install necessary software • Install library for gpio and other tools $ sudo apt -get install -y wiringpi git vim • Download the scripts $ git clone https :// github.com/Roma2Lug - Projects/MusicOnLinux.git • Open the script $ cd MusicOnLinux/Scripts $ vim keyboard.sh $ vim smario.sh
  • 10. Final steps Script’s permission and execution • Give execute permission $ chmod +x keyboard.sh $ chmod +x smario.sh • Execute the scripts! $ ./ keyboard.sh $ ./ smario.sh
  • 11. Tone function #! /bin/bash tone () { local note="$1" local duration="$2" if test "$note" -eq 0; then gpio -g mode 18 in else local frequency=$(python -c "print ’{0:.0f }’. format (600000.0/440.0/2**(( $note -69) /12.0))") gpio -g mode 18 pwm gpio pwmr "$(( frequency ))" gpio -g pwm 18 "$(( frequency /2 ))" gpio pwm -ms sleep $duration tone 0 fi }
  • 12. Tone function in details (1) tone () { local note="$1" local duration="$2" if test "$note" -eq 0; then gpio -g mode 18 in ... • First parameter: note. • Second parameter: duration of the note. • Test if the note is 0 then put the GPIO in input mode, so the speaker doesn’t make any sound.
  • 13. Tone function in details (2) ... else local frequency=$(python -c "print ’{0:.0f }’. format (600000.0/440.0/2**(( $note -69) /12.0))") ... • We use the formula below to obtain the frequency of the speaker K · 440 2 X−69 12 • K = 19.2MHz 32 = 600kHz is the base frequency on which the notes are calculated. It is dependent to the hardware of Pi. • The so called twelfth root of two or 12 √ 2 is an algebraic irrational number. It is most important in music theory, where it represents the frequency ratio of a semitone in twelve-tone equal temperament. • X is the range of the note, encoded in ASCII.
  • 14. Tone function in details (3) ... gpio -g mode 18 pwm gpio pwmr "$(( frequency ))" gpio -g pwm 18 "$(( frequency /2 ))" gpio pwm -ms sleep $duration tone 0 fi } • These lines of code tell to Pi to give HIGH signal through GPIO port 18 at a rate frequency to the connected speaker with a modulation algorithm called Pulse Width Modulation (PWM). • The speaker beeps the "note" for a time "duration". • Finally the last command mute the sound by recalling the tone function with 0. Without this line the speaker will sound indefinitily(!!!).