Пример #1
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"
     ])
Пример #2
0
 def testWriteFullBeat(self):
     beat = Beat.Beat(Counter.Counter("e+a"))
     handle = StringIO()
     indenter = fileUtils.Indenter(handle)
     dbfsv0.BeatStructureV0().write(beat, indenter)
     output = handle.getvalue().splitlines()
     self.assertEqual(output, ["BEAT_START", "  COUNT |^e+a|", "BEAT_END"])
Пример #3
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'])
Пример #4
0
 def testSimpleDefaultWrite(self):
     myCounter = Counter.Counter("e+a")
     count = MeasureCount.makeSimpleCount(myCounter, 4)
     handle = StringIO()
     indenter = fileUtils.Indenter(handle)
     dbfsv1.DefaultMeasureCountStructureV1().write(count, indenter)
     output = handle.getvalue().splitlines()
     self.assertEqual(output,
                      ["START_DEFAULT_MEASURE_COUNT",
                       "  BEAT_START",
                       "    NUM_TICKS 4",
                       "    COUNT |^e+a|",
                       "  BEAT_END",
                       "  BEAT_START",
                       "    NUM_TICKS 4",
                       "    COUNT |^e+a|",
                       "  BEAT_END",
                       "  BEAT_START",
                       "    NUM_TICKS 4",
                       "    COUNT |^e+a|",
                       "  BEAT_END",
                       "  BEAT_START",
                       "    NUM_TICKS 4",
                       "    COUNT |^e+a|",
                       "  BEAT_END",
                       "END_DEFAULT_MEASURE_COUNT"])
Пример #5
0
 def testComplexWrite(self):
     counter1 = Counter.Counter("e+a")
     counter2 = Counter.Counter("+a")
     counter3 = Counter.Counter("+")
     counter4 = Counter.Counter("e+a")
     count = MeasureCount.MeasureCount()
     count.addBeats(Beat.Beat(counter1), 1)
     count.addBeats(Beat.Beat(counter2), 1)
     count.addBeats(Beat.Beat(counter3), 1)
     count.addBeats(Beat.Beat(counter4, 2), 1)
     handle = StringIO()
     indenter = fileUtils.Indenter(handle)
     dbfsv1.MeasureCountStructureV1().write(count, indenter)
     output = handle.getvalue().splitlines()
     self.assertEqual(output,
                      ["START_MEASURE_COUNT",
                       "  BEAT_START",
                       "    NUM_TICKS 4",
                       "    COUNT |^e+a|",
                       "  BEAT_END",
                       "  BEAT_START",
                       "    NUM_TICKS 3",
                       "    COUNT |^+a|",
                       "  BEAT_END",
                       "  BEAT_START",
                       "    NUM_TICKS 2",
                       "    COUNT |^+|",
                       "  BEAT_END",
                       "  BEAT_START",
                       "    NUM_TICKS 2",
                       "    COUNT |^e+a|",
                       "  BEAT_END",
                       "END_MEASURE_COUNT"])
Пример #6
0
 def testWrite(self):
     counter = Counter.Counter("^bcd", "^fgh", "^jkl")
     handle = StringIO()
     indenter = fileUtils.Indenter(handle)
     dbfsv0.CounterFieldV0("COUNT", getter=lambda _: counter).write_all(
         self, indenter)
     self.assertEqual(handle.getvalue(), "COUNT |^bcd|\n")
Пример #7
0
 def write(cls, kit, handle, version=DBConstants.CURRENT_KIT_FORMAT):
     kitBuffer = StringIO()
     indenter = fileUtils.Indenter(kitBuffer)
     indenter(DBConstants.DB_KIT_FILE_FORMAT_STR, version)
     fileStructure = cls._KIT_FF_MAP.get(
         version, cls._KIT_FF_MAP[DBConstants.CURRENT_KIT_FORMAT])()
     fileStructure.write(kit, indenter)
     handle.write(kitBuffer.getvalue())
Пример #8
0
 def testWrite(self):
     handle = StringIO()
     indenter = fileUtils.Indenter(handle)
     self.beat.write(indenter)
     output = handle.getvalue().splitlines()
     self.assertEqual(
         output,
         ["BEAT_START", "  NUM_TICKS 2", "  COUNT |^e+a|", "BEAT_END"])
Пример #9
0
 def write(score, handle, version=DBConstants.CURRENT_FILE_FORMAT):
     scoreBuffer = StringIO()
     indenter = fileUtils.Indenter(scoreBuffer)
     indenter(DBConstants.DB_FILE_FORMAT_STR, version)
     fileStructure = _FS_MAP.get(version,
                                 _FS_MAP[DBConstants.CURRENT_FILE_FORMAT])()
     fileStructure.write(score, indenter)
     handle.write(scoreBuffer.getvalue())
Пример #10
0
 def testSimpleWrite(self):
     myCounter = Counter.Counter("e+a")
     count = MeasureCount.makeSimpleCount(myCounter, 4)
     handle = StringIO()
     indenter = fileUtils.Indenter(handle)
     dbfsv0.MeasureCountStructureV0().write(count, indenter)
     output = handle.getvalue().splitlines()
     self.assertEqual(output, [
         "COUNT_INFO_START", "  REPEAT_BEATS 4", "  BEAT_START",
         "    COUNT |^e+a|", "  BEAT_END", "COUNT_INFO_END"
     ])
Пример #11
0
 def testWrite(self):
     options = FontOptions.FontOptions()
     handle = StringIO()
     indenter = fileUtils.Indenter(handle)
     options.write(indenter)
     output = handle.getvalue().splitlines()
     self.assertEqual(output, [
         "FONT_OPTIONS_START", "  NOTEFONT MS Shell Dlg 2",
         "  NOTEFONTSIZE 10", "  SECTIONFONT MS Shell Dlg 2",
         "  SECTIONFONTSIZE 14", "  METADATAFONT MS Shell Dlg 2",
         "  METADATAFONTSIZE 16", "FONT_OPTIONS_END"
     ])
Пример #12
0
 def testWrite(self):
     options = FontOptions.FontOptions()
     handle = StringIO()
     indenter = fileUtils.Indenter(handle)
     dbfsv0.FontOptionsStructureV0().write(options, indenter)
     output = handle.getvalue().splitlines()
     self.assertEqual(output, [
         "FONT_OPTIONS_START", "  NOTEFONT Noto Sans", "  NOTEFONTSIZE 10",
         "  SECTIONFONT Noto Sans", "  SECTIONFONTSIZE 14",
         "  METADATAFONT Noto Sans", "  METADATAFONTSIZE 16",
         "FONT_OPTIONS_END"
     ])
Пример #13
0
 def testWrite(self):
     handle = StringIO()
     indenter = fileUtils.Indenter(handle)
     self.count.write(indenter)
     output = handle.getvalue().splitlines()
     self.assertEqual(output,
                      ["COUNT_INFO_START",
                       "  REPEAT_BEATS 4",
                       "  BEAT_START",
                       "    COUNT |^e+a|",
                       "  BEAT_END",
                       "COUNT_INFO_END"])
Пример #14
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'])
Пример #15
0
 def testWrite(self):
     meta = ScoreMetaData.ScoreMetaData()
     meta.makeEmpty()
     handle = StringIO()
     indenter = fileUtils.Indenter(handle)
     meta.save(indenter)
     output = handle.getvalue().splitlines()
     self.assertEqual(output, [
         "SCORE_METADATA", "  TITLE Untitled", "  ARTIST Unknown",
         "  ARTISTVISIBLE True", "  CREATOR Nobody",
         "  CREATORVISIBLE True", "  BPM 120", "  BPMVISIBLE True",
         "  WIDTH 80", "  KITDATAVISIBLE True", "  METADATAVISIBLE True",
         "  BEATCOUNTVISIBLE True", "  EMPTYLINESVISIBLE True",
         "  MEASURECOUNTSVISIBLE False", "END_SCORE_METADATA"
     ])
Пример #16
0
 def testWrite(self):
     drum, first_, second_ = self.makeDrum()
     second_.shortcut = "a"
     outstring = StringIO()
     indenter = fileUtils.Indenter(outstring)
     dbfsv0.DrumFieldV0("DRUM",
                        getter=lambda _: drum).write_all(self, indenter)
     outlines = outstring.getvalue().splitlines()
     self.assertEqual(len(outlines), 4)
     self.assertEqual(outlines[0], "DRUM test,td,x,False")
     self.assertEqual(outlines[1],
                      "  NOTEHEAD x 71,96,normal,default,0,none,0,y")
     self.assertEqual(outlines[2],
                      "  NOTEHEAD y 100,96,normal,default,0,none,0,a")
     self.assertEqual(outlines[3],
                      "  NOTEHEAD z 72,100,ghost,cross,1,choke,1,c")
Пример #17
0
 def _saveKit(self):
     directory = self._scoreDirectory
     if directory is None:
         home = QDesktopServices.HomeLocation
         directory = unicode(QDesktopServices.storageLocation(home))
     fname = QFileDialog.getSaveFileName(parent = self,
                                         caption = "Save DrumBurp kit",
                                         directory = directory,
                                         filter = _KIT_FILTER)
     if len(fname) == 0:
         return
     fname = unicode(fname)
     newKit, unused = self.getNewKit()
     with open(fname, 'w') as handle:
         indenter = fileUtils.Indenter(handle)
         newKit.write(indenter)
     QMessageBox.information(self, "Kit saved", "Successfully saved drumkit")
Пример #18
0
 def _writeKit(self, name):
     indenter = fileUtils.Indenter("")
     handle = StringIO()
     self._currentKit.write(handle, indenter)
     self._settings.setValue(name, handle.getvalue())
     self._populate()
Пример #19
0
 def get_output(head):
     handle = StringIO()
     indenter = fileUtils.Indenter(handle)
     dbfsv1.NoteHeadStructureV1().write(head, indenter)
     return handle.getvalue().splitlines()
Пример #20
0
 def setUp(self):
     self.handle = StringIO()
     self.indenter = fileUtils.Indenter(self.handle)
Пример #21
0
 def get_output(self):
     handle = StringIO()
     indenter = fileUtils.Indenter(handle)
     self.measure.write(indenter)
     return handle.getvalue().splitlines()
Пример #22
0
 def get_output(self):
     handle = StringIO()
     indenter = fileUtils.Indenter(handle)
     dbfsv0.MeasureStructureV0().write(self.measure, indenter)
     return handle.getvalue().splitlines()
Пример #23
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'])
Пример #24
0
 def testWrite(self):
     handle = StringIO()
     indenter = fileUtils.Indenter(handle)
     self.counter.write(indenter)
     self.assertEqual(handle.getvalue(), "COUNT |^bcd|\n")