Exemplo n.º 1
0
def counterMaker(beatLength, numTicks):
    # Create a MeasureCount from an 'old style' specification, where
    # all we are given is the number of ticks in a beat and the total number
    # of ticks in the bar
    defaultRegistry = CounterRegistry()
    counts = [count[1] for count in defaultRegistry.countsByTicks(beatLength)]
    count = counts[0]
    mc = MeasureCount()
    mc.addSimpleBeats(count, numTicks / beatLength)
    return mc
Exemplo n.º 2
0
def counterMaker(beatLength, numTicks):
    # Create a MeasureCount from an 'old style' specification, where
    # all we are given is the number of ticks in a beat and the total number
    # of ticks in the bar
    defaultRegistry = CounterRegistry()
    counts = [count[1] for count in
              defaultRegistry.countsByTicks(beatLength)]
    count = counts[0]
    mc = MeasureCount()
    mc.addSimpleBeats(count, numTicks / beatLength)
    return mc
Exemplo n.º 3
0
 def makeEmptyScore(numMeasures, counter = None, kit = None):
     score = Score()
     if kit is None:
         kit = DrumKitFactory.DrumKitFactory.getNamedDefaultKit()
     score.drumKit = kit
     if counter is None:
         registry = CounterRegistry()
         counter = list(registry.countsByTicks(2))
         counter = counter[0][1]
         counter = makeSimpleCount(counter, 4)
     for dummy in xrange(numMeasures):
         score.insertMeasureByIndex(len(counter), counter = counter)
     score.scoreData.makeEmpty()
     return score
Exemplo n.º 4
0
 def makeEmptyScore(numMeasures, counter=None, kit=None):
     score = Score()
     if kit is None:
         kit = DrumKitFactory.DrumKitFactory.getNamedDefaultKit()
     score.drumKit = kit
     if counter is None:
         registry = CounterRegistry()
         counter = list(registry.countsByTicks(2))
         counter = counter[0][1]
         counter = makeSimpleCount(counter, 4)
     for dummy in xrange(numMeasures):
         score.insertMeasureByIndex(len(counter), counter=counter)
     score.scoreData.makeEmpty()
     return score
Exemplo n.º 5
0
class CounterFieldV0(SimpleValueField):
    registry = CounterRegistry()
    def _processData(self, data):
        if data[0] == "|" and data[-1] == "|":
            data = data[1:-1]
        data = Data.DBConstants.BEAT_COUNT + data[1:]
        try:
            return self.registry.findMaster(data)
        except KeyError:
            raise DBErrors.BadCount()

    def _toString(self, counter):
        return "|" + str(counter) + "|"
Exemplo n.º 6
0
 def __init__(self):
     self._staffs = []
     self.drumKit = DrumKitFactory.DrumKitFactory.emptyKit()
     self._callBack = None
     self._callBacksEnabled = True
     self.scoreData = ScoreMetaData()
     self._sections = []
     self._formatState = None
     self.paperSize = "Letter"
     counter = CounterRegistry().getCounterByIndex(0)
     self.defaultCount = makeSimpleCount(counter, 4)
     self.systemSpacing = 25
     self.fontOptions = FontOptions()
     self.lilysize = 20
     self.lilypages = 0
     self.lilyFill = True
     self.lilyFormat = 0
     self.fileFormat = None
Exemplo n.º 7
0
 def __init__(self):
     super(QDisplayProperties, self).__init__()
     self._xMargins = 20
     self._yMargins = 30
     self._xSpacing = self._START_NOTE_WIDTH
     self._ySpacing = self._START_NOTE_HEIGHT
     self._lineSpacing = self._START_LINE_SPACE
     self._noteFont = None
     self._defaultNoteFontSize = 10
     self._sectionFont = None
     self._sectionFontSize = 20
     self._metadataVisible = True
     self._metadataFont = None
     self._metadataFontSize = 20
     self._kitDataVisible = False
     self._beatCountVisible = True
     self._emptyLinesVisible = True
     self._measureCountsVisible = False
     self._head = None
     self._width = 80
     self._counterRegistry = CounterRegistry()
     self._score = None
Exemplo n.º 8
0
class TestMeasure(unittest.TestCase):
    reg = CounterRegistry()

    def setUp(self):
        self.measure = Measure(16)
        counter = self.reg.getCounterByName("16ths")
        mc = MeasureCount()
        mc.addSimpleBeats(counter, 4)
        self.measure.setBeatCount(mc)

    def testCount(self):
        count = self.measure.count()
        self.assertEqual(count, [
            "1", "e", "+", "a", "2", "e", "+", "a", "3", "e", "+", "a", "4",
            "e", "+", "a"
        ])
        measure = Measure(16)
        self.assertEqual(measure.count(), [" "] * 16)

    def testEmptyMeasure(self):
        self.assertEqual(len(self.measure), 16)
        self.assertEqual(self.measure.numNotes(), 0)
        self.assertEqual(
            self.measure.getNote(NotePosition(noteTime=0, drumIndex=0)),
            EMPTY_NOTE)
        self.assertFalse(self.measure.isSectionEnd())
        self.assertFalse(self.measure.isRepeatEnd())
        self.assertFalse(self.measure.isRepeatStart())

    def testIsEmpty_True(self):
        self.assert_(self.measure.isEmpty())

    def testIsEmpty_False(self):
        self.measure.addNote(NotePosition(noteTime=0, drumIndex=0), "o")
        self.assertFalse(self.measure.isEmpty())

    def testGetNote_BadTime(self):
        self.assertRaises(BadTimeError, self.measure.getNote,
                          NotePosition(noteTime=-1, drumIndex=0))
        self.assertRaises(BadTimeError, self.measure.getNote,
                          NotePosition(noteTime=20, drumIndex=0))

    def testNumNotes(self):
        for i in range(0, 16):
            self.measure.addNote(NotePosition(noteTime=i, drumIndex=0), "o")
        self.assertEqual(self.measure.numNotes(), 16)

    def testAddNote(self):
        self.measure.addNote(NotePosition(noteTime=0, drumIndex=0), "o")
        notePos = NotePosition(noteTime=0, drumIndex=0)
        self.assertEqual(self.measure.getNote(notePos), "o")

    def testAddNote_BadTime(self):
        self.assertRaises(BadTimeError, self.measure.addNote,
                          NotePosition(noteTime=-1, drumIndex=0), "x")
        self.assertRaises(BadTimeError, self.measure.addNote,
                          NotePosition(noteTime=20, drumIndex=0), "x")

    def testIterNotes(self):
        for i in range(0, 4):
            self.measure.addNote(NotePosition(noteTime=4 * i, drumIndex=i),
                                 str(i))
        for i, (np, head) in enumerate(self.measure):
            self.assertEqual(head, str(i))
            self.assertEqual(np.noteTime, 4 * i)
            self.assertEqual(np.drumIndex, i)

    def testDeleteNote(self):
        np = NotePosition(noteTime=0, drumIndex=0)
        self.measure.addNote(np, "o")
        self.measure.deleteNote(np)
        self.assertEqual(self.measure.numNotes(), 0)
        self.assertEqual(self.measure.getNote(np), EMPTY_NOTE)

    def testDeleteNote_BadTime(self):
        self.assertRaises(BadTimeError, self.measure.deleteNote,
                          NotePosition(noteTime=-1, drumIndex=0))
        self.assertRaises(BadTimeError, self.measure.deleteNote,
                          NotePosition(noteTime=20, drumIndex=0))

    def testToggleNote(self):
        np = NotePosition(noteTime=0, drumIndex=0)
        self.measure.toggleNote(np, "o")
        self.assertEqual(self.measure.getNote(np), "o")
        self.assertEqual(self.measure.numNotes(), 1)
        self.measure.toggleNote(np, "o")
        self.assertEqual(self.measure.numNotes(), 0)
        self.assertEqual(self.measure.getNote(np), EMPTY_NOTE)

    def testToggleNote_ChangeNote(self):
        np = NotePosition(noteTime=0, drumIndex=0)
        self.measure.toggleNote(np, "o")
        self.measure.toggleNote(np, "x")
        self.assertEqual(self.measure.getNote(np), "x")

    def testToggleNote_BadTime(self):
        self.assertRaises(BadTimeError, self.measure.toggleNote,
                          NotePosition(noteTime=-1, drumIndex=0), "x")
        self.assertRaises(BadTimeError, self.measure.toggleNote,
                          NotePosition(noteTime=20, drumIndex=0), "x")

    def testSetSectionEnd_NoRepeat(self):
        self.assertFalse(self.measure.isSectionEnd())
        self.assertFalse(self.measure.isLineEnd())
        self.measure.setSectionEnd(True)
        self.assert_(self.measure.isSectionEnd())
        self.assert_(self.measure.isLineEnd())
        self.measure.setSectionEnd(False)
        self.assertFalse(self.measure.isSectionEnd())
        self.assertFalse(self.measure.isLineEnd())

    def testSetSectionEnd_Repeat(self):
        self.measure.setRepeatEnd(True)
        self.assertFalse(self.measure.isSectionEnd())
        self.measure.setSectionEnd(True)
        self.assert_(self.measure.isSectionEnd())
        self.assert_(self.measure.isRepeatEnd())
        self.measure.setSectionEnd(False)
        self.assertFalse(self.measure.isSectionEnd())
        self.assert_(self.measure.isRepeatEnd())
        self.measure.setRepeatEnd(False)
        self.assertFalse(self.measure.isSectionEnd())
        self.assertFalse(self.measure.isRepeatEnd())

    def testSetRepeatStart(self):
        self.measure.setRepeatStart(True)
        self.assert_(self.measure.isRepeatStart())
        self.measure.setRepeatStart(False)
        self.assertFalse(self.measure.isRepeatStart())

    def testSetRepeatEnd_NotSectionEnd(self):
        self.measure.setRepeatEnd(True)
        self.assert_(self.measure.isRepeatEnd())
        self.measure.setRepeatEnd(False)
        self.assertFalse(self.measure.isRepeatEnd())

    def testSetRepeatEnd_IsSectionEnd(self):
        self.measure.setSectionEnd(True)
        self.measure.setRepeatEnd(True)
        self.assert_(self.measure.isRepeatEnd())
        self.measure.setRepeatEnd(False)
        self.assertFalse(self.measure.isRepeatEnd())

    def testLineBreak(self):
        self.assertFalse(self.measure.isLineBreak())
        self.assertFalse(self.measure.isLineEnd())
        self.measure.setLineBreak(True)
        self.assert_(self.measure.isLineBreak())
        self.assert_(self.measure.isLineEnd())
        self.measure.setLineBreak(False)
        self.assertFalse(self.measure.isLineBreak())
        self.assertFalse(self.measure.isLineEnd())

    def testClearMeasure(self):
        self.measure.addNote(NotePosition(noteTime=0, drumIndex=0), "x")
        self.measure.addNote(NotePosition(noteTime=1, drumIndex=1), "o")
        self.assertEqual(self.measure.numNotes(), 2)
        self.assertFalse(self.measure.isEmpty())
        self.measure.clear()
        self.assert_(self.measure.isEmpty())

    def testCopyPaste(self):
        self.measure.addNote(NotePosition(noteTime=0, drumIndex=0), "x")
        self.measure.addNote(NotePosition(noteTime=1, drumIndex=1), "o")
        measure2 = Measure(8)
        copied = self.measure.copyMeasure()
        measure2.pasteMeasure(copied)
        self.assertEqual(len(measure2), 16)
        self.assertEqual(measure2.numNotes(), 2)
        self.assertEqual(measure2.getNote(NotePosition(None, None, 0, 0)), "x")
        self.assertEqual(measure2.getNote(NotePosition(None, None, 1, 1)), "o")

    def testCopyPasteWithDecorations(self):
        self.measure.addNote(NotePosition(noteTime=0, drumIndex=0), "x")
        self.measure.addNote(NotePosition(noteTime=1, drumIndex=1), "o")
        self.measure.setRepeatEnd(True)
        self.measure.setRepeatStart(True)
        self.measure.setLineBreak(True)
        self.measure.setSectionEnd(True)
        measure2 = Measure(8)
        self.assertFalse(measure2.isRepeatEnd())
        self.assertFalse(measure2.isRepeatStart())
        self.assertFalse(measure2.isLineBreak())
        self.assertFalse(measure2.isSectionEnd())
        copied = self.measure.copyMeasure()
        measure2.pasteMeasure(copied, True)
        self.assertEqual(len(measure2), 16)
        self.assertEqual(measure2.numNotes(), 2)
        self.assertEqual(measure2.getNote(NotePosition(None, None, 0, 0)), "x")
        self.assertEqual(measure2.getNote(NotePosition(None, None, 1, 1)), "o")
        self.assertTrue(measure2.isRepeatEnd())
        self.assertTrue(measure2.isRepeatStart())
        self.assertTrue(measure2.isLineBreak())
        self.assertTrue(measure2.isSectionEnd())

    def testChangeCount_Shorter(self):
        self.measure.addNote(NotePosition(noteTime=0, drumIndex=0), "a")
        self.measure.addNote(NotePosition(noteTime=1, drumIndex=1), "b")
        self.measure.addNote(NotePosition(noteTime=2, drumIndex=0), "c")
        self.measure.addNote(NotePosition(noteTime=3, drumIndex=1), "d")
        self.measure.addNote(NotePosition(noteTime=4, drumIndex=0), "e")
        self.measure.addNote(NotePosition(noteTime=5, drumIndex=1), "f")
        self.measure.addNote(NotePosition(noteTime=6, drumIndex=0), "g")
        self.measure.addNote(NotePosition(noteTime=7, drumIndex=1), "h")
        self.measure.addNote(NotePosition(noteTime=8, drumIndex=0), "i")
        self.measure.addNote(NotePosition(noteTime=9, drumIndex=1), "j")
        self.measure.addNote(NotePosition(noteTime=10, drumIndex=0), "k")
        self.measure.addNote(NotePosition(noteTime=11, drumIndex=1), "l")
        self.measure.addNote(NotePosition(noteTime=12, drumIndex=0), "m")
        self.measure.addNote(NotePosition(noteTime=13, drumIndex=1), "n")
        self.measure.addNote(NotePosition(noteTime=14, drumIndex=0), "o")
        self.measure.addNote(NotePosition(noteTime=15, drumIndex=1), "p")
        counter = self.reg.getCounterByName("8ths")
        mc = MeasureCount()
        mc.addSimpleBeats(counter, 3)
        self.measure.setBeatCount(mc)
        self.assertEqual(len(self.measure), 6)
        self.assertEqual(self.measure.numNotes(), 6)
        self.assertEqual(self.measure.noteAt(noteTime=0, drumIndex=0), "a")
        self.assertEqual(self.measure.noteAt(noteTime=1, drumIndex=0), "c")
        self.assertEqual(self.measure.noteAt(noteTime=2, drumIndex=0), "e")
        self.assertEqual(self.measure.noteAt(noteTime=3, drumIndex=0), "g")
        self.assertEqual(self.measure.noteAt(noteTime=4, drumIndex=0), "i")
        self.assertEqual(self.measure.noteAt(noteTime=5, drumIndex=0), "k")

    def testChangeCount_Longer(self):
        self.measure.addNote(NotePosition(noteTime=0, drumIndex=0), "a")
        self.measure.addNote(NotePosition(noteTime=1, drumIndex=1), "b")
        self.measure.addNote(NotePosition(noteTime=2, drumIndex=0), "c")
        self.measure.addNote(NotePosition(noteTime=3, drumIndex=1), "d")
        self.measure.addNote(NotePosition(noteTime=4, drumIndex=0), "e")
        self.measure.addNote(NotePosition(noteTime=5, drumIndex=1), "f")
        self.measure.addNote(NotePosition(noteTime=6, drumIndex=0), "g")
        self.measure.addNote(NotePosition(noteTime=7, drumIndex=1), "h")
        self.measure.addNote(NotePosition(noteTime=8, drumIndex=0), "i")
        self.measure.addNote(NotePosition(noteTime=9, drumIndex=1), "j")
        self.measure.addNote(NotePosition(noteTime=10, drumIndex=0), "k")
        self.measure.addNote(NotePosition(noteTime=11, drumIndex=1), "l")
        self.measure.addNote(NotePosition(noteTime=12, drumIndex=0), "m")
        self.measure.addNote(NotePosition(noteTime=13, drumIndex=1), "n")
        self.measure.addNote(NotePosition(noteTime=14, drumIndex=0), "o")
        self.measure.addNote(NotePosition(noteTime=15, drumIndex=1), "p")
        counter = self.reg.getCounterByName("32nds")
        mc = MeasureCount()
        mc.addSimpleBeats(counter, 5)
        self.measure.setBeatCount(mc)
        self.assertEqual(len(self.measure), 40)
        self.assertEqual(self.measure.numNotes(), 16)
        self.assertEqual(self.measure.noteAt(noteTime=0, drumIndex=0), "a")
        self.assertEqual(self.measure.noteAt(noteTime=2, drumIndex=1), "b")
        self.assertEqual(self.measure.noteAt(noteTime=4, drumIndex=0), "c")
        self.assertEqual(self.measure.noteAt(noteTime=6, drumIndex=1), "d")
        self.assertEqual(self.measure.noteAt(noteTime=8, drumIndex=0), "e")
        self.assertEqual(self.measure.noteAt(noteTime=10, drumIndex=1), "f")
        self.assertEqual(self.measure.noteAt(noteTime=12, drumIndex=0), "g")
        self.assertEqual(self.measure.noteAt(noteTime=14, drumIndex=1), "h")
        self.assertEqual(self.measure.noteAt(noteTime=16, drumIndex=0), "i")
        self.assertEqual(self.measure.noteAt(noteTime=18, drumIndex=1), "j")
        self.assertEqual(self.measure.noteAt(noteTime=20, drumIndex=0), "k")
        self.assertEqual(self.measure.noteAt(noteTime=22, drumIndex=1), "l")
        self.assertEqual(self.measure.noteAt(noteTime=24, drumIndex=0), "m")
        self.assertEqual(self.measure.noteAt(noteTime=26, drumIndex=1), "n")
        self.assertEqual(self.measure.noteAt(noteTime=28, drumIndex=0), "o")
        self.assertEqual(self.measure.noteAt(noteTime=30, drumIndex=1), "p")

    def testLineIsVisible(self):
        self.measure.addNote(NotePosition(noteTime=0, drumIndex=0), "a")
        self.measure.addNote(NotePosition(noteTime=2, drumIndex=2), "a")
        self.measure.addNote(NotePosition(noteTime=3, drumIndex=7), "a")
        self.assert_(self.measure.lineIsVisible(0))
        self.assert_(self.measure.lineIsVisible(2))
        self.assert_(self.measure.lineIsVisible(7))
        self.assertFalse(self.measure.lineIsVisible(1))
        self.assertFalse(self.measure.lineIsVisible(3))
        self.assertFalse(self.measure.lineIsVisible(4))
        self.assertFalse(self.measure.lineIsVisible(5))
        self.assertFalse(self.measure.lineIsVisible(6))
        self.assertFalse(self.measure.lineIsVisible(8))
Exemplo n.º 9
0
'''
Created on Apr 9, 2016

@author: mike_000
'''
import unittest
import StringIO
from Notation import lilypond
from Data.DrumKitFactory import DrumKitFactory
from Data.Counter import CounterRegistry
from Data.Measure import Measure
from Data.MeasureCount import MeasureCount

_REG = CounterRegistry()


class TestCompoundSticking(unittest.TestCase):
    def setUp(self):
        self.kit = DrumKitFactory.getNamedDefaultKit()
        self.lilykit = lilypond.LilyKit(self.kit)
        self.indenter = lilypond.LilyIndenter()
        self.output = StringIO.StringIO()
        self.indenter.setHandle(self.output)
        self.measure = Measure()
        counter = _REG.getCounterByName("Triplets")
        mc = MeasureCount()
        mc.addSimpleBeats(counter, 4)
        self.measure.setBeatCount(mc)

    def testCompoundSticking(self):
        self.measure.setAbove(0, "L")
Exemplo n.º 10
0
class TestWriteMeasure(unittest.TestCase):
    reg = CounterRegistry()

    def setUp(self):
        self.measure = Measure(16)
        counter = self.reg.getCounterByName("16ths")
        mc = MeasureCount.MeasureCount()
        mc.addSimpleBeats(counter, 4)
        self.measure.setBeatCount(mc)

    def get_output(self):
        handle = StringIO()
        indenter = fileUtils.Indenter(handle)
        dbfsv0.MeasureStructureV0().write(self.measure, indenter)
        return handle.getvalue().splitlines()

    def testWriteEmpty(self):
        output = self.get_output()
        self.assertEqual(output, [
            'START_BAR 16', '  COUNT_INFO_START', '    REPEAT_BEATS 4',
            '    BEAT_START', '      COUNT |^e+a|', '    BEAT_END',
            '  COUNT_INFO_END', '  BARLINE NORMAL_BAR,NO_BAR',
            '  BARLINE NORMAL_BAR,NO_BAR', 'END_BAR'
        ])

    def testWriteSimple(self):
        self.measure.addNote(NotePosition(noteTime=0, drumIndex=0), "a")
        self.measure.addNote(NotePosition(noteTime=1, drumIndex=1), "b")
        self.measure.addNote(NotePosition(noteTime=2, drumIndex=0), "c")
        self.measure.addNote(NotePosition(noteTime=3, drumIndex=1), "d")
        self.measure.addNote(NotePosition(noteTime=4, drumIndex=0), "e")
        self.measure.addNote(NotePosition(noteTime=5, drumIndex=1), "f")
        self.measure.addNote(NotePosition(noteTime=6, drumIndex=0), "g")
        self.measure.addNote(NotePosition(noteTime=7, drumIndex=1), "h")
        self.measure.addNote(NotePosition(noteTime=8, drumIndex=0), "i")
        self.measure.addNote(NotePosition(noteTime=9, drumIndex=1), "j")
        self.measure.addNote(NotePosition(noteTime=10, drumIndex=0), "k")
        self.measure.addNote(NotePosition(noteTime=11, drumIndex=1), "l")
        self.measure.addNote(NotePosition(noteTime=12, drumIndex=0), "m")
        self.measure.addNote(NotePosition(noteTime=13, drumIndex=1), "n")
        self.measure.addNote(NotePosition(noteTime=14, drumIndex=0), "o")
        self.measure.addNote(NotePosition(noteTime=15, drumIndex=1), "p")
        output = self.get_output()
        self.assertEqual(output, [
            'START_BAR 16', '  COUNT_INFO_START', '    REPEAT_BEATS 4',
            '    BEAT_START', '      COUNT |^e+a|', '    BEAT_END',
            '  COUNT_INFO_END', '  BARLINE NORMAL_BAR,NO_BAR', '  NOTE 0,0,a',
            '  NOTE 1,1,b', '  NOTE 2,0,c', '  NOTE 3,1,d', '  NOTE 4,0,e',
            '  NOTE 5,1,f', '  NOTE 6,0,g', '  NOTE 7,1,h', '  NOTE 8,0,i',
            '  NOTE 9,1,j', '  NOTE 10,0,k', '  NOTE 11,1,l', '  NOTE 12,0,m',
            '  NOTE 13,1,n', '  NOTE 14,0,o', '  NOTE 15,1,p',
            '  BARLINE NORMAL_BAR,NO_BAR', 'END_BAR'
        ])

    def testWriteDecorations(self):
        self.measure.setLineBreak(True)
        self.measure.setSectionEnd(True)
        self.measure.setRepeatEnd(True)
        self.measure.setRepeatStart(True)
        self.measure.alternateText = "xxx"
        self.measure.repeatCount = 10
        self.measure.simileDistance = 2
        self.measure.simileIndex = 1
        output = self.get_output()
        self.assertEqual(output, [
            'START_BAR 16', '  COUNT_INFO_START', '    REPEAT_BEATS 4',
            '    BEAT_START', '      COUNT |^e+a|', '    BEAT_END',
            '  COUNT_INFO_END', '  BARLINE NORMAL_BAR,REPEAT_START,NO_BAR',
            ('  BARLINE NORMAL_BAR,LINE_BREAK,NO_BAR,' +
             'SECTION_END,REPEAT_END'), '  REPEAT_COUNT 10', '  ALTERNATE xxx',
            '  SIMILE 2', '  SIMINDEX 1', 'END_BAR'
        ])
Exemplo n.º 11
0
class TestWriteMeasure(unittest.TestCase):
    reg = CounterRegistry()

    def setUp(self):
        self.measure = Measure(16)
        counter = self.reg.getCounterByName("16ths")
        mc = MeasureCount.MeasureCount()
        mc.addSimpleBeats(counter, 4)
        self.measure.setBeatCount(mc)

    def get_output(self):
        handle = StringIO()
        indenter = fileUtils.Indenter(handle)
        dbfsv1.MeasureStructureV1().write(self.measure, indenter)
        return handle.getvalue().splitlines()

    def testWriteEmpty(self):
        output = self.get_output()
        self.assertEqual(output,
                         ['START_MEASURE',
                          '  START_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_MEASURE_COUNT',
                          '  STARTBARLINE 1',
                          '  ENDBARLINE 1',
                          '  REPEAT_COUNT 1',
                          '  SHOWABOVE False',
                          '  SHOWBELOW False',
                          'END_MEASURE'])

    def testWriteSimple(self):
        self.measure.addNote(NotePosition(noteTime=0, drumIndex=0), "a")
        self.measure.addNote(NotePosition(noteTime=1, drumIndex=1), "b")
        self.measure.addNote(NotePosition(noteTime=2, drumIndex=0), "c")
        self.measure.addNote(NotePosition(noteTime=3, drumIndex=1), "d")
        self.measure.addNote(NotePosition(noteTime=4, drumIndex=0), "e")
        self.measure.addNote(NotePosition(noteTime=5, drumIndex=1), "f")
        self.measure.addNote(NotePosition(noteTime=6, drumIndex=0), "g")
        self.measure.addNote(NotePosition(noteTime=7, drumIndex=1), "h")
        self.measure.addNote(NotePosition(noteTime=8, drumIndex=0), "i")
        self.measure.addNote(NotePosition(noteTime=9, drumIndex=1), "j")
        self.measure.addNote(NotePosition(noteTime=10, drumIndex=0), "k")
        self.measure.addNote(NotePosition(noteTime=11, drumIndex=1), "l")
        self.measure.addNote(NotePosition(noteTime=12, drumIndex=0), "m")
        self.measure.addNote(NotePosition(noteTime=13, drumIndex=1), "n")
        self.measure.addNote(NotePosition(noteTime=14, drumIndex=0), "o")
        self.measure.addNote(NotePosition(noteTime=15, drumIndex=1), "p")
        output = self.get_output()
        self.assertEqual(output,
                         ['START_MEASURE',
                          '  START_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_MEASURE_COUNT',
                          '  STARTBARLINE 1',
                          '  NOTE 0,0,a',
                          '  NOTE 1,1,b',
                          '  NOTE 2,0,c',
                          '  NOTE 3,1,d',
                          '  NOTE 4,0,e',
                          '  NOTE 5,1,f',
                          '  NOTE 6,0,g',
                          '  NOTE 7,1,h',
                          '  NOTE 8,0,i',
                          '  NOTE 9,1,j',
                          '  NOTE 10,0,k',
                          '  NOTE 11,1,l',
                          '  NOTE 12,0,m',
                          '  NOTE 13,1,n',
                          '  NOTE 14,0,o',
                          '  NOTE 15,1,p',
                          '  ENDBARLINE 1',
                          '  REPEAT_COUNT 1',
                          '  SHOWABOVE False',
                          '  SHOWBELOW False',
                          'END_MEASURE'])

    def testWriteDecorations(self):
        self.measure.setLineBreak(True)
        self.measure.setSectionEnd(True)
        self.measure.setRepeatEnd(True)
        self.measure.setRepeatStart(True)
        self.measure.alternateText = "xxx"
        self.measure.repeatCount = 10
        self.measure.simileDistance = 2
        self.measure.simileIndex = 1
        self.measure.showAbove = True
        self.measure.setAbove(1, "R")
        output = self.get_output()
        self.assertEqual(output,
                         ['START_MEASURE',
                          '  START_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_MEASURE_COUNT',
                          '  STARTBARLINE 3',
                          '  ENDBARLINE 29',
                          '  REPEAT_COUNT 10',
                          '  ALTERNATE xxx',
                          '  SIMILE 2',
                          '  SIMINDEX 1',
                          '  SHOWABOVE True',
                          '  ABOVETEXT IFIgICAgICAgICAgICAgIA==',
                          '  SHOWBELOW False',
                          'END_MEASURE'])