コード例 #1
0
ファイル: DrumKitFactory.py プロジェクト: Whatang/DrumBurp
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
ファイル: testdbfsv1.py プロジェクト: Whatang/DrumBurp
 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' ])
コード例 #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
ファイル: testdbfsv1.py プロジェクト: thomasfillon/DrumBurp
 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'])
コード例 #5
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"
     ])
コード例 #6
0
ファイル: testdbfsv0.py プロジェクト: Whatang/DrumBurp
 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"])
コード例 #7
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
コード例 #8
0
ファイル: testDrum.py プロジェクト: jguardon/DrumBurp
 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
コード例 #9
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
コード例 #10
0
ファイル: testdbfsv0.py プロジェクト: Whatang/DrumBurp
 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
コード例 #11
0
ファイル: testdbfsv1.py プロジェクト: Whatang/DrumBurp
 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' ])
コード例 #12
0
ファイル: testdbfsv1.py プロジェクト: thomasfillon/DrumBurp
 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'])
コード例 #13
0
ファイル: testdbfsv1.py プロジェクト: Whatang/DrumBurp
 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'])
コード例 #14
0
ファイル: testdbfsv1.py プロジェクト: thomasfillon/DrumBurp
 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'])