Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request for help with the pitch module #136

Closed
JoanEliot opened this issue Aug 29, 2019 · 1 comment
Closed

Request for help with the pitch module #136

JoanEliot opened this issue Aug 29, 2019 · 1 comment

Comments

@JoanEliot
Copy link

The python-ly library sounds like it would be a big help to me in the complicated Python-Lilypond project I have underway--but I'm unable to make sense of the docs. Maybe it's because they assume competence with Python classes, which I sorely lack. So I would appreciate pointers on the pitch module.

My goal is to write a function/module that transposes any passage of Lilypond music either up or down so that the lowest pitch (for example) winds up after transposition in a specified range. For example, suppose I want the lowest pitch in a chord to fall within the octave below middle C, "c" to "b" in Lilypond-ese. Given a Lilypond F major chord <f a c'>, if I ask for the chord in C I should get a downward transposition to (or an equivalent Lilypond relative transposition command); whereas if I want transposition to G I should get in return <g b d'> or a Lilypond command transposing the chord up.

All that is just so you have an idea of what I'm trying to do -- I don't seek help on the logic or Python fundamentals, just on how to use the pitch module in general.

After creating a python-ly Document object full of Lilypond tokens--I can do that--how do I feed the Document to the pitch module to get and modify a working set of just the pitches (with their octaves) so that I can test them? As in "find the lowest pitch in the passage, apply the proposed transposition to that pitch in the downward direction, test the result against my range, if that doesn't work try the upward direction." Feeding a Document into the PitchIterator class "works," ie no error occurs, but PitchIterator.pitches seems to provide iteration over blocks (lines), not pitches. What's the correct way to examine Lilypond music one pitch at a time?

python_ly_doc = ly.document.Document(music_string)
 pitch_it = ly.pitch.PitchIterator(python_ly_doc, language=u'english') #any language is fine
 for not_a_ptch in pitch_it.pitches(): 
     print (not_a_ptch) # pitches() returns Block objects, not pitches
 # for ptch in pitch_it: # error "not iterable" ; pitch_it() "not callable"

Then the next question: How does one use the transpose submodule? Once I know which direction to transpose, I guess I can just write the corresponding Lilypond \transpose command to the file. But how is transpose supposed to work? Do you feed it a Document somehow?

Thanks for any help on this stuff.

@jeanas
Copy link
Member

jeanas commented Feb 27, 2023

I'm closing this old issue. Sorry that your question was not answered. If you still want help, please ask on https://groups.google.com/g/frescobaldi.

@jeanas jeanas closed this as not planned Won't fix, can't repro, duplicate, stale Feb 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants