User:Fabien Labeyrie/Wifi Orchestra: Difference between revisions

From XPUB & Lens-Based wiki
(Created page with "== Titre == '''Description''' '''Structure''' *Mettre du texte :-> Et la sous-catégorie '''Input example''' Text1 <source lang="text"> Contenu du texte ... </source> ...")
 
No edit summary
 
(26 intermediate revisions by the same user not shown)
Line 1: Line 1:
== Titre ==
[[Category:prototyping]]
[[Category:2011_P1.01]]
__NOTOC__
__NOEDITSECTION__


<div style="width: 600px; font-family:Arial">
==<span style="color:#0B0080">Wifi Orchestra</span>==
<hr style="height:5px; margin-top:-15px; background-color:#FFF">
<br />


'''Description'''
While people are allowed to go online anywhere and contacting the other end of the world anytime thanks to wireless connexion, they don't really interact with internet users physically revolving around them.


The following lines of code get anyone nearby participating in a never-ending concert, where the connexion data of everyone are mixed together in cyber jam session.
<br />


==<div style="margin-top:30px">How does it work ?</div>==
<hr style="height:5px; margin-top:-15px; background-color:#FFF">


'''Structure'''
=====Technologies involved=====
[http://en.wikipedia.org/wiki/Bash_%28Unix_shell%29 Bash scripting] / [http://www.undef.org.uk/code/midge/ Midge]
<br />


*Mettre du texte
=====Steps=====
:-> Et la sous-catégorie
<div style="margin-left:-55px; margin-top:10px;">
# &nbsp;&nbsp;&nbsp;&nbsp;We are checking the wifi connexions around.
# &nbsp;&nbsp;&nbsp;&nbsp;After getting the data, the MAC adresses are combined together resulting a series of numbers.
# &nbsp;&nbsp;&nbsp;&nbsp;Those numbers are then converted into music notes, based on a pentatonic scale.
</div>
<br />


'''Input example'''
==<div style="margin-top:30px">Source code</div>==
<hr style="height:5px; margin-top:-15px; background-color:#FFF">


Text1
All of this is launched by a single line in the shell :
<source lang="bash">
sudo iwlist eth1 scan | sed -f convertAdress.sed | bash dispatchNotes.sh
</source>
<br />
 
But there is some under cover coding behind that. <br />
We need first to scan the waves around with ''iwlist scan wlan0''.
Here comes the list of connexions around :


<source lang="text">
<source lang="text">
Contenu du texte
eth1      Scan completed :
...
          Cell 01 - Address: 00:23:AB:BF:FB:C0
                    ESSID:"eduroam"
                    Protocol:IEEE 802.11bg
                    Mode:Master
                    Frequency:2.437 GHz (Channel 6)
                    Encryption key:on
                    Bit Rates:6 Mb/s; 9 Mb/s; 11 Mb/s; 12 Mb/s; 18 Mb/s
                              24 Mb/s; 36 Mb/s; 48 Mb/s; 54 Mb/s
                    Quality=76/100  Signal level=-53 dBm 
                    IE: WPA Version 1
                        Group Cipher : CCMP
                        Pairwise Ciphers (1) : CCMP
                        Authentication Suites (2) : 802.1x Proprietary
                    IE: IEEE 802.11i/WPA2 Version 1
                        Group Cipher : CCMP
                        Pairwise Ciphers (1) : CCMP
                        Authentication Suites (2) : 802.1x Proprietary
                    Extra: Last beacon: 728ms ago
          Cell 02 - Address: 00:18:F6:F5:97:4F
                    ESSID:"ThomsonAC6D8D"
                    Protocol:IEEE 802.11bg
                    ...
</source>
</source>


<br/ >
We are then using a ''sed'' script in order to keep the relevant informations only, in other words the numbers from each connexion's address.
[''convertAdress.sed'']
<source lang="bash">
# This will only output the addresses lines
/Address/!d
# This will keep the numbers only
s/[^0123456789]//g
# Each number is then converted into note
s/00//g
s/0/c /g
s/1/c /g
s/2/e- /g
s/3/e- /g
s/4/f /g
s/5/f /g
s/6/g /g
s/7/g /g
s/8/b- /g
s/9/b- /g
</source>


'''Output example'''
<br />
Next is to [http://en.wikipedia.org/wiki/Pipeline_%28software%29 pipe] the result in a shell script which already contains the essential Midge language structure to play sound.


[[File:nomDuSample.ogg]]
[''dispatchNotes.sh'']


<source lang="bash">
# The cat stuff is a trick to make bash avoid this part
cat <<END


'''Observations'''


*Numero un
@head {
*Numero deux
    \$time_sig 3/4
*Numero 3
    \$tempo 45
}
@body {
    @channel 1 {
        \$patch 99
        \$octave 4
        \$length 24
\$reverb 100
%repeat 100 {
END


'''Relevant code'''
# This part will be interpreted by bash which will look for the notes
iAdd="0"
while read line;
do
if (("$iAdd" == "0" )); then
echo $line
iAdd=$[$iAdd + 1]
elif (("$iAdd" == "1" )); then
echo $line
iAdd=$[$iAdd + 1]
elif (("$iAdd" == "2" )); then
echo $line
iAdd=$[$iAdd + 1]
elif (("$iAdd" == "3" )); then
echo $line
iAdd=$[$iAdd + 1]
elif (("$iAdd" == "4" )); then
echo $line
iAdd=$[$iAdd + 1]
elif (("$iAdd" == "5" )); then
echo $line
iAdd=$[$iAdd + 1]
elif (("$iAdd" == "6" )); then
echo $line
iAdd=$[$iAdd + 1]
elif (("$iAdd" == "7" )); then
echo $line
iAdd=$[$iAdd + 1]
elif (("$iAdd" == "8" )); then
echo $line
iAdd=$[$iAdd + 1]
elif (("$iAdd" == "9" )); then
echo $line
iAdd=$[$iAdd + 1]


[wrapper.sh]
else
iAdd="-1"
fi
done 


<source lang="bash">
Contenu du script
</source>


[filter.sed]
cat <<END
}
}


''Comment''
}


<source lang="bash">
END
Contenu du bash
</source>
</source>
<br />
==<div style="margin-top:30px">Output</div>==
<hr style="height:5px; margin-top:-15px; background-color:#FFF">
[[File:sortieDJ.ogg]]
<br />


[run.sh]
==<div style="margin-top:30px">Work in progress</div>==
<hr style="height:5px; margin-top:-15px; background-color:#FFF">


''Comment''
For now we are only dealing with the ''MAC adresses'', but we could go further by dealing with the ''name'' of the connexions and the ''signal strength''. Those new data would be use to determine the tempo of the music and the instruments. Each person connected would then be taken as a new musical line.


<source lang="bash">
</div>
Contenu du base
</source>

Latest revision as of 21:58, 6 April 2011



Wifi Orchestra



While people are allowed to go online anywhere and contacting the other end of the world anytime thanks to wireless connexion, they don't really interact with internet users physically revolving around them.

The following lines of code get anyone nearby participating in a never-ending concert, where the connexion data of everyone are mixed together in cyber jam session.

How does it work ?


Technologies involved

Bash scripting / Midge

Steps
  1.     We are checking the wifi connexions around.
  2.     After getting the data, the MAC adresses are combined together resulting a series of numbers.
  3.     Those numbers are then converted into music notes, based on a pentatonic scale.


Source code


All of this is launched by a single line in the shell :

sudo iwlist eth1 scan | sed -f convertAdress.sed | bash dispatchNotes.sh


But there is some under cover coding behind that.
We need first to scan the waves around with iwlist scan wlan0. Here comes the list of connexions around :

eth1      Scan completed :
          Cell 01 - Address: 00:23:AB:BF:FB:C0
                    ESSID:"eduroam"
                    Protocol:IEEE 802.11bg
                    Mode:Master
                    Frequency:2.437 GHz (Channel 6)
                    Encryption key:on
                    Bit Rates:6 Mb/s; 9 Mb/s; 11 Mb/s; 12 Mb/s; 18 Mb/s
                              24 Mb/s; 36 Mb/s; 48 Mb/s; 54 Mb/s
                    Quality=76/100  Signal level=-53 dBm  
                    IE: WPA Version 1
                        Group Cipher : CCMP
                        Pairwise Ciphers (1) : CCMP
                        Authentication Suites (2) : 802.1x Proprietary
                    IE: IEEE 802.11i/WPA2 Version 1
                        Group Cipher : CCMP
                        Pairwise Ciphers (1) : CCMP
                        Authentication Suites (2) : 802.1x Proprietary
                    Extra: Last beacon: 728ms ago
          Cell 02 - Address: 00:18:F6:F5:97:4F
                    ESSID:"ThomsonAC6D8D"
                    Protocol:IEEE 802.11bg
                    ...


We are then using a sed script in order to keep the relevant informations only, in other words the numbers from each connexion's address.

[convertAdress.sed]

# This will only output the addresses lines
/Address/!d

# This will keep the numbers only
s/[^0123456789]//g

# Each number is then converted into note
s/00//g 
s/0/c /g
s/1/c /g
s/2/e- /g
s/3/e- /g
s/4/f /g
s/5/f /g
s/6/g /g
s/7/g /g
s/8/b- /g
s/9/b- /g


Next is to pipe the result in a shell script which already contains the essential Midge language structure to play sound.

[dispatchNotes.sh]

# The cat stuff is a trick to make bash avoid this part
cat <<END


@head {
    \$time_sig 3/4
    \$tempo 45
}
@body {
 
    @channel 1 {
        \$patch 99
        \$octave 4
        \$length 24
	\$reverb 100
	%repeat 100 {
END

# This part will be interpreted by bash which will look for the notes
iAdd="0"
while read line; 
do 
	if (("$iAdd" == "0" )); then
		 echo $line
		iAdd=$[$iAdd + 1] 
	elif (("$iAdd" == "1" )); then
		echo $line
		iAdd=$[$iAdd + 1] 
	elif (("$iAdd" == "2" )); then
		echo $line
		iAdd=$[$iAdd + 1]
	elif (("$iAdd" == "3" )); then
		echo $line 
		iAdd=$[$iAdd + 1]
	elif (("$iAdd" == "4" )); then
		echo $line
		iAdd=$[$iAdd + 1]
	elif (("$iAdd" == "5" )); then
		echo $line
		iAdd=$[$iAdd + 1]
	elif (("$iAdd" == "6" )); then
		echo $line
		iAdd=$[$iAdd + 1]
	elif (("$iAdd" == "7" )); then
		echo $line
		iAdd=$[$iAdd + 1]
	elif (("$iAdd" == "8" )); then
		echo $line
		iAdd=$[$iAdd + 1]
	elif (("$iAdd" == "9" )); then
		echo $line
		iAdd=$[$iAdd + 1]

	else 
		iAdd="-1"
	fi
done   	


cat <<END
	}
}

}

END


Output


File:SortieDJ.ogg

Work in progress


For now we are only dealing with the MAC adresses, but we could go further by dealing with the name of the connexions and the signal strength. Those new data would be use to determine the tempo of the music and the instruments. Each person connected would then be taken as a new musical line.