最近新发现的歌谱排版软件Lilypond
生活随笔
收集整理的這篇文章主要介紹了
最近新发现的歌谱排版软件Lilypond
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
事情的起因是我在制作一款歌譜生成軟件,希望找找樂譜的繪圖庫,居然發(fā)現(xiàn)完全沒有現(xiàn)成的庫,不得不承認(rèn),國內(nèi)外計(jì)算機(jī)水平是差著不少的。。。因?yàn)?#xff0c;在百度上完全找不到這方面的內(nèi)容,搜索歌譜排版,歌譜轉(zhuǎn)pdf等等,一直沒有結(jié)果。而在google上搜英文,東西一堆一堆的,于是我就把一個(gè)個(gè)人認(rèn)為非常好的軟件拿過來分享一下。
Lilypond是一款GNU軟件,免費(fèi)而開源,可以將一篇歌譜腳本自動(dòng)排版成五線譜,ps文檔和midi樂,而且渲染質(zhì)量非常之高,這是下面它的效果圖:
而它使用的腳本則是自定義語法規(guī)則的描述類語言:
\header {title = "LilyPond demo"enteredby="Han-Wen Nienhuys"maintainer="hanwen@xs4all.nl"texidoc = "heavily mutilated Edition Peters Morgenlied by Schubert" } \version "2.12.0"ignoreMelisma = \set ignoreMelismata = ##t ignoreMelismaOff = \unset ignoreMelismata #(set-global-staff-size 21)\paper {%#(set-global-staff-size (* 5.8 mm))indent = #(* mm 4)line-width = #(* mm 140)interscoreline = 2.\mmbetween-system-space = 15\mmragged-bottom = ##t }modernAccidentals = {\set Staff.extraNatural = ##f\set Staff.autoAccidentals = #'(Staff (same-octave . 1) (any-octave . 0))\set Staff.autoCautionaries = #'() }melody = \relative c'' \repeat volta 2 \context Voice = "singer" {\time 6/8\autoBeamOffs1*0^\markup { \larger { \hspace #-3.0 Lieblich, etwas geschwind } }R2.r4 r8 c4 g8 |\acciaccatura { f16 } e4 c8<<\new Voice { \stemUp f8. g16 }{ \stemDown f8.[ g16] } >> \stemNeutral a8 |fis4 g8 c16[ b a g] f[ e] |d4 f8\transpose a' e' \relative c'' { a16[ g fis! g] f![ d] } |g4. r8 gis gis |a4 a16.[ b32] c8[( a]) fis8 |g4.~ g8-\fermata }firstVerse = \lyricmode {\set stanza = "1."Sü -- ?es Licht! Aus\ignoreMelismagol --\ignoreMelismaOffde -- nen Pfor -- ten brichst du __ | sie -- gend durch __ die Nacht. Sch? -- ner Tag, du __ bist er -- wacht. __ }secondVerse = \lyricmode {\set stanza = "2."いろはに ??? та та ほへど ちり ぬるをЖъл дю ля ??いろ はに ??? та та ほへ ちり ぬるЖъл дю ля __ }pianoRH = \relative c''' \repeat volta 2\new Voice {#(set-accidental-style 'modern)\voiceOneg16( fis a g fis g f e d c b\oneVoicea ) | <g e>8( <es fis a> <d e bes'> <c e c'>\arpeggio) r8 r | r8 c'( e,) f r a |\once \override DynamicLineSpanner #'padding =#3r8<< { fis( g) } \\<< { a4 } { s8\> s8\! } >>>>r8 <e c g>8[ <e c g>] |<d c a>4. r8 \clef bass <d b f> <d b f> |\crescTextCresce,16_" "\<g c g e g d gis b gis d gis |c, e a e c e a,-\f\! d fis d a d |b d g d b g e16. r32\fermata}pianoLH = \relative c'' \repeat volta 2\new Voice {#(set-accidental-style 'modern)\voiceTwog16( fis a g fis gf e d c b\change Staff = down\oneVoiced,) | g4.( b,8) r r\clef treble \grace s16 r8 <bes'>8-> <bes c>8->([ <a c>)] r <f c'> |\clef bassr8 dis( e) r c c |f,4. g8[ r8 g] |<c, c,>4. <e e,>4. |a,4. <d d,>4. |g,8 r r g16 r16\fermata }\book {\score {<< \time 6/8\new Staff \with {fontSize = #-3\override StaffSymbol #'staff-space = #(magstep -3)} <<\context Staff #(set-accidental-style 'modern)\melody >>\lyricsto "singer" \new Lyrics \firstVerse\lyricsto "singer" \new Lyrics \secondVerse\new PianoStaff << \set PianoStaff.instrumentName = \markup {\bold\larger\larger\larger\larger\huge"2."}\context Staff = up <<\pianoRH\pianoLH>>\context Staff = down { \clef bass \skip 1*2 }>> >>\layout {\context {\Lyrics\override VerticalAxisGroup #'minimum-Y-extent = #'(-0.85 . 2.2)\override LyricText #'font-size = #-1}\context {\Score\override Beam #'thickness = #0.55\override Beam #'auto-knee-gap = #4.0\override SpacingSpanner #'spacing-increment = #1.0\override Stem #'stemlet-length = #0.5\override Slur #'height-limit = #1.5}}\midi {\context {\ScoretempoWholesPerMinute = #(ly:make-moment 70 4)}}}}
中間的部分就是描述了樂譜的旋律和符號(hào),具體的內(nèi)容規(guī)則就請(qǐng)看幫助文檔了,另外,幫助文檔大概有300兆左右。。。
這款軟件可以很方便的通過命令行調(diào)用,(因?yàn)槭荊NU的嘛),使用方法就是
lilypond 文件名 (當(dāng)然還有各種可選參數(shù)表,具體就看help吧)
我用C#寫了段腳本生成代碼,然后用cmd命令調(diào)用了一下,有需要的就當(dāng)做參考吧:
/* * @Author: sxf * @Date: 2014-01-12 22:02:12 * @Last Modified by: sxf * @Last Modified time: 2014-01-16 12:43:15 */using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows; using System.Diagnostics; using System.IO;class GenerateStaff{String title = "Demo";public void Set(String title){this.title = title;}StreamWriter sw;public void Generate(String str) {sw = new StreamWriter(str,false);sw.WriteLine("\\header {");sw.WriteLine("title = \"{0}\" ",title);sw.WriteLine("}");sw.WriteLine("\\version \"2.12.0\"");sw.WriteLine("ignoreMelisma =\\set ignoreMelismata = ##t");sw.WriteLine("ignoreMelismaOff = \\unset ignoreMelismata");sw.WriteLine("#(set-global-staff-size {0})",21);sw.WriteLine("\\paper {{\n%#(set-global-staff-size (* {0} mm))",5.8);sw.WriteLine("indent = #(* mm {0})",4);sw.WriteLine("line-width = #(* mm {0})",140);sw.WriteLine("interscoreline = {0}.\\mm",2);sw.WriteLine("between-system-space = {0}\\mm",15);sw.WriteLine("ragged-bottom = ##t ");sw.WriteLine("}");sw.WriteLine("modernAccidentals = {");sw.WriteLine("\\set Staff.extraNatural = ##f");sw.WriteLine("\\set Staff.autoAccidentals = #\'(Staff (same-octave . 1) (any-octave . 0))");sw.WriteLine("\\set Staff.autoCautionaries = #\'() ");sw.WriteLine("}");sw.Write("melody = ");writeRelative("c\'\' ");// writeClef("bass");writeTime(6,8);// sw.Write("\\repeat volta 2 \\context Voice = \"singer\" ");sw.WriteLine("{");// sw.WriteLine("\\autoBeamOff");writeClef("bass");// writeTime(6,8);// sw.WriteLine("\\autoBeamOff");// sw.WriteLine("s1*0^\\markup {{ \\larger {{ \\hspace #-3.0 Lieblich, etwas geschwind }} }}");// sw.WriteLine("R2.");writeNote(1);writeNote(2);for (int i = 1; i < 8; ++i){writeNote(i,4);}for (int i = 1; i < 8; ++i){writeNote(i,4);}Random ra = new Random();for (int i = 1; i < 250; ++i){writeNote(ra.Next(7)+1,8);}sw.WriteLine("}");sw.Close();}int mi(int x){int y = 2;for (int i =1;i<x;++i){y*= 2;}return y;}void writeRelative(String str) {sw.Write("\\relative {0}",str);}void writeClef(String str){sw.WriteLine("\\clef {0} ",str);}void writeTime(int p,int q) {sw.WriteLine("\\time {0}/{1}",p,q);}char[] md = {'#','c','d','e','f','g','a','b'};void writeNote(int p) {sw.Write("{0} ",md[p]);}void writeNote(int p,int q) {sw.Write("{0}{1} ",md[p],q);}}class MainClass {static void Main() {test("sxf","hello.ly");}static void test(String str,String filename) {Console.WriteLine("Hello,{0}",str);GenerateStaff gs = new GenerateStaff();gs.Generate(filename);RenderPdf(filename);}static void RenderPdf(String str) {//定義一個(gè)ProcessStartInfo實(shí)例System.Diagnostics.ProcessStartInfo info = new System.Diagnostics.ProcessStartInfo();//設(shè)置啟動(dòng)進(jìn)程的初始目錄info.WorkingDirectory = System.Environment.CurrentDirectory;//設(shè)置啟動(dòng)進(jìn)程的應(yīng)用程序或文檔名info.FileName = System.Environment.CurrentDirectory+"\\usr\\bin\\lilypond";Console.WriteLine(info.WorkingDirectory);//設(shè)置啟動(dòng)進(jìn)程的參數(shù)info.Arguments = System.Environment.CurrentDirectory + "\\"+str;//設(shè)置不顯示窗口 info.CreateNoWindow = true; //啟動(dòng)由包含進(jìn)程啟動(dòng)信息的進(jìn)程資源try{System.Diagnostics.Process.Start(info);}catch (System.ComponentModel.Win32Exception we){Console.WriteLine(we.Message);return;}} }
總結(jié)
以上是生活随笔為你收集整理的最近新发现的歌谱排版软件Lilypond的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 百度文库下载文档,没财富值,没下载卷也能
- 下一篇: 【小白学前端】化腐朽为神奇-Bootst