Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/Util/NoteDB.py
diff options
context:
space:
mode:
authoramartin <olpc@xo-00-CE-12.localdomain>2007-06-29 20:04:34 (GMT)
committer amartin <olpc@xo-00-CE-12.localdomain>2007-06-29 20:04:34 (GMT)
commitfd69395099d5302cb4db19e910e292410b4ae95c (patch)
treeab75467ccff25629eab4263b21df5fc634fead19 /Util/NoteDB.py
parent601e1f48e93d7768736cbb2d54015ed2776e5845 (diff)
load/save page props
Diffstat (limited to 'Util/NoteDB.py')
-rw-r--r--Util/NoteDB.py28
1 files changed, 23 insertions, 5 deletions
diff --git a/Util/NoteDB.py b/Util/NoteDB.py
index 014ec5e..e7f68c9 100644
--- a/Util/NoteDB.py
+++ b/Util/NoteDB.py
@@ -25,10 +25,17 @@ class Note:
self.cs = cs
class Page:
- def __init__( self, beats, color = 0 ): # , tempo, insruments, color = 0 ):
+ def __init__( self, beats, color = 0, instruments = False ): # , tempo, insruments, color = 0 ):
self.beats = beats
- self.color = color
self.ticks = beats*Config.TICKS_PER_BEAT
+
+ self.color = color
+
+ if not instruments:
+ self.instruments = [ Config.INSTRUMENTS["kalimba"].instrumentId for i in range(Config.NUMBER_OF_TRACKS-1) ] + [ Config.INSTRUMENTS["drum1kit"].instrumentId ]
+ else:
+ self.instruments = instruments[:]
+
self.nextNoteId = 0 # first note will be 1
def genId( self ):
@@ -293,9 +300,20 @@ class NoteDB:
#=======================================================
# Track Functions
- #def deleteTracks( self, pages, which ):
-
- #def duplicateTracks( self, pages, which, insert ):
+ def setInstrument( self, pages, track, instrumentId ):
+ print "setinstrument", pages, track, instrumentId
+ stream = []
+ for page in pages:
+ self.pages[page].instruments[track] = instrumentId
+ notes = self.getNotesByTrack( page, track )
+ sub = []
+ for note in notes:
+ sub.append( note.id )
+ sub.append( instrumentId )
+ if len(sub):
+ stream += [ page, track, PARAMETER.INSTRUMENT, len(sub)//2 ] + sub
+ if len(stream):
+ self.updateNotes( stream + [-1] )
#=======================================================