Code Monkey home page Code Monkey logo

abjad-ext-nauert's Introduction

Abjad 3.19

Abjad helps composers build up complex pieces of music notation in iterative and incremental ways. Use Abjad to create a symbolic representation of all the notes, rests, chords, tuplets, beams and slurs in any score. Because Abjad extends the Python programming language, you can use Abjad to make systematic changes to music as you work. Because Abjad wraps the LilyPond music notation package, you can use Abjad to control the typographic detail of symbols on the page.

https://img.shields.io/travis/Abjad/abjad/master.svg?style=flat-square https://img.shields.io/pypi/v/abjad.svg?style=flat-square https://img.shields.io/pypi/dm/abjad.svg?style=flat-square

Abjad's documentation is available here: https://abjad.github.io

Abjad's install instructions are tested on macOS and Linux.

Abjad requires Python 3.10 or later:

~$ python --version
Python 3.11.0

Abjad requires LilyPond 2.23.6 or later.

Make sure LilyPond is installed: http://lilypond.org/development.html

Make sure LilyPond is callable from the commandline:

$ lilypond --version
GNU LilyPond 2.23.80 (running Guile 2.2)

Create a Python 3 virtual environment for Abjad: https://docs.python.org/3/tutorial/venv.html

Activate the virtual environment and then use pip to install Abjad:

~$ python -m pip install abjad

Start Python, import Abjad, start making music notation:

~$ python
>>> import abjad
>>> note = abjad.Note("c'4")
>>> abjad.show(note)

hello.png


Join the Abjad community: https://abjad.github.io/appendices/community.html

abjad-ext-nauert's People

Contributors

josiah-wolf-oberholtzer avatar nivlekp avatar trevorbaca avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

abjad-ext-nauert's Issues

Initial Update

The bot created this issue to inform you that pyup.io has been set up on this repo.
Once you have closed it, the bot will open pull requests for updates as soon as they are available.

Quantizer takes forever when WeightedSearchTree is used

The following piece of code takes forever to run.
There seems to be an infinite loop somewhere when the job_handler is called.
Further investigation required.

import abjad
from abjadext import nauert

search_tree = nauert.WeightedSearchTree()
quantizer = nauert.Quantizer()
durations = [1000, 500, 500, 250, 250, 500, 250, 250, 100, 100, 100, 100, 100]
pitches = range(len(durations))
q_event_sequence = nauert.QEventSequence.from_millisecond_pitch_pairs(
    tuple(zip(durations, pitches))
)
q_schema = nauert.MeasurewiseQSchema(search_tree=search_tree)
result = quantizer(q_event_sequence, q_schema=q_schema)
abjad.show(result)

Weird behaviours with Weighted Search Trees

There are a couple of weird behaviours with the weighted search trees.

One example could be reproduced by the following code:

import time

import abjad
from abjadext import nauert

start_time = time.time()
definition = {"divisors": (2, 3, 5, 7), "max_depth": 2, "max_divisions": 2}
search_tree = nauert.WeightedSearchTree(definition=definition)
quantizer = nauert.Quantizer()
durations = [457.14285, 814.1, 228.5714, 1440, 960]
pitches = range(len(durations))
q_event_sequence = nauert.QEventSequence.from_millisecond_pitch_pairs(
    tuple(zip(durations, pitches))
)
q_schema = nauert.MeasurewiseQSchema(search_tree=search_tree, time_signature=(7, 8), use_full_measure=True)
result = quantizer(q_event_sequence, q_schema=q_schema, attach_tempos=True)
staff = abjad.Staff([result])
abjad.show(staff)
print("--- %s seconds ---" % (time.time() - start_time))
print(abjad.lilypond(staff))

which results in

--- 3.9978859424591064 seconds ---
\new Staff
{
    \new Voice
    {
        {
            \tweak text #tuplet-number::calc-fraction-text
            \times 6/7
            {
                \tempo 4=60
                \time 7/8
                c'8
                cs'4
                ~
                \grace {
                    d'16
                }
                ef'16
            }
            \times 4/7
            {
                e'2..
                ~
            }
        }
        {
            \times 4/5
            {
                e'8
                r32
            }
            r2.
        }
    }
}

Notice that \times 4/7 { e'2.. } should probably just be e'2.

Check time_signature property of MeasurewiseQSchema

If we set only a single time signature in MeasurewiseQSchema using the keyword time_signature, then the time_signature would display properly.

>>> q_schema = abjadext.nauert.MeasurewiseQSchema(
...     time_signature=abjad.TimeSignature((3, 4))
... )
>>> q_schema.time_signature
TimeSignature((3, 4))

However, if we are using the non-sequential time-step setting via a dictionary, then it would only return the default time signature (4, 4).

>>> a = {"time_signature": abjad.TimeSignature((7, 32))}
>>> b = {"time_signature": abjad.TimeSignature((3, 4))}
>>> c = {"time_signature": abjad.TimeSignature((5, 8))}

>>> settings = {
...     2: a,
...     4: b,
...     6: c,
... }

>>> q_schema = abjadext.nauert.MeasurewiseQSchema(settings)
>>> q_schema.time_signature
TimeSignature((4, 4))

Maybe this behavior makes sense, maybe not.

MeasurewiseAttackPointOptimizer not working for multi-measure jobs

import abjad
from abjadext import nauert

durations = [1000] * 8
pitches = [0, 2] * 4

sequence = nauert.QEventSequence.from_millisecond_pitch_pairs(
    tuple(zip(durations, pitches))
)

optimizer = nauert.MeasurewiseAttackPointOptimizer()
quantizer = nauert.Quantizer()
result = quantizer(sequence, attack_point_optimizer=optimizer)

This would result in:

Traceback (most recent call last):
  File "optimise.py", line 13, in <module>
    result = quantizer(sequence, attack_point_optimizer=optimizer)
  File "/Users/tszkiupang/abjad-ext-nauert/abjadext/nauert/quantizer.py", line 273, in __call__
    notation = q_target(
  File "/Users/tszkiupang/abjad-ext-nauert/abjadext/nauert/qtargets.py", line 112, in __call__
    return self._notate(
  File "/Users/tszkiupang/abjad-ext-nauert/abjadext/nauert/qtargets.py", line 351, in _notate
    attack_point_optimizer(measure)
  File "/Users/tszkiupang/abjad-ext-nauert/abjadext/nauert/attackpointoptimizers.py", line 200, in __call__
    assert time_signature is not None, repr(time_signature)
AssertionError: None

Check gracehandlers behaviors

There seem to be some odd behaviors in handling grace notes.

The first odd behavior results in a "grace rest" attaching to a pitched note, as shown below:

import abjad
from abjadext import nauert

quantizer = nauert.Quantizer()
durations = [1000, 1, 999]
pitches = [0, None, 0]
q_event_sequence = nauert.QEventSequence.from_millisecond_pitch_pairs(
    tuple(zip(durations, pitches))
)
result = quantizer(q_event_sequence)
print(abjad.lilypond(result))

which results in

\new Voice
{
    {
        \tempo 4=60
        %%% \time 4/4 %%%
        c'4
        \grace {
            r16
        }
        c'4
        r4
        r4
    }
}

The second one results in a grace note attaching to a rest.
A snippet might be uploaded later (or not).

Another weird behaviour of Quantizer with weighted search trees

import time

import abjad
from abjadext import nauert

start_time = time.time()
definition = {"divisors": (2, 3, 5, 7), "max_depth": 2, "max_divisions": 2}
search_tree = nauert.WeightedSearchTree(definition=definition)
quantizer = nauert.Quantizer()
durations = [400, 1000, 1260, 840, 20, 610, 420, 2450]
pitches = range(len(durations))
q_event_sequence = nauert.QEventSequence.from_millisecond_pitch_pairs(
    tuple(zip(durations, pitches))
)
q_schema = nauert.MeasurewiseQSchema(search_tree=search_tree, time_signature=(7, 8), use_full_measure=True)
result = quantizer(q_event_sequence, q_schema=q_schema, attach_tempos=True)
staff = abjad.Staff([result])
abjad.show(staff)
print("--- %s seconds ---" % (time.time() - start_time))
print(abjad.lilypond(staff))

The code above produces:

--- 4.411861896514893 seconds ---
\new Staff
{
    \new Voice
    {
        {
            \tweak text #tuplet-number::calc-fraction-text
            \times 7/10
            {
                \times 4/7
                {
                    \tempo 4=60
                    \time 7/8
                    c'4
                    cs'2
                    ~
                    cs'8
                }
                \tweak text #tuplet-number::calc-fraction-text
                \times 3/5
                {
                    d'2.
                    ef'2
                }
            }
        }
        {
            \times 4/5
            {
                \grace {
                    e'16
                }
                f'8.
                fs'8
            }
            \tweak text #tuplet-number::calc-fraction-text
            \times 5/7
            {
                g'2..
            }
        }
    }
}

The last note is a standalone tuplet, which seems very strange.

Update default branch to main

Hi @nivlekp! Would you be interested in updating the name of Nauert's default from 'master' to (the much more neutral-sounding) 'main'? I updated Abjad and the rmakers today, so if you'd like to make the corresponding change, feel free. It's super easy. Just go to ...

https://github.com/Abjad/abjad-ext-nauert/branches

... and click on the icon of the pencil to the right of the default branch. A rename modal is available, and everything works easily.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.