User:Laurier Rochon/prototyping/funeralhymn

From XPUB & Lens-Based wiki

Funeral hymn

Description

Lacking the fundamental compositional knowledge to pretend I can make something sound right, I decided to make a simple, conceptual/generative piece that works with semi-live data. My application uses PHP to retrieve a list of recently deceased people in the Netherlands via an RSS aggregator, then BASH and CURL to download it to the computer, and finally BASH, SED and MIDGE to concatenate a sad, disorganized hymn (played with the church organ patch) of all the dead people, using their names and cities as input. The notes emerge from a semi-random association of text with formally-accepted letters for MIDGE to convert, and pauses for a slight moment between individuals.

Please note : I am using this feed for another project at the moment - I didn't decide to materialize people's decay into sound right off the top of my head (notwithstanding I think it's still interesting).


Structure

  • (cron job running, creates a fresh file every 12 hours)
-> creates a txt file on the server
-> sends the file to working directory
  • bash wrapper.sh | midge
-> for every line in the text file
-> in the channels part, create a new channel, use a variable to increment it
-> insert blank notes for all the people before you
-> insert relevant notes for new person | pipe it through SED to make sure the syntax is correct
  • timidity a.out.mid
-> play


Input example

Text file looks a bit like

Hub Penders (Geulle)
Margaret Meijer - van Breugel
Cornelis de Visser (Yerseke)
Geert Dirks (Nuland)
Wilfred de Kruijf (Maastricht)
Herman Siemen Douma (Workum)
Jan Hendrik Stoffers (Assen)
Ferdinand Jozef Franciscus (Ferry) Rikkers (Zwolle)
Maria Louise (Mia) Timmermans - Meulendijks (Venlo)
...


Output example

File:Sample funeral.ogg


Observations

  • Different variables within any of the loops could be used to apply variations and mod the notes. Unfortunately, I found the midge syntax to be rather cryptic, and clearly lack the musical theory to make sense of it.
  • I saw many opportunities to expand on this kind of scraping, i.e. perform a second search/scrape for individual people, and make them personalized hymns depending on what is found.
  • I'm not sure what kind of effect the pause between micro-pieces has (other than a delimiter), perhaps gluing the whole thing together would just be better...

Relevant code

[getnames.php]

<?

$str = "";
//create new dom
$doc = new DOMDocument();
  //load the feed
  $doc->load('http://www.mensenlinq.nl/mensenlinq/overlijdennl/site/advertentie/rss/rss.xml');
  $arrFeeds = array();
  //loop through the titles, within all <items>
  foreach ($doc->getElementsByTagName('item') as $node) {
    $str .= $node->getElementsByTagName('title')->item(0)->nodeValue."\n";
  }

//and create the file!
$myFile = "names.txt";
$fh = fopen($myFile, 'w') or die("can't open file");
fwrite($fh, $str);
fclose($fh);

?>

[wrapper.sh]

cat <<EOF
#normal head stuff
@head {
    \$time_sig 4/4
    \$tempo 120
}
@body {
 
EOF

c=1
cc=0

#for every line in the file
while read line;
do
        #I have restricted results here, for the sake of the example output file
	if [ $c -lt 5 ]; then
                #using our incremented vars, we could do some interesting things here
		echo "@channel ${c} {        \$patch 20        \$volume 127        \$octave 2        \$length 8         "
		z=0
                #for every past character, insert a silent note, to that all notes don't play at once
		while [  $z -lt ${cc} ]; do
             		echo "r "
            		let z=z+1 
	        done
                #filter using SED
		echo "${line}" | tr '[A-Z]' '[a-z]' | sed -f filter.sed
		echo "}"
		linelen=${#line}
		cc=$[$cc+$linelen]

	fi
#++
c=$[$c+1]

#in my txt file
done < names.txt

cat <<EOF
}
EOF

[filter.sed]

I really need to work on my reg exps...sigh.

s/[ ]*$//g
s/^$//g
s/\n//g
s/\t//g
s/$//g
s/ë//g
s/(//g
s/)//g
s/-//g

s/1/c /g
s/2/c+ /g
s/3/d /g
s/4/d+ /g
s/5/e /g
s/6/f+ /g
s/7/g /g
s/8/g+ /g
s/9/a /g
s/0/a+ /g

s/ //g
s/./& /g

s/[a-b]/a/g
s/[c-d]/b/g
s/[e-f]/c/g
s/[h-i]/d/g
s/[j-k]/e/g
s/[l-m]/f/g
s/[n-o]/g/g

s/[p-q]/a+/g
s/[r-s]/b+/g
s/[t-u]/c+/g
s/[v-w]/d+/g
s/[x-y]/e+/g
s/z/f+/g

[run.sh]

To run it all at once

sudo curl -o names.txt http://aesonmusic.com/obit/names.txt
bash wrapper.sh | midge
timidity a.out.mid

MIDGE file (about 2% of it)

@head {
    $time_sig 4/4
    $tempo 120
}
@body {
 
@channel 1 {        $patch 20        $volume 127        $octave 2        $length 8         
d c+ a a+ c g b c b+ b+ g c c+ f f c 
}
@channel 2 {        $patch 20        $volume 127        $octave 2        $length 8         
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
f a b+ g a b+ c c+ f c d e c b+ d+ a g a b+ c c+ g c f 
}
@channel 3 {        $patch 20        $volume 127        $octave 2        $length 8         
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
b g b+ g c f d b+ b c d+ d b+ b+ c b+ e+ c b+ b+ c e c 
}
@channel 4 {        $patch 20        $volume 127        $octave 2        $length 8         
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
g c c b+ c+ b d b+ e b+ g c+ f a g b 
}
@channel 5 {        $patch 20        $volume 127        $octave 2        $length 8         
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
d+ d f c b+ c b b c e b+ c+ d e c f a a b+ c+ b+ d b d c+ 
}
@channel 6 {        $patch 20        $volume 127        $octave 2        $length 8         
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
d c b+ f a g b+ d c f c g b g c+ f a d+ g b+ e c+ f 
}
@channel 7 {        $patch 20        $volume 127        $octave 2        $length 8         
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
e a g d c g b b+ d e b+ c+ g c c c b+ b+ a b+ b+ c g 
}
@channel 8 {        $patch 20        $volume 127        $octave 2        $length 8         
r 
r 
r 
r 
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r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
r 
f a b+ d a f g c+ d b+ c f d a c+ d f f c b+ f a g b+ f c c+ f c g b d e e b+ d+ c g f g 
}