12 * Helping with development::
17 @section CodingStyle - standards while programming for GNU LilyPond
19 As a general rule, you should always try to continue computations, even
20 if there is some kind of error. When the program stops, it is often very
21 hard for a user to pinpoint what part of the input causes an
22 error. Finding the culprit is much easier if there is some viewable
25 So functions and methods do not return errorcodes, they never crash, but
26 report a programming_error and try to carry on.
28 @unnumberedsubsec Languages
30 C++ and Python are preferred. Python code should use an indent of 8,
33 @unnumberedsubsec Filenames
35 Definitions of classes that are only accessed via pointers
36 (*) or references (&) shall not be included as include files.
42 ".cc" Implementation files
43 ".icc" Inline definition files
44 ".tcc" non inline Template defs
51 (append '(("\\.make$" . makefile-mode)
53 ("\\.icc$" . c++-mode)
54 ("\\.tcc$" . c++-mode)
56 ("\\.pod$" . text-mode)
62 The class Class_name is coded in @file{class-name.*}
64 @unnumberedsubsec Indentation
66 Standard GNU coding style is used. In emacs:
69 (add-hook 'c++-mode-hook
70 '(lambda() (c-set-style "gnu")
75 If you like using font-lock, you can also add this to your @file{.emacs}:
78 (setq font-lock-maximum-decoration t)
79 (setq c++-font-lock-keywords-3
81 c++-font-lock-keywords-3
82 '(("\\b\\([a-zA-Z_]+_\\)\\b" 1 font-lock-variable-name-face)
83 ("\\b\\([A-Z]+[a-z_]+\\)\\b" 1 font-lock-type-face))
87 @unnumberedsubsec Classes and Types
93 @unnumberedsubsec Members
97 Type Class::member_type_
98 Type Class::member_type ()
101 the @code{type} is a Hungarian notation postfix for @code{Type}. See below
103 @unnumberedsubsec Macros
105 Macro names should be written in uppercase completely.
107 @unnumberedsubsec Broken code
109 Try not to write broken code. This includes hardwired dependencies,
110 hardwired constants, slow algorithms and obvious limitations. If you can
111 not avoid it, mark the place clearly, and add a comment explaining
112 shortcomings of the code.
114 @unnumberedsec Hungarian notation naming convention
116 The C++ part of LilyPond uses a naming convention derived from the
117 so-called @emph{Hungarian Notation}. Macros, @code{enum}s and
118 @code{const}s are all uppercase, with the parts of the names separated
121 The hungarian notation is to be used when variables are not declared
122 near usage (mostly in member variables and functions).
124 @unnumberedsubsec Types
128 unsigned char. (The postfix _by is ambiguous)
142 Zero terminated c string
147 @unnumberedsubsec User defined types
157 Slur* slur_p = new Slur;
161 @unnumberedsubsec Modifiers
163 The following types modify the meaning of the prefix.
164 These are preceded by the prefixes:
172 const. Note that the proper order is @code{Type const}
173 and not @code{const Type}
175 A const pointer. This would be equivalent to @code{_c_l}, but since any
176 "const" pointer has to be a link (you can't delete a const pointer),
179 temporary pointer to object (link)
181 pointer to newed object
186 @unnumberedsubsec Adjective
188 Adjectives such as global and static should be spelled out in full.
189 They come before the noun that they refer to, just as in normal english.
193 foo_global_i: a global variable of type int commonly called "foo".
197 static class members do not need the static_ prefix in the name (the
198 Class::var notation usually makes it clear that it is static)
202 Variable loop: an integer
204 Temporary variable: an unsigned integer
206 Variable test: a character
207 @item @code{first_name_str}
208 Variable first_name: a String class object
209 @item @code{last_name_ch_a}
210 Variable last_name: a @code{char} array
212 Variable foo: an @code{Int*} that you must delete
214 Variable bar: an @code{Int*} that you must not delete
217 Generally default arguments are taboo, except for nil pointers.
219 The naming convention can be quite conveniently memorised, by
220 expressing the type in english, and abbreviating it
224 static Array<int*> foo
228 @code{foo} can be described as "the static int-pointer user-array", so you get
237 @unnumberedsec Miscellaneous
239 For some tasks, some scripts are supplied, notably creating patches, a
240 mirror of the website, generating the header to put over cc and hh
241 files, doing a release.
246 @section Making patches
248 @unnumberedsec Track and distribute your code changes
250 This page documents how to distribute your changes to GNU lilypond
252 We would like to have unified context diffs with full pathnames. A
253 script automating supplied with Lily.
255 Distributing a change normally goes like this:
258 @item make your fix/add your code
259 @item Add changes to CHANGES, and add yourself to Documentation/topdocs/AUTHORS.texi
260 @item generate a patch,
261 @item e-mail your patch to one of the mailing lists
262 gnu-music-discuss@@gnu.org or bug-gnu-music@@gnu.org
265 Please do not send entire files, even if the patch is bigger than the
266 original. A patch makes it clear what is changed, and it won't
267 overwrite previous (not yet released) changes.
269 @unnumberedsec Generating a patch
274 make -C lilypond-x.y.z/ distclean
275 make -C lilypond-x.y.z.NEW/ distclean
276 diff -urN lilypond-x.y.z/ lilypond-x.y.z.NEW/
279 Complicated (but automated) version:
281 In @file{VERSION}, set MY_PATCH_LEVEL:
291 In @file{CHANGES}, enter a summary of changes:
297 * A concise, yet clearly readable description of what changed.
301 Then, from the top of Lily's source tree, type
307 These handy python scripts assume a directory structure which looks
312 lilypond -> lilypond-x.y.z # symlink to development directory
313 lilypond-x.y.z/ # current development
314 patches/ # patches between different releases
315 releases/ # .tar.gz releases
319 @unnumberedsec Applying patches
321 [outdated: please use xdeltas]
323 If you're following LilyPond development regularly, you probably want to
324 download just the patch for each subsequent release.
325 After downloading the patch (into the patches directory, of course), simply
330 gzip -dc ../patches/lilypond-0.1.74.diff.gz | patch -p1 -E
334 and don't forget to make automatically generated files:
338 autoconf footnote(patches don't include automatically generated files,
339 i.e. file(configure) and files generated by file(configure).)
346 @section Localisation - User messages in LilyPond
348 This document provides some guidelines for uniformising user messages.
349 In the absence of other standards, we'll be using these rules when coding
350 for LilyPond. Hopefully, this can be replaced by general GNU
351 guidelines in the future.
353 Not-preferred messages are marked with @code{+}. By convention,
354 agrammatical examples are marked with @code{*}.
356 @subsection Guidelines
361 Every message to the user should be localised (and thus be marked
362 for localisation). This includes warning and error messages.
365 Don't localise/gettextify:
368 @item @code{programming_error ()}s
369 @item @code{programming_warning ()}s
371 @item output strings (PostScript, TeX)
375 Messages to be localised must be encapsulated in @code{_ (STRING)}
376 or @code{_f (FORMAT, ...)}. Eg:
379 warning (_ ("Need music in a score"));
380 error (_f ("Can't open file: `%s'", file_name));
383 In some rare cases you may need to call @code{gettext ()} by hand.
384 This happens when you pre-define (a list of) string constants for later
385 use. In that case, you'll probably also need to mark these string
386 constants for translation, using @code{_i (STRING)}. The @code{_i}
387 macro is a no-op, it only serves as a marker for @file{xgettext}.
390 char const* messages[] = @{
391 _i ("enable debugging output"),
392 _i ("ignore lilypond version"),
399 puts (gettext (messages [i]));
404 @file{flower/getopt-long.cc} and @file{lily/main.cc}.
407 Don't use leading or trailing whitespace in messages.
410 Messages containing a final verb, or a gerund (@code{-ing}-form)
411 always start with a capital. Other (simpler) messages start with
415 The word `foo' is not declared.
417 Not declaring: `foo'.
421 To avoid having a number of different messages for the same situation,
422 we'll use quoting like this @code{"message: `%s'"} for all strings.
423 Numbers are not quoted:
426 _f ("Can't open file: `%s'", name_str)
427 _f ("Can't find charater number: %d", i)
431 Think about translation issues. In a lot of cases, it is better to
432 translate a whole message. The english grammar mustn't be imposed on
433 the translator. So, iso
436 _ ("Stem at ") + moment.str () + _(" doen't fit in beam")
443 _f ("Stem at %s doen't fit in beam", moment.str ())
447 Split up multi-sentence messages, whenever possible. Instead of
450 warning (_f ("out of tune! Can't find: `%s', "Key_engraver"));
452 warning (_f ("Can't find font `%s', loading default",
460 warning (_ ("out of tune:");
461 warning (_f ("Can't find: `%s', "Key_engraver"));
463 warning (_f ("Can't find font: `%s', font_name));
464 warning (_f ("Loading default font"));
468 If you must have multiple-sentence messages, use full punctuation.
469 Use two spaces after end of sentence punctuation.
470 No punctuation (esp. period) is used at the end of simple messages.
473 _f ("Non-matching braces in text `%s', adding braces", text)
474 _ ("Debug output disabled. Compiled with NPRINT.")
475 _f ("Huh? Not a Request: `%s'. Ignoring.", request)
479 Don't modularise too much; a lot of words cannot be translated
481 It's probably safe to treat most occurences of words like
482 stem, beam, crescendo as separately translatable words.
485 When translating, it is preferrable to put interesting information
486 at the end of the message, rather than embedded in the middle.
487 This especially applies to frequently used messages, even if this
488 would mean sacrificing a bit of eloquency. This holds for original
489 messages too, of course.
492 en: can't open: `foo.ly'
493 + nl: kan `foo.ly' niet openen (1)
494 kan niet openen: `foo.ly'* (2)
495 niet te openen: `foo.ly'* (3)
498 The first nl message, although gramatically and stylishly correct,
499 is not friendly for parsing by humans (even if they speak dutch).
500 I guess we'd prefer something like (2) or (3).
503 Please don't run make po/po-update with GNU gettext < 0.10.35
507 @node Helping with development
508 @section Getting involved
510 If you want to help developing LilyPond your efforts are appreciated.
511 You can help LilyPond in several ways. Not all tasks requiring
512 programming or understanding the full source code.
514 Please don't expect us to give you instructions on what you should
515 do. We're just a bunch of simple hackers, and we're absolutely
516 incompetent about management, design in advance, delegating work.
517 Some people write to us "I want to help, what should I do?", but we
518 never know what to answer them.
520 If you want to hack, just start hacking. You can send us the result as
521 a patch, and we'll gladly incorporate it.
523 If you need some hints on where to get started: there are a number of
524 specific areas where you could do work.
526 @unnumberedsubsec Users
528 Mutopia needs your help. The mutopia project is a collection of public
529 domain sheet music. You can help the project by entering music (either
530 by hand, or by converting from scans or MIDI) and submitting it. Point
531 your browser to the @uref{http://sca.uwaterloo.ca/Mutopia, Mutopia
534 @unnumberedsubsec Writers
536 The documentation of LilyPond and related utilities needs a lot of
537 work. The documentation is written in
538 @uref{http://www.gnu.org/software/texinfo,texinfo}. The documentation of
539 LilyPond is sorely lacking in terms of completeness, depth and
542 Write if you know how to write english documentation in texinfo, and
543 know about music and music notation. You must also know how to use
544 LilyPond (or be prepared to learn using it). The task is not especially
545 hard, but it is a lot of work, and you must be familiar with LilyPond.
547 @unnumberedsubsec Translators
549 LilyPond is completely ready for internationalized messages, but there
550 are only a few translations so far (dutch, italian, german, japanese,
551 french, russian). Translation involves writing a .po file, which is
552 relatively easy, and does not even require running LilyPond.
554 @unnumberedsubsec Hackers
556 There are lots of possibilities of improving the program itself. There
557 are both small projects and big ones. Most of them are listed in our
558 TODO file, listed on the homepage of Jan and
559 @uref{http://www.cs.uu.nl/~hanwen/lily-devel,Han-Wen}. Modifying
560 LilyPond almost always requires patches to the C++ part.
562 If you still don't have any idea what to do, you might want to browse
563 the mailing lists; Users do lots of feature requests, and you could
564 implement any of them.
567 There are also numerous other interesting projects that are more or less
571 @item Writing convertors, eg. from NIFF and MIDI (we tried writing one with
572 limited success: midi2ly, included with lilypond.)
574 We found that writing them in Python is the easiest.
576 @item Writing a GUI frontend to
577 LilyPond. At the moment @uref{denemo,denemo.sourceforge.net} is the most
580 @item Helping write @uref{http://solfege.sourceforge.net/,solfege
583 @item Helping @uref{primrose.sourceforge.net,primrose}, a tool for
584 scanning sheet music.
588 @section An incomplete description of the Enigma Transport Format
590 Enigma Transport Format (ETF for short) is a format designed by Coda music
591 technology, and it is used in the proprietary notation package
592 Finale. Since it is very poorly documented, I'll attempt some
595 ETF is an memory dump where object pointers have been replaced by object
596 numbers. The numbers are larger than 0 and the number 0 is used to
597 denote the nil pointer. The dump is encoded in ASCII (where the mac
598 version uses CR, and the PC CR/LF as line delimiters)
600 A file is divided into sections like this
611 @var{DATA} is stored in the form of tagged lines, where a tagged line looks
615 ^TG(N1[,N2]) X1 X2 X3 (etc)
618 The caret is at the start of the line, @code{TG} is a two letter tag,
619 and @var{N1} (and optionally @var{N2}) are numbers identifying the
620 object to be described. @var{X3}, @var{X4} etc contain data in the form
621 of either a signed 16 bit number, or a 32 bit number (in hex, with a $
622 sign prepended). The number of Xs per line for a certain tag is
625 The numbers in @code{N1} need not be consecutive or ascending, mostly.
628 If an object is too large to fit on a single line (which typically has
629 only five X's), it is put on multiple lines and padded with zero's, eg.
636 (the GF object requires 6 16 bit words, hence the 4 padding zeroes).
640 Each staff can contain up to four layers, where a layer correspond to a
641 horizontal `line' of notes. Each layer is broken up into frames, where
642 each frame is one measure of a layer.
645 ^GF(s,m) @var{c} @var{flags} @var{f1} @var{f2} @var{f3}
646 ^GF(s,m) @var{f4} 0 0 0 0
649 Here @var{s} is the staff number, @var{m} the measure number,
650 @var{flags} is a 16-bit bit-vector, and @var{f1} to @var{f4} are frame
651 identifiers. @var{c} is a clef-identifier.
653 There is a second variant of the @code{GF} tag, which has only one line;
657 ^GF(s,m) @var{fr} @var{c} @var{x} @var{y} @var{z}
660 here, @code{fr} is a frame number, @code{c} the clef number. The
661 function of x, y , z is unknown.
663 A frame is described by the FR tag
666 ^FR(@var{n}) @var{n1} @var{n2} 0 0
669 This means frame number @var{n} runs from note @var{n1} to note @var{n2}
670 Where `running from' is interpreted as ``that part of a linked note list
671 that starts with note @var{n1} and ends with note @var{n2}''. This is
672 something different from the sequence of notes
673 @var{n1}, @var{n1 + 1} , ... , @var{n2 - 1}, @var{n2}.
675 Notes (or more accurately chord-notes/rests) are described as follows:
678 ^eE(@var{n}) @var{l1 l2 dur pos $flags extflags pitchcount}
682 This is note number @var{n} (in list where @var{l1} and @var{l2} are
685 Durations are stored as a number where 1024 is the quarter note, 512 the
686 eighth, etc. Dotted notes are stored by multiplying the dur field
689 pitchcount is the number of pitch records. Each pitchrecord looks like
693 (note that the line starts with spaces, and not with a caret)
696 pitch is a 16 bit number, where the lower order 4-bits is a signed
697 nybble which adds an alteration (0 = natural, 1 = sharp, etc.)
698 The remaining 12 bits encodes the note-name (octave inclusive.)
700 Both the alteration and the note-name are relative to the scale as
701 defined by the key-signature in this measure. The person who invented
702 this should have his head checked out.
704 The key and time signature are defined in the MS field
706 ^MS(n) space key beats beatlen y z
709 @var{n} is the measure number. @var{space} is the width of the
710 measure (?), @var{key} the number of the keysignature (0 = C major, 1 G
711 major, etc. 255 = F major, 254 = Bflat major). beats and beatlen
712 determine time signature.
714 Key and time are determined score wide. The mind boggles at how they
715 plan to do polytonal and polymetric music. And how do they do
716 mid-measure keychanges?
718 Slurs are (among others) stored with an Sx tag
721 ^Sx(@var{slurnumber}) @var{stuff}
724 The slur has many parameters. The 6th number on the first line is the
725 starting note, the 3rd number on the 4th line the ending note.
728 Some other information can be found in the Finale Plug-in Development
729 (there is a vague manual, and some source files that are useful).
731 You can download the PDK from Coda's website,
732 @uref{http://www.codamusic.com/coda/Fin2000_pdk_download.asp}. You do
733 need to register as a user (you can also do it if you have never bought
751 DO (shape expression),
752 DT (text expression),
756 IX (articulation definition - documented in edata.h),
757 Iu (instrument used - documented in edata.h),
758 LA (layer preferences - documented in eprfdata.h),
759 MN (measure number region),
762 RS (repeat style - documented in edata.h),
763 RT (text repeat style text - documented in edata.h),
765 SS (staff system spec),