Use Lilypond typesetting under Gnu/linux simplified

Source: Internet
Author: User

Although Gnu/linux is not omnipotent, it does offer free, open solutions in many cases. These two days I want to do a simplified, search the online score typesetting software, found the Lilypond software based on the GPL protocol. But Lilypond is used to make staff. Fortunately, a jianpu-ly.py script written by Silas of Cambridge University was found to be able to eventually generate simplified by calling Lilypond. See here for a detailed description of it.

The script supports the following simplified syntax rules:

    • Scale: 1 2 3 4 5 6 7 1 '
    • Empty shot: 0
    • Rise and Fall tone: #1 B2
    • Two low eight degrees, low eight degrees, midrange, eight degrees high, two eight degrees: 1,, 1, 1 1 ' 1 '
    • 64 points, 32 points, 16 points, eight points, four diaeresis (one shot): H1 D1 S1 Q1 1
    • Fu Note: S1. Q1. 1.
    • Half note (two beats): 1-
    • Fu half Note (three beats): 1--
    • Full note (four beats): 1---
    • Beats: 4/4
    • Major: 1=bb
    • Minor: 6=f#
    • Title: title= Tea Picking Dance
    • Triple tone: 3[Q1 Q1 Q1]
    • Repeat: r{1 1 1} a{2 | 3}

A typical simplified source file is as follows:

title= Title 1=C2/41 2 3 4 5 6 7 1 '

After you save the file as Jianpu.txt, call jianpu-ly.py to generate the Lilypond input file:

jianpu-ly.py < Jianpu.txt > jianpu.ly

The Lilypond program is then called to generate a score file in the specified format. Surprisingly, not only can be formatted in PDF, PS, PNG and other formats of simplified, but also to generate MIDI files, directly play audition. You can call Lilypond in the following ways:

---PS jianpu.ly

You can use timidity to play the generated MIDI file directly, or convert it to riff WAV format, and then listen with a regular audio player.

Timidity-ow-o Jianpu.wav Jianpu.midi

In order to automate the above commands, I wrote a bash script make_jianpu.sh with the following code:

#!/bin/Bashscript_name="make_jianpu.sh"Script_usage=$(Cat<<Eofmake_jianpu.SH[OPTIONS] jianpu.txteof) script_function=$(Cat<<Eofbatch convertion of a jianpu into Lilypond script Theninto PDF, PNG, MIDI and waveof) Script_doc=$(Cat<<EOF-h Display this help. EOF) Script_examples=$(Cat<<eofeof) State_prefix="==="Warning_prefix="***"Error_prefix="!!!"functionDisplay_help () {if[-N"$script _usage"]; Then    Echo-E"Usage: $script _usage"    fi        if[-N"$script _function"]; Then    Echo-E"$script _function"    fi        if[-N"$script _doc"] ; Then    Echo-E"\n$script_doc"    fi} whileGetopts": hr:"Opt Do     Case$optinchh) display_help exit0 ;; \?) Display_help Exit1 ;; Esac DoneShift$ ($OPTIND-1)) Jianpu_txt=" $"# Clear old generated filesif[-E"${jianpu_txt%txt}ly"]; Then    RM "${jianpu_txt%txt}ly"fiif[-E"${jianpu_txt%txt}pdf"]; Then    RM "${jianpu_txt%txt}pdf"fiif[-E"${jianpu_txt%txt}png"]; Then    RM "${jianpu_txt%txt}png"fiif[-E"${jianpu_txt%txt}midi"]; Then    RM "${jianpu_txt%txt}midi"fiif[-E"${jianpu_txt%txt}wav"]; Then    RM "${jianpu_txt%txt}wav"fiif[-E"$jianpu _txt"]; ThenJianpu-ly.py <"$jianpu _txt">"${jianpu_txt%txt}ly"    if[-E"${jianpu_txt%txt}ly"]; Then# Generate PDFfileLilypond"${jianpu_txt%txt}ly"                if[-E"${jianpu_txt%txt}pdf"]; Then            Echo "simplified PDF file generated successfully! "# Generate PNGfileLilypond--png"${jianpu_txt%txt}ly"            if[-E"${jianpu_txt%txt}png"]; Then                Echo "simplified picture file generated successfully! "# Generate WAVfileFrom Midiif[-E"${jianpu_txt%txt}midi"]; Then                    Echo "MIDI file generation succeeded! "TiMidity-ow-o"${jianpu_txt%txt}wav" "${jianpu_txt%txt}midi"                    if[-E"${jianpu_txt%txt}wav"]; Then                        Echo "WAV file generated successfully! "                    Else                        Echo "unable to generate WAV file, please check simplified syntax error! "                    fi                Else                    Echo "Unable to generate MIDI file, please check simplified syntax error! "                fi            Else                Echo "unable to generate simplified picture file, please check simplified syntax error! "            fi         Else            Echo "Unable to generate PDF file, please check simplified syntax error! "        fi    Else        Echo "unable to generate the Ly file, please check the simplified syntax error! "    fiElse    Echo "input file could not be found: $jianpu _txt! "fi

In addition, I found in the process of using the default Lilypond settings, although the ability to generate the correct MIDI files, but can not be typeset out the rise, fall and restore Number (accidentals). After some temptation, it is found that only the 168th line in the/usr/share/lilypond/2.14.2/ly/engraver-init.ly file is added:

\consists "Accidental_engraver"

To resolve the problem. This is because the Lilypond file generated by the Jianpu-ly.py script transformation is based on the rhythmicstaff context. The default configuration in engraver-init.ly does not include the "carving" (engrave) of accidentals. So, you need to add it manually.

At this point, the tools for simplified typesetting have been prepared. I tried to arrange the "Colonel Boji March" fragment as follows. You can experience the effect of Lilypond.

Source file:

title= Colonel Boji March 1=c2/4q1 ' q0 Q7. S6 Q5 Q3 Q1 Q3 Q5 S5 S6 Q5 S5 S6 5-r{Q5 Q3 0 q0 Q3 Q4 Q5 3 ' 3 ' 1 '-Q5 Q3 0 q0 Q3 Q4 Q3 5 5 4-q4 Q2 0}a{q0 Q2 Q3 Q4 Q5 Q3 0 q0 Q3 Q4 Q3 Q2 5 Q3 q#4 2 Q6 5 (-5)-|   Q0 Q6 Q7 Q6} Q1 ' Q5 0 q0 Q5 Q4 Q3 Q2 6 Q2 Q7, 5 Q7, 1 (-1) Q3 Q3 1 '. Q7 S6 s#5 Q6 Q5 Q4 3 (-Q3) Q3 Q4 Q3 6 q#5. S6 1 ' Q6. S1 ' #2 ' (-#2 ') 6 3 '. Q2 ' s1 ' S7 Q6 q#5. S6 2. Q4 Q6 q0 s1 ' s7 s1 ' s2 ' Q3 ' q0 Q7. S1 ' 6 (-6) Q3 Q3 1 '. Q7 S6 s#5 Q6 Q5 Q4 3 (-Q3) Q3 Q4 Q3 6 q#5. S6 1 ' Q6. S1 ' #2 ' (-#2 ') 6 3 '. Q2 ' s1 ' S7 Q6 q#5. S6 2. Q4 Q6 q0 s1 ' s7 s1 ' s2 ' Q3 ' q0 Q7. S1 ' 6 (-6) 5-> \ff

Simplified

Use Lilypond typesetting under Gnu/linux simplified

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.