-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add temporary fix for sonate sheet music
- Loading branch information
Michiexb
authored and
Karel van Klink
committed
Jul 22, 2020
1 parent
ad8d835
commit 4eb934f
Showing
16 changed files
with
177 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
Created on Fri Jul 10 15:29:26 2020 | ||
@author: super | ||
""" | ||
|
||
from itertools import groupby | ||
|
||
def calc_freq(times): | ||
times2 = [t for t in times if t is not None] | ||
time_f = [len(list(group)) for key, group in groupby(sorted(times2))] | ||
nr_instruments = max(time_f) | ||
freq_array = time_f*nr_instruments | ||
freq_array2 = [] | ||
offset = 0 | ||
for i,t in enumerate(times): | ||
if t is None: | ||
freq_array2.append(0) | ||
offset += 1 | ||
else: | ||
freq_array2.append(freq_array[i-offset]) | ||
return freq_array2 | ||
|
||
def fix_staff_relations(staffs): | ||
times = [s.nr_timewise for s in staffs] | ||
instruments = [s.nr_instrument for s in staffs if s.nr_instrument is not None] | ||
nr_instruments = max(instruments) | ||
|
||
freq_array2 = calc_freq(times) | ||
|
||
added_times = [] | ||
for i in range(len(freq_array2)): | ||
if freq_array2[i] == 0: | ||
if freq_array2[i-1] == nr_instruments: | ||
times[i] = times[i-nr_instruments]+1 | ||
added_times.append(times[i]) | ||
else: | ||
times[i] = times[i-1] | ||
freq_array2 = calc_freq(times) | ||
else: | ||
times[i] = times[i] + len(list(set(added_times))) | ||
|
||
instrs = [] | ||
ini = 0 | ||
inst = 0 | ||
for i in range(len(times)): | ||
if times[i] == ini: | ||
inst += 1 | ||
else: | ||
inst = 1 | ||
ini = times[i] | ||
instrs.append(inst) | ||
staffs[i].nr_timewise = times[i] | ||
staffs[i].nr_instrument = inst | ||
|
||
return instrs | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters