User:Natasa Siencnik/prototyping/markov: Difference between revisions

From XPUB & Lens-Based wiki
No edit summary
 
(64 intermediate revisions by the same user not shown)
Line 1: Line 1:
[[Category:Prototyping]]
[[Category: Prototyping]]
[[Category:2011 P1.03]]
[[Category:Markov chants]]


=The Art of the Fugue=
=The Art of the Fugue=
MARKOV CHAIN WITH J.S. BACH
MARKOV CHANTS WITH J.S. BACH
<br />
<br />
<br />
<br />


===Concept===
===Concept===
[[File:Scetchbook2011-02_markov.jpg | 750px]]<br />
<br />
[[File:Scetchbook2011-01_markov.jpg | 750px]]<br />
<br />


===Scripting Progress===
===Scripting Progress===


=====Python : Script 2011-05-23=====
=====Python : Script 2011-05-23 (not working)=====
<source lang="php">
<source lang="python">
#!/usr/bin/env python
#!/usr/bin/env python


import random
import random


nexttone = {}
fugue = {}
nexttone = {"l2/d3":["l2/a3", "l2/c+3"], l2/a3: ["l2/f3"], l2/f3: ["l2/d3", "l8/f3"], l2/c+3: ["l4/d3"], l4/d3: ["l4/e3"], l4/e3: ["l2/f3"], l8/f3: ["l8/g3","l8/e3"], l8/g3: ["l8/f3"], l8/e3: ["l2/d3"]}
fugue = {
    "l2/d3":["l2/a3", "l2/c+3"],  
    "l2/a3": ["l2/f3"],  
    "l2/f3": ["l2/d3", "l8/f3"],  
    "l2/c+3": ["l4/d3"],  
    "l4/d3": ["l4/e3"],  
    "l4/e3": ["l2/f3"],  
    "l8/f3": ["l8/g3","l8/e3"],  
    "l8/g3": ["l8/f3"],  
    "l8/e3": ["l2/d3"]
}
 
# start with first / one tone (KEY) in the dictionary
# look in the list of the KEY to find next possibilities
# pick a random VALUE from the list that belongs to the key
# asign this next tone to start this loop again
 
# variable tone
for t in enumerate(tones):
    print t, tones[i+1]
 
random.choice()
 
#MIDGE
@head {
    $time_sig 2/2
    $tempo 120
}
@body {
    @channel 1 {
        $patch 1
        $octave 4
        $length 16
        # tones here
    }
}
 
#MIDI FILE
#play with timidity


#l2/d3: ["l2/a3", "l2/c+3"]
#l2/a3: ["l2/f3"]
#l2/f3: ["l2/d3", "l8/f3"]
#l2/c+3: ["l4/d3"]
#l4/d3: ["l4/e3"]
#l4/e3: ["l2/f3"]
#l8/f3: ["l8/g3","l8/e3"]
#l8/g3: ["l8/f3"]
#l8/e3: ["l2/d3"]
</source>
</source>


=====Python : Script 2011-05-24=====
=====Python : Script <i>fugue.py</i> 2011-05-24=====
<source lang="python">
#!/usr/bin/env python
import random
fugue = {}
fugue = {
    "/l2/d4":["/l2/a4", "/l2/c+4"],
    "/l2/a4": ["/l2/f4"],
    "/l2/f4": ["/l2/d4", "/l8/f4"],
    "/l2/c+4": ["/l4/d4"],
    "/l4/d4": ["/l4/e4"],
    "/l4/e4": ["/l2/f4"],
    "/l8/f4": ["/l8/g4","/l8/e4"],
    "/l8/g4": ["/l8/f4"],
    "/l8/e4": ["/l2/d4"]
}
 
#here we print / place the timidity structure
print """
@head {
    $time_sig 4/4
    $tempo 220
}
@body {
    @channel 1 {
        $patch 1
        $octave 4
        $length 16
"""
 
tone = "/l2/d4"
for x in range(64):
print tone
#this new variable tone is overwriting the old tone! => variable as empty bowl symbolism
tone = random.choice(fugue[tone])
 
#here we print / place the timidity structure
print """
    }
}
"""
</source>
<source lang="php">
<source lang="php">
TERMINAL:
natasa@natasa-linux:~/pzi/3_TRIMESTER/PROTOTYPING/20110524_fugue$ python fugue.py | midge
found 1 music tracks
midi output written to a.out.mid
natasa@natasa-linux:~/pzi/3_TRIMESTER/PROTOTYPING/20110524_fugue$ timidity a.out.mid
Playing a.out.mid
Playing time: ~31 seconds
natasa@natasa-linux:~/pzi/3_TRIMESTER/PROTOTYPING/20110524_fugue$ timidity -Ov a.out.mid
Playing a.out.mid
Output a_out.ogg
</source>
</source>
===Useful Links===
<span style="font-size:8pt">


http://en.wikipedia.org/wiki/The_Art_of_Fugue
=====Python : Script <i>fugue_out.sh</i> 2011-05-30=====
<source lang="python">
# $ for variable in bash
in=$1
# strip off extention
b=${in%.*}
echo $b
 
python $1 | midge -o $b.mid
 
timidity -Ov $b.mid
</source>
 
=====Python : Script <i>fugues_out.sh</i> 2011-05-30=====
<source lang="python">
for ((i=1; i<5; i++))
do
bash fugue_out.sh fugue.py
mv fugue.mid fugue_0$i.mid
mv fugue.ogg fugue_0$i.ogg
done
</source>
<source lang="php">
TERMINAL:
natasa@natasa-linux:~/pzi/3_TRIMESTER/PROTOTYPING/20110524_fugue$ bash fugues_out.sh
</source>
 
Voice 01 (Octave 3)
[[File:Fugue_01_20110530.ogg]]
<br />
Voice 02 (Octave 3)
[[File:Fugue_02_20110530.ogg]]
<br />
Voice 03 (Octave 3)
[[File:Fugue_03_20110530.ogg]]
<br />
Voice 04 (Octave 3)
[[File:Fugue_04_20110530.ogg]]
<br />
=====Python : Script <i>fugue_octave.py</i> 2011-06-08=====
<source lang="python">
#!/usr/bin/env python
import random
fugue = {}
fugue = {
    "/l2/d":["/l2/a", "/l2/c+"],
    "/l2/a": ["/l2/f"],
    "/l2/f": ["/l2/d", "/l8/f"],
    "/l2/c+": ["/l4/d"],
    "/l4/d": ["/l4/e"],
    "/l4/e": ["/l2/f"],
    "/l8/f": ["/l8/g","/l8/e"],
    "/l8/g": ["/l8/f"],
    "/l8/e": ["/l2/d"]
}
 
print """
@head {
    $time_sig 4/4
    $tempo 220
}
@body {
    @channel 1 {
        $patch 1
        $octave 3
        $length 16
"""
 
tone = "/l2/d"
for x in range(64):
print tone
#this new variable tone is overwriting the old tone! => variable as empty bowl symbolism
tone = random.choice(fugue[tone])


http://pzwart3.wdka.hro.nl/wiki/Poetry_generators
print """
    }
}
"""
</source>


http://pzwart3.wdka.hro.nl/wiki/Sedsongs#midge
Voice 01 (Octave 2)
[[File:Fugue_01_20110608.ogg]]
<br />
Voice 02 (Octave 3)
[[File:Fugue_04_20110530.ogg]]
<br />
Voice 03 (Octave 4)
[[File:Fugue_01-octave4_20110608.ogg]]
<br />


http://manpages.ubuntu.com/manpages/hardy/man1/midge.1.html
=====Questions=====
How can I make the octave a variable (midge)?<br />
How can I at least play two voices simultaneously (two channels)?<br />
How can these two channels have different octaves?
<br />
<br />


http://piano.congland.com/
===Useful Links===
<span style="font-size:8pt">
http://en.wikipedia.org/wiki/The_Art_of_Fugue<br />
http://en.wikipedia.org/wiki/Piano_key_frequencies<br />
http://pzwart3.wdka.hro.nl/wiki/Poetry_generators<br />
http://pzwart3.wdka.hro.nl/wiki/Sedsongs#midge<br />
http://manpages.ubuntu.com/manpages/hardy/man1/midge.1.html<br />
http://piano.congland.com/<br />
</span>

Latest revision as of 11:37, 21 June 2011


The Art of the Fugue

MARKOV CHANTS WITH J.S. BACH

Concept

Scetchbook2011-02 markov.jpg

Scetchbook2011-01 markov.jpg

Scripting Progress

Python : Script 2011-05-23 (not working)
#!/usr/bin/env python

import random

fugue = {}
fugue = {
    "l2/d3":["l2/a3", "l2/c+3"], 
    "l2/a3": ["l2/f3"], 
    "l2/f3": ["l2/d3", "l8/f3"], 
    "l2/c+3": ["l4/d3"], 
    "l4/d3": ["l4/e3"], 
    "l4/e3": ["l2/f3"], 
    "l8/f3": ["l8/g3","l8/e3"], 
    "l8/g3": ["l8/f3"], 
    "l8/e3": ["l2/d3"]
}

# start with first / one tone (KEY) in the dictionary
# look in the list of the KEY to find next possibilities
# pick a random VALUE from the list that belongs to the key
# asign this next tone to start this loop again

# variable tone
for t in enumerate(tones):
    print t, tones[i+1]

random.choice()

#MIDGE
@head {
    $time_sig 2/2
    $tempo 120
}
@body {
    @channel 1 {
        $patch 1
        $octave 4
        $length 16
        # tones here
    }
}

#MIDI FILE
#play with timidity
Python : Script fugue.py 2011-05-24
#!/usr/bin/env python
 
import random
 
fugue = {}
fugue = {
    "/l2/d4":["/l2/a4", "/l2/c+4"], 
    "/l2/a4": ["/l2/f4"], 
    "/l2/f4": ["/l2/d4", "/l8/f4"], 
    "/l2/c+4": ["/l4/d4"], 
    "/l4/d4": ["/l4/e4"], 
    "/l4/e4": ["/l2/f4"], 
    "/l8/f4": ["/l8/g4","/l8/e4"], 
    "/l8/g4": ["/l8/f4"], 
    "/l8/e4": ["/l2/d4"]
}

#here we print / place the timidity structure
print """
@head {
    $time_sig 4/4
    $tempo 220
}
@body {
    @channel 1 {
        $patch 1
        $octave 4
        $length 16
"""

tone = "/l2/d4"
for x in range(64):
	print tone
	#this new variable tone is overwriting the old tone! => variable as empty bowl symbolism
	tone = random.choice(fugue[tone])

#here we print / place the timidity structure
print """
    }
}
"""
TERMINAL:

natasa@natasa-linux:~/pzi/3_TRIMESTER/PROTOTYPING/20110524_fugue$ python fugue.py | midge
found 1 music tracks
midi output written to a.out.mid

natasa@natasa-linux:~/pzi/3_TRIMESTER/PROTOTYPING/20110524_fugue$ timidity a.out.mid
Playing a.out.mid
Playing time: ~31 seconds

natasa@natasa-linux:~/pzi/3_TRIMESTER/PROTOTYPING/20110524_fugue$ timidity -Ov a.out.mid
Playing a.out.mid
Output a_out.ogg
Python : Script fugue_out.sh 2011-05-30
# $ for variable in bash
in=$1
# strip off extention
b=${in%.*} 
echo $b

python $1 | midge -o $b.mid

timidity -Ov $b.mid
Python : Script fugues_out.sh 2011-05-30
for ((i=1; i<5; i++))
do
bash fugue_out.sh fugue.py
mv fugue.mid fugue_0$i.mid
mv fugue.ogg fugue_0$i.ogg
done
TERMINAL:
natasa@natasa-linux:~/pzi/3_TRIMESTER/PROTOTYPING/20110524_fugue$ bash fugues_out.sh

Voice 01 (Octave 3) File:Fugue 01 20110530.ogg
Voice 02 (Octave 3) File:Fugue 02 20110530.ogg
Voice 03 (Octave 3) File:Fugue 03 20110530.ogg
Voice 04 (Octave 3) File:Fugue 04 20110530.ogg

Python : Script fugue_octave.py 2011-06-08
#!/usr/bin/env python
 
import random
 
fugue = {}
fugue = {
    "/l2/d":["/l2/a", "/l2/c+"], 
    "/l2/a": ["/l2/f"], 
    "/l2/f": ["/l2/d", "/l8/f"], 
    "/l2/c+": ["/l4/d"], 
    "/l4/d": ["/l4/e"], 
    "/l4/e": ["/l2/f"], 
    "/l8/f": ["/l8/g","/l8/e"], 
    "/l8/g": ["/l8/f"], 
    "/l8/e": ["/l2/d"]
}

print """
@head {
    $time_sig 4/4
    $tempo 220
}
@body {
    @channel 1 {
        $patch 1
        $octave 3
        $length 16
"""

tone = "/l2/d"
for x in range(64):
	print tone
	#this new variable tone is overwriting the old tone! => variable as empty bowl symbolism
	tone = random.choice(fugue[tone])

print """
    }
}
"""

Voice 01 (Octave 2) File:Fugue 01 20110608.ogg
Voice 02 (Octave 3) File:Fugue 04 20110530.ogg
Voice 03 (Octave 4) File:Fugue 01-octave4 20110608.ogg

Questions

How can I make the octave a variable (midge)?
How can I at least play two voices simultaneously (two channels)?
How can these two channels have different octaves?

Useful Links

http://en.wikipedia.org/wiki/The_Art_of_Fugue
http://en.wikipedia.org/wiki/Piano_key_frequencies
http://pzwart3.wdka.hro.nl/wiki/Poetry_generators
http://pzwart3.wdka.hro.nl/wiki/Sedsongs#midge
http://manpages.ubuntu.com/manpages/hardy/man1/midge.1.html
http://piano.congland.com/