lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: convert from absolute to relative


From: Yota
Subject: Re: convert from absolute to relative
Date: Fri, 22 Aug 2008 16:04:07 +0200
User-agent: Thunderbird 2.0.0.16 (X11/20080724)

Jonathan > thank you for the remarks and for the samples too.

Neil > I corrected this small bug, indeed the script didn't care of the options you fed it with. And if you prefer nederlands default output, just change in lilymusic.py line 38
lily_out_style = "italiano"
into
lily_out_style = "nederlands"

For today, I give up finding an easy way to parse a complex .ly file... i'll try later :D

Nevertheless, the script should run better. To launch it, you may copy the part containing only the notes into a separate file

ex : from
clarinet = { ... } or \new Staff {... }
extract { ... } (with the braces) and copy into a new file


to use it :
python lilymusic.py --out_style="nederlands" < test.ly > new.ly (thx carl)

to download it (new version) :
http://dl.free.fr/pXHJyTc5P

+ handle comments and multiline comments
+ put a \include "italiano.ly" on top according to the chosen style
! corrected bug : you can now use --out_style

TODO
- handle properly \key indications

Yota

Jonathan Kulp wrote:
This is a good idea, Yota. I was going through some of my first Lilypond files today and found that I had written them in absolute mode and wished I'd had a script to convert them to relative. I did them by hand since they were very short, but for anything longer, a script like yours would be very helpful.

I ran your script on the test file "in.ly" included in your archive and it seemed to work fine (the absolute pitches were changed to relative) but then I couldn't get the resulting file to compile in lilypond. I worked on it for a few minutes but couldn't find the problem and gave up.

I also ran the python script on one of my own files and had problems with it. First of all, it doesn't seem to recognize comments properly, as it goes through my comments changing them as if they were pitch indications. It did the same thing to the title in my Header block and even added a stray { that caused errors when trying to compile. Also, I use the default Dutch pitch names, and while it read them correctly, it also changed them to the Italian pitch names in the conversion process.

I wish I could help tweaking the code, but I have no idea how to write in Python. I'll be glad to test the script out when you make changes to it, though. Hope it helps to see these samples.

Best,

Jonathan

%%%%%%%%%%%%%%%%%

% My original file in absolute mode:

\version "2.10.25"
\header {
  title = "1:1 Exercise 2"
  composer = "Jonathan Kulp"
}

\paper {
ragged-right = ##f
}

\layout {
indent = 0.5\cm
}

\new PianoStaff <<
\new Staff { \time 3/4
    \key f \major
    #(set-global-staff-size 24)

% begin inserting notes for treble staff here

    f'4 g' a'
    e' f' d'
    bes' a' g'
    f'2 r4
    \bar "||"
  }

\new Staff { \clef bass
    \key f \major

% begin inserting notes for bass staff here

    s2.*4
  }
>>

%%%%%%%%%%%%%%%%%%%%%%

% Resulting file after running it through lilymusic.py
% This file does not compile at all. See next example for
% my adjustments to make it compile but it still has problems
% after that...

\version "2.10.25"
\header {
  title = "1:1 Exercise 2"\relative do { doomposer = "Jonathan Kulp"
}

\paper {
ragged-right = ##fa
}

\layout {
indent = 0.5\cm
}

\new PianoStaff <<
\new Staff { \time 3/4
    \key f \major
    #(set-sollobal-staff-size 24)

% sigin inserting notes faor treble staff here

    fa'4 sol la
    mi fa re
    sib' la sol
    fa2 r4
    \bar "||"
  }

\new Staff { \clef si,ass
    \key f \major

% sigin inserting notes faor siass staff here

    s2.*4
  }
>>



%%%%%%%%%%%%%%%%%%%%%

% same file after fixing the clef line and key indication, and removing
% the extra { that was inserted in the title causing errors
% This file compiles but the notes are in wrong octaves--
% The absolute-to-relative didn't work right
% Also you can see that it changes "composer" to "doomposer"
% and I had to use \include "italiano.ly"
% it changes ragged-right value to "##fa" instead of ##f
% I also had to fix the #(set-global-staff-size line


\version "2.10.25"
\include "italiano.ly"
\header {
  title = "1:1 Exercise 2"
  doomposer = "Jonathan Kulp"
}

\paper {
ragged-right = ##fa
}

\layout {
indent = 0.5\cm
}

\new PianoStaff <<
\new Staff { \time 3/4
    \key fa \major
    #(set-global-staff-size 24)

% sigin inserting notes faor treble staff here

    fa'4 sol la
    mi fa re
    sib' la sol
    fa2 r4
    \bar "||"
  }

\new Staff { \clef bass
    \key fa \major

% sigin inserting notes faor siass staff here

    s2.*4
  }
>>


Yota wrote:
Good evening everybody,

Being unable to find a nice tool to handle lilypond sources, I designed mine.

I worked on this little script which (even if its buggy) should perform some essential tasks:

- convert absolute music to relative music
- transpose the source (from bes to c for example)
- change the naming scheme

in the future I hope it will also

- shrink R1 R1 R1 R1 R1 R1 R1 R1 R1 R1 R1 stuffs into R1 * 11

the parser is very naive and need to be improved, but the code should be flexible enough to let some room for improvements.

if you wanna play with it, download it from http://dl.free.fr/mQx7nFhQQ , expand it and use python. The main script is lilymusic.py ; to be feeded from the stdin.

ex : cat in.ly | python lilymusic.py



feedback appreciated

... now goin' to bed


_______________________________________________
lilypond-user mailing list
address@hidden
http://lists.gnu.org/mailman/listinfo/lilypond-user







reply via email to

[Prev in Thread] Current Thread [Next in Thread]