time signature

21 views
Skip to first unread message

Rogerio Barbosa

unread,
Sep 4, 2022, 5:46:03 PM9/4/22
to abjad-user
Hello,

I generated a staff algorithmically and need to change time signature, but I can't attach it directly on the first item. What should be done to insert a TimeSignature(5,4) in the fragment below?

Staff("{ { 2/3 c'8 { 2/3 c'16 c'8 } c'8 } c'32 c'16 c'32 { 2/3 c'8 c'16 } c'8 c'2 c'8 }", lilypond_type='RhythmicStaff')

Thanks,

Rogério Vasconcelos

Davi Raubach Tuchtenhagen

unread,
Sep 5, 2022, 9:19:27 AM9/5/22
to abjad-user

Hi Rogério,

I get an error trying to parse your lilypond code so I changed it:

    import abjad
    staff = abjad.Staff(
      r"{ \times 2/3 { c'8  \times 2/3 { c'16 c'8 } c'8 } c'32 c'16 c'32 \times 2/3 {  c'8 c'16 } c'8 c'2 c'8 }", lilypond_type='RhythmicStaff')  

In this case, the first element in staff (staff[0]) is a container because of the brackets "{}", the first one inside this container (staff[0][0]) is also a container because it is a tuplet. You cannot attach time signatures to a container. Check abjad.attach documentation: https://abjad.github.io/api/abjad/bind.html?highlight=attach#abjad.bind.attach

You can attach time signatures to a leaf. I would use abjad.select to do that:

    first_leaf = abjad.select.leaf(staff, 0)
    abjad.attach(abjad.TimeSignature((5, 4)), first_leaf)
    print(abjad.lilypond(staff))
    
\new RhythmicStaff
{
    {
        {
            \tweak edge-height #'(0.7 . 0)
            \times 2/3
            {
                \time 5/4
                c'8
            }
            {
                \tweak edge-height #'(0.7 . 0)
                \times 2/3
                {
                    c'16
                }
                c'8
            }
            c'8
        }
        c'32
        c'16
        c'32
        {
            \tweak edge-height #'(0.7 . 0)
            \times 2/3
            {
                c'8
            }
            c'16
        }
        c'8
        c'2
        c'8
    }
}

I'm using abjad 3.10 and lilypond 2.23.6.

Best regards,

Davi



--
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/a45ae023-5a43-49ee-bd77-bbdc1c8a7fcan%40googlegroups.com.

Rogerio Barbosa

unread,
Sep 5, 2022, 9:59:57 AM9/5/22
to abjad...@googlegroups.com
Hi Davi,

thank you very much for the help. I understand the right way of attaching TimeSignature to the first leaf of the music. I didn't know how to select the leaf before. In relation to the disappearance of '\times' in the expression, I understand that it would be necessary to use abjad.LilyPondFile and abjad.lilypond to get a correct string of the staff expression.  
Your hint was really helpful.

Regards,

Rogério

Martín Rincón Botero

unread,
Sep 5, 2022, 10:59:44 AM9/5/22
to Abjad-User
Hi Rogerio,

you don't need LilypondFile to print the lilypond output of a staff. You can do that with print(abjad.lilypond(staff)).

—Martín.



Rogerio Barbosa

unread,
Sep 5, 2022, 12:03:06 PM9/5/22
to abjad...@googlegroups.com
True! I'm still not familiar with Abjad's commands.
Thanks

You received this message because you are subscribed to a topic in the Google Groups "abjad-user" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/abjad-user/2URYTnvB6Z4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to abjad-user+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/abjad-user/cbae711a-6c01-4d97-96cf-d23ffd60e1b5%40iPhone-von-Martin.
Reply all
Reply to author
Forward
0 new messages