diff options
author | Robert Jonsson <spamatica@gmail.com> | 2010-10-13 19:34:22 +0000 |
---|---|---|
committer | Robert Jonsson <spamatica@gmail.com> | 2010-10-13 19:34:22 +0000 |
commit | 8a2c2824a59d7644e13bc52c9a0ecbd641f21f95 (patch) | |
tree | 064ad3f2bf8daab0ad27b128abd86a9bbdb1e496 /muse2/share/pybridge/examples | |
parent | a27706d9629e8b592cca4659f865b70adef24e6d (diff) |
new branch muse2, first checkin
Diffstat (limited to 'muse2/share/pybridge/examples')
-rw-r--r-- | muse2/share/pybridge/examples/addpartexample.py | 29 | ||||
-rw-r--r-- | muse2/share/pybridge/examples/addtrack.py | 33 | ||||
-rw-r--r-- | muse2/share/pybridge/examples/ctrlexample.py | 26 | ||||
-rw-r--r-- | muse2/share/pybridge/examples/effecttoggle.py | 23 | ||||
-rw-r--r-- | muse2/share/pybridge/examples/mute.py | 20 | ||||
-rw-r--r-- | muse2/share/pybridge/examples/repeatpart.py | 61 | ||||
-rw-r--r-- | muse2/share/pybridge/examples/setpositionexample.py | 35 | ||||
-rw-r--r-- | muse2/share/pybridge/examples/tempoexample.py | 6 | ||||
-rw-r--r-- | muse2/share/pybridge/examples/trackparamchangeexample.py | 21 |
9 files changed, 254 insertions, 0 deletions
diff --git a/muse2/share/pybridge/examples/addpartexample.py b/muse2/share/pybridge/examples/addpartexample.py new file mode 100644 index 00000000..65c41bdf --- /dev/null +++ b/muse2/share/pybridge/examples/addpartexample.py @@ -0,0 +1,29 @@ +""" +//========================================================= +// MusE +// Linux Music Editor +// (C) Copyright 2009 Mathias Gyllengahm (lunar_shuttle@users.sf.net) +//========================================================= +""" + +import Pyro.core +muse=Pyro.core.getProxyForURI('PYRONAME://:Default.muse') + +# +# Example on how to insert a new note, outcommented since I run the script several times and it inserts so many notes :-) +# But it works! +# + + +rpos = muse.getRPos() +lpos = muse.getLPos() + +event = {'data':[61,100,0], + 'tick':0, # Relative offset of part - 0 = beginning of part + 'type':"note", + 'len':rpos - lpos} + +part = {'events': [event], + 'tick': lpos} +muse.createPart("Track 1", lpos, rpos - lpos, part) + diff --git a/muse2/share/pybridge/examples/addtrack.py b/muse2/share/pybridge/examples/addtrack.py new file mode 100644 index 00000000..116b35c0 --- /dev/null +++ b/muse2/share/pybridge/examples/addtrack.py @@ -0,0 +1,33 @@ +""" +//========================================================= +// MusE +// Linux Music Editor +// (C) Copyright 2009 Mathias Gyllengahm (lunar_shuttle@users.sf.net) +//========================================================= +""" + +import Pyro.core +import time + +muse=Pyro.core.getProxyForURI('PYRONAME://:Default.muse') + +for j in range(0,5): + for i in range(0,30): + muse.addMidiTrack("amiditrack" + str(i)) + for i in range(0,30): + muse.deleteTrack("amiditrack" + str(i)) + +for i in range(0, 10): + print i + muse.addMidiTrack("amiditrack") + muse.addWaveTrack("awavetrack") + muse.addOutput("anoutput") + muse.addInput("aninput") + muse.setMute("aninput", False) + muse.setAudioTrackVolume("aninput",1.0) + muse.deleteTrack("amiditrack") + muse.deleteTrack("awavetrack") + muse.deleteTrack("anoutput") + muse.deleteTrack("aninput") + time.sleep(1) + diff --git a/muse2/share/pybridge/examples/ctrlexample.py b/muse2/share/pybridge/examples/ctrlexample.py new file mode 100644 index 00000000..9e28afad --- /dev/null +++ b/muse2/share/pybridge/examples/ctrlexample.py @@ -0,0 +1,26 @@ +""" +//========================================================= +// MusE +// Linux Music Editor +// (C) Copyright 2009 Mathias Gyllengahm (lunar_shuttle@users.sf.net) +//========================================================= +""" + +import Pyro.core +import time + +muse=Pyro.core.getProxyForURI('PYRONAME://:Default.muse') +#for i in range(0,10): +# print "Ctrl no " + str(i) + " = " + str(muse.getMidiControllerValue("Track 1", i)) + +""" +for i in range(0,127): + muse.setMidiControllerValue("Track 1", 7, i) + time.sleep(0.1) +""" + +muse.setMidiControllerValue("Track 1", 7, 56) +print muse.getMidiControllerValue("Track 1", 7) +print muse.getAudioTrackVolume("Out 1") +muse.setAudioTrackVolume("Out 1", -1.0) + diff --git a/muse2/share/pybridge/examples/effecttoggle.py b/muse2/share/pybridge/examples/effecttoggle.py new file mode 100644 index 00000000..6feb4bca --- /dev/null +++ b/muse2/share/pybridge/examples/effecttoggle.py @@ -0,0 +1,23 @@ +""" +//========================================================= +// MusE +// Linux Music Editor +// (C) Copyright 2009 Mathias Gyllengahm (lunar_shuttle@users.sf.net) +//========================================================= +""" + +import Pyro.core +import time + +muse=Pyro.core.getProxyForURI('PYRONAME://:Default.muse') +trackname = "wavtrack" + +fxs = muse.getTrackEffects(trackname) +print fxs + +for i in range (0,10): + muse.toggleTrackEffect(trackname,0, False) + time.sleep(1) + muse.toggleTrackEffect(trackname,0, True) + time.sleep(1) + diff --git a/muse2/share/pybridge/examples/mute.py b/muse2/share/pybridge/examples/mute.py new file mode 100644 index 00000000..5732a7f8 --- /dev/null +++ b/muse2/share/pybridge/examples/mute.py @@ -0,0 +1,20 @@ +""" +//========================================================= +// MusE +// Linux Music Editor +// (C) Copyright 2009 Mathias Gyllengahm (lunar_shuttle@users.sf.net) +//========================================================= +""" + +import Pyro.core +import time + +muse=Pyro.core.getProxyForURI('PYRONAME://:Default.muse') +for i in range(0,10): + muse.setMute("Strings", False) + muse.setMute("Lead1", True) + time.sleep(1) + muse.setMute("Strings", True) + muse.setMute("Lead1", False) + time.sleep(1) + diff --git a/muse2/share/pybridge/examples/repeatpart.py b/muse2/share/pybridge/examples/repeatpart.py new file mode 100644 index 00000000..e2b8ff31 --- /dev/null +++ b/muse2/share/pybridge/examples/repeatpart.py @@ -0,0 +1,61 @@ +""" +//========================================================= +// MusE +// Linux Music Editor +// (C) Copyright 2009 Mathias Gyllengahm (lunar_shuttle@users.sf.net) +//========================================================= +""" + +import Pyro.core +import sys +import time + +SLEEPIVAL=0.3 + +def advanceToNextSection(muse, newlpos, newrpos): + print "Advancing..." + currpos = muse.getRPos() + curlpos = muse.getLPos() + curpos = muse.getCPos() + muse.setLoop(False) + + while curpos < currpos: + time.sleep(SLEEPIVAL) + curpos = muse.getCPos() + print "Leaving current section..." + muse.setRPos(newrpos) + curpos = muse.getCPos() + + while curpos < newlpos: + time.sleep(SLEEPIVAL) + curpos = muse.getCPos() + print "Entered new section" + muse.setLPos(newlpos) + muse.setLoop(True) + return + +muse=Pyro.core.getProxyForURI('PYRONAME://:Default.muse') +muse.stopPlay() +parts = muse.getParts("Track 1") +muse.setLPos(parts[0]['tick']) +muse.setRPos(parts[0]['tick'] + parts[0]['len']) +muse.setCPos(0) +time.sleep(0.2) # Hmmm, don't like it but it seems necessary to pause a short while before starting play +muse.setLoop(True) +muse.startPlay() + +for i in range(1, len(parts)): + part = parts[i] + tick = part['tick'] + len = part['len'] + print "Press enter to advance to next section/part!" + sys.stdin.read(1) + advanceToNextSection(muse, tick, tick + len) + +print "This is the final section. Disabling loop and leaving..." +muse.setLoop(False) + +#print "Press enter to leave final section" +#sys.stdin.read(1) +#muse.setLoop(False) + diff --git a/muse2/share/pybridge/examples/setpositionexample.py b/muse2/share/pybridge/examples/setpositionexample.py new file mode 100644 index 00000000..476410d9 --- /dev/null +++ b/muse2/share/pybridge/examples/setpositionexample.py @@ -0,0 +1,35 @@ +""" +//========================================================= +// MusE +// Linux Music Editor +// (C) Copyright 2009 Mathias Gyllengahm (lunar_shuttle@users.sf.net) +//========================================================= +""" + +import Pyro.core +import time +muse=Pyro.core.getProxyForURI('PYRONAME://:Default.muse') +parts = muse.getParts("Track 1") + +ptick = parts[0]['tick'] +len = parts[0]['len'] +muse.setLPos(ptick) +muse.setRPos(ptick + len) +muse.setCPos(ptick + len / 2) + +songlen = muse.getSongLen() +#print "Song length: " + str(songlen) + +# +# Copy first part to after current song length, thus increase song length with length of first part +# +newsonglen = songlen + parts[0]['len'] +muse.setSongLen(newsonglen) +muse.createPart("Track 1", songlen + 1, parts[0]['len'], parts[0]) +time.sleep(1) + +lastpart = muse.getParts("Track 1").pop() +print lastpart['id'] +muse.deletePart(lastpart['id']) +print muse.getDivision() + diff --git a/muse2/share/pybridge/examples/tempoexample.py b/muse2/share/pybridge/examples/tempoexample.py new file mode 100644 index 00000000..ed12638d --- /dev/null +++ b/muse2/share/pybridge/examples/tempoexample.py @@ -0,0 +1,6 @@ +import Pyro.core + +muse=Pyro.core.getProxyForURI('PYRONAME://:Default.muse') + +print "Tempo: " + str(muse.getTempo(0)) + diff --git a/muse2/share/pybridge/examples/trackparamchangeexample.py b/muse2/share/pybridge/examples/trackparamchangeexample.py new file mode 100644 index 00000000..0681ccb4 --- /dev/null +++ b/muse2/share/pybridge/examples/trackparamchangeexample.py @@ -0,0 +1,21 @@ +""" +//========================================================= +// MusE +// Linux Music Editor +// (C) Copyright 2009 Mathias Gyllengahm (lunar_shuttle@users.sf.net) +//========================================================= +""" +import Pyro.core +import time + +muse=Pyro.core.getProxyForURI('PYRONAME://:Default.muse') + +muse.setMidiTrackParameter("Track 1", "velocity",10) +muse.setMidiTrackParameter("Track 1", "compression",101) +muse.setMidiTrackParameter("Track 1", "delay",2) +muse.setMidiTrackParameter("Track 1", "transposition",1) + +for i in range(-127, 127): + muse.setMidiTrackParameter("Track 1", "velocity",i) + time.sleep(0.1) + |