Esempio n. 1
0
    def testTinyNotationStream(self):
        st = TinyNotationStream(
            'e2 f#8 r f trip{g16 f e-} d8 c B trip{d16 c B}')
        ret = ""
        for thisNote in st:
            ret += self.compactNoteInfo(thisNote) + "\n"

        #d1 = st.duration
        #l1 = d1.quarterLength
        self.assertAlmostEquals(st.duration.quarterLength, 6.0)

        ret += "Total duration of Stream: " + common.strTrimFloat(
            st.duration.quarterLength) + "\n"
        canonical = '''
E E 4 half 2.0
F# F 4 sharp eighth 0.5
rest eighth 0.5
F F 4 eighth 0.5
G G 4 16th 0.1667 & is a tuplet (in fact STARTS the tuplet)
F F 4 16th 0.1667 & is a tuplet
E- E 4 flat 16th 0.1667 & is a tuplet (in fact STOPS the tuplet)
D D 4 eighth 0.5
C C 4 eighth 0.5
B B 3 eighth 0.5
D D 4 16th 0.1667 & is a tuplet (in fact STARTS the tuplet)
C C 4 16th 0.1667 & is a tuplet
B B 3 16th 0.1667 & is a tuplet (in fact STOPS the tuplet)
Total duration of Stream: 6.0
'''
        self.assertTrue(common.basicallyEqual(canonical, ret), ret)
Esempio n. 2
0
    def testTinyNotationStream(self):
        st = TinyNotationStream('e2 f#8 r f trip{g16 f e-} d8 c B trip{d16 c B}')
        ret = ""
        for thisNote in st:
            ret += self.compactNoteInfo(thisNote) + "\n"
        
        #d1 = st.duration
        #l1 = d1.quarterLength
        self.assertAlmostEquals(st.duration.quarterLength, 6.0)
        
        ret += "Total duration of Stream: " + common.strTrimFloat(st.duration.quarterLength) + "\n"
        canonical = '''
E E 4 half 2.0
F# F 4 sharp eighth 0.5
rest eighth 0.5
F F 4 eighth 0.5
G G 4 16th 0.1667 & is a tuplet (in fact STARTS the tuplet)
F F 4 16th 0.1667 & is a tuplet
E- E 4 flat 16th 0.1667 & is a tuplet (in fact STOPS the tuplet)
D D 4 eighth 0.5
C C 4 eighth 0.5
B B 3 eighth 0.5
D D 4 16th 0.1667 & is a tuplet (in fact STARTS the tuplet)
C C 4 16th 0.1667 & is a tuplet
B B 3 16th 0.1667 & is a tuplet (in fact STOPS the tuplet)
Total duration of Stream: 6.0
'''
        self.assertTrue(common.basicallyEqual(canonical, ret), ret)
Esempio n. 3
0
 def compactNoteInfo(self, note):
     '''
     A debugging info tool, returning information about a note
     E- E 4 flat 16th 0.1667 & is a tuplet (in fact STOPS the tuplet)
     '''
     ret = ""
     if (note.isNote is True):
         ret += note.name + " " + note.step + " " + str(note.octave)
         if (note.accidental is not None):
             ret += " " + note.accidental.name
     elif (note.isRest is True):
         ret += "rest"
     else:
         ret += "other note type"
     if (note.tie is not None):
         ret += " (Tie: " + note.tie.type + ")"
     ret += " " + note.duration.type
     ret += " " + common.strTrimFloat(note.duration.quarterLength)
     if len(note.duration.tuplets) > 0:
         ret += " & is a tuplet"
         if note.duration.tuplets[0].type == "start":
             ret += " (in fact STARTS the tuplet)"
         elif note.duration.tuplets[0].type == "stop":
             ret += " (in fact STOPS the tuplet)"
     if len(note.expressions) > 0:
         if (isinstance(note.expressions[0], expressions.Fermata)):
             ret += " has Fermata"
     return ret
Esempio n. 4
0
 def compactNoteInfo(self, note):
     '''
     A debugging info tool, returning information about a note
     E- E 4 flat 16th 0.1667 & is a tuplet (in fact STOPS the tuplet)
     '''
     ret = ""
     if (note.isNote is True):
         ret += note.name + " " + note.step + " " + str(note.octave)
         if (note.accidental is not None):
             ret += " " + note.accidental.name
     elif (note.isRest is True):
         ret += "rest"
     else:
         ret += "other note type"
     if (note.tie is not None):
         ret += " (Tie: " + note.tie.type + ")"
     ret += " " + note.duration.type
     ret += " " + common.strTrimFloat(note.duration.quarterLength)
     if len(note.duration.tuplets) > 0:
         ret += " & is a tuplet"
         if note.duration.tuplets[0].type == "start":
             ret += " (in fact STARTS the tuplet)"
         elif note.duration.tuplets[0].type == "stop":
             ret += " (in fact STOPS the tuplet)"
     if len(note.expressions) > 0:
         if (isinstance(note.expressions[0], expressions.Fermata)):
             ret += " has Fermata"
     return ret