johentsch / ms3

A parser for annotated MuseScore 3 files.
https://ms3.readthedocs.io
GNU General Public License v3.0
41 stars 3 forks source link

Changing the instrumentation to "Drumset" #84

Closed arinaLozhkina closed 1 year ago

arinaLozhkina commented 1 year ago

tests passed closes #80, #82 and #81

johentsch commented 1 year ago

P.S.:

arinaLozhkina commented 1 year ago

P.S.:

  • Are you introducing the name="None" property into the <Channel> tag on purpose? If not, please prevent that.
  • The <keysig>0</keysig> is important to add, too.
  • For the <controller> tags I'm not sure, you might know more about their importance?

I searched for controller tags but only found Kubernetes related ones, I don't know how important that is in this context

johentsch commented 1 year ago

I'm sorry for the format of warnings, I will change them. How should I describe then that there is no values to update for example for violinI because it is not recognised, so I have to normalise them?

The warning in question was Don't recognize trackName 'cello'. Did you mean celo? I use the fields of old trackName musicxml default 4. I think the first part is good (except that celo is not a thing in English, it should suggest Violoncello). But the second part is confusing, how about something like Instrumentation of staff <n> is left unchanged ('current instrument'). Please make sure to include the staff number somewhere in the message or, if it's easy to do, the numbers of all staves in the part that would have been changed given a correct value.

johentsch commented 1 year ago
  • For the <controller> tags I'm not sure, you might know more about their importance?

I searched for controller tags but only found Kubernetes related ones, I don't know how important that is in this context

Kubernetes has nothing to do with this and it is very unlikely to find information on what these tags mean on the web. I just thought you might have encountered them before and found what they are needed for. But if not, let's ignore them until they reveal their importance.

arinaLozhkina commented 1 year ago

Hi @arinaLozhkina,

below I'm reporting a bug that makes the ms3 metadata --instrumentation command fail when changing the instrumentation to "Drumset").

But before we get to that, here's an important update on ms3' development guidelines introduced with #87:

  1. Every commit is now automatically linted, re-formatted, and checked for common errors.

  2. Development now should be done using the latest version of pandas, i.e. >2 (instead of ==1.5.3). For this you can update your setup in two steps (after updating your drumset_changes branch):

  3. Head to your ms3 codebase, and, using your virtual environment, run pip install -U -e .[dev]. This should update your pandas to 2.0.3 (check using pip show pandas) and also install the pre-commit package.

  4. Then, in the same folder, run pre-commit install. This ensures that your code is linted and checked everytime you commit changes. If some of the tests do not pass, the changes are not committed. There are two cases: 2a) The code is re-formatted and you can simply commit again, now everything goes through. 2b) You get an error (e.g., most commonly, a line is longer than the 120 character limit) and you need to fix it before you can commit. Pycharm can help with automatic formatting, e.g. via the settings Hard wrap at:, Wrap on typing, and Ensure right margin is not exceeded, amongst others, all found under Settings -> Editor -> Code Style -> Python.

OK, and now for the bug report:

Traceback (most recent call last):
  File "\\?\~\.conda\envs\ms3\Scripts\ms3-script.py", line 33, in <module>
    sys.exit(load_entry_point('ms3', 'console_scripts', 'ms3')())
  File "~\pycharmprojects\ms3\src\ms3\cli.py", line 721, in run
    args.func(args)
  File "~\pycharmprojects\ms3\src\ms3\cli.py", line 184, in metadata
    modified_score_files = p.update_score_metadata_from_tsv(write_empty_values=args.empty,
  File "~\pycharmprojects\ms3\src\ms3\parse.py", line 1351, in update_score_metadata_from_tsv
    modified = corpus.update_score_metadata_from_tsv(
  File "~\pycharmprojects\ms3\src\ms3\corpus.py", line 3260, in update_score_metadata_from_tsv
    modified = piece_obj.update_score_metadata_from_tsv(
  File "~\pycharmprojects\ms3\src\ms3\piece.py", line 1620, in update_score_metadata_from_tsv
    MSCX.instrumentation.set_instrument(staff, instrument)
  File "~\pycharmprojects\ms3\src\ms3\bs4_parser.py", line 3060, in set_instrument
    value = new_values[field_to_change]
  File "~\.conda\envs\ms3\lib\site-packages\pandas\core\series.py", line 1007, in __getitem__
    return self._get_value(key)
  File "~\.conda\envs\ms3\lib\site-packages\pandas\core\series.py", line 1116, in _get_value
    loc = self.index.get_loc(label)
  File "~\.conda\envs\ms3\lib\site-packages\pandas\core\indexes\base.py", line 3655, in get_loc
    raise KeyError(key) from err
KeyError: 'keysig'

The bug is caused by the instrument_defaults.csv, I have updated it in 6f10526

johentsch commented 1 year ago

Thank you @arinaLozhkina! The conversion to drumset is now working for the Händel case but when I try this with the first ABC example, setting any of the four instruments to Drumset there are still to problems remaining:

1) The key signatures are still displayed. 2) When you playback the score in MuseScore, it is not played by a string instrument anymore, and not by a drumset yet, instead it's played by a piano 😞

The diff shows, again, the target on the left side, i.e. the XML after manually changing the instrument to drumset in MuseScore 3 and, on the right, the result of doing the change via ms3 metadata --instrumentation -i n01: image

Solving 1) is as simple as adding the <keysig>0</keysig>. Is that maybe what you've created the keysig column for in the instrument defaults CSV? I think it might currently be missing the 0 value.

Problem 2) obviously has to do with the <Channel> configuration. I've looked into it a bit further and found that the <controller> tags seem to encode the settings for the instruments that can be controlled in MuseScore's Mixer (F10): image For example, I think <controller ctrl="10" value="63"> seems to encode the value of the "Pan" slider, which is set to 63. I don't know what the controls "0" and "32" stand for -- maybe you find out? In any case I've played around with the values for them and apparently it takes exactly those to to produce drumset sounds. (My guess is that ctrl="0" encodes the binary checkbox that says "Drumset", that's why it needs to be set to value="1".)