Allow programs to contain a volume modifier
This commit is contained in:
parent
7106630129
commit
8d43c78f26
12
git-sound.py
12
git-sound.py
@ -140,7 +140,7 @@ class GitMIDI(MIDIFile):
|
|||||||
self.__setup_midi()
|
self.__setup_midi()
|
||||||
self.__setup_repo()
|
self.__setup_repo()
|
||||||
|
|
||||||
def gen_volume(self, deletions, insertions):
|
def gen_volume(self, deletions, insertions, modifier):
|
||||||
"""
|
"""
|
||||||
Generate a volume based on the number of modified lines
|
Generate a volume based on the number of modified lines
|
||||||
(insertions - deletions).
|
(insertions - deletions).
|
||||||
@ -152,7 +152,7 @@ class GitMIDI(MIDIFile):
|
|||||||
return max(
|
return max(
|
||||||
self.__volume_deviation,
|
self.__volume_deviation,
|
||||||
min(127 - self.__volume_deviation,
|
min(127 - self.__volume_deviation,
|
||||||
63 - deletions + insertions))
|
63 - deletions + insertions + modifier))
|
||||||
|
|
||||||
def sha_to_note(self, sha):
|
def sha_to_note(self, sha):
|
||||||
note_num = reduce(lambda res, digit: res + int(digit, 16),
|
note_num = reduce(lambda res, digit: res + int(digit, 16),
|
||||||
@ -166,18 +166,22 @@ class GitMIDI(MIDIFile):
|
|||||||
file_notes = []
|
file_notes = []
|
||||||
|
|
||||||
for file_name, file_stat in stat.files.items():
|
for file_name, file_stat in stat.files.items():
|
||||||
|
volume_mod = self.__program['file'].get('volume', 0)
|
||||||
file_notes.append({
|
file_notes.append({
|
||||||
'note': self.sha_to_note(get_file_sha(commit, file_name)) +
|
'note': self.sha_to_note(get_file_sha(commit, file_name)) +
|
||||||
self.__program['file']['octave'] * 12,
|
self.__program['file']['octave'] * 12,
|
||||||
'volume': self.gen_volume(file_stat['deletions'],
|
'volume': self.gen_volume(file_stat['deletions'],
|
||||||
file_stat['insertions']),
|
file_stat['insertions'],
|
||||||
|
volume_mod),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
volume_mod = self.__program['commit'].get('volume', 0)
|
||||||
return {
|
return {
|
||||||
'commit_note': self.sha_to_note(commit.hexsha) +
|
'commit_note': self.sha_to_note(commit.hexsha) +
|
||||||
self.__program['commit']['octave'] * 12,
|
self.__program['commit']['octave'] * 12,
|
||||||
'commit_volume': self.gen_volume(stat.total['deletions'],
|
'commit_volume': self.gen_volume(stat.total['deletions'],
|
||||||
stat.total['insertions']),
|
stat.total['insertions'],
|
||||||
|
volume_mod),
|
||||||
'file_notes': file_notes,
|
'file_notes': file_notes,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user