Open siers opened 6 years ago
But you did see the documentation at https://python-ly.readthedocs.io/en/latest/ ? -- Diese Nachricht wurde von meinem Android-Gerät mit K-9 Mail gesendet.
Yes. :)
On Sat., 13 Oct. 2018, 8:01 am Urs Liska, notifications@github.com wrote:
But you did see the documentation at https://python-ly.readthedocs.io/en/latest/ ?
Diese Nachricht wurde von meinem Android-Gerät mit K-9 Mail gesendet.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/wbsoft/python-ly/issues/131#issuecomment-429511589, or mute the thread https://github.com/notifications/unsubscribe-auth/AAOWi-NqAysXJICRPMu0mZMutk-1i0hTks5ukXOMgaJpZM4XaUHW .
Ok, just to be clear: you want to import ly
into a Python a program and use it's functionality, you're not talking about the standalone ly
script. Is that correct?
Yeah, that is correct.
I hope I am not mistaken in that this repo lets you parse lilypond and manipulate with the syntax trees?
I too would be very grateful for some sample code/a basic tutorial on using the library in Python scripts. Please see request for specific guidance opened as new issue--after several hours I can create a Document object but still can't figure out how to use it in a practical way. Even some uncommented excerpts from whatever projects you all have already done would be very informative, I bet. Thanks.
I'm not 100% sure but IIRC python-ly
is able to parse, read and manipulate a document, but it can't write a document yet, so it's not possible to generate a document from scratch.
I'm not sure if that relates to the questions in this thread, though.
For what it's worth, my project doesn't require writing documents, just reading/parsing Lilypond code. Somehow I was able to get python-ly to report back duration information to my program from Document objects I create from in-memory strings. I think I was just lucky. No such luck with the pitch module.
Perhaps this should be a separate issue but I would also like guidance on what lilypond features can or cannot be parsed. I'm trying to convert a book's worth of music ultimately into a bespoke braille notation. ParseSource.parse_text is failing on one of the supplied examples (hopefully attached). Here is the code fragment I'm using: In [1]: import ly
In [2]: from ly.musicxml.lymus2musxml import ParseSource
In [3]: parser=ParseSource()
In [4]: xml=parser.parse_text(open('Tinwood.ly','r').read()) Warning! Couldn't parse source! Digging a bit further it appears get_score isn't finding a score node. The attached .ly file seems to think there is one. This might be something subtle with the .ly file or an incompleteness in the parser. That's perfectly fine. I can work on the .ly files to make them acceptable but I could use some guidance on what does and doesn't work. Can the developers make available some of the test files they've been using so we can get some sense of what works? Perhaps an examples directory? I tried to attach the .ly file which didn't seem to work so I'm trying to paste it here. Apologies, this web interface isn't the most nonvisually accessible.
\header { title = "Tinwood" tagline = "" % removed }
#(set-global-staff-size 17)
\paper { print-page-number = ##f markup-system-spacing #'basic-distance = #15 system-system-spacing #'basic-distance = #20
paper-width = 21.0\cm
paper-height = 29.7\cm
top-margin = 1.0\cm
bottom-margin = 2.0\cm
left-margin = 1.0\cm
right-margin = 1.0\cm
}
\layout { indent = 0.0\cm }
PartPOneVoiceOne = \relative bes' { \clef "treble" \key bes \major \numericTimeSignature\time 4/4 \partial 2 \repeat volta 3 { bes2 | % 2 f4 f4 f4 f4 | % 3 d4. es8 f4 f4 | % 4 g8 ( [ f8 ) g8 ( a8 ) ] bes4 a4 | % 5 bes2 \fermata bes2 | % 6 d4 c4 bes4 a4 | % 7 g2 g4 a4 | % 8 bes4 a4 g4 fis4 | % 9 g2 \fermata bes2 | \barNumberCheck #10 bes4 bes4 bes4 d8 ( [ c8 ) ] | % 11 bes2 bes4 bes4 | % 12 es,4 es4 d4 d4 | % 13 c2 bes2 \mp | % 14 f'4 f4 f4 f4 | % 15 f4. ( es8 ) d2 | % 16 \time 2/4 | % 16 f2 \ff | % 17 \numericTimeSignature\time 4/4 bes4 bes4 c4 c4 | % 18 d2 es4 c4 | % 19 bes4 bes4 a8 ( [ g8 ) ] a4 | \barNumberCheck #20 bes2 \fermata } }
PartPOneVoiceOneLyricsOne = \lyricmode { \set stanza = "1. " Come all ye wear -- y tra -- vel -- lers, Come let us join and sing The ev -- er -- last -- ing prais -- es of Je -- sus Christ our King; We've had a ted -- ious jour -- ney and tire -- some, it is true, But see how ma -- ny dan -- gers, But see how ma -- ny dan -- gers The Lord hath brought us through.}
PartPTwoVoiceOne = \relative d' { \clef "treble" \key bes \major \numericTimeSignature\time 4/4 \partial 2 \repeat volta 3 { d2 | % 2 d4 d4 d4 d4 | % 3 bes4. c8 d4 d4 | % 4 es4 es4 d4 c4 | % 5 d2 \fermata d2 | % 6 d4 d4 d4 es4 | % 7 bes2 bes4 es4 | % 8 d4 es4 d4 d4 | % 9 bes2 d2 | \barNumberCheck #10 d4 d4 d4 f4 | % 11 d2 d4 d4 | % 12 c4 c4 d4 bes4 | % 13 a2 bes2 \mp | % 14 bes4 d4 d4 d4 | % 15 d4. ( c8 ) bes2 | % 16 \time 2/4 | % 16 d2 \ff | % 17 \numericTimeSignature\time 4/4 f4 f4 f4 f4 | % 18 f2 g4 es4 | % 19 d4 d4 c4 c4 | \barNumberCheck #20
d2 \fermata }
}
PartPTwoVoiceOneLyricsOne = \lyricmode { \set stanza = "1. " Come all ye wear -- y tra -- vel -- lers, Come let us join and sing The ev -- er -- last -- ing prais -- es of Je -- sus Christ our King; We've had a ted -- ious jour -- ney and tire -- some, it is true, But see how ma -- ny dan -- gers, But see how ma -- ny dan -- gers The Lord hath brought us through.}
PartPTwoVoiceOneLyricsTwo = \lyricmode { \set stanza = "2. " At first when Je -- sus found _ us, He called us un -- to him, And_he point -- ed out the dan -- gers, Of fall -- ing in -- to sin; The world, the flesh and Sa -- tan, Will prove to us a snare, Ex -- cept we do re -- ject them, Ex -- cept we do re -- ject them, By faith and hum -- ble prayer. }
PartPTwoVoiceOneLyricsThree = \lyricmode { \set stanza = "3. " But by our dis -- o -- be -- di -- ence, With sor -- row we con -- fess, We long have had to wan -- der In that dark wild -- er -- ness, Where we might soon have faint -- ed, In that en -- chant -- ed ground, But now and then a clust -- er, But now and then a clust -- er Of pleas -- ant grapes we found. } PartPThreeVoiceOne = \relative f' { \clef "treble" \key bes \major \numericTimeSignature\time 4/4
\partial 2 \repeat volta 3 {
f2 | % 2
bes4 bes4 bes4 bes4 | % 3
bes4. a8 bes4 bes4 | % 4
bes4 g4 f4 f4 | % 5
f2 \fermata f2 | % 6
g4 fis4 g4 a4 | % 7
bes2 bes4 c4 | % 8
d4 c4 bes4 a4 | % 9
g2 \fermata f2 | \barNumberCheck #10
f4 f4 f4 f4 | % 11
f2 f4 f4 | % 12
a4 a4 bes4 f4 | % 13
f2 \fermata r2 | % 14
R1 | % 15
R1 | % 16
\time 2/4 | % 16
bes2 \ff \ff | % 17
\numericTimeSignature\time 4/4 bes4 bes4 a4 a4 | % 18
bes2 bes4 g4 | % 19
f4 f4 f4 f4 | \barNumberCheck #20
f2 \fermata }
}
PartPThreeVoiceOneLyricsOne = \lyricmode { Come all ye "wear-y" \skip4 tra -- vel -- "lers," Come let us join and sing The ev -- er -- last -- ing prais -- es of Je -- sus Christ our "King;" "We've" had a ted -- ious jour -- ney and tire -- "some," it is "true," But see how ma -- ny dan -- gers The Lord hath brought us "through." "found." "found." }
PartPFourVoiceOne = \relative bes, { \clef "bass" \key bes \major \numericTimeSignature\time 4/4 \partial 2 \repeat volta 3 { bes2 | % 2 bes4 bes4 bes4 f4 | % 3 bes4. c8 d4 bes4 | % 4 es4 c4 f4 f,4 | % 5 bes2 \fermata bes2 | % 6 g4 a4 bes4 c4 | % 7 d2 d4 fis4 | % 8 g4 c,4 d4 d4 | % 9 g,2 \fermata bes2 | \barNumberCheck #10 bes4 bes4 bes4 f4 | % 11 bes2 bes4 bes4 | % 12 c4 c4 bes4 bes4 | % 13 f2 \fermata r2 | % 14 R1 | % 15 R1 | % 16 \time 2/4 bes'2 | % 17 \numericTimeSignature\time 4/4 d,4 d4 f4 f4 | % 18 bes4 ( as4 ) g4 es4 | % 19 f4 f4 f,4 f4 | \barNumberCheck #20 bes2 } }
PartPFourVoiceOneLyricsOne = \lyricmode { Come all ye "wear-y" \skip4 tra -- vel -- "lers," Come let us join and sing The ev -- er -- last -- ing prais -- es of Je -- sus Christ our "King;" "we've" had a ted -- ious jour -- ney and tire -- "some," it is "true," But see how ma -- ny dan -- gers The Lord hath brought us "through." "found." "found." }
% The score definition \score { \new ChoirStaff << \new Staff <<
\context Staff <<
\context Voice = "PartPOneVoiceOne" { \PartPOneVoiceOne }
\new Lyrics = "firstVerse" \lyricsto "PartPOneVoiceOne" \PartPOneVoiceOneLyricsOne
%\new Lyrics \lyricsto "PartPOneVoiceOne" \PartPOneVoiceOneLyricsTwo
%\new Lyrics \lyricsto "PartPOneVoiceOne" \PartPOneVoiceOneLyricsThree
>>
>>
\new Staff <<
\context Staff <<
\context Voice = "PartPTwoVoiceOne" { \PartPTwoVoiceOne }
\new Lyrics \lyricsto "PartPTwoVoiceOne" \PartPTwoVoiceOneLyricsOne
\new Lyrics \lyricsto "PartPTwoVoiceOne" \PartPTwoVoiceOneLyricsTwo
\new Lyrics \lyricsto "PartPTwoVoiceOne"
\PartPTwoVoiceOneLyricsThree
>>
>>
\new Staff <<
\context Staff <<
\context Voice = "PartPThreeVoiceOne" { \PartPThreeVoiceOne }
\new Lyrics = "TfirstVerse"\lyricsto "PartPThreeVoiceOne" \PartPThreeVoiceOneLyricsOne
%\new Lyrics \lyricsto "PartPThreeVoiceOne" \PartPOneVoiceOneLyricsTwo
%\new Lyrics \lyricsto "PartPThreeVoiceOne" \PartPOneVoiceOneLyricsThree
>>
>>
\new Staff <<
\context Staff <<
\context Voice = "PartPFourVoiceOne" { \PartPFourVoiceOne }
\new Lyrics \lyricsto "PartPFourVoiceOne" \PartPFourVoiceOneLyricsOne
%\new Lyrics \lyricsto "PartPFourVoiceOne" %\PartPOneVoiceOneLyricsTwo
%\new Lyrics \lyricsto "PartPFourVoiceOne"
%\PartPOneVoiceOneLyricsThree
>>
>>
>>
}
Hi,
I'd like to transform some lilypond source code and cut and move all the variable definitions.
I found an example in the docs on how to get a list of tokens from a file, but I couldn't figure out how to get a parse tree. There are any examples of this or maybe I've missed them. There are also no tests from which to gain insight.