Custom barlines and no time signature

1,438 views
Skip to first unread message

Luca Monteverdi

unread,
Mar 4, 2021, 12:27:06 PM3/4/21
to abjad-user
Hi all, I have a string that looks like this:

eqs'4 | fqs,4 fqs'4 | g,,4 g,4 |

My goal is to have no time signature on the staff and have the barlines show up when there's the | symbol.

I create the list with this procedure:

# ListOfFreq is a list of lists of frequencies, like [[440, 220], [180], [267, 345, 224]]
# I want each sublist in its own measure.
for List in ListOfFreq:
        for freqNote in List:
            if (freqNote > vlcLo) and (freqNote < vlcHi): # If the note is in Cello Range
                nota = pitch(freqNota) # convert frequency to pitch
                ListaVlc += nota+"4 "  #create the string
        ListaVlc += "| "
    staff = ab.Staff(ListaVlc) 
    ab.show(staff)

What am I doing wrong?

Luca Monteverdi

unread,
Mar 4, 2021, 12:52:20 PM3/4/21
to abjad-user
EDIT: I manage to divide the measures correctly, formatting the list as
eqs'4 \bar "|"fqs,4 e'4 \bar "|"aqs,4 ds'4 fqs'4 \bar "|"
instead and it works, now I have to remove the time signature

Martín Rincón Botero

unread,
Mar 4, 2021, 1:09:54 PM3/4/21
to abjad-user
Hi Luca,

if you want to remove the first time signature (I suppose you’re talking about Lilypond’s default 4/4), you have to attach a LilypondLiteral with \omit Staff.TimeSignature.

Cheers,
Martín.
--
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/654efc79-0a8c-4dc2-9f5f-41f58784456dn%40googlegroups.com.

Luca Monteverdi

unread,
Mar 4, 2021, 1:22:10 PM3/4/21
to abjad-user
That works, but abjad still thinks that the music is in 4/4, adding a barline after the fourth quarter note:
asdfasdf.png

There shouldn't be a barline after the low D.

Trevor Bača

unread,
Mar 4, 2021, 1:24:51 PM3/4/21
to abjad...@googlegroups.com

Hi Luca,

Abjad ignores the “|” symbols in LilyPond input. You can include “|” symbols if you want visual clarity for yourself when you’re typing LilyPond input code, but Abjad ignores them creating notes.

To draw bar lines in LilyPond, ask LilyPond to create time signatures.

To hide time signatures in LilyPond, use \override TimeSignature.stencil = ##f or \override TimeSignature.transparent = ##t or an equivalent LilyPond command.

One way to implement your sublists-to-measures pattern in Abjad looks like this:

pitch_lists = [[12, 14], [16, 17, 19], [21]]
staff = abjad.Staff()
note_duration = abjad.Duration((1, 4))

for pitch_list in pitch_lists:
    notes = [abjad.Note(pitch, note_duration) for pitch in pitch_list]
    measure_duration = len(pitch_list) * note_duration
    time_signature = abjad.TimeSignature(measure_duration)
    abjad.attach(time_signature, notes[0])
    staff.extend(notes)

abjad.override(staff).time_signature.stencil = "##f"
abjad.show(staff)

sublists.png
Do this to see the LilyPond code Abjad makes under the hood:

string = abjad.lilypond(staff)                                                            
print(string)
\new Staff
\with
{
    \override TimeSignature.stencil = ##f
}
{
    \time 1/2
    c''4
    d''4
    \time 3/4
    e''4
    f''4
    g''4
    \time 1/4
    a''4
}

Trevor.


--
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/654efc79-0a8c-4dc2-9f5f-41f58784456dn%40googlegroups.com.


--

Luca Monteverdi

unread,
Mar 4, 2021, 2:00:12 PM3/4/21
to abjad-user
Thank you very much for your response!

This is more of a Python question, rather than an abjad one, but:

How can I modify this line of code so that only pitches in a certain range are selected? 
    notes = [abjad.Note(pitch, note_duration) for pitch in pitch_list]

Using the list you used as an example, I want only the pitches from 14 to 19.
This leaves the last bar empty.
However, in that case I want an empty bar, rather than no bar. Could you please point me in the right direction?

Thank you again, I'm quite a beginner even in Python haha


Martín Rincón Botero

unread,
Mar 4, 2021, 2:34:01 PM3/4/21
to abjad...@googlegroups.com, abjad-user
Hi Luca,

I'm sure Trevor can answer this better than me, but what you want in that exact line is not really possible, since that line is iterating each sublist, and there are no sublists in the pitch_lists that cover all the pitches that you want. One solution is to make sublists of the pitches that you want grouped together. Another solution is selecting the pitches in the range that you're giving after having them in the staff.

You can for example create a new staff that will have only the notes that you want (by taking those notes away from the first staff), so:


pitch_lists = [[12, 14], [16, 17, 19], [21]]
staff = abjad.Staff()
note_duration = abjad.Duration((1, 4))
for pitch_list in pitch_lists:
    notes = [abjad.Note(pitch, note_duration) for pitch in pitch_list]
    measure_duration = len(pitch_list) * note_duration
    time_signature = abjad.TimeSignature(measure_duration)
    abjad.attach(time_signature, notes[0])
    staff.extend(notes)
staff_ = abjad.Staff()
for note in staff:
    if note.written_pitch.number in range(14, 20):
        staff_.append(note)
>>> staff_
Staff("d''4 e''4 f''4 g''4")
>>> staff
Staff("c''4 a''4")

If you want to keep the original notes in the original staff as well, you'll have to copy them with abjad.mutate.copy(). You can also use containers instead of staves. I personally use them to manipulate short passages before adding those containers to the actual staff.

—Martín.
--
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.

Luca Monteverdi

unread,
Mar 4, 2021, 4:23:00 PM3/4/21
to abjad-user
Hm, I'm starting to understand how the whole thing works.

Basically, the following is what I want:
asdfasdf.png
The "All Notes" staff is here only for explanation, I don't want it in my final score, but the gist is to distribute the pitches in each "measure" to the instruments.


Still, I want to retain the original "measure" division. It may happen that there are no notes available in a certain range for some measure, and instead of "skipping" that measure, I want it to be empty.
Caveat: I'm using only quarter notes here, but I want to be able to have different durations for each note. This means that not all the instruments will have the same duration in the same bar, but I still want a barline in the same place for everyone.

Is it too difficult to do? I realize it isn't really really simple

Luca Monteverdi

unread,
Mar 4, 2021, 4:48:17 PM3/4/21
to abjad-user
Ok, better explanation of the result I want. The process should be:
-choose max 3 or 4  notes in the range of the instrument from the "master list" of notes.
-randomize both pitch order and rhythms, allowing for repeated notes.

asdfasdf.png
Reply all
Reply to author
Forward
0 new messages