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)
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 += thisNote.compactNoteInfo() + "\n" d1 = st.duration l1 = d1.quarterLength self.assertAlmostEquals(st.duration.quarterLength, 6.0) ret += "Total duration of Stream: " + str(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.166666666667 & is a tuplet (in fact STARTS the tuplet) F F 4 16th 0.166666666667 & is a tuplet E- E 4 flat 16th 0.166666666667 & 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.166666666667 & is a tuplet (in fact STARTS the tuplet) C C 4 16th 0.166666666667 & is a tuplet B B 3 16th 0.166666666667 & is a tuplet (in fact STOPS the tuplet) Total duration of Stream: 6.0 """ self.assertTrue(common.basicallyEqual(canonical, ret))
class StreamException(Exception): pass if (__name__ == "__main__"): (note1,note2,note3,note4) = (note.Note (), note.Note (), note.Note(), note.Note()) note1.name = "C"; note2.name = "D"; note3.name = "E-"; note4.name = "F#" rest1 = note.Rest() rest1.duration.type = "eighth" note1.duration.type = "whole"; note2.duration.type = "half" note3.duration.type = "quarter"; note4.duration.type = "eighth" stream1 = Stream ([note1, note2, note3, rest1, note4]) assert stream1.totalDuration == 8 for tN in stream1: tN.duration.dots = 1 a = stream1.lily.value assert common.basicallyEqual(a, r'''\override Staff.StaffSymbol #'color = #(x11-color 'LightSlateGray) \clef "treble" c'1. d'2. ees'4. r8. fis'8. ''') ts1 = meter.TimeSignature("2/4") stream1.applyTimeSignature(ts1) stream1.setNoteTimeInfo(True) print stream1.intervalOverRestsList noteFollowingRest = stream1.noteFollowingNote(rest1, True) assert noteFollowingRest.name == "F#", "noteFollowingNote is not working!" assert note3.editorial.melodicIntervalOverRests.niceName == "Augmented Second", "melodicIntervalOverRests aint workin either!" note11 = note.Note() note11.name = "C" note11.duration.type = "quarter" note12 = note.Note() note11.name = "D" note12.duration.type = "quarter" note13 = note.Note()
note2.name = "D" note3.name = "E-" note4.name = "F#" rest1 = note.Rest() rest1.duration.type = "eighth" note1.duration.type = "whole" note2.duration.type = "half" note3.duration.type = "quarter" note4.duration.type = "eighth" stream1 = Stream([note1, note2, note3, rest1, note4]) assert stream1.totalDuration == 8 for tN in stream1: tN.duration.dots = 1 a = stream1.lily.value assert common.basicallyEqual( a, r'''\override Staff.StaffSymbol #'color = #(x11-color 'LightSlateGray) \clef "treble" c'1. d'2. ees'4. r8. fis'8. ''' ) ts1 = meter.TimeSignature("2/4") stream1.applyTimeSignature(ts1) stream1.setNoteTimeInfo(True) print stream1.intervalOverRestsList noteFollowingRest = stream1.noteFollowingNote(rest1, True) assert noteFollowingRest.name == "F#", "noteFollowingNote is not working!" assert note3.editorial.melodicIntervalOverRests.niceName == "Augmented Second", "melodicIntervalOverRests aint workin either!" note11 = note.Note() note11.name = "C" note11.duration.type = "quarter" note12 = note.Note() note11.name = "D" note12.duration.type = "quarter"