Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code: check_midi_file function: ignore only one TYPE? #4

Open
ZhaoJY1 opened this issue Nov 24, 2020 · 1 comment
Open

Code: check_midi_file function: ignore only one TYPE? #4

ZhaoJY1 opened this issue Nov 24, 2020 · 1 comment

Comments

@ZhaoJY1
Copy link

ZhaoJY1 commented Nov 24, 2020

Hi Ethan,

I'm reading your code, and I found something confusing:

line 111 - 116 in the function check_midi_file in render_by-instrument.py :

# Make sure there's more than one TYPE of instrument
unique_inst = len(set([utils.get_inst_class(inst_classes, i, pgm0_is_piano) for i in pm.instruments]))
if unique_inst == len(pm.instruments):
# There's only one type of source!
return False

Are these lines only allowing those midi files with some instruments included, those but of the same 'class', to pass?

For example, if we have a midi file with only two tracks and they are asigned with violin (program number 40) and piano (program number 0), respectively. And this midi file will simply not pass the check, does this make sense?

Maybe these lines were intended to be deleted but you forgot? Because in the function header, you did not even mention the TYPE criterion.

Regards!
Jianye

@ethman
Copy link
Owner

ethman commented Nov 24, 2020

Hi Jianye,

Yeah, good catch. It looks like that line has a mistake in it. The check should be something like if unique_inst == 1:. But if a band definition file (band_classes_def) is provided that pretty much does the same thing, so that check can safely be removed in that case. What it'll do is it will just reject the case where there is only one of each type of track in it, as you pointed out.

Feel free to omit that check in your own code, or make a PR here.

Thanks again,
Ethan

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants