maker(durations)
to a container identified with the same argument. I am using this type of comparison in different methods. For example, to write different pitches to different materials.abjad.AnnotatedTimespan.annotation
;
abjad.Duration
and adds an annotation
argument;
rmakers.stack.tag
abjad.Container.tag
(maybe I should use identifier
or name
here)
pitches = { "material_01": abjad.PitchSegment("c' d'"), "material_02": abjad.PitchSegment("e' f'"),}
tag
is the wrongest.--
You received this message because you are subscribed to the Google Groups "abjad-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to abjad-user+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/abjad-user/CABcTPwMKa0-tdUZRuWrcvBXwrod%2BQKWJKcp4DK3xxpuZSxmrCw%40mail.gmail.com.
import abjad import muda # my library from abjadext import rmakers rmaker01 = rmakers.stack( rmakers.talea([2, -1], 16, extra_counts=[1]), rmakers.extract_trivial(), tag=abjad.Tag("mat01"),) rmaker02 = rmakers.stack( rmakers.talea([1, -2], 16, extra_counts=[1]), rmakers.extract_trivial(), tag=abjad.Tag("mat02"),) makers = [rmaker01, rmaker02] annotated_divisions = [ muda.AnnotatedDuration((1, 2), annotation="mat01"), muda.AnnotatedDuration((1, 2), annotation="mat02") ] container = abjad.Container() for division in annotated_divisions: for maker in makers: if maker.tag.string == division.annotation: selection = maker([division]) container.append(abjad.Container(selection, tag=maker.tag)) lilypond_file = abjad.LilyPondFile(items=[container]) abjad.persist.as_ly(lilypond_file, "example.ly")
\version "2.20.0" %! abjad.LilyPondFile._get_format_pieces() \language "english" %! abjad.LilyPondFile._get_format_pieces() { { %! mat01 \times 8/9 { %! mat01 c'8 %! mat01 r16 %! mat01 c'8 %! mat01 r16 %! mat01 c'8 %! mat01 r16 %! mat01 } %! mat01 } %! mat01 { %! mat02 \times 8/9 { %! mat02 c'16 %! mat02 r8 %! mat02 c'16 %! mat02 r8 %! mat02 c'16 %! mat02 r8 %! mat02 } %! mat02 } %! mat02 }
import abjad from abjadext import rmakers class AnnotatedDuration(abjad.Duration): def __new__(cls, *arguments, **kwargs): return super().__new__(cls, arguments[0]) def __init__(self, *arguments, **kwargs): self.arguments = arguments self.annotation = kwargs.get('annotation') rmaker01 = rmakers.stack( rmakers.talea([2, -1], 16, extra_counts=[1]), rmakers.extract_trivial(), tag=abjad.Tag("mat01"),) rmaker02 = rmakers.stack( rmakers.talea([1, -2], 16, extra_counts=[1]), rmakers.extract_trivial(), tag=abjad.Tag("mat02"),) makers = [rmaker01, rmaker02] annotated_divisions = [ AnnotatedDuration((1, 2), annotation="mat01"), AnnotatedDuration((1, 2), annotation="mat02") ] container = abjad.Container() for division in annotated_divisions: for maker in makers: if maker.tag.string == division.annotation: selection = maker([division]) container.append(abjad.Container(selection, tag=maker.tag)) lilypond_file = abjad.LilyPondFile(items=[container]) abjad.persist.as_ly(lilypond_file, "example.ly")
Hi Davi,
You can make things really easy by just ignoring Abjad’s tags and annotations. They’re not really fully documented features anyway. No need to subclass anything either. Just use Python’s built-in lists, dictionaries and tuples. One example might look like this:
maker_01 = rmakers.stack(
rmakers.talea([2, -1], 16, extra_counts=[1]),
rmakers.extract_trivial(),
)
maker_02 = rmakers.stack(
rmakers.talea([1, -2], 16, extra_counts=[1]),
rmakers.extract_trivial(),
)
makers = {
"01": maker_01,
"02": maker_02,
}
commands = [
((1, 2), "01"),
((1, 2), "02"),
]
voice = abjad.Voice(name="Voice_1")
for command in commands:
duration, name = command
maker = makers[name]
selection = maker([duration])
voice.append(selection)
Then:
lilypond_file = abjad.LilyPondFile(items=[voice])
string = abjad.lilypond(lilypond_file)
print(string)
\version "2.23.1"
\language "english"
\context Voice = "Voice_1"
{
\times 8/9
{
c'8
r16
c'8
r16
c'8
r16
}
\times 8/9
{
c'16
r8
c'16
r8
c'16
r8
}
}
And:
abjad.show(lilypond_file)
--
You received this message because you are subscribed to the Google Groups "abjad-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to abjad-user+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/abjad-user/CABcTPwMkn_noUf_AXHJNkYvj%2BcitkHtFokx710xt7UtWGx1z3w%40mail.gmail.com.
<makers.png>
To view this discussion on the web visit https://groups.google.com/d/msgid/abjad-user/CACTvJ4Ws9HZ91tfFxCdZuONVCwCnrqCN9SiXKg6sEWYq7LOCwA%40mail.gmail.com.