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