Exemplo n.º 1
0
import glob
import sys
from pitch import read_pitch, filter_pitch, plot_pitch
from intonation import detect_intonation, filter_intonation, plot_intonation

# Create graphs of time vs pitch and time vs intonation for all files in the 
# given directory

directory = sys.argv[1]
chunk = int(sys.argv[2])
limit = float(sys.argv[3])
threshold = float(sys.argv[4])
anchor = float(sys.argv[5])

wavs = glob.glob(directory + '/*.wav')
for w in wavs:
    pitches = read_pitch(w, chunk)
    pitches = filter_pitch(pitches, limit)
    plot_pitch(pitches, w)

    intonations = detect_intonation(pitches)
    intonations = filter_intonation(intonations, threshold)
    plot_intonation(intonations, anchor, w)

print "done"
Exemplo n.º 2
0
import glob
import sys
from pitch import read_pitch, filter_pitch, plot_pitch
from intonation import detect_intonation, filter_intonation, get_melody

# Create a text file listing the names and melody patterns of all files in the
# given directory

directory = sys.argv[1]
chunk = int(sys.argv[2])
limit = int(sys.argv[3])
threshold = float(sys.argv[4])

outfile = open(directory + '/intonation.txt', 'w')

wavs = glob.glob(directory + '/*.wav')
for w in wavs:
    pitches = read_pitch(w, chunk)
    pitches = filter_pitch(pitches, limit)

    intonations = detect_intonation(pitches)
    intonations = filter_intonation(intonations, threshold)

    outfile.write("%s:\t%s\n" % (w, get_melody(intonations)))

outfile.close()
print "done"
Exemplo n.º 3
0
    if intonations == None: return ""
    melody = ""
    for i in intonations:
        if i.intonation > 0: melody += "RISING "
        elif i.intonation < 0: melody += "FALLING "
    return melody


if __name__ == "__main__":
    if len(sys.argv) < 4:
        print "Usage: %s <filename> <fft_size> <limit> <threshold>" % sys.argv[0]
        sys.exit(1)

    filename = sys.argv[1]
    chunk = int(sys.argv[2]) # 1024
    limit = int(sys.argv[3]) # 170 works for me, depends on your F0
    threshold = float(sys.argv[4]) # try 15

    pitches = read_pitch(filename, chunk)
    pitches = filter_pitch(pitches, limit)

    intonations = detect_intonation(pitches)
    # print intonations
    intonations = filter_intonation(intonations, threshold)
    # print intonations

    # arbitrary starting point for intonation plot since we don't keep concrete pitch data
    anchor = 100 
    plot_intonation(intonations, anchor, filename)