Add macros
[opus_libre.git] / bin / macros.scm
blob97f95465ce24c9851d62e1a04d0519e1fbb64cd6
1 ;------------------------------------------------------------------;
2 ; opus_libre -- macros.scm                                         ;
3 ;                                                                  ;
4 ; (c) 2008-2010 Valentin Villenave <valentin@villenave.net>        ;
5 ;                                                                  ;
6 ;     opus_libre is a free framework for GNU LilyPond: you may     ;
7 ; redistribute it and/or modify it under the terms of the GNU      ;
8 ; General Public License, version 3 or later: gnu.org/licenses     ;
9 ;                                                                  ;
10 ;------------------------------------------------------------------;
12 ; Input macros.
14 (load "../lib/libmusic.scm")
16 ;; Rhythm shortcuts -----------------------------------------------;
17 (make-simple-function lang:tuplet-letter ; default: \t
18                       #{ \times 2/3 $x #})
20 (make-simple-function lang:tuplet-letter-double ; \tt
21                       #{ \times 4/5 $x #})
23 (make-simple-function lang:tuplet-letter-triple ; \ttt
24                       #{ \times 4/6 $x #})
26 (make-simple-function lang:tuplet-letter-quad ; \tttt
27                       #{ \times 4/7 $x #})
29 ;; Auto octavation ------------------------------------------------;
30 (define oct
31   (define-music-function (parser location mus) (ly:music?)
32     (octavize mus)))
34 ;; Articulation shortcuts -----------------------------------------;
35 ;;TODO: how about an alist? (see libmusic.scm)
36 (make-script '(st . "staccato"))
37 (make-script '(acc . "accent"))
38 (make-script '(det . "tenuto")) ; as in "détaché"
39 (make-script '(stdet . "portato"))
40 (make-script '(accdet . '("tenuto" "accent")))
41 (make-script '(accst . '("accent" "staccato")))
42 (make-script '(dwnb . "downbow"))
44 ;; Polyphony shortcuts --------------------------------------------;
45 (define pl
46   (define-music-function (parser location one two)
47     (ly:music? ly:music?)
48     #{ << { \voiceTwo $one } \\ { \voiceOne $two } >> #}))
50 (staff-change-command lang:upper-hand) ;; depending on your input language:
51 (staff-change-command lang:lower-hand) ;; \rh or \md etc. for switching staves.
54 (define hideNote #{
55 \once \override Dots #'transparent = ##t
56 \once \override NoteHead #'transparent = ##t
57 \once \override NoteHead #'no-ledgers = ##t
58 \once \override Stem #'transparent = ##t
59 \once \override Beam #'transparent = ##t
60 \once \override Accidental #'transparent = ##t
61 #})
63 (define hideNoteHead #{
64 \once \override NoteHead #'transparent = ##t
65 #})
67 (define hideNoteHeads
68   (define-music-function (parser location x) (ly:music?)
69   #{\override NoteHead #'transparent = ##t $x \revert NoteHead #'transparent #}))
71 (define graceNote #{
72 \once \set fontSize = #-2
73 #})
75 (define graceNotes
76   (define-music-function (parser location x) (ly:music?)
77   #{ \tiny $x \normalsize #}))
79 (define lightBeam #{
80 \once \override Beam #'beam-thickness = #0.36
81 \once \override Beam #'gap = #0.5
82 #})
84 (define lightBeams
85   (define-music-function (parser location x) (ly:music?) #{
86 \override Beam #'beam-thickness = #0.36
87 \override Beam #'gap = #0.5
89 \revert Beam #'beam-thickness
90 \revert Beam #'gap
91 #}))
93 (define whiteNote
94   (define-music-function (parser location arg) (ly:music?)
95     (set! (ly:music-property arg 'tweaks)
96                                  (acons 'duration-log 1
97                                     (ly:music-property arg 'tweaks)))
98                          arg))
100 (define blackNote
101   (define-music-function (parser location arg) (ly:music?)
102     (set! (ly:music-property arg 'tweaks)
103                                  (acons 'duration-log 4
104                                     (ly:music-property arg 'tweaks)))
105                          arg))