{"id":133,"date":"2011-05-14T17:24:00","date_gmt":"2011-05-14T15:24:00","guid":{"rendered":"http:\/\/www.sululab.com\/blog\/2011\/05\/14\/android-arduino-sequencer\/"},"modified":"2022-04-20T18:50:32","modified_gmt":"2022-04-20T16:50:32","slug":"android-arduino-sequencer","status":"publish","type":"post","link":"https:\/\/www.sululab.com\/blog\/2011\/05\/14\/android-arduino-sequencer\/","title":{"rendered":"Android Arduino Sequencer"},"content":{"rendered":"<p><a href=\"http:\/\/3.bp.blogspot.com\/-4mm6mlBFbos\/TcrRAkgw2gI\/AAAAAAAAAmU\/wREV-m0wHxM\/s1600\/schema.png\"><img decoding=\"async\" alt=\"\" border=\"0\" id=\"BLOGGER_PHOTO_ID_5605522493947304450\" src=\"http:\/\/3.bp.blogspot.com\/-4mm6mlBFbos\/TcrRAkgw2gI\/AAAAAAAAAmU\/wREV-m0wHxM\/s320\/schema.png\" style=\"cursor: hand; cursor: pointer; display: block; height: 282px; margin: 0px auto 10px; text-align: center; width: 316px;\"><\/a><br \/>\nEnglish version below<br \/>\nCon questo prototipo ci siamo posti l&#8217;obiettivo di avere il controllo di un semplice sequencer attraverso un cellulare Android. Il sequencer \u00e8 implementato all&#8217;interno di Arduino. Al momento non ci siamo molto concentrati sull&#8217;aspetto grafico, preferendo risolvere i molti problemi tecnici che si sono presentati.<br \/>\nQuesto progetto \u00e8 composto da due blocchi principali: uno \u00e8 costituito da <a href=\"http:\/\/www.arduino.cc\/\">Arduino<\/a> con l&#8217;<a href=\"http:\/\/www.arduino.cc\/en\/Main\/ArduinoEthernetShield\">Ethernet Shield<\/a> e il <a href=\"http:\/\/www.robot-italy.com\/product_info.php?products_id=1396\">MIDI Shield<\/a>, l&#8217;altro da uno smartphone con <a href=\"http:\/\/www.android.com\/\">Android<\/a>. I due blocchi si scambiano messaggi <a href=\"http:\/\/en.wikipedia.org\/wiki\/Open_Sound_Control\">OSC<\/a> (Open Sound Control) attraverso un router sfruttando la connessione ethernet per Arduino e quella WiFi per lo smartphone Android. L&#8217;Open Sound Control \u00e8 un protocollo di comunicazione tra computer, sintetizzatori audio e altri dispositivi multimediali ottimizzato per le connessioni in rete.<br \/>\nL&#8217;ultima versione di <a href=\"http:\/\/processing.org\/\">Processing<\/a>, la 1.5, prevede due modalit\u00e0 di sviluppo: una, quella classica, per desktop\/web e l&#8217;altra per <a href=\"http:\/\/wiki.processing.org\/w\/Android\">Android<\/a>. Questa \u00e8 un novit\u00e0 importante perch\u00e8 in questo modo diventa molto semplice sviluppare applicazioni per tutti quei dispositivi mobili (smartphone, tablet, &#8230;) che usano il sistema operativo Android, perlomeno pi\u00f9 semplice rispetto all&#8217;utilizzo del <a href=\"http:\/\/developer.android.com\/sdk\/index.html\">SDK nativo di Android<\/a>. Tutte le operazioni necessarie per iniziare a sviluppare in Processing per Android sono descritte nella <a href=\"http:\/\/wiki.processing.org\/w\/Android\">pagina<\/a> relativa del Wiki.<\/p>\n<p>La prima applicazione sviluppata per prendere confidenza con la nuova modalit\u00e0 di Processing \u00e8 un&#8217;interfaccia grafica al semplice <a href=\"http:\/\/sululab.blogspot.com\/2011\/03\/midi-sequencer.html\">MIDI Sequencer<\/a> per uno smartphone con Android.<br \/>\nL&#8217;applicazione crea una griglia di 8&#215;8 quadrati sullo schermo dello smartphone che diventano altrettante aree sensibili per impostare (con un tap) e visualizzare (mediante il combiamento di colore) le note da suonare negli 8 step. Il cambiamento di stato delle aree nella griglia viene inviato ad <a href=\"http:\/\/www.arduino.cc\/\">Arduino<\/a> (equipaggiato con un <a href=\"http:\/\/www.arduino.cc\/en\/Main\/ArduinoEthernetShield\">Ethernet Shield<\/a> e un <a href=\"http:\/\/www.robot-italy.com\/product_info.php?products_id=1396\">MIDI Shield<\/a>) mediante messaggi <a href=\"http:\/\/en.wikipedia.org\/wiki\/Open_Sound_Control\">OSC<\/a>.<\/p>\n<p>Arduino riceve i messaggi OSC via rete, cambia la sua rappresentazione interna dello stato della griglia di conseguenza, invia le note da suonare all&#8217;interfaccia <a href=\"http:\/\/en.wikipedia.org\/wiki\/Musical_Instrument_Digital_Interface\">MIDI<\/a> e invia messaggi OSC allo smartphone per mantenere sincronizzato lo step temporale in cui viene suonata la nota con la visualizzazione sullo schermo.<\/p>\n<p>Il semplice MIDI Sequencer implementato prevede l&#8217;uso di due canali MIDI (0 e 1) che possono essere impostati indipendentemente l&#8217;uno dalla&#8217;ltro. La selezione del canale avviene attraverso un tap sui quadrati posizionati sotto la griglia. I messaggi MIDI generati da Arduino vengono inviati al computer usando un&#8217;interfaccia MIDI\/USB, nel computer con sistema operativo Linux (<a href=\"http:\/\/ubuntustudio.org\/\">Ubuntu Studio<\/a>) gira il sintetizzatore software <a href=\"http:\/\/qsynth.sourceforge.net\/qsynth-index.html\">Qsynth<\/a>. Ovviamente l&#8217;uscita MIDI potrebbe anche essere collegata direttamente ad un sintetizzatore hardware rendendo il tutto indipendente dal computer.<\/p>\n<p>Componenti principali Arduino:<\/p>\n<ul>\n<li><a href=\"http:\/\/www.arduino.cc\/\">Arduino<\/a><\/li>\n<li><a href=\"http:\/\/www.arduino.cc\/en\/Main\/ArduinoEthernetShield\">Ethernet Shield<\/a><\/li>\n<li><a href=\"http:\/\/www.robot-italy.com\/product_info.php?products_id=1396\">MIDI Shield<\/a><\/li>\n<li>Libreria <a href=\"http:\/\/arduino.cc\/playground\/uploads\/Interfacing\/Z_OSC.zip\">Z_OSC<\/a> basata su <a href=\"http:\/\/recotana.com\/recotanablog\/closet\">ArdOSC<\/a> e modificata per funzionare con Linux (nomi di alcuni include file con maiuscole e minuscole incoerenti tra la chiamata all&#8217;interno dei file sorgenti e il nome nel file system) (<a href=\"http:\/\/www.hifilab.it\/doc\/Z_OSC-ab.zip\">Z_OSC-ab.zip<\/a>)<\/li>\n<li>Sketch scritto per Arduino (<a href=\"http:\/\/www.hifilab.it\/doc\/ArduinoSeq.zip\">ArduinoSeq.zip<\/a>)<\/li>\n<\/ul>\n<p>Componenti principali Android:<\/p>\n<ul>\n<li>Smartphone con Android 2.2 (dovrebbe andar bene dalla 2.1 in su)<\/li>\n<li>Router Wi-Fi per il collegamento di rete tra lo smartphone e Arduino<\/li>\n<li>Sketch scritto per Processing nella modalit\u00e0 di sviluppo per Android (<a href=\"http:\/\/www.hifilab.it\/doc\/AndroidSeq.zip\">AndroidSeq.zip<\/a>)<\/li>\n<\/ul>\n<p><iframe loading=\"lazy\" frameborder=\"0\" height=\"299\" src=\"http:\/\/player.vimeo.com\/video\/23442329?title=0&amp;byline=0&amp;portrait=0&amp;autoplay=0\" width=\"398\"><\/iframe><br \/>\nIn futuro vorremmo espandere questo progetto facendo in modo che i diversi canali vengano controllati da diversi cellulari, oltre a migliorare il sequencer stesso, sia da un punto di vista grafico, sia per renderlo pi\u00f9 consono alle esigenze di un musicista.<br \/>\n<a href=\"http:\/\/3.bp.blogspot.com\/-42-0xHRi7lA\/TcrSQvTQ4nI\/AAAAAAAAAmc\/_ms9VpbOHeU\/s1600\/schema_futuro.png\"><img decoding=\"async\" alt=\"\" border=\"0\" id=\"BLOGGER_PHOTO_ID_5605523871233008242\" src=\"http:\/\/3.bp.blogspot.com\/-42-0xHRi7lA\/TcrSQvTQ4nI\/AAAAAAAAAmc\/_ms9VpbOHeU\/s320\/schema_futuro.png\" style=\"cursor: hand; cursor: pointer; display: block; height: 298px; margin: 0px auto 10px; text-align: center; width: 320px;\"><\/a><\/p>\n<hr>\n<p>With this prototype we wanted to control a simple sequencer through an  Android phone. The sequencer is implemented in Arduino. At the moment we have not really focused on the appearance, preferring to solve many technical problems that occurred.<br \/>\nThe project is composed of two main blocks: one consisting of  <a href=\"http:\/\/www.arduino.cc\/\">Arduino<\/a> with <a href=\"http:\/\/www.arduino.cc\/en\/Main\/ArduinoEthernetShield\">Ethernet Shield<\/a> and <a href=\"http:\/\/www.sparkfun.com\/products\/9595\">MIDI Shield<\/a>, the other  of an <a href=\"http:\/\/www.android.com\/\">Android<\/a> smartphone. The two blocks are exchanging <a href=\"http:\/\/en.wikipedia.org\/wiki\/Open_Sound_Control\">OSC<\/a> (Open Sound Control) messages through a router using the ethernet connection for the Arduino and WiFi for the Android smartphone. Open Sound Control is a protocol for communication among computers, sound synthesizers, and other multimedia devices that is optimized for modern networking technology.<br \/>\nThe latest release of <a href=\"http:\/\/processing.org\/\">Processing<\/a> (1.5) provides two development modes: the classic one for desktop\/web and another one for <a href=\"http:\/\/wiki.processing.org\/w\/Android\">Android<\/a>. This is a significant change because now it is much easier to develop applications for all those mobile devices (smartphones, tablet, &#8230;) that use Android operating system, at least easier than using the native <a href=\"http:\/\/developer.android.com\/sdk\/index.html\">Android SDK<\/a>. All the necessary operations to start developing in Processing for Android are described on the relative Wiki <a href=\"http:\/\/wiki.processing.org\/w\/Android\">page<\/a>.<\/p>\n<p>The first application developed to study the new Processing mode is a graphical interface for the simple <a href=\"http:\/\/sululab.blogspot.com\/2011\/03\/midi-sequencer.html\">MIDI Sequencer<\/a>, for an Android smartphone.<br \/>\nThis application creates a grid of 8&#215;8 squares on the smartphone screen that become sensitive areas to set up (with a tap) and display (changing the colours) the notes to play in 8 steps. The state change of the squares in the grid is sent to <a href=\"http:\/\/www.arduino.cc\/\">Arduino<\/a> (equipped with an <a href=\"http:\/\/www.arduino.cc\/en\/Main\/ArduinoEthernetShield\">Ethernet Shield<\/a> and a <a href=\"http:\/\/www.sparkfun.com\/products\/9595\">MIDI Shield<\/a>) by <a href=\"http:\/\/en.wikipedia.org\/wiki\/Open_Sound_Control\">OSC<\/a> messages.<\/p>\n<p>Arduino receives OSC messages by the network, changes its internal representation of the state of the grid, sends notes to play to the <a href=\"http:\/\/en.wikipedia.org\/wiki\/Musical_Instrument_Digital_Interface\">MIDI<\/a> interface and sends OSC messages to the smartphone to synchronize the time step in which the note is played with the squares on the screen.<\/p>\n<p>The simple MIDI Sequencer implemented uses two MIDI channels (0 and 1) that can be set independently by a tap on the squares placed below the grid. The MIDI messages generated by Arduino are sent to the computer using a MIDI\/USB interface, the computer with Linux operative system (<a href=\"http:\/\/ubuntustudio.org\/\">Ubuntu Studio<\/a>) run <a href=\"http:\/\/qsynth.sourceforge.net\/qsynth-index.html\">Qsynth<\/a> software synthesizer. Of course, the MIDI output can also be connected directly to a hardware synthesizer making the system completely independent from your computer.<\/p>\n<p>Main Arduino components:<\/p>\n<ul>\n<li><a href=\"http:\/\/www.arduino.cc\/\">Arduino<\/a><\/li>\n<li><a href=\"http:\/\/www.arduino.cc\/en\/Main\/ArduinoEthernetShield\">Ethernet Shield<\/a><\/li>\n<li><a href=\"http:\/\/www.sparkfun.com\/products\/9595\">MIDI Shield<\/a><\/li>\n<li><a href=\"http:\/\/arduino.cc\/playground\/uploads\/Interfacing\/Z_OSC.zip\">Z_OSC<\/a> library based on <a href=\"http:\/\/recotana.com\/recotanablog\/closet\">ArdOSC<\/a> and modified to work on Linux (some include file names with case inconsistencies between the call in the source and the file system name) (<a href=\"http:\/\/www.hifilab.it\/doc\/Z_OSC-ab.zip\">Z_OSC-ab.zip<\/a>)<\/li>\n<li>Arduino sketch (<a href=\"http:\/\/www.hifilab.it\/doc\/ArduinoSeq.zip\">ArduinoSeq.zip<\/a>)<\/li>\n<\/ul>\n<p>Main Android components:<\/p>\n<ul>\n<li>Android 2.2 smartphone (should work from 2.1 up)<\/li>\n<li>Wi-Fi Router for the network connection between the smartphone and Arduino<\/li>\n<li>Processing sketch written in the Android development mode (<a href=\"http:\/\/www.hifilab.it\/doc\/AndroidSeq.zip\">AndroidSeq.zip<\/a>)<\/li>\n<\/ul>\n<p>In the future we would like to expand this project so that different channels are controlled by different phones, as well as improving the sequencer itself, both from a graphical point of view and to respond better to the needs of a musician.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>English version below Con questo prototipo ci siamo posti l&#8217;obiettivo di avere il controllo di un semplice sequencer attraverso un cellulare Android. Il sequencer \u00e8 implementato all&#8217;interno di Arduino. Al momento non ci siamo molto concentrati sull&#8217;aspetto grafico, preferendo risolvere&#8230; <a class=\"more-link\" href=\"https:\/\/www.sululab.com\/blog\/2011\/05\/14\/android-arduino-sequencer\/\">Continua a leggere &rarr;<\/a><\/p>\n","protected":false},"author":1,"featured_media":631,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[221,72,219,222,216,220],"tags":[],"class_list":["post-133","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-android","category-arduino","category-midi","category-osc","category-processing","category-sequencer"],"_links":{"self":[{"href":"https:\/\/www.sululab.com\/blog\/wp-json\/wp\/v2\/posts\/133","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.sululab.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.sululab.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.sululab.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sululab.com\/blog\/wp-json\/wp\/v2\/comments?post=133"}],"version-history":[{"count":1,"href":"https:\/\/www.sululab.com\/blog\/wp-json\/wp\/v2\/posts\/133\/revisions"}],"predecessor-version":[{"id":1134,"href":"https:\/\/www.sululab.com\/blog\/wp-json\/wp\/v2\/posts\/133\/revisions\/1134"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.sululab.com\/blog\/wp-json\/wp\/v2\/media\/631"}],"wp:attachment":[{"href":"https:\/\/www.sululab.com\/blog\/wp-json\/wp\/v2\/media?parent=133"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sululab.com\/blog\/wp-json\/wp\/v2\/categories?post=133"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sululab.com\/blog\/wp-json\/wp\/v2\/tags?post=133"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}