Пример #1
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)
Пример #2
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"
     ])
Пример #3
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)
Пример #4
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"])
Пример #5
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()
Пример #6
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'])
Пример #7
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'])