Make scale and programs configurable(ish)

This commit is contained in:
Gergely Polonkai 2016-05-24 13:02:11 +02:00
parent b5ab65e0a2
commit 84e4cd4ef8

View File

@ -13,10 +13,38 @@ from git import Repo
from git.objects.blob import Blob from git.objects.blob import Blob
from git.exc import InvalidGitRepositoryError from git.exc import InvalidGitRepositoryError
# The original scale was: [60, 62, 64, 65, 67, 69, 71] scales = {
notes = [68, 69, 71, 72, 74, 76, 77] 'c-major': [60, 62, 64, 65, 67, 69, 71],
'a-harmonic-minor': [68, 69, 71, 72, 74, 76, 77],
'chromatic': [60, 61, 62, 63, 64, 65, 66, 67, 68, 69],
}
notes = scales['a-harmonic-minor']
notecount = len(notes) notecount = len(notes)
programs = {
'sitar-tablah': {
'commit': {
'program': 104,
'octave': -2,
},
'file': {
'program': 115,
'octave': -1,
},
},
'bells': {
'commit': {
'program': 14,
'octave': 0,
},
'file': {
'program': 9,
'octave': 0,
},
},
}
program = programs['sitar-tablah']
def gen_volume(deletions, insertions, deviation=10): def gen_volume(deletions, insertions, deviation=10):
return max( return max(
@ -57,14 +85,16 @@ def gen_note(commit):
for file_name, file_stat in stat.files.items(): for file_name, file_stat in stat.files.items():
file_notes.append({ file_notes.append({
'note': sha_to_note(get_file_sha(commit, file_name)) - 12, 'note': sha_to_note(get_file_sha(commit, file_name)) +
program['file']['octave'] * 12,
'volume': gen_volume(file_stat['deletions'], 'volume': gen_volume(file_stat['deletions'],
file_stat['insertions'], file_stat['insertions'],
deviation=10), deviation=10),
}) })
return { return {
'commit_note': sha_to_note(commit.hexsha) - 24, 'commit_note': sha_to_note(commit.hexsha) +
program['commit']['octave'] * 12,
'commit_volume': gen_volume(stat.total['deletions'], 'commit_volume': gen_volume(stat.total['deletions'],
stat.total['insertions'], stat.total['insertions'],
deviation=20), deviation=20),
@ -210,8 +240,10 @@ decor_channel = 1
# Duration of one note # Duration of one note
duration = 0.3 duration = 0.3
repo_midi.addProgramChange(track, log_channel, 0, 104) repo_midi.addProgramChange(track, log_channel,
repo_midi.addProgramChange(track, decor_channel, 0, 115) 0, program['commit']['program'])
repo_midi.addProgramChange(track, decor_channel,
0, program['file']['program'])
# WRITE THE SEQUENCE # WRITE THE SEQUENCE
for section in log: for section in log: