<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ca">
	<id>http://wiki.joanillo.org/index.php?action=history&amp;feed=atom&amp;title=EWI-USB_amb_la_Raspberry_Pi</id>
	<title>EWI-USB amb la Raspberry Pi - Historial de revisió</title>
	<link rel="self" type="application/atom+xml" href="http://wiki.joanillo.org/index.php?action=history&amp;feed=atom&amp;title=EWI-USB_amb_la_Raspberry_Pi"/>
	<link rel="alternate" type="text/html" href="http://wiki.joanillo.org/index.php?title=EWI-USB_amb_la_Raspberry_Pi&amp;action=history"/>
	<updated>2026-04-20T05:52:14Z</updated>
	<subtitle>Historial de revisió per a aquesta pàgina del wiki</subtitle>
	<generator>MediaWiki 1.34.2</generator>
	<entry>
		<id>http://wiki.joanillo.org/index.php?title=EWI-USB_amb_la_Raspberry_Pi&amp;diff=250810&amp;oldid=prev</id>
		<title>Joan: /* EWI-USB + Raspberry Pi amb fluidsynth */</title>
		<link rel="alternate" type="text/html" href="http://wiki.joanillo.org/index.php?title=EWI-USB_amb_la_Raspberry_Pi&amp;diff=250810&amp;oldid=prev"/>
		<updated>2013-11-13T17:01:48Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;EWI-USB + Raspberry Pi amb fluidsynth&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Pàgina nova&lt;/b&gt;&lt;/p&gt;&lt;div&gt;__TOC__&lt;br /&gt;
El EWI-USB s'ha de connectar a un ordinador. Tinc el sinte JV-1010 (i el JV-2080), però no em són útils per connectar-hi el EWI-USB. Ara bé, i si utilitzo una Raspberry PI com a plataforma portàtil per aconseguir una configuració mínima i pràctica?&lt;br /&gt;
&lt;br /&gt;
=Referències=&lt;br /&gt;
''Autostatic'' ha escrit (novembre 2013) un article per fer sonar en Salamander Grand Piano a la RP (Using a Raspberry Pi as a piano, http://linux.autostatic.com/).&lt;br /&gt;
&lt;br /&gt;
D'aquest article i els scripts que programa es pot extreure coses interessants que caldria repassar: Jack a baixa latència, desactivar la wifi,... es comenta que és important tenir una SD de bona qualitat (per ex, class 10).&lt;br /&gt;
*http://linux.autostatic.com/&lt;br /&gt;
&lt;br /&gt;
=EWI-USB + Raspberry Pi amb fluidsynth=&lt;br /&gt;
*http://www.siliconstuff.com/2012/08/fluidsynth-on-raspberry-pi.html&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ sudo apt-get install fluidsynth&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Després d'instal.lar el fluidsynth tinc disponible el soundfont /usr/share/sounds/sf2/FluidR3_GM.sf2, però també en puc carregar d'altres. Des del portàtil carrego soundfonts:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ scp Casio_VL-1.SF2 pi@192.168.1.135:/home/pi&lt;br /&gt;
$ scp Natural_Oboe.sf2 pi@192.168.1.135:/home/pi&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Arrenco el fluidsynth amb un soundfont:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ fluidsynth -a alsa -m alsa_seq /home/pi/Casio_VL-1.SF2&lt;br /&gt;
$ fluidsynth -a alsa -m alsa_seq /usr/share/sounds/sf2/FluidR3_GM.sf2&lt;br /&gt;
$ fluidsynth -a alsa -m alsa_seq /home/pi/Natural_Oboe.sf2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Tinc el EWI-USB connectat:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ aconnect -iol&lt;br /&gt;
client 0: 'System' [type=kernel]&lt;br /&gt;
    0 'Timer           '&lt;br /&gt;
    1 'Announce        '&lt;br /&gt;
client 14: 'Midi Through' [type=kernel]&lt;br /&gt;
    0 'Midi Through Port-0'&lt;br /&gt;
client 20: 'EWI-USB' [type=kernel]&lt;br /&gt;
    0 'EWI-USB MIDI 1  '&lt;br /&gt;
client 128: 'FLUID Synth (2431)' [type=user]&lt;br /&gt;
    0 'Synth input port (2431:0)'&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Faig la connexió ALSA:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ aconnect 20:0 128:0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
I ja sona. Per als soundfonts grans la latència és considerable. Per al soundfont petit la latència és menor. Estic fent les proves amb una Raspberry de 256MB (amb una de 512MB el resultat hauria de ser millor).&lt;br /&gt;
&lt;br /&gt;
El meu EWI-USB el tinc configurat per defecte que soni pel canal 16 (15 si 0-15). Què he de fer per escollir un altre instrument?&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;gt; channels&lt;br /&gt;
chan 0, Yamaha Grand Piano&lt;br /&gt;
chan 1, Yamaha Grand Piano&lt;br /&gt;
chan 2, Yamaha Grand Piano&lt;br /&gt;
chan 3, Yamaha Grand Piano&lt;br /&gt;
chan 4, Yamaha Grand Piano&lt;br /&gt;
chan 5, Yamaha Grand Piano&lt;br /&gt;
chan 6, Yamaha Grand Piano&lt;br /&gt;
chan 7, Yamaha Grand Piano&lt;br /&gt;
chan 8, Yamaha Grand Piano&lt;br /&gt;
chan 9, Standard&lt;br /&gt;
chan 10, Yamaha Grand Piano&lt;br /&gt;
chan 11, Yamaha Grand Piano&lt;br /&gt;
chan 12, Yamaha Grand Piano&lt;br /&gt;
chan 13, Yamaha Grand Piano&lt;br /&gt;
chan 14, Yamaha Grand Piano&lt;br /&gt;
chan 15, Yamaha Grand Piano&lt;br /&gt;
&lt;br /&gt;
&amp;gt; inst 1&lt;br /&gt;
...&lt;br /&gt;
000-056 Trumpet&lt;br /&gt;
000-057 Trombone&lt;br /&gt;
000-058 Tuba&lt;br /&gt;
000-059 Muted Trumpet&lt;br /&gt;
000-060 French Horns&lt;br /&gt;
000-061 Brass Section&lt;br /&gt;
000-062 Synth Brass 1&lt;br /&gt;
000-063 Synth Brass 2&lt;br /&gt;
000-064 Soprano Sax&lt;br /&gt;
000-065 Alto Sax&lt;br /&gt;
000-066 Tenor Sax&lt;br /&gt;
000-067 Baritone Sax&lt;br /&gt;
000-068 Oboe&lt;br /&gt;
000-069 English Horn&lt;br /&gt;
000-070 Bassoon&lt;br /&gt;
000-071 Clarinet&lt;br /&gt;
000-072 Piccolo&lt;br /&gt;
000-073 Flute&lt;br /&gt;
000-074 Recorder&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Si vull el so de clarinet faré:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;gt; prog 15 71&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
i fico el valor 15 perquè per defecte tinc configurat el EWI-USB per tal de què soni pel canal 15.&lt;br /&gt;
==Millorar el volum==&lt;br /&gt;
Després hi ha un problema de volum que es soluciona molt fàcilment amb el alsa-mixer:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ alsamixer&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
o recordar que el fluidsynth també té l'opció del guany.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ fluidsynth -a alsa -m alsa_seq -g 1 /home/pi/Natural_Oboe.sf2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
He de procurar que no hi hagi saturació en el so. Un valor de -g 5 provoca saturació, és massa alt. -g 1 és correcte, també es pot jugar amb el alsamixer.&lt;br /&gt;
&lt;br /&gt;
Puc jugar amb '''alsamixer'''. El problema que tinc és que el Master d' '''alsamixer''' està a la meitat cada vegada que arrenco la Raspberry. i '''alsamixer''' és un entorn gràfic de consola, i no té opcions de terminal per canviar el volum del master. Però això es pot fer des del terminal fent ''amixer'' en comptes de ''alsamixer'':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ amixer set Master 40%+ &amp;gt; /dev/null&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Millorar la latència (veure més avall, solució udev)==&lt;br /&gt;
Quan arrenco el fluidsynth sempre dóna el missatge de:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
fluidsynth: warning: Failed to pin the sample data to RAM; swapping is possible&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Evidentment aquest problema amb la RAM ja se l'ha trobat altra gent:&lt;br /&gt;
*http://lists.gnu.org/archive/html/fluid-dev/2012-10/msg00013.html&lt;br /&gt;
&lt;br /&gt;
El més important per millorar el rendiment és que a mi m'han deixat la Rasperry Pi Model B de fa uns mesos amb 256MB, però que si n'aconsegueixo una de nova vindrà amb 512MB i per tant el rendiment serà millor...&lt;br /&gt;
*http://www.raspberrypi.org/phpBB3/viewtopic.php?f=26&amp;amp;t=22199&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
The Model B was originally shipped with 256MB but recently doubled to 512MB.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ fluidsynth -a alsa -m alsa_seq /home/pi/Natural_Oboe.sf2&lt;br /&gt;
FluidSynth version 1.1.5&lt;br /&gt;
Copyright (C) 2000-2011 Peter Hanappe and others.&lt;br /&gt;
Distributed under the LGPL license.&lt;br /&gt;
SoundFont(R) is a registered trademark of E-mu Systems, Inc.&lt;br /&gt;
&lt;br /&gt;
fluidsynth: warning: Failed to pin the sample data to RAM; swapping is possible.&lt;br /&gt;
fluidsynth: warning: No preset found on channel 9 [bank=128 prog=0]&lt;br /&gt;
fluidsynth: warning: Requested a period size of 64, got 256 instead&lt;br /&gt;
Type 'help' for help topics.&lt;br /&gt;
&lt;br /&gt;
&amp;gt; fluidsynth: warning: Failed to set thread to high priority&lt;br /&gt;
fluidsynth: warning: Failed to set thread to high priority&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Dels missatges veig que tinc un problema amb la RAM (ja ho sabia), que tinc un ''period size'' de 256 i que no estic treballant amb alta prioritat per a l'audio.&lt;br /&gt;
&lt;br /&gt;
Canviant el valor de -z tampoc soluciona res. Valors més grans de 256 (512, 1024) empitjora la latència. Valor de 64 no l'agafa.&lt;br /&gt;
&lt;br /&gt;
'''Solució:'''&lt;br /&gt;
*http://lists.gnu.org/archive/html/fluid-dev/2012-10/msg00018.html&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ sudo joe /etc/security/limits.d/pi.conf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pi - rtprio 99&lt;br /&gt;
pi - memlock unlimited&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
i reiniciar. '''Compte!''' si poso ''rtprio 85'' en comptes de ''rtprio 99'' també hi ha latència.&lt;br /&gt;
&lt;br /&gt;
Ara ja arrenco amb mode RT i no em dóna el missatge:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ fluidsynth -a alsa -m alsa_seq -g 1 /home/pi/Natural_Oboe.sf2&lt;br /&gt;
version 1.1.5&lt;br /&gt;
Copyright (C) 2000-2011 Peter Hanappe and others.&lt;br /&gt;
Distributed under the LGPL license.&lt;br /&gt;
SoundFont(R) is a registered trademark of E-mu Systems, Inc.&lt;br /&gt;
&lt;br /&gt;
fluidsynth: warning: No preset found on channel 9 [bank=128 prog=0]&lt;br /&gt;
fluidsynth: warning: Requested a period size of 64, got 256 instead&lt;br /&gt;
Type 'help' for help topics.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
El curiós del cas és que el mode tradicional que feina en el portàtil no funciona, no arregla la latència:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ sudo adduser pi audio&lt;br /&gt;
$ groups&lt;br /&gt;
pi adm dialout cdrom sudo audio video plugdev games users netdev input&lt;br /&gt;
&lt;br /&gt;
$ sudo joe /etc/security/limits.conf&lt;br /&gt;
&lt;br /&gt;
@audio   -  rtprio     99&lt;br /&gt;
@audio   -  memlock    unlimited&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Automatització (1a versió)==&lt;br /&gt;
*http://www.stuffaboutcode.com/2012/06/raspberry-pi-run-program-at-start-up.html&lt;br /&gt;
&lt;br /&gt;
Al final queda de la següent manera:&lt;br /&gt;
&lt;br /&gt;
fitxer '''/home/pi/arrencar_fluidsynth1.sh''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
/usr/bin/fluidsynth -a alsa -m alsa_seq -g 1  /home/pi/Natural_Oboe.sf2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
==Marge de millores==&lt;br /&gt;
'''NOTA''': veure l'apartat UDEV. Els meus problemes de latència es solucionen quan enxufo el EWI-USB un cop arrencada la màquina. En canvi. Si tinc el EWI-USB connectat des del principi, tinc problemes de latència una mica aleatoris, no importa la RAM que tingui... Per tant, veure el script que s'executa en l'apartat '''udev'''.&lt;br /&gt;
&lt;br /&gt;
Bàsicament la configuració funciona, però encara obtinc ''a vegades'' una certa latència, la qual cosa fa pensar que hi ha alguna variable que me la fa ballar. El fet de què sigui ''a vegades'' fa pensar que hi ha algun malfuncionament que es podria corregir.&lt;br /&gt;
#Utilitzar la RP de 512 MB&lt;br /&gt;
#Utilitzar un USB powered hub (http://www.raspipc.es/tienda.php?ver=articulo&amp;amp;id=1065 - http://es.farnell.com/dynamode/usb-h70-1a2-0/hub-usb-2-0-7-puertos-with-uk-ac/dp/2115058)&lt;br /&gt;
#Overclocking de la RP&lt;br /&gt;
#provar una altra targeta SD&lt;br /&gt;
&lt;br /&gt;
*http://wiki.linuxaudio.org/wiki/raspberrypi&lt;br /&gt;
*http://lists.linuxaudio.org/pipermail/linux-audio-user/2013-April/092322.html&lt;br /&gt;
 &lt;br /&gt;
'''powered USB hub'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Yes, that's why I'm now using a powered USB hub and I plug the UA-25 &lt;br /&gt;
into the hub. The hub has a 5V/3.7A power supply. In my case I also &lt;br /&gt;
experienced SD corruption when using a GPU frequency higher than 250.&lt;br /&gt;
&lt;br /&gt;
Check the current of the adapter, if it's somewhere around 1A you might &lt;br /&gt;
need a more powerful adapter as the RPi already draws 700mA IIRC.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Una altra variable també pot ser el tipus de targeta SD. No totes tenen la mateixa qualitat:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
What kind of SD are you using? I've used different SD cards with &lt;br /&gt;
different results. I'm now using a cheap OEM class 10 SD card that does &lt;br /&gt;
get corrupted quickly but performance is better than other SD cards I've &lt;br /&gt;
used. Whenever I change something I make a backup now.&lt;br /&gt;
&lt;br /&gt;
SanDisk SD's are being recommended for use with the RPi. &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
==scripts per arrencar amb el sistema==&lt;br /&gt;
fitxer '''/home/pi/arrencar_fluidsynth2.sh''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
/bin/sleep 2&lt;br /&gt;
/usr/bin/amixer set Master 40%+ &amp;gt; /dev/null&lt;br /&gt;
/bin/sleep 2&lt;br /&gt;
FLUIDSYNTH=$(/usr/bin/aconnect -o -l | awk '/FLUID/{print $2.&amp;quot;0&amp;quot;}')&lt;br /&gt;
/bin/sleep 2&lt;br /&gt;
#echo $FLUIDSYNTH&lt;br /&gt;
/usr/bin/aconnect EWI-USB:0 $FLUIDSYNTH&lt;br /&gt;
/bin/sleep 2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ sudo chmod a+x /home/pi/arrencar_fluidsynth1.sh&lt;br /&gt;
$ sudo chmod a+x /home/pi/arrencar_fluidsynth2.sh&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Ara faig els scripts d'arrencada:&lt;br /&gt;
&lt;br /&gt;
fitxer '''/etc/init.d/arrencar_fluidsynth1''': ('''nota''': utilitzo ''sudo -u pi'' per tal de què el script s'executi com a usuari normal que té permisos d'alta prioritat)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ sudo joe /etc/init.d/arrencar_fluidsynth1&lt;br /&gt;
&lt;br /&gt;
#! /bin/sh&lt;br /&gt;
# /etc/init.d/arrencar_fluidsynth1&lt;br /&gt;
&lt;br /&gt;
### BEGIN INIT INFO&lt;br /&gt;
# Provides:          arrencar_fluidsynth1&lt;br /&gt;
# Required-Start:    &lt;br /&gt;
# Required-Stop:     &lt;br /&gt;
# Default-Start:     2 3 4 5&lt;br /&gt;
# Default-Stop:      0 1 6&lt;br /&gt;
# Short-Description: arrencar_fluidsynth1&lt;br /&gt;
# Description:       arrencar_fluidsynth1&lt;br /&gt;
### END INIT INFO&lt;br /&gt;
&lt;br /&gt;
# If you want a command to always run, put it here&lt;br /&gt;
&lt;br /&gt;
# Carry out specific functions when asked to by the system&lt;br /&gt;
case &amp;quot;$1&amp;quot; in&lt;br /&gt;
  start)&lt;br /&gt;
    sudo -u pi /home/pi/arrencar_fluidsynth1.sh&lt;br /&gt;
    ;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
exit 0 &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
fitxer '''/etc/init.d/arrencar_fluidsynth2''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ sudo joe /etc/init.d/arrencar_fluidsynth2&lt;br /&gt;
&lt;br /&gt;
#! /bin/sh&lt;br /&gt;
# /etc/init.d/arrencar_fluidsynth2&lt;br /&gt;
&lt;br /&gt;
### BEGIN INIT INFO&lt;br /&gt;
# Provides:          arrencar_fluidsynth2&lt;br /&gt;
# Required-Start:    &lt;br /&gt;
# Required-Stop:     &lt;br /&gt;
# Default-Start:     2 3 4 5&lt;br /&gt;
# Default-Stop:      0 1 6&lt;br /&gt;
# Short-Description: arrencar_fluidsynth2&lt;br /&gt;
# Description:       arrencar_fluidsynth2&lt;br /&gt;
### END INIT INFO&lt;br /&gt;
&lt;br /&gt;
# If you want a command to always run, put it here&lt;br /&gt;
&lt;br /&gt;
# Carry out specific functions when asked to by the system&lt;br /&gt;
case &amp;quot;$1&amp;quot; in&lt;br /&gt;
  start)&lt;br /&gt;
    sudo -u pi /home/pi/arrencar_fluidsynth2.sh&lt;br /&gt;
    ;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
exit 0 &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo chmod 755 /etc/init.d/arrencar_fluidsynth1&lt;br /&gt;
sudo chmod 755 /etc/init.d/arrencar_fluidsynth2&lt;br /&gt;
&lt;br /&gt;
sudo update-rc.d arrencar_fluidsynth1 defaults&lt;br /&gt;
sudo update-rc.d arrencar_fluidsynth2 defaults&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
El problema està en què no puc ficar en el mateix script l'arrencada del fluidsynth i el aconnect, perquè el fluidsynth sempre es queda amb el prompt (''&amp;gt;''), i tampoc puc utilitzar ''&amp;amp;''. En una ocasió havia utilitzat ''xterm'', però aquí a la raspberry PI no em val.&lt;br /&gt;
&lt;br /&gt;
Així funciona la connexió. La latència, que em pensava que tenia solucionada, veig que encara falla... Segurament el problema és que estic fent ''sudo'', i per tant estic executant totes aquestes comandes com a ''root'' i no com a ''pi''.&lt;br /&gt;
&lt;br /&gt;
Fixem-nos la diferència de fer:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ groups&lt;br /&gt;
pi adm dialout cdrom sudo audio video plugdev games users netdev input&lt;br /&gt;
pi@raspberrypi ~ $ sudo groups&lt;br /&gt;
root&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Per eliminar els scripts d'arrencada:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ sudo update-rc.d -f  arrencar_fluidsynth1 remove &lt;br /&gt;
$ sudo update-rc.d -f  arrencar_fluidsynth2 remove &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
==udev: executar un script quan endollo un dispositiu USB==&lt;br /&gt;
===prova: endollar un ratolí òptic===&lt;br /&gt;
*http://ubuntuforums.org/showthread.php?t=1530332&lt;br /&gt;
&lt;br /&gt;
connecto un ratolí òptic:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ dmesg&lt;br /&gt;
...&lt;br /&gt;
[11556.310613] usb 1-1.1: new low-speed USB device number 4 using ehci_hcd&lt;br /&gt;
[11556.410453] input: Logitech USB Optical Mouse as /devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.1/1-1.1:1.0/input/input12&lt;br /&gt;
[11556.410802] generic-usb 0003:046D:C05B.0002: input,hidraw0: USB HID v1.11 Mouse [Logitech USB Optical Mouse] on usb-0000:00:1a.0-1.1/input0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ udevinfo -a -p /sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.1/1-1.1:1.0/input/input12&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
no tinc disponible udevinfo però puc utilitzar udevadm:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ sudo udevadm info -a -p /sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.1/1-1.1:1.0/input/input12&lt;br /&gt;
&lt;br /&gt;
Udevadm info starts with the device specified by the devpath and then&lt;br /&gt;
walks up the chain of parent devices. It prints for every device&lt;br /&gt;
found, all possible attributes in the udev rules key format.&lt;br /&gt;
A rule to match, can be composed by the attributes of the device&lt;br /&gt;
and the attributes from one single parent device.&lt;br /&gt;
&lt;br /&gt;
  looking at device '/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.1/1-1.1:1.0/input/input12':&lt;br /&gt;
    KERNEL==&amp;quot;input12&amp;quot;&lt;br /&gt;
    SUBSYSTEM==&amp;quot;input&amp;quot;&lt;br /&gt;
    DRIVER==&amp;quot;&amp;quot;&lt;br /&gt;
    ATTR{name}==&amp;quot;Logitech USB Optical Mouse&amp;quot;&lt;br /&gt;
    ATTR{phys}==&amp;quot;usb-0000:00:1a.0-1.1/input0&amp;quot;&lt;br /&gt;
    ATTR{uniq}==&amp;quot;&amp;quot;&lt;br /&gt;
    ATTR{properties}==&amp;quot;0&amp;quot;&lt;br /&gt;
&lt;br /&gt;
  looking at parent device '/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.1/1-1.1:1.0':&lt;br /&gt;
    KERNELS==&amp;quot;1-1.1:1.0&amp;quot;&lt;br /&gt;
    SUBSYSTEMS==&amp;quot;usb&amp;quot;&lt;br /&gt;
    DRIVERS==&amp;quot;usbhid&amp;quot;&lt;br /&gt;
    ATTRS{bInterfaceNumber}==&amp;quot;00&amp;quot;&lt;br /&gt;
    ATTRS{bAlternateSetting}==&amp;quot; 0&amp;quot;&lt;br /&gt;
    ATTRS{bNumEndpoints}==&amp;quot;01&amp;quot;&lt;br /&gt;
    ATTRS{bInterfaceClass}==&amp;quot;03&amp;quot;&lt;br /&gt;
    ATTRS{bInterfaceSubClass}==&amp;quot;01&amp;quot;&lt;br /&gt;
    ATTRS{bInterfaceProtocol}==&amp;quot;02&amp;quot;&lt;br /&gt;
    ATTRS{supports_autosuspend}==&amp;quot;1&amp;quot;&lt;br /&gt;
&lt;br /&gt;
  looking at parent device '/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.1':&lt;br /&gt;
    KERNELS==&amp;quot;1-1.1&amp;quot;&lt;br /&gt;
    SUBSYSTEMS==&amp;quot;usb&amp;quot;&lt;br /&gt;
    DRIVERS==&amp;quot;usb&amp;quot;&lt;br /&gt;
    ATTRS{configuration}==&amp;quot;&amp;quot;&lt;br /&gt;
    ATTRS{bNumInterfaces}==&amp;quot; 1&amp;quot;&lt;br /&gt;
    ATTRS{bConfigurationValue}==&amp;quot;1&amp;quot;&lt;br /&gt;
    ATTRS{bmAttributes}==&amp;quot;a0&amp;quot;&lt;br /&gt;
    ATTRS{bMaxPower}==&amp;quot; 98mA&amp;quot;&lt;br /&gt;
    ATTRS{urbnum}==&amp;quot;17614&amp;quot;&lt;br /&gt;
    ATTRS{idVendor}==&amp;quot;046d&amp;quot;&lt;br /&gt;
    ATTRS{idProduct}==&amp;quot;c05b&amp;quot;&lt;br /&gt;
    ATTRS{bcdDevice}==&amp;quot;5400&amp;quot;&lt;br /&gt;
    ATTRS{bDeviceClass}==&amp;quot;00&amp;quot;&lt;br /&gt;
    ATTRS{bDeviceSubClass}==&amp;quot;00&amp;quot;&lt;br /&gt;
    ATTRS{bDeviceProtocol}==&amp;quot;00&amp;quot;&lt;br /&gt;
    ATTRS{bNumConfigurations}==&amp;quot;1&amp;quot;&lt;br /&gt;
    ATTRS{bMaxPacketSize0}==&amp;quot;8&amp;quot;&lt;br /&gt;
    ATTRS{speed}==&amp;quot;1.5&amp;quot;&lt;br /&gt;
    ATTRS{busnum}==&amp;quot;1&amp;quot;&lt;br /&gt;
    ATTRS{devnum}==&amp;quot;4&amp;quot;&lt;br /&gt;
    ATTRS{devpath}==&amp;quot;1.1&amp;quot;&lt;br /&gt;
    ATTRS{version}==&amp;quot; 2.00&amp;quot;&lt;br /&gt;
    ATTRS{maxchild}==&amp;quot;0&amp;quot;&lt;br /&gt;
    ATTRS{quirks}==&amp;quot;0x0&amp;quot;&lt;br /&gt;
    ATTRS{avoid_reset_quirk}==&amp;quot;0&amp;quot;&lt;br /&gt;
    ATTRS{authorized}==&amp;quot;1&amp;quot;&lt;br /&gt;
    ATTRS{manufacturer}==&amp;quot;Logitech&amp;quot;&lt;br /&gt;
    ATTRS{product}==&amp;quot;USB Optical Mouse&amp;quot;&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Fixar-se amb els següents valors perquè és els que haurem de ficar en el fitxer de ''regles'':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    SUBSYSTEMS==&amp;quot;usb&amp;quot;&lt;br /&gt;
    ATTRS{product}==&amp;quot;USB Optical Mouse&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ sudo joe  /etc/udev/rules.d/touchpad.rules&lt;br /&gt;
&lt;br /&gt;
#/etc/udev/rules.d/touchpad.rules&lt;br /&gt;
ACTION==&amp;quot;add&amp;quot;, SUBSYSTEMS==&amp;quot;usb&amp;quot;, ATTRS{product}==&amp;quot;USB Optical Mouse&amp;quot;, RUN+=&amp;quot;/home/joan/prova_mouse.sh&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
fitxer /home/joan/prova_mouse.sh:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
ls -la /home/joan/rutes_GPS &amp;gt; /home/joan/hola.txt&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
I ara efectivament desconnectem el mouse, el tornem a conectar, i podem mirar el contigut del fitxer hola.txt:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ cat hola.txt&lt;br /&gt;
total 5232&lt;br /&gt;
drwxrwxr-x  2 joan joan   4096 Jun  6 19:00 .&lt;br /&gt;
drwxr-xr-x 86 joan joan  20480 Jun  6 19:54 ..&lt;br /&gt;
-rw-rw-r--  1 joan joan 163256 Jan 30 17:50 080727-trialerada-per-collserola.gpx&lt;br /&gt;
-rw-r--r--  1 joan joan  64806 Nov  6  2012 2012-11-04 0859__20121104_0859.gpx&lt;br /&gt;
-rw-r--r--  1 joan joan  62978 Nov  6  2012 2012-11-04 1004__20121104_1004.gpx&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Puc comprovar que el script s'executa fent:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ sudo udevadm test /sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.1/1-1.1:1.0/input/input16&lt;br /&gt;
...&lt;br /&gt;
run: '/home/joan/prova_mouse.sh'&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
(compte! perquè pot haver canviat el nom del dispositiu: input16 en comptes de input12). En qualsevol cas, el script s'executa igualment.&lt;br /&gt;
&lt;br /&gt;
==udev: Endollar el EWI-USB==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ dmesg&lt;br /&gt;
...&lt;br /&gt;
[  184.553228] usb 1-1.2: new full-speed USB device number 4 using dwc_otg&lt;br /&gt;
[  184.654878] usb 1-1.2: New USB device found, idVendor=09e8, idProduct=006d&lt;br /&gt;
[  184.654906] usb 1-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=0&lt;br /&gt;
[  184.654922] usb 1-1.2: Product: EWI-USB&lt;br /&gt;
[  184.654934] usb 1-1.2: Manufacturer: Akai Professional, LLC.&lt;br /&gt;
[  184.850265] usbcore: registered new interface driver snd-usb-audio&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ sudo joe  /etc/udev/rules.d/ewiusb.rules&lt;br /&gt;
&lt;br /&gt;
#/etc/udev/rules.d/ewiusb.rules&lt;br /&gt;
ACTION==&amp;quot;add&amp;quot;, SUBSYSTEMS==&amp;quot;usb&amp;quot;, ATTRS{product}==&amp;quot;EWI-USB&amp;quot;, RUN+=&amp;quot;/home/pi/ewiscript.sh&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
prova:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ joe /home/pi/ewiscript.sh&lt;br /&gt;
&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
ls -la /home/pi/Desktop &amp;gt; /home/pi/hola.txt&lt;br /&gt;
&lt;br /&gt;
$ sudo chmod a+x /home/pi/ewiscript.sh&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
I ara efectivament desconnectem el EWI, el tornem a conectar, i podem mirar el contigut del fitxer hola.txt&lt;br /&gt;
&lt;br /&gt;
Ara que funciona el script ewiscript.sh, ja puc fer que executi el fluidsynth i les connexions ALSA&lt;br /&gt;
==scripts per arrencar fluidsynth amb udev==&lt;br /&gt;
Sempre havia tingut el problema d'arrencar fluidsynth (que sempre apareix el prompt &amp;gt; a pesar de l'opció -i) en una consola diferent. L'ús de &amp;amp; tampoc funciona. Finalment, el problema es pot resoldre utilitzant la utilitat '''screen''' (http://www.thegeekstuff.com/2010/07/screen-command-examples/):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ sudo apt-get install screen&lt;br /&gt;
&lt;br /&gt;
NAME&lt;br /&gt;
       screen - screen manager with VT100/ANSI terminal emulation&lt;br /&gt;
&lt;br /&gt;
SYNOPSIS&lt;br /&gt;
       screen [ -options ] [ cmd [ args ] ]&lt;br /&gt;
       screen -r [[pid.]tty[.host]]&lt;br /&gt;
       screen -r sessionowner/[[pid.]tty[.host]]&lt;br /&gt;
&lt;br /&gt;
$ screen -d -m -S fluidsynth -t &amp;quot;fluidsynth&amp;quot; /usr/bin/fluidsynth -a alsa -m alsa_seq -g 1  /home/pi/Natural_Oboe.sf2&lt;br /&gt;
$ screen -d -r fluidsynth&lt;br /&gt;
&lt;br /&gt;
$ ps aux | grep fluidsynth&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
efectivament el procés fluidsynth està arrencat i puc executar noves comandes.&lt;br /&gt;
&lt;br /&gt;
fitxer '''ewiscript.sh''':-c 4 -z 256 -r 44100&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
if [ -z `pidof -s fluidsynth` ]; then&lt;br /&gt;
	screen -d -m -S fluidsynth -t &amp;quot;fluidsynth&amp;quot; /usr/bin/fluidsynth -a alsa -m alsa_seq -g 1 -c 4 -z 256 -r 48000 /home/pi/Natural_Oboe.sf2&lt;br /&gt;
	/bin/sleep 3&lt;br /&gt;
	/usr/bin/amixer set Master 40%+ &amp;gt; /dev/null&lt;br /&gt;
	/bin/sleep 2&lt;br /&gt;
	FLUIDSYNTH=$(/usr/bin/aconnect -o -l | awk '/FLUID/{print $2.&amp;quot;0&amp;quot;}')&lt;br /&gt;
	/bin/sleep 2&lt;br /&gt;
	#echo $FLUIDSYNTH&lt;br /&gt;
	/usr/bin/aconnect EWI-USB:0 $FLUIDSYNTH&lt;br /&gt;
	/bin/sleep 2&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Al final, el més important per tal de reduir la latència ha estat l'argument -c 4 (que és el número d'àudio buffers). Augmentar la quantitat no millora el rendiment, però en canvi suprimir l'argument o reduir el valor empitjora clarament la latència. D'altra banda, -z 64 o 128 no ho agafa, i per tant m'he d'acontentar amb -z 256. Segurament el valor de samplerate de 48000 és millor que el de 44100.&lt;br /&gt;
&lt;br /&gt;
=EWI-USB + Raspberry Pi + Roland JV-1010=&lt;br /&gt;
L'altra solució (que no haurà de tenir gens de latència) és utilitzar el JV-1010.&lt;br /&gt;
&lt;br /&gt;
Em baso en:&lt;br /&gt;
*http://www.youtube.com/watch?v=Hb2QJ1pRo10&lt;br /&gt;
&lt;br /&gt;
Necessito un cable que converteixi USB a MIDI:&lt;br /&gt;
*http://www.ebay.es/itm/Cable-MIDI-a-USB-to-Conversor-Adaptador-Convertidor-Windows-Mac-Linux-2256-/261025231603?pt=LH_DefaultDomain_186&amp;amp;hash=item3cc650f2f3&lt;br /&gt;
&lt;br /&gt;
ara busco un script que em funcioni quan connecti la EWI-USB, i que funcioni tant per a un synth hard (roland) com per a un synth soft (fluidsynth):&lt;br /&gt;
&lt;br /&gt;
ewiscript.sh, versió 1:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
#script que s'ha d'executar quan connectem el EWI-USB. Dos casos: a) synth hardware (roland); b) synth software (fluidsynth)&lt;br /&gt;
&lt;br /&gt;
#mirem si tenim connectat el cable usb-midi&lt;br /&gt;
if [ -z `/usr/bin/aconnect -iol | grep USB2.0-MIDI | awk '/client/{print $1}'` ]; then&lt;br /&gt;
&lt;br /&gt;
#no està connectat: b) synth software (fluidsynth)&lt;br /&gt;
if [ -z `pidof -s fluidsynth` ]; then&lt;br /&gt;
screen -d -m -S fluidsynth -t &amp;quot;fluidsynth&amp;quot; /usr/bin/fluidsynth -a alsa -m alsa_seq -g 1  /home/pi/Natural_Oboe.sf2&lt;br /&gt;
/bin/sleep 3&lt;br /&gt;
/usr/bin/amixer set Master 40%+ &amp;gt; /dev/null&lt;br /&gt;
/bin/sleep 2&lt;br /&gt;
FLUIDSYNTH=$(/usr/bin/aconnect -o -l | awk '/FLUID/{print $2.&amp;quot;0&amp;quot;}')&lt;br /&gt;
/bin/sleep 2&lt;br /&gt;
#echo $FLUIDSYNTH&lt;br /&gt;
/usr/bin/aconnect EWI-USB:0 $FLUIDSYNTH&lt;br /&gt;
/bin/sleep 2&lt;br /&gt;
fi&lt;br /&gt;
else&lt;br /&gt;
#a) synth hardware (roland)&lt;br /&gt;
USBMIDI=$(/usr/bin/aconnect -o -l | awk '/client/' | awk '/USB2.0/{print $2.&amp;quot;0&amp;quot;}')&lt;br /&gt;
/usr/bin/aconnect EWI-USB:0 $USBMIDI&lt;br /&gt;
/bin/sleep 2&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Autor}}, abril 2013&lt;/div&gt;</summary>
		<author><name>Joan</name></author>
		
	</entry>
</feed>