コード例 #1
0
parser = ArgumentParser(description="Calculate variability positionally across tunes")
parser.add_argument("-a", "--accidentals", dest="accidentals", type=int, default=2)
parser.add_argument("-t", "--type", dest="type", type=str, default="jig")
parser.add_argument("-l", "--limit", dest="limit", type=int, default=100)
args = parser.parse_args()

tunes = Tune.objects.filter(rhythm=args.type, key__accidentals="s", key__number_of_accidentals=args.accidentals)

if args.limit > 0:
    tunes = tunes[: args.limit]

tune_count = tunes.count()

progress = ProgressBar(tune_count)
progress.width = 60
errors = 0
print progress, "{: >5,d} / {: <5,d}".format(0, tune_count), chr(27) + "[A"

byOffset = {}
byBeat = {}

for i, tune in enumerate(tunes.values_list("raw_abc", flat=True)):
    progress.update_time(i)
    print progress, "{: >5,d} / {: <5,d}".format(i, tune_count), "Errors: {}".format(errors), chr(27) + "[A"

    try:
        score = parseData(tune, format="abc")
        key = score.analyze("key")

        for note in score.flat.notesAndRests:
コード例 #2
0
'''

parser = ArgumentParser(description="Convert notes in tunes to CSV")
parser.add_argument('db', metavar='DATABASE', type=str)
parser.add_argument('output', metavar='CSVFILE', type=str)

args = parser.parse_args()

conn = sqlite3.connect(args.db)
c = conn.cursor()

c.execute(TUNE_COUNT_SQL)
tune_count = c.fetchone()[0]

progress = ProgressBar(tune_count)
progress.width = 80

with file(args.output, 'wb') as output:
    writer = csv.writer(output)

    for i, (tuneId, abc) in enumerate(c.execute(TUNE_SQL)):
        progress.update_time(i)
        print progress, chr(27) + '[A'

        try:
            score = converter.parseData(abc, format='abc')
            row = [tuneId]

            for note in score.flat.notesAndRests:
                duration = note.quarterLength
                ps = -1
コード例 #3
0
                    default=2)
parser.add_argument('-t', '--type', dest='type', type=str, default='jig')
parser.add_argument('-l', '--limit', dest='limit', type=int, default=100)
args = parser.parse_args()

tunes = Tune.objects.filter(rhythm=args.type,
                            key__accidentals='s',
                            key__number_of_accidentals=args.accidentals)

if args.limit > 0:
    tunes = tunes[:args.limit]

tune_count = tunes.count()

progress = ProgressBar(tune_count)
progress.width = 60
errors = 0
print progress, '{: >5,d} / {: <5,d}'.format(0, tune_count), chr(27) + '[A'

byOffset = {}
byBeat = {}

for i, tune in enumerate(tunes.values_list('raw_abc', flat=True)):
    progress.update_time(i)
    print progress, '{: >5,d} / {: <5,d}'.format(
        i, tune_count), 'Errors: {}'.format(errors), chr(27) + '[A'

    try:
        score = parseData(tune, format='abc')
        key = score.analyze('key')