Exemple #1
0
 def testWriteSimple(self):
     drum = Drum("test", "td", "x", True)
     defaultHead = HeadData(shortcut = "y")
     drum.addNoteHead("x", defaultHead)
     outstring = StringIO()
     indenter = fileUtils.Indenter(outstring)
     dbfsv1.DrumStructureV1().write(drum, indenter)
     outlines = outstring.getvalue().splitlines()
     self.assertEqual(outlines,
                        ['START_DRUM',
                         '  NAME test',
                         '  ABBR td',
                         '  DEFAULT_HEAD x',
                         '  LOCKED True',
                         '  HEADLIST x',
                         '  START_NOTEHEAD',
                         '    MIDINOTE 71',
                         '    MIDIVOLUME 96',
                         '    EFFECT normal',
                         '    NOTATIONHEAD default',
                         '    NOTATIONLINE 0',
                         '    NOTATIONEFFECT none',
                         '    STEM 0',
                         '    SHORTCUT y',
                         '  END_NOTEHEAD',
                         'END_DRUM' ])
Exemple #2
0
 def testReadHead(self):
     dataString = "x 72,100,ghost,cross,1,choke,1,c"
     drum = Drum("test", "td", "x")
     drum.readHeadData(dataString)
     self.assertEqual(len(drum), 1)
     self.assertEqual(drum.head, "x")
     self.assertEqual(drum[0], "x")
Exemple #3
0
 def testReadHead(self):
     dataString = "x 72,100,ghost,cross,1,choke,1,c"
     drum = Drum("test", "td", "x")
     drum.readHeadData(dataString)
     self.assertEqual(len(drum), 1)
     self.assertEqual(drum.head, "x")
     self.assertEqual(drum[0], "x")
Exemple #4
0
 def testWriteSimple(self):
     drum = Drum("test", "td", "x", True)
     defaultHead = HeadData(shortcut="y")
     drum.addNoteHead("x", defaultHead)
     outstring = StringIO()
     indenter = fileUtils.Indenter(outstring)
     dbfsv1.DrumStructureV1().write(drum, indenter)
     outlines = outstring.getvalue().splitlines()
     self.assertEqual(outlines,
                      ['START_DRUM',
                       '  NAME test',
                       '  ABBR td',
                       '  DEFAULT_HEAD x',
                       '  LOCKED True',
                       '  HEADLIST x',
                       '  START_NOTEHEAD',
                       '    MIDINOTE 71',
                       '    MIDIVOLUME 96',
                       '    EFFECT normal',
                       '    NOTATIONHEAD default',
                       '    NOTATIONLINE 0',
                       '    NOTATIONEFFECT none',
                       '    STEM 0',
                       '    SHORTCUT y',
                       '  END_NOTEHEAD',
                       'END_DRUM'])
Exemple #5
0
 def testEquality(self):
     drum1 = Drum("test drum", "td", "x")
     drum2 = Drum("test drum", "td", "x")
     drum3 = Drum("test drum", "d2", "x")
     drum4 = Drum("test drum2", "td", "x")
     drum5 = Drum("test drum2", "d2", "x")
     self.assertEqual(drum1, drum2)
     self.assertEqual(drum1, drum3)
     self.assertEqual(drum1, drum4)
     self.assertNotEqual(drum1, drum5)
Exemple #6
0
 def testGuessHeadData_Unknown(self):
     drum = Drum("test", "td", "x")
     drum.guessHeadData()
     self.assertEqual(len(drum), 1)
     self.assertEqual(drum[0], "x")
     headData = drum.headData(None)
     self.assertEqual(headData.midiNote, DefaultKits.DEFAULT_NOTE)
     self.assertEqual(headData.midiVolume, DefaultKits.DEFAULT_VOLUME)
     self.assertEqual(headData.effect, "normal")
     self.assertEqual(headData.notationHead, "default")
     self.assertEqual(headData.notationLine, 0)
     self.assertEqual(headData.notationEffect, "none")
     self.assertEqual(headData.stemDirection, DefaultKits.STEM_UP)
     self.assertEqual(headData.shortcut, "x")
def _loadDefaultKit(kit, kitInfo=None):
    for (drumData, midiNote, notationHead, notationLine,
         stemDirection) in kitInfo["drums"]:
        drum = Drum(*drumData)
        headData = HeadData(midiNote=midiNote,
                            notationHead=notationHead,
                            notationLine=notationLine,
                            stemDirection=stemDirection)
        drum.addNoteHead(drum.head, headData)
        for (extraHead, newMidi, newMidiVolume, newEffect, newNotationHead,
             newNotationEffect,
             shortcut) in kitInfo["heads"].get(drum.abbr, []):
            if newMidi is None:
                newMidi = midiNote
            if newMidiVolume is None:
                newMidiVolume = headData.midiVolume
            newData = HeadData(newMidi,
                               newMidiVolume,
                               newEffect,
                               notationLine=notationLine,
                               notationHead=newNotationHead,
                               notationEffect=newNotationEffect,
                               stemDirection=stemDirection,
                               shortcut=shortcut)
            drum.addNoteHead(extraHead, newData)
        drum.checkShortcuts()
        kit.addDrum(drum)
Exemple #8
0
 def testGuessHeadData_Unknown(self):
     drum = Drum("test", "td", "x")
     drum.guessHeadData()
     self.assertEqual(len(drum), 1)
     self.assertEqual(drum[0], "x")
     headData = drum.headData(None)
     self.assertEqual(headData.midiNote, DefaultKits.DEFAULT_NOTE)
     self.assertEqual(headData.midiVolume, DefaultKits.DEFAULT_VOLUME)
     self.assertEqual(headData.effect, "normal")
     self.assertEqual(headData.notationHead, "default")
     self.assertEqual(headData.notationLine, 0)
     self.assertEqual(headData.notationEffect, "none")
     self.assertEqual(headData.stemDirection, DefaultKits.STEM_UP)
     self.assertEqual(headData.shortcut, "x")
Exemple #9
0
 def makeDrum():
     drum = Drum("test", "td", "x")
     defaultHead = HeadData(shortcut="y")
     drum.addNoteHead("x", defaultHead)
     newHead = HeadData(100)
     drum.addNoteHead("y", newHead)
     drum.addNoteHead("z", None)
     return drum, defaultHead, newHead
Exemple #10
0
 def testReadHead(self):
     dataString = "x 72,100,ghost,cross,1,choke,1,c"
     drum = Drum("test", "td", "x")
     dbfsv0.NoteHeadFieldV0.readHeadData(drum.abbr, dataString)
     dbfsv0.DrumKitStructureV0.guessHeadData(drum)
     self.assertEqual(len(drum), 1)
     self.assertEqual(drum.head, "x")
     self.assertEqual(drum[0], "x")
Exemple #11
0
 def makeDrum():
     drum = Drum("test", "td", "x")
     defaultHead = HeadData(shortcut="y")
     drum.addNoteHead("x", defaultHead)
     newHead = HeadData(100)
     drum.addNoteHead("y", newHead)
     headData = HeadData(72, 100, "ghost", "cross", 1, "choke",
                         DefaultKits.STEM_DOWN, "c")
     drum.addNoteHead("z", headData)
     return drum, defaultHead, newHead
Exemple #12
0
def _loadDefaultKit(kit, kitInfo = None):
    for (drumData, midiNote, notationHead,
         notationLine, stemDirection) in kitInfo["drums"]:
        drum = Drum(*drumData)
        headData = HeadData(midiNote = midiNote,
                            notationHead = notationHead,
                            notationLine = notationLine,
                            stemDirection = stemDirection)
        drum.addNoteHead(drum.head, headData)
        for (extraHead,
             newMidi,
             newMidiVolume,
             newEffect,
             newNotationHead,
             newNotationEffect,
             shortcut) in kitInfo["heads"].get(drum.abbr, []):
            if newMidi is None:
                newMidi = midiNote
            if newMidiVolume is None:
                newMidiVolume = headData.midiVolume
            newData = HeadData(newMidi, newMidiVolume, newEffect,
                               notationLine = notationLine,
                               notationHead = newNotationHead,
                               notationEffect = newNotationEffect,
                               stemDirection = stemDirection,
                               shortcut = shortcut)
            drum.addNoteHead(extraHead, newData)
        drum.checkShortcuts()
        kit.addDrum(drum)
Exemple #13
0
 def makeDrum():
     drum = Drum("test", "td", "x")
     defaultHead = HeadData(shortcut = "y")
     drum.addNoteHead("x", defaultHead)
     newHead = HeadData(100)
     drum.addNoteHead("y", newHead)
     drum.addNoteHead("z", None)
     return drum, defaultHead, newHead
 def _addDrum(self):
     drum = Drum.makeSimple("New drum", "XX", "o")
     self._currentKit.append(drum)
     self._oldLines[drum] = -1
     self.kitTable.addItem(drum.name)
     self.kitTable.setCurrentRow(len(self._currentKit) - 1)
     self._checkDrumButtons()
     self._checkAbbrs()
     self.drumName.setFocus()
     self.drumName.selectAll()
Exemple #15
0
 def _addDrum(self):
     drum = Drum.makeSimple("New drum", "XX", "o")
     self._currentKit.append(drum)
     self._oldLines[drum] = -1
     self.kitTable.addItem(drum.name)
     self.kitTable.setCurrentRow(len(self._currentKit) - 1)
     self._checkDrumButtons()
     self._checkAbbrs()
     self.drumName.setFocus()
     self.drumName.selectAll()
Exemple #16
0
 def testWriteExtraHeads(self):
     drum = Drum("test", "td", "x")
     defaultHead = HeadData(shortcut="y")
     drum.addNoteHead("x", defaultHead)
     newHead = HeadData(100, shortcut='a')
     drum.addNoteHead("y", newHead)
     headData = HeadData(72, 100, "ghost", "cross", 1, "choke",
                         DefaultKits.STEM_DOWN, "c")
     drum.addNoteHead("z", headData)
     outstring = StringIO()
     indenter = fileUtils.Indenter(outstring)
     dbfsv1.DrumStructureV1().write(drum, indenter)
     outlines = outstring.getvalue().splitlines()
     self.assertEqual(outlines,
                      ['START_DRUM',
                       '  NAME test',
                       '  ABBR td',
                       '  DEFAULT_HEAD x',
                       '  LOCKED False',
                       '  HEADLIST xyz',
                       '  START_NOTEHEAD',
                       '    MIDINOTE 71',
                       '    MIDIVOLUME 96',
                       '    EFFECT normal',
                       '    NOTATIONHEAD default',
                       '    NOTATIONLINE 0',
                       '    NOTATIONEFFECT none',
                       '    STEM 0',
                       '    SHORTCUT y',
                       '  END_NOTEHEAD',
                       '  START_NOTEHEAD',
                       '    MIDINOTE 100',
                       '    MIDIVOLUME 96',
                       '    EFFECT normal',
                       '    NOTATIONHEAD default',
                       '    NOTATIONLINE 0',
                       '    NOTATIONEFFECT none',
                       '    STEM 0',
                       '    SHORTCUT a',
                       '  END_NOTEHEAD',
                       '  START_NOTEHEAD',
                       '    MIDINOTE 72',
                       '    MIDIVOLUME 100',
                       '    EFFECT ghost',
                       '    NOTATIONHEAD cross',
                       '    NOTATIONLINE 1',
                       '    NOTATIONEFFECT choke',
                       '    STEM 1',
                       '    SHORTCUT c',
                       '  END_NOTEHEAD',
                       'END_DRUM'])
Exemple #17
0
 def makeDrum():
     drum = Drum("test", "td", "x")
     defaultHead = HeadData(shortcut = "y")
     drum.addNoteHead("x", defaultHead)
     newHead = HeadData(100)
     drum.addNoteHead("y", newHead)
     headData = HeadData(72, 100, "ghost", "cross", 1, "choke",
                         DefaultKits.STEM_DOWN, "c")
     drum.addNoteHead("z", headData)
     return drum, defaultHead, newHead
Exemple #18
0
 def testWriteExtraHeads(self):
     drum = Drum("test", "td", "x")
     defaultHead = HeadData(shortcut = "y")
     drum.addNoteHead("x", defaultHead)
     newHead = HeadData(100, shortcut = 'a')
     drum.addNoteHead("y", newHead)
     headData = HeadData(72, 100, "ghost", "cross", 1, "choke",
                         DefaultKits.STEM_DOWN, "c")
     drum.addNoteHead("z", headData)
     outstring = StringIO()
     indenter = fileUtils.Indenter(outstring)
     dbfsv1.DrumStructureV1().write(drum, indenter)
     outlines = outstring.getvalue().splitlines()
     self.assertEqual(outlines,
                        ['START_DRUM',
                         '  NAME test',
                         '  ABBR td',
                         '  DEFAULT_HEAD x',
                         '  LOCKED False',
                         '  HEADLIST xyz',
                         '  START_NOTEHEAD',
                         '    MIDINOTE 71',
                         '    MIDIVOLUME 96',
                         '    EFFECT normal',
                         '    NOTATIONHEAD default',
                         '    NOTATIONLINE 0',
                         '    NOTATIONEFFECT none',
                         '    STEM 0',
                         '    SHORTCUT y',
                         '  END_NOTEHEAD',
                         '  START_NOTEHEAD',
                         '    MIDINOTE 100',
                         '    MIDIVOLUME 96',
                         '    EFFECT normal',
                         '    NOTATIONHEAD default',
                         '    NOTATIONLINE 0',
                         '    NOTATIONEFFECT none',
                         '    STEM 0',
                         '    SHORTCUT a',
                         '  END_NOTEHEAD',
                         '  START_NOTEHEAD',
                         '    MIDINOTE 72',
                         '    MIDIVOLUME 100',
                         '    EFFECT ghost',
                         '    NOTATIONHEAD cross',
                         '    NOTATIONLINE 1',
                         '    NOTATIONEFFECT choke',
                         '    STEM 1',
                         '    SHORTCUT c',
                         '  END_NOTEHEAD',
                         'END_DRUM' ])
Exemple #19
0
 def _addDrum(self):
     drum = Drum("New drum", "XX", "o")
     drum.guessHeadData()
     drum.checkShortcuts()
     self._currentKit.append(drum)
     self._oldLines[drum] = -1
     self.kitTable.addItem(drum.name)
     self.kitTable.setCurrentRow(len(self._currentKit) - 1)
     self._checkDrumButtons()
     self._checkAbbrs()
     self.drumName.setFocus()
     self.drumName.selectAll()
Exemple #20
0
 def testAddDrum(self):
     self.kit = DrumKit.getNamedDefaultKit()
     numDrums = len(self.kit)
     drum = Drum("test drum", "td", "x")
     self.kit.addDrum(drum)
     self.assertEqual(len(self.kit), numDrums + 1)
Exemple #21
0
 def testWrite(self):
     kit = DrumKit.DrumKit()
     drum = Drum("One", "d1", "x", True)
     drum.addNoteHead("x", HeadData())
     drum.addNoteHead("g",
                      HeadData(effect = "ghost", notationEffect = "ghost"))
     drum.checkShortcuts()
     kit.addDrum(drum)
     drum = Drum("Two", "d2", "o")
     drum.addNoteHead("o", HeadData(notationLine = -5, stemDirection = 1))
     drum.addNoteHead("O", HeadData(effect = "accent",
                                    notationEffect = "accent",
                                    notationLine = -5, stemDirection = 1))
     drum.checkShortcuts()
     kit.addDrum(drum)
     handle = StringIO()
     indenter = fileUtils.Indenter(handle)
     dbfsv0.DrumKitStructureV0().write(kit, indenter)
     outlines = handle.getvalue().splitlines()
     self.assertEqual(outlines,
                      ["KIT_START",
                       "  DRUM One,d1,x,True",
                       "    NOTEHEAD x 71,96,normal,default,0,none,0,x",
                       "    NOTEHEAD g 71,96,ghost,default,0,ghost,0,g",
                       "  DRUM Two,d2,o,False",
                       "    NOTEHEAD o 71,96,normal,default,-5,none,1,o",
                       "    NOTEHEAD O 71,96,accent,default,-5,accent,1,a",
                       "KIT_END"])
Exemple #22
0
 def testDrum(self):
     drum = Drum("test drum", "td", "x")
     self.assertEqual(drum.name, "test drum")
     self.assertEqual(drum.abbr, "td")
     self.assertEqual(drum.head, "x")
     self.assertFalse(drum.locked)
Exemple #23
0
 def testGuessHeadData_Known(self):
     drum = Drum("HiTom", "HT", "o")
     drum.guessHeadData()
     self.assertEqual(list(drum), ["o", "O", "g", "f", "d"])
     headData = drum.headData(None)
     self.assertEqual(headData.midiNote, 50)
Exemple #24
0
 def testWrite(self):
     kit = DrumKit.DrumKit()
     drum = Drum("One", "d1", "x", True)
     drum.addNoteHead("x", HeadData())
     drum.addNoteHead("g",
                      HeadData(effect="ghost", notationEffect="ghost"))
     drum.checkShortcuts()
     kit.addDrum(drum)
     drum = Drum("Two", "d2", "o")
     drum.addNoteHead("o", HeadData(notationLine=-5, stemDirection=1))
     drum.addNoteHead("O", HeadData(effect="accent",
                                    notationEffect="accent",
                                    notationLine=-5, stemDirection=1))
     drum.checkShortcuts()
     kit.addDrum(drum)
     handle = StringIO()
     indenter = fileUtils.Indenter(handle)
     dbfsv1.DrumKitStructureV1().write(kit, indenter)
     outlines = handle.getvalue().splitlines()
     self.assertEqual(outlines,
                      ['START_KIT',
                       '  START_DRUM',
                       '    NAME One',
                       '    ABBR d1',
                       '    DEFAULT_HEAD x',
                       '    LOCKED True',
                       '    HEADLIST xg',
                       '    START_NOTEHEAD',
                       '      MIDINOTE 71',
                       '      MIDIVOLUME 96',
                       '      EFFECT normal',
                       '      NOTATIONHEAD default',
                       '      NOTATIONLINE 0',
                       '      NOTATIONEFFECT none',
                       '      STEM 0',
                       '      SHORTCUT x',
                       '    END_NOTEHEAD',
                       '    START_NOTEHEAD',
                       '      MIDINOTE 71',
                       '      MIDIVOLUME 96',
                       '      EFFECT ghost',
                       '      NOTATIONHEAD default',
                       '      NOTATIONLINE 0',
                       '      NOTATIONEFFECT ghost',
                       '      STEM 0',
                       '      SHORTCUT g',
                       '    END_NOTEHEAD',
                       '  END_DRUM',
                       '  START_DRUM',
                       '    NAME Two',
                       '    ABBR d2',
                       '    DEFAULT_HEAD o',
                       '    LOCKED False',
                       '    HEADLIST oO',
                       '    START_NOTEHEAD',
                       '      MIDINOTE 71',
                       '      MIDIVOLUME 96',
                       '      EFFECT normal',
                       '      NOTATIONHEAD default',
                       '      NOTATIONLINE -5',
                       '      NOTATIONEFFECT none',
                       '      STEM 1',
                       '      SHORTCUT o',
                       '    END_NOTEHEAD',
                       '    START_NOTEHEAD',
                       '      MIDINOTE 71',
                       '      MIDIVOLUME 96',
                       '      EFFECT accent',
                       '      NOTATIONHEAD default',
                       '      NOTATIONLINE -5',
                       '      NOTATIONEFFECT accent',
                       '      STEM 1',
                       '      SHORTCUT a',
                       '    END_NOTEHEAD',
                       '  END_DRUM',
                       'END_KIT'])
Exemple #25
0
 def testDefaultHead(self):
     drum = Drum("test drum", "td", "x")
     self.assertEqual(len(drum), 0)
     self.assertEqual(drum.head, "x")
     self.assertFalse(drum.isAllowedHead("x"))
     self.assertRaises(KeyError, drum.headData, None)
Exemple #26
0
 def testGuessHeadData_Known(self):
     drum = Drum("HiTom", "HT", "o")
     drum.guessHeadData()
     self.assertEqual(list(drum), ["o", "O", "g", "f", "d"])
     headData = drum.headData(None)
     self.assertEqual(headData.midiNote, 50)
Exemple #27
0
 def testWrite(self):
     kit = DrumKit.DrumKit()
     drum = Drum("One", "d1", "x", True)
     drum.addNoteHead("x", HeadData())
     drum.addNoteHead("g",
                      HeadData(effect = "ghost", notationEffect = "ghost"))
     drum.checkShortcuts()
     kit.addDrum(drum)
     drum = Drum("Two", "d2", "o")
     drum.addNoteHead("o", HeadData(notationLine = -5, stemDirection = 1))
     drum.addNoteHead("O", HeadData(effect = "accent",
                                    notationEffect = "accent",
                                    notationLine = -5, stemDirection = 1))
     drum.checkShortcuts()
     kit.addDrum(drum)
     handle = StringIO()
     indenter = fileUtils.Indenter(handle)
     dbfsv1.DrumKitStructureV1().write(kit, indenter)
     outlines = handle.getvalue().splitlines()
     self.assertEqual(outlines,
                      ['START_KIT',
                         '  START_DRUM',
                         '    NAME One',
                         '    ABBR d1',
                         '    DEFAULT_HEAD x',
                         '    LOCKED True',
                         '    HEADLIST xg',
                         '    START_NOTEHEAD',
                         '      MIDINOTE 71',
                         '      MIDIVOLUME 96',
                         '      EFFECT normal',
                         '      NOTATIONHEAD default',
                         '      NOTATIONLINE 0',
                         '      NOTATIONEFFECT none',
                         '      STEM 0',
                         '      SHORTCUT x',
                         '    END_NOTEHEAD',
                         '    START_NOTEHEAD',
                         '      MIDINOTE 71',
                         '      MIDIVOLUME 96',
                         '      EFFECT ghost',
                         '      NOTATIONHEAD default',
                         '      NOTATIONLINE 0',
                         '      NOTATIONEFFECT ghost',
                         '      STEM 0',
                         '      SHORTCUT g',
                         '    END_NOTEHEAD',
                         '  END_DRUM',
                         '  START_DRUM',
                         '    NAME Two',
                         '    ABBR d2',
                         '    DEFAULT_HEAD o',
                         '    LOCKED False',
                         '    HEADLIST oO',
                         '    START_NOTEHEAD',
                         '      MIDINOTE 71',
                         '      MIDIVOLUME 96',
                         '      EFFECT normal',
                         '      NOTATIONHEAD default',
                         '      NOTATIONLINE -5',
                         '      NOTATIONEFFECT none',
                         '      STEM 1',
                         '      SHORTCUT o',
                         '    END_NOTEHEAD',
                         '    START_NOTEHEAD',
                         '      MIDINOTE 71',
                         '      MIDIVOLUME 96',
                         '      EFFECT accent',
                         '      NOTATIONHEAD default',
                         '      NOTATIONLINE -5',
                         '      NOTATIONEFFECT accent',
                         '      STEM 1',
                         '      SHORTCUT a',
                         '    END_NOTEHEAD',
                         '  END_DRUM',
                         'END_KIT'])
Exemple #28
0
 def testAddDrum(self):
     numDrums = len(self.kit)
     drum = Drum("test drum", "td", "x")
     self.kit.addDrum(drum)
     self.assertEqual(len(self.kit), numDrums + 1)
Exemple #29
0
 def testDefaultHead(self):
     drum = Drum("test drum", "td", "x")
     self.assertEqual(len(drum), 0)
     self.assertEqual(drum.head, "x")
     self.assertFalse(drum.isAllowedHead("x"))
     self.assertRaises(KeyError, drum.headData , None)
Exemple #30
0
 def testWrite(self):
     kit = DrumKit.DrumKit()
     drum = Drum("One", "d1", "x", True)
     drum.addNoteHead("x", HeadData())
     drum.addNoteHead("g", HeadData(effect="ghost", notationEffect="ghost"))
     drum.checkShortcuts()
     kit.addDrum(drum)
     drum = Drum("Two", "d2", "o")
     drum.addNoteHead("o", HeadData(notationLine=-5, stemDirection=1))
     drum.addNoteHead(
         "O",
         HeadData(effect="accent",
                  notationEffect="accent",
                  notationLine=-5,
                  stemDirection=1))
     drum.checkShortcuts()
     kit.addDrum(drum)
     handle = StringIO()
     indenter = fileUtils.Indenter(handle)
     dbfsv0.DrumKitStructureV0().write(kit, indenter)
     outlines = handle.getvalue().splitlines()
     self.assertEqual(outlines, [
         "KIT_START", "  DRUM One,d1,x,True",
         "    NOTEHEAD x 71,96,normal,default,0,none,0,x",
         "    NOTEHEAD g 71,96,ghost,default,0,ghost,0,g",
         "  DRUM Two,d2,o,False",
         "    NOTEHEAD o 71,96,normal,default,-5,none,1,o",
         "    NOTEHEAD O 71,96,accent,default,-5,accent,1,a", "KIT_END"
     ])