MeasureMapLoader
loader.score.MeasureMapLoader(**kwargs)Load MeasureMap JSON files into ScoreStore.
MeasureMapLoader parses the MeasureMap JSON format (as specified in the MeasureMap paper) and returns a ScoreStore with populated MeasureData.
The loader handles: - Compressed MeasureMap (minimal entries, defaults inferred) - Expanded MeasureMap (all fields explicit) - Validation of structure (MC unique, qstamp monotonic, next valid)
Attributes
| Name | Type | Description |
|---|---|---|
| unit | TimeUnit |
Always TimeUnit.quarters (MeasureMap uses quarter beats). |
| expanded_data | list[dict[str, Any]] |
The fully expanded measure list after loading. |
Examples
>>> loader = MeasureMapLoader()
>>> loader.load("WoO71.measures.mm.json")
>>> print(len(loader.store.measures)) # Number of measures
240>>> # Access flow control summary
>>> summary = loader.store.measures.get_flow_control_summary()
>>> print(f"Repeats: {summary['repeat_starts']} starts, {summary['repeat_ends']} ends")Methods
| Name | Description |
|---|---|
| compute_default_traversal | Compute the default traversal sequence from the expanded data. |
| get_traversal_summary | Get summary of the default traversal. |
compute_default_traversal
loader.score.MeasureMapLoader.compute_default_traversal()Compute the default traversal sequence from the expanded data.
The algorithm follows the ‘next’ field, using visit counts to choose which branch to take at repeat points.
From the design spec:
sequence = []
current_mc = 1
visit_counts = defaultdict(int)
while current_mc != -1:
bar = get_bar_by_mc(mm_data, current_mc)
sequence.append(bar["ID"])
next_options = bar["next"]
visit_counts[current_mc] += 1
idx = min(visit_counts[current_mc] - 1, len(next_options) - 1)
current_mc = next_options[idx]
return TraversalMap(sequence=sequence)Returns
| Name | Type | Description |
|---|---|---|
list[int] |
List of MC values in traversal order. |
get_traversal_summary
loader.score.MeasureMapLoader.get_traversal_summary()Get summary of the default traversal.
Returns
| Name | Type | Description |
|---|---|---|
dict[str, Any] |
Dict with traversal statistics. |