Make note length configurable in GitMIDI

This commit is contained in:
Gergely Polonkai 2016-06-09 20:24:04 +02:00
parent 862030ab58
commit 35a16022b6

View File

@ -371,7 +371,8 @@ class GitMIDI(MIDIFile):
scale=None, scale=None,
program=None, program=None,
volume_range=107, volume_range=107,
skip=0): skip=0,
note_duration=0.3)
MIDIFile.__init__(self, 1) MIDIFile.__init__(self, 1)
self.__verbose = verbose self.__verbose = verbose
@ -389,6 +390,7 @@ class GitMIDI(MIDIFile):
self.__pygame_inited = False self.__pygame_inited = False
self.__playing = False self.__playing = False
self.__skip = skip self.__skip = skip
self.__note_duration = note_duration
self.__need_commits = self.__program['commit']['program'] is not None self.__need_commits = self.__program['commit']['program'] is not None
self.__need_files = self.__program['file']['program'] is not None self.__need_files = self.__program['file']['program'] is not None
@ -524,16 +526,13 @@ class GitMIDI(MIDIFile):
log_channel = 0 log_channel = 0
decor_channel = 1 decor_channel = 1
# Duration of one note
duration = 0.3
log_length = len(self.git_log) log_length = len(self.git_log)
current = 0 current = 0
# WRITE THE SEQUENCE # WRITE THE SEQUENCE
for section in self.git_log: for section in self.git_log:
current += 1 current += 1
section_len = len(section['file_notes']) * duration section_len = len(section['file_notes']) * self.__note_duration
if callback is not None: if callback is not None:
callback(max_count=log_length, current=current) callback(max_count=log_length, current=current)
@ -547,8 +546,9 @@ class GitMIDI(MIDIFile):
if self.__need_files: if self.__need_files:
for i, file_note in enumerate(section['file_notes']): for i, file_note in enumerate(section['file_notes']):
self.addNote(track, decor_channel, self.addNote(track, decor_channel,
file_note['note'], time + i * duration, file_note['note'],
duration, file_note['volume']) time + i * self.__note_duration,
self.__note_duration, file_note['volume'])
time += section_len time += section_len