Ejemplo n.º 1
0
def test_interval():
    
    scale = Scale(Note(1))
    
    notes = [Note(n+1) for n in [0, 2, 4, 5, 7, 9, 11]]
    
    for note in notes:
        print scale.interval(note, 7)        
Ejemplo n.º 2
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.º 3
0
def test_randomNote():
    
    scale = Scale(Note(40))
    
    print Note(40)
    
    print scale._shiftedScale
    print scale._shiftedPentatonicScale
    
    for _ in range(10):
        print scale.getRandomNote(minOctave=0, 
                                  maxOctave=8, 
                                  pentatonic=False)
    
    print    
    
    for _ in range(10):
        print scale.getRandomNote(minOctave=3, 
                                  maxOctave=5, 
                                  pentatonic=True) 
Ejemplo n.º 4
0
def test_randomChord():
    
    scale = Scale(Note(2))
    
    for _ in range(10):
        chord =  scale.getRandomChord(
                       minOctave        = 0,
                       maxOctave        = 3,
                       minSize          = 3,
                       maxSize          = 8,        # number of notes in the chord
                       basicOnly        = True,     # contain only I, IV, V and parallel as base note
                       seconds          = False,    # if chords may contain seconds
                       thirds           = True,     # if chords may contain thirds
                       fourths          = False,    # if chords may contain fourths
                       fifths           = True,    # if chords may contain fourths
                       sixths           = False,    # if chords may contain sixths
                       sevenths         = False,    # if chords may contain sevenths
                       # TODO:
                       allowDirectSemitones   = False,    # if direct semitones shall be allowed in the chord
                       )
        print str(chord.baseNote) + " " + str(chord) 
Ejemplo n.º 5
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