コード例 #1
0
ファイル: aug30.py プロジェクト: rafaelalmeida/music21
def rhythmLine(baseNote=None, minLength=8.0, maxProbability=0.5):
    if baseNote is None:
        baseNote = note.QuarterNote()
    newStream = stream.Part()
    while newStream.duration.quarterLength < minLength:
        currentProbability = (newStream.duration.quarterLength /
                              minLength) * maxProbability
        newNote = copy.deepcopy(baseNote)

        x = random.random()
        while x < currentProbability:
            #            print(x, currentProbability)
            newNote.duration = alterRhythm(newNote.duration)
            currentProbability *= .75
            x = random.random()

        y = random.random()
        z = random.random()

        if z < 0.5:
            direction = 1
        else:
            direction = -1
        while y < currentProbability:
            #            print(x, currentProbability)
            newNote.ps += direction
            currentProbability *= .75
            y = random.random()

        newNote.articulations.append(articulations.Staccatissimo())
        newStream.append(newNote)
        #newStream.getNoteTimeInfo()

    return newStream
コード例 #2
0
def happyBirthday():
    hb = tinyNotation.TinyNotationStream\
        ("d8. d16 e4 d g f#2 d8. d16 e4 d a g2 "
         "d8. d16 d'4 b g8. g16 f#4 e c'8. c'16 b4 g a g2", "3/4")
    hb.insert(0, key.KeySignature(1))
    hb.insert(0, tempo.TempoText("Brightly"))
    hb.insert(0, tempo.MetronomeMark(number = 120, referent = note.QuarterNote()))
    hb.makeNotation(inPlace=True, cautionaryNotImmediateRepeat=False)
    return hb
コード例 #3
0
	def export(self): 
		"""Export the transcribed music."""
		if ( self.saveFileStr.get() not in self.saveDefault ):
			# Set the tempo
			tempoObject = tempo.MetronomeMark( None, 
												int(self.tempo.get()), 
												note.QuarterNote() )
			self.transcribedPart.insert(tempoObject)
			
			# Write to disk
			success = self.transcribedPart.write(fp=self.saveFile)
			if ( success ):
				saveMsg = "Your file has been saved to %s." % success
				tkMessageBox.showinfo("File saved!", saveMsg )
		elif ( self.saveFileStr.get() == "" ):
			self.saveFileStr.set(self.saveDefault)		
			pass
		else:
			# Don't have a save location... should get that
			self.getSavePath()
			self.export()
コード例 #4
0
    def testStreamLilySimple(self):
        from music21 import meter, note, stream

        b = stream.Stream()
        b.insert(0, note.QuarterNote('C5'))
        b.insert(1, note.QuarterNote('D5'))
        b.insert(2, note.QuarterNote('E5'))
        b.insert(3, note.QuarterNote('F5'))
        b.insert(4, note.QuarterNote('G5'))
        b.insert(5, note.QuarterNote('A5'))

        bestC = b.bestClef(allowTreble8vb=True)
        ts = meter.TimeSignature("3/4")

        b.insert(0, bestC)
        b.insert(0, ts)

        conv = LilypondConverter()
        outStr = conv.fromObject(b)

        self.assertEqual(
            outStr,
            u'\n  { \\clef "treble"  \\time 3/4  c\'\'4 d\'\'4 e\'\'4 f\'\'4 g\'\'4 a\'\'4  }'
        )