]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/usage/external.itely
DOC: revise Vim support in Usage Text Editors
[lilypond.git] / Documentation / usage / external.itely
1 @c -*- coding: utf-8; mode: texinfo; -*-
2
3 @ignore
4     Translation of GIT committish: FILL-IN-HEAD-COMMITTISH
5
6     When revising a translation, copy the HEAD committish of the
7     version that you are working on.  For details, see the Contributors'
8     Guide, node Updating translation committishes..
9 @end ignore
10
11 @c \version "2.12.0"
12
13 @node External programs
14 @chapter External programs
15
16 LilyPond can interact with other programs in various ways.
17
18 @menu
19 * Point and click::
20 * Text editor support::
21 * Converting from other formats::
22 * LilyPond output in other programs::
23 * Independent includes::
24 @end menu
25
26
27 @node Point and click
28 @section Point and click
29
30 @cindex point and click
31
32 Point and click lets you find notes in the input by clicking on them
33 in the PDF viewer.  This makes it easier to find input that causes
34 some error in the sheet music.
35
36 When this functionality is active, LilyPond adds hyperlinks to the PDF
37 file.  These hyperlinks are sent to the web-browser, which opens a
38 text-editor with the cursor in the right place.
39
40 To make this chain work, you should configure your PDF viewer to
41 follow hyperlinks using the @file{lilypond-invoke-editor} script
42 supplied with LilyPond.
43
44 For Xpdf on UNIX, the following should be present in
45 @file{xpdfrc}@footnote{On UNIX, this file is found either in
46 @file{/etc/xpdfrc} or as @file{.xpdfrc} in your home directory.}
47
48 @example
49 urlCommand     "lilypond-invoke-editor %s"
50 @end example
51
52 The program @file{lilypond-invoke-editor} is a small helper
53 program.  It will invoke an editor for the special @code{textedit}
54 URIs, and run a web browser for others.  It tests the environment
55 variable @code{EDITOR} for the following patterns,
56
57 @table @code
58 @item emacs
59   this will invoke
60 @example
61 emacsclient --no-wait +@var{line}:@var{column} @var{file}
62 @end example
63 @item gvim
64   this will invoke
65 @example
66 gvim --remote +:@var{line}:norm@var{column} @var{file}
67 @end example
68
69 @item nedit
70 this will invoke
71 @example
72   nc -noask +@var{line} @var{file}'
73 @end example
74 @end table
75
76 The environment variable @code{LYEDITOR} is used to override this.  It
77 contains the command line to start the editor, where @code{%(file)s},
78 @code{%(column)s}, @code{%(line)s} is replaced with the file, column
79 and line respectively.  The  setting
80
81 @example
82 emacsclient --no-wait +%(line)s:%(column)s %(file)s
83 @end example
84
85 @noindent
86 for @code{LYEDITOR} is equivalent to the standard emacsclient
87 invocation.
88
89
90 @cindex file size, output
91
92 The point and click links enlarge the output files significantly.  For
93 reducing the size of PDF and PS files, point and click may be switched
94 off by issuing
95
96 @example
97 \pointAndClickOff
98 @end example
99
100 @noindent
101 in a @file{.ly} file.  Point and click may be explicitly enabled with
102
103 @example
104 \pointAndClickOn
105 @end example
106
107 Alternately, you may disable point and click with a command-line
108 option:
109
110 @example
111 lilypond -dno-point-and-click file.ly
112 @end example
113
114 @warning{You should always turn off point and click in any LilyPond
115 files to be distributed to avoid including path information about
116 your computer in the .pdf file, which can pose a security risk.}
117 @node Text editor support
118 @section Text editor support
119
120 @cindex editors
121 @cindex vim
122 @cindex emacs
123 @cindex modes, editor
124 @cindex syntax coloring
125 @cindex coloring, syntax
126
127 There is support for different text editors for LilyPond.
128
129 @menu
130 * Emacs mode::
131 * Vim mode::
132 * Other editors::
133 @end menu
134
135 @node Emacs mode
136 @unnumberedsubsec Emacs mode
137
138 Emacs has a @file{lilypond-mode}, which provides keyword
139 autocompletion, indentation, LilyPond specific parenthesis matching
140 and syntax coloring, handy compile short-cuts and reading LilyPond
141 manuals using Info.  If @file{lilypond-mode} is not installed on your
142 platform, see below.
143
144 An Emacs mode for entering music and running LilyPond is contained in
145 the source archive in the @file{elisp} directory.  Do @command{make
146 install} to install it to @var{elispdir}.  The file @file{lilypond-init.el}
147 should be placed to @var{load-path}@file{/site-start.d/} or appended
148 to your @file{~/.emacs} or @file{~/.emacs.el}.
149
150 As a user, you may want add your source path (e.g. @file{~/site-lisp/}) to
151 your @var{load-path} by appending the following line (as modified) to your
152 @file{~/.emacs}
153
154 @c any reason we do not advise:  (push "~/site-lisp" load-path)
155 @example
156 (setq load-path (append (list (expand-file-name "~/site-lisp")) load-path))
157 @end example
158
159
160 @node Vim mode
161 @unnumberedsubsec Vim mode
162
163 For @uref{http://@/www@/.vim@/.org,VIM}, a @file{vimrc} is supplied,
164 along with syntax coloring tools.  A Vim mode for entering music and
165 running LilyPond is contained in the source archive in @code{$VIM}
166 directory.
167
168 To enable the Vim mode, locate the @file{filetype.vim} file and find
169 the first section which looks like
170
171 @example
172 au filegroup detect
173 (many lines here)
174 augroup END
175 @end example
176
177 then insert the following lines in the section, which is generally in
178 alphabetic order
179
180 @example
181 : LilyPond
182   au! BufNewFile,BufRead *.ly,*.ily           setf lilypond
183 @end example
184
185 The next step is to append the following line to your @file{vimrc}
186
187 @example
188 set runtimepath+=/usr/local/share/lilypond/$@{LILYPOND_VERSION@}/vim/
189 @end example
190
191 @noindent
192 where $@{LILYPOND_VERSION@} is your LilyPond version.  If your LilyPond
193 is installed in a different location, the path should be modified to suit.
194 To locate the @file{filetype.vim} and @file{.vimrc} files being used in
195 your install of Vim, use the @code{":version"} in a Vim session.
196
197
198 @node Other editors
199 @unnumberedsubsec Other editors
200
201 Other editors (both text and graphical) support LilyPond, but
202 their special configuration files are not distributed with
203 LilyPond.  Consult their documentation for more information.  Such
204 editors are listed in @rweb{Easier editing}.
205
206
207 @node Converting from other formats
208 @section Converting from other formats
209
210 Music can be entered also by importing it from other formats.  This
211 chapter documents the tools included in the distribution to do so.
212 There are other tools that produce LilyPond input, for example GUI
213 sequencers and XML converters.  Refer to the
214 @uref{http://@/lilypond@/.org,website} for more details.
215
216 These are separate programs from @command{lilypond} itself, and are
217 run on the command line; see @ref{Command-line usage} for more
218 information.  If you have MacOS 10.3 or 10.4 and you have trouble
219 running some of these scripts, e.g. @code{convert-ly}, see
220 @rweb{MacOS X}.
221
222
223 @knownissues
224 We unfortunately do not have the resources to maintain these
225 programs; please consider them @qq{as-is}.  Patches are appreciated, but
226 bug reports will almost certainly not be resolved.
227
228 @menu
229 * Invoking midi2ly::            Importing MIDI.
230 * Invoking musicxml2ly::        Importing MusicXML.
231 * Invoking abc2ly::             Importing ABC.
232 * Invoking etf2ly::             Importing Finale.
233 * Other formats::
234 @end menu
235
236
237
238 @node Invoking midi2ly
239 @subsection Invoking @command{midi2ly}
240
241 @cindex MIDI
242
243 @command{midi2ly} translates a Type@tie{}1 MIDI file to a LilyPond source
244 file.
245
246 MIDI (Music Instrument Digital Interface) is a standard for digital
247 instruments: it specifies cabling, a serial protocol and a file
248 format.  The MIDI file format is a de facto standard format for
249 exporting music from other programs, so this capability may come in
250 useful when importing files from a program that has a converter for a
251 direct format.
252
253 @command{midi2ly} converts tracks into @rinternals{Staff} and
254 channels into @rinternals{Voice} contexts.  Relative mode is used
255 for pitches, durations are only written when necessary.
256
257 It is possible to record a MIDI file using a digital keyboard, and
258 then convert it to @file{.ly}.  However, human players are not
259 rhythmically exact enough to make a MIDI to LY conversion trivial.
260 When invoked with quantizing (@code{-s} and @code{-d} options)
261 @command{midi2ly} tries to compensate for these timing errors, but is not
262 very good at this.  It is therefore not recommended to use @command{midi2ly}
263 for human-generated midi files.
264
265
266 It is invoked from the command-line as follows,
267 @example
268 midi2ly [@var{option}]@dots{} @var{midi-file}
269 @end example
270
271 Note that by @q{command-line}, we mean the command line of the
272 operating system.  See @ref{Converting from other formats}, for
273 more information about this.
274
275 The following options are supported by @command{midi2ly}.
276
277 @table @code
278 @item -a, --absolute-pitches
279 Print absolute pitches.
280
281 @item -d, --duration-quant=@var{DUR}
282 Quantize note durations on @var{DUR}.
283
284 @item -e, --explicit-durations
285 Print explicit durations.
286
287 @item -h,--help
288 Show summary of usage.
289
290 @item -k, --key=@var{acc}[:@var{minor}]
291 Set default key.  @math{@var{acc} > 0} sets number of sharps;
292 @math{@var{acc} < 0} sets number of flats.  A minor key is indicated by
293 @code{:1}.
294
295 @item -o, --output=@var{file}
296 Write output to @var{file}.
297
298 @item -s, --start-quant=@var{DUR}
299 Quantize note starts on @var{DUR}.
300
301 @item -t, --allow-tuplet=@var{DUR}*@var{NUM}/@var{DEN}
302 Allow tuplet durations @var{DUR}*@var{NUM}/@var{DEN}.
303
304 @item -v, --verbose
305 Be verbose.
306
307 @item -V, --version
308 Print version number.
309
310 @item -w, --warranty
311 Show warranty and copyright.
312
313 @item -x, --text-lyrics
314 Treat every text as a lyric.
315 @end table
316
317
318 @knownissues
319
320 Overlapping notes in an arpeggio will not be correctly rendered.  The
321 first note will be read and the others will be ignored.  Set them all
322 to a single duration and add phrase markings or pedal indicators.
323
324
325 @node Invoking musicxml2ly
326 @subsection Invoking @code{musicxml2ly}
327
328 @cindex MusicXML
329
330 @uref{http://@/www.@/musicxml@/.org/,MusicXML} is an XML dialect
331 for representing music notation.
332
333 @command{musicxml2ly} extracts the notes, articulations, score structure,
334 lyrics, etc. from part-wise MusicXML files, and writes them to a .ly
335 file.  It is invoked from the command-line.
336
337
338 It is invoked from the command-line as follows,
339 @example
340 musicxml2ly [@var{option}]@dots{} @var{xml-file}
341 @end example
342
343 Note that by @q{command-line}, we mean the command line of the
344 operating system.  See @ref{Converting from other formats}, for
345 more information about this.
346
347 If the given filename is @file{-}, @command{musicxml2ly} reads input
348 from the command line.
349
350 The following options are supported by @command{musicxml2ly}:
351
352 @table @code
353 @item -a, --absolute
354 convert pitches in absolute mode.
355
356 @item -h,--help
357 print usage and option summary.
358
359 @item -l, --language=LANG
360 use a different language file 'LANG.ly' and corresponding pitch names,
361 e.g. 'deutsch' for deutsch.ly and German note names.
362
363 @item --lxml
364 use the lxml.etree Python package for XML-parsing; uses less memory and cpu time.
365
366 @item --nd --no-articulation-directions
367 do not convert directions (@code{^}, @code{_} or @code{-}) for
368 articulations, dynamics, etc.
369
370 @item --no-beaming
371 do not convert beaming information, use LilyPond's automatic
372 beaming instead.
373
374 @item -o,--output=@var{file}
375 set output filename to @var{file}.  If @var{file} is @file{-}, the output
376 will be printed on stdout.  If not given, @var{xml-file}@file{.ly} will
377 be used.
378
379 @item -r,--relative
380 convert pitches in relative mode (default).
381
382 @item -v,--verbose
383 be verbose.
384
385 @item --version
386 print version information.
387
388 @item -z,--compressed
389 input file is a zip-compressed MusicXML file.
390 @end table
391
392
393 @node Invoking abc2ly
394 @subsection Invoking @code{abc2ly}
395
396 @warning{This program is not supported, and may be remove from
397 future versions of LilyPond.}
398
399 @cindex ABC
400
401 ABC is a fairly simple ASCII based format.  It is described at the ABC site:
402
403 @quotation
404 @uref{http://@/www@/.walshaw@/.plus@/.com/@/abc/@/learn@/.html}.
405 @end quotation
406
407 @command{abc2ly} translates from ABC to LilyPond.  It is invoked as follows:
408
409 @example
410 abc2ly [@var{option}]@dots{} @var{abc-file}
411 @end example
412
413 The following options are supported by @command{abc2ly}:
414
415 @table @code
416 @item -b,--beams=None
417 preserve ABC's notion of beams
418 @item -h,--help
419 this help
420 @item -o,--output=@var{file}
421 set output filename to @var{file}.
422 @item -s,--strict
423 be strict about success
424 @item --version
425 print version information.
426 @end table
427
428 There is a rudimentary facility for adding LilyPond code to the ABC
429 source file.  If you say:
430
431 @example
432 %%LY voices \set autoBeaming = ##f
433 @end example
434
435 This will cause the text following the keyword @q{voices} to be inserted
436 into the current voice of the LilyPond output file.
437
438 Similarly,
439
440 @example
441 %%LY slyrics more words
442 @end example
443
444 will cause the text following the @q{slyrics} keyword to be inserted
445 into the current line of lyrics.
446
447
448 @knownissues
449
450 The ABC standard is not very @q{standard}.  For extended features
451 (e.g., polyphonic music) different conventions exist.
452
453 Multiple tunes in one file cannot be converted.
454
455 ABC synchronizes words and notes at the beginning of a line;
456 @command{abc2ly} does not.
457
458 @command{abc2ly} ignores the ABC beaming.
459
460
461 @node Invoking etf2ly
462 @subsection Invoking @command{etf2ly}
463
464 @warning{This program is not supported, and may be remove from
465 future versions of LilyPond.}
466
467 @cindex ETF
468 @cindex enigma
469 @cindex Finale
470 @cindex Coda Technology
471
472 ETF (Enigma Transport Format) is a format used by Coda Music
473 Technology's Finale product.  @command{etf2ly} will convert part of an ETF
474 file to a ready-to-use LilyPond file.
475
476 It is invoked from the command-line as follows.
477
478 @example
479 etf2ly [@var{option}]@dots{} @var{etf-file}
480 @end example
481
482 Note that by @q{command-line}, we mean the command line of the
483 operating system.  See @ref{Converting from other formats}, for
484 more information about this.
485
486 The following options are supported by @command{etf2ly}:
487
488 @table @code
489 @item -h,--help
490 this help
491 @item -o,--output=@var{FILE}
492 set output filename to @var{FILE}
493 @item --version
494 version information
495 @end table
496
497
498 @knownissues
499
500 The list of articulation scripts is incomplete.  Empty measures
501 confuse @command{etf2ly}.  Sequences of grace notes are ended improperly.
502
503
504 @node Other formats
505 @subsection Other formats
506
507 @cindex External programs, generating LilyPond files
508
509 LilyPond itself does not come with support for any other formats,
510 but some external tools can also generate LilyPond files.  These
511 are listed in @rweb{Easier editing}.
512
513
514
515 @node LilyPond output in other programs
516 @section LilyPond output in other programs
517
518 This section shows methods to integrate text and music, different than
519 the automated method with @command{lilypond-book}.
520
521 @menu
522 * Many quotes from a large score::
523 * Inserting LilyPond output into OpenOffice.org::
524 * Inserting LilyPond output into other programs::
525 @end menu
526
527 @node Many quotes from a large score
528 @unnumberedsubsec Many quotes from a large score
529
530 If you need to quote many fragments from a large score, you can also use
531 the clip systems feature, see @ruser{Extracting fragments of music}.
532
533
534 @node Inserting LilyPond output into OpenOffice.org
535 @unnumberedsubsec Inserting LilyPond output into OpenOffice.org
536
537 @cindex OpenOffice.org
538
539 LilyPond notation can be added to OpenOffice.org with
540 @uref{http://@/ooolilypond@/.sourceforge@/.net@/,OOoLilyPond}.
541
542
543 @node Inserting LilyPond output into other programs
544 @unnumberedsubsec Inserting LilyPond output into other programs
545
546 To insert LilyPond output in other programs, use @code{lilypond}
547 instead of @code{lilypond-book}.  Each example must be created
548 individually and added to the document; consult the documentation for
549 that program.  Most programs will be able to insert LilyPond output in
550 @file{PNG}, @file{EPS}, or @file{PDF} formats.
551
552 To reduce the white space around your LilyPond score, use
553 the following options
554
555 @example
556 \paper@{
557   indent=0\mm
558   line-width=120\mm
559   oddFooterMarkup=##f
560   oddHeaderMarkup=##f
561   bookTitleMarkup = ##f
562   scoreTitleMarkup = ##f
563 @}
564
565 @{ c1 @}
566 @end example
567
568 To produce a useful @file{EPS} file, use
569
570 @example
571 lilypond -dbackend=eps -dno-gs-load-fonts -dinclude-eps-fonts   myfile.ly
572
573 @file{PNG}:
574 lilypond -dbackend=eps -dno-gs-load-fonts -dinclude-eps-fonts --png myfile.ly
575 @end example
576
577
578 @node Independent includes
579 @section Independent @code{include}s
580
581 Some people have written large (and useful!) code that can be
582 shared between projects.  This code might eventually make its way
583 into LilyPond itself, but until that happens, you must download
584 and @code{\include} them manually.
585
586
587 @menu
588 * MIDI articulation::
589 @end menu
590
591
592 @node MIDI articulation
593 @subsection MIDI articulation
594
595 LilyPond can be used to produce MIDI output, for
596 @qq{proof-hearing} what has been written.  However, only dynamics,
597 explicit tempo markings, and the notes and durations themselves
598 are produced in the output.
599
600 The @emph{articulate} project is one attempt to get more of the
601 information in the score into he MIDI.  It works by shortening
602 notes not under slurs, to @q{articulate} the notes.  The amount of
603 shortening depends on any articulation markings attached to a
604 note: staccato halves the note value, tenuto gives a note its full
605 duration, and so on.  The script also realises trills and turns,
606 and could be extended to expand other ornaments such as mordents.
607
608 @example
609 @uref{http://@/www@/.nicta@/.com@/.au/@/people/@/chubbp/@/articulate}
610 @end example
611
612 @knownissues
613
614 Its main limitation is that it can only affect things it knows
615 about: anything that is merely textual markup (instead of a note
616 property) is still ignored.
617
618