Ejemplo n.º 1
0
def test_composition():
    
    random.seed(427)
    
    scale = Scale(Note(0))

    track1 = Track()
    track2 = Track()
    
    chord = scale.getRandomChord()
    track1.appendChord(chord, 0.25)
    print chord
    
    chord = scale.getRandomChord()
    track1.appendChord(chord, 0.5)
    print chord
    
    
    chord = scale.getRandomChord()
    track2.appendChord(chord, 2.0)
    print chord
    
    chord = scale.getRandomChord()
    track2.appendChord(chord, 1.0)
    print chord
       
    comp = Composition(120, 44100)
    comp.addTrack(track1)
    comp.addTrack(track2)
    
    print
    print "Running composition..."
    for sample in range(5 * 44100):
        noteOn = comp.getNoteOnEvents()
        noteOff = comp.getNoteOffEvents()
        
        if noteOn:
            print "NoteOn events: sample = " + str(sample)
            print noteOn
            
        if noteOff:
            print "NoteOff events: sample = " + str(sample)
            print noteOff
            
        comp.advanceBySample()
Ejemplo n.º 2
0
def test_track():
    
    scale = Scale(Note(0))
    track = Track()
    
    chord = scale.getRandomChord()
    track.appendChord(chord, 0.25)
    chord = scale.getRandomChord()
    track.appendChord(chord, 0.5)
    chord = scale.getRandomChord()
    track.appendChord(chord, 2.0)
    chord = scale.getRandomChord()
    track.appendChord(chord, 1.0)
    
    chord = scale.getRandomChord()
    track.insertChord(0.4, chord, 1.0)

    print track