Skip to content

Commit

Permalink
Merge pull request #86 from johentsch/44-incipits
Browse files Browse the repository at this point in the history
Allow metronome mark to appear in MC 2
  • Loading branch information
johentsch authored Aug 2, 2023
2 parents 0236b6a + e4dcca1 commit c8a3f3c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 6 additions & 2 deletions src/ms3/bs4_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -471,8 +471,12 @@ def perform_checks(self):
by extension, by ms3 review, too)."""
# check if the first measure includes a metronome mark
events = self._events
first_bar_event_types = events.loc[events.mc == 1, "event"]
if 'Tempo' not in first_bar_event_types.values:
first_two_mcs_event_types = events.loc[events.mc.isin((1,2)), "event"]
metronome_mark_missing = True
if 'Tempo' in first_two_mcs_event_types.values:
metronome_mark_missing = False
# here we could insert logic for treating incipit measure groups differently
if metronome_mark_missing:
msg = "No metronome mark found in the very first measure"
tempo_selector = (events.event == 'Tempo').fillna(False)
if tempo_selector.sum() == 0:
Expand Down
4 changes: 2 additions & 2 deletions src/ms3/transformations.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ def add_quarterbeats_col(df: pd.DataFrame,
offset_dict: Union[pd.Series, dict],
interval_index: bool = False) -> pd.DataFrame:
""" Insert a column measuring the distance of events from MC 1 in quarter notes. If no 'mc_onset' column is present,
the column corresponds to the values given in the offset_dict..
the column corresponds to the values given in the offset_dict.
Parameters
----------
df : :obj:`pandas.DataFrame`
DataFrame with an ``mc_playthrough`` and an ``mc_onset`` column.
DataFrame with an ``mc`` or ``mc_playthrough`` column, and an ``mc_onset`` column.
offset_dict : :obj:`pandas.Series` or :obj:`dict`, optional
| If unfolded: {mc_playthrough -> offset}
| Otherwise: {mc -> offset}
Expand Down

0 comments on commit c8a3f3c

Please sign in to comment.