Skip to content

Commit

Permalink
docs
Browse files Browse the repository at this point in the history
  • Loading branch information
gesellkammer committed Jul 15, 2023
1 parent d2c9468 commit 120ac41
Show file tree
Hide file tree
Showing 9 changed files with 646 additions and 768 deletions.
Binary file added docs/assets/notebook-musicxmlio.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions docs/core.rst
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ Table of Contents
coreplayintro
config
workspace
coretools
symbols
coreio
Input / Output (import/export to musicxml, lilypond, MiDI, ...) <coreio>
Pure Notation <symbols>
Miscellaneous Tools <coretools>

5 changes: 1 addition & 4 deletions docs/coreio.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Input / Output

.. toctree::
:maxdepth: 1
:hidden:

musicxmlio <notebooks/musicxmlio>

Expand All @@ -25,10 +26,6 @@ Musicxml

Introduction to notes, chords, voices, etc. Notation and playback

#.. figure:: assets/notebook-musicxmlio.png
# :height: 300px
# :target: notebooks/musicxmlio


Lilypond
========
Expand Down
276 changes: 0 additions & 276 deletions docs/getWorkspace.rst

This file was deleted.

1,076 changes: 615 additions & 461 deletions docs/notebooks/getWorkspace.ipynb

Large diffs are not rendered by default.

10 changes: 1 addition & 9 deletions docs/notebooks/setTempo.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -167,14 +167,6 @@
"setTempo(84, 2)\n",
"getScoreStruct().show()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "8c20ea91-5779-4214-a057-aed2c984d9b9",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand All @@ -193,7 +185,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.7"
"version": "3.9.15"
}
},
"nbformat": 4,
Expand Down
21 changes: 11 additions & 10 deletions docs/workspace.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,18 @@ from previous sessions (see :meth:`CoreConfig.save() <maelzel.core.config.CoreCo

.. admonition:: See Also

- :func:`~maelzel.core.workspace.makeConfig`
- :ref:`config`

Example Notebooks
~~~~~~~~~~~~~~~~~

.. toctree::
:maxdepth: 1

The active Workspace <notebooks/getWorkspace>
setTempo: modify the tempo of the active ScoreStruct <notebooks/setTempo>


Example
~~~~~~~

Expand Down Expand Up @@ -91,14 +100,6 @@ active config are used:
.. image:: assets/workspace-temporaryworkspace.png


Example Notebooks
-----------------

.. toctree::
:maxdepth: 1

The active Workspace <getWorkspace>
setTempo: modify the tempo of the active ScoreStruct <setTempo>



Expand All @@ -107,5 +108,5 @@ Example Notebooks
.. automodapi:: maelzel.core.workspace
:allowed-package-names: maelzel.core.workspace,maelzel.core.config,maelzel.music.dynamics
:no-inheritance-diagram:
:headings: =-
:no-heading:

11 changes: 9 additions & 2 deletions maelzel/core/chain.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,19 @@ def __init__(self,
properties: dict[str, Any] = None,
parent: MObj = None,
_init=True):
if isinstance(items, str):
_init = True

if _init:
if offset is not None:
offset = asF(offset)
if items is not None:
items = [item if isinstance(item, (MEvent, Chain)) else asEvent(item)
for item in items]
if isinstance(items, str):
items = [line.strip() for line in items.splitlines()]
items = [asEvent(item) for item in items if item]
else:
items = [item if isinstance(item, (MEvent, Chain)) else asEvent(item)
for item in items]

if items is not None:
for item in items:
Expand Down
9 changes: 6 additions & 3 deletions maelzel/scoring/quantprofile.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from __future__ import annotations
from math import sqrt
from functools import cache
from dataclasses import dataclass, field as _field, fields as _fields
from maelzel.scoring.common import F, division_t, number_t, logger
Expand Down Expand Up @@ -122,7 +123,7 @@ class QuantizationProfile:
numNestedTupletsPenalty: list[float] = _factory([0., 0.1, 0.4, 0.5, 0.8, 0.8])
"""Penalty applied to nested levels by level"""

complexNestedTupletsFactor: float = 1.5
complexNestedTupletsFactor: float = 1.8
"""For certain combinations of nested tuplets an extra complexity factor can be applied.
If this factor is 1.0, then no extra penalty is calculated. Any number above 1 will
penalize complex nested tuplets (prefer (5, 5, 5) over (3, 3, 3, 3, 3)).
Expand Down Expand Up @@ -414,12 +415,14 @@ def _divisionPenalty(division: division_t,
numSubdivsPenalty = profile.numSubdivsPenaltyMap[1]
cardinality = 1
else:
internalPenalty = sum(_divisionPenalty(subdiv, profile, nestingLevel+1, maxPenalty=maxPenalty)[0]
for subdiv in division)
internalPenalty = sqrt(sum(_divisionPenalty(subdiv, profile, nestingLevel+1, maxPenalty=maxPenalty)[0]**2
for subdiv in division))
divPenalty = internalPenalty + profile.divisionPenaltyMap.get(len(division), maxPenalty)
numSubdivsPenalty = profile.numSubdivsPenaltyMap.get(len(division), maxPenalty)
cardinality = max(1, _divisionCardinality(division, excludeBinary=True))

cardinalityPenalty = profile.divisionCardinalityPenaltyMap.get(cardinality, maxPenalty)

# We only calculate level penalty on the outmost level
levelPenalty = profile.numNestedTupletsPenalty[_divisionDepth(division)] if nestingLevel == 0 else 0

Expand Down

0 comments on commit 120ac41

Please sign in to comment.