예제 #1
0
def noRepeat(song):
    fitness = 0
    for i in range(len(song) - 4):
        prev,dum,dum,dum,next = song[i:i+5] # Compare notes of same track
        noteDiff3 = abs(midiNote.getPitch(next) - midiNote.getPitch(prev))
        if noteDiff3 != 0 : fitness += 1
    fitness /= float(len(song)) if len(song) > 0 else 0
    return fitness*0.1
예제 #2
0
def longBass(song):
    fitness = 0
    for note in song:
        pitch = midiNote.getPitch(note)
        dur = midiNote.getDur(note)
        if pitch > 59 and dur < 64: fitness += 1
        if pitch < 51 and dur > 92: fitness += 1 
    return fitness/float(len(song))*0.25
예제 #3
0
def writeNote(note, noteDict, f):
    track = midiNote.getTrack(note)
    channel = midiNote.getChan(note)
    noteStr = noteDict[midiNote.getPitch(note)]
    duration = (midiNote.getDur(note)) / 4 / 8.0
    fraction = duration.as_integer_ratio()
    wholeNum = (fraction[0]) / int(fraction[1])
    numer = fraction[0] % fraction[1]
    # output = "FOL   (BA %4d   CR %9.6f)   TR %2d   CH %2d   NT  %8s   %d+%d/%d\n"\
    #          % (bar, time, track, channel, noteStr, wholeNum, numer, fraction[1])
    output = "FOL  TR %2d   CH %2d   NT  %8s   %d+%d/%d\n" % (track, channel, noteStr, wholeNum, numer, fraction[1])
    f.write(output)
예제 #4
0
def arpeggio(song):
    fitness = 0
    for i in range(len(song) - 4):
        prev,dum,note,dum,next = song[i:i+5] # Compare notes of same track
        noteDiff1 = abs(midiNote.getPitch(note) - midiNote.getPitch(next))
        noteDiff2 = abs(midiNote.getPitch(prev) - midiNote.getPitch(note))
        noteDiff3 = abs(midiNote.getPitch(next) - midiNote.getPitch(prev))
        if noteDiff1 == 4 and noteDiff2 == 3: fitness += 0.5
        if noteDiff1 == 3 and noteDiff2 == 4: fitness += 0.5
        if noteDiff3 == 7 or noteDiff3 == 6: fitness += 0.5
    fitness /= float(len(song)) if len(song) > 0 else 0
    return fitness*0.25
예제 #5
0
def notTooHigh(song):
    fitness = 0
    for note in song:
        if midiNote.getPitch(note) < 75: fitness += 1
    return fitness/float(len(song))*0.15
예제 #6
0
def scaleC(song):
    fitness = 0
    for note in song:
        pitch = midiNote.getPitch(note)
        if pitch%12 in [0, 2, 3, 5, 7, 8, 10]: fitness += 1
    return fitness/float(len(song))*0.25