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