summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/leadsheets/leadsheets.library.musicsymbols.code.tex
blob: 3095250f48f41c3da335d4c573028bc7ae079594 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
% --------------------------------------------------------------------------
% the LEADSHEETS package
% 
%   typesetting leadsheets and songbooks
%
% --------------------------------------------------------------------------
% Clemens Niederberger
% E-Mail: contact@mychemistry.eu
% --------------------------------------------------------------------------
% Copyright 2014--2022 Clemens Niederberger
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
% of this license or (at your option) any later version.
% The latest version of this license is in
%   http://www.latex-project.org/lppl.txt
% and version 1.3 or later is part of all distributions of LaTeX
% version 2005/12/01 or later.
%
% This work has the LPPL maintenance status `maintained'.
%
% The Current Maintainer of this work is Clemens Niederberger.
% --------------------------------------------------------------------------
\LeadsheetsLibrary{musicsymbols}{2016/02/15 musical symbols}
\RequirePackage{etoolbox}

% define a LaTeX font that uses the `musix' font from MusiXTeX:
\DeclareFontFamily{U}{musix}{}%
\DeclareFontShape{U}{musix}{m}{n}{%
  <-12>   s * [1.5] musix11
  <12-15> s * [1.5] musix13
  <15-18> s * [1.5] musix16
  <18-23> s * [1.5] musix20
  <23->   s * [1.5] musix29
}{}%

% a font switch command:
\newrobustcmd*\musix{\usefont{U}{musix}{m}{n}\selectfont}
% a text font command:
\DeclareTextFontCommand{\textmusix}{\musix}

% the `symbol' command: raises the symnol since most symbols are too low for
% use in normal text:
\newrobustcmd*\musicsymbol[2][0pt]{%
  \raisebox{\dimexpr.45ex+(#1)\relax}{\textmusix{#2}}%
}

\newrobustcmd*\leadsheets@altostrut{%
  \vphantom{\rule[-.5\normalbaselineskip]{1pt}{1.4\normalbaselineskip}}%
}
\newrobustcmd*\leadsheets@treblestrut{%
  \vphantom{\rule[-.4\normalbaselineskip]{1pt}{1.5\normalbaselineskip}}%
}

% define the symbols
\renewrobustcmd*\sharp       {\kern.05em\musicsymbol[.2ex]{4}\kern-.05em}
\renewrobustcmd*\flat        {\kern-.05em\musicsymbol{2}\kern-.06em}
\renewrobustcmd*\natural     {\musicsymbol{6}\kern-.06em}
\newrobustcmd*\doublesharp   {\kern.05em\musicsymbol{5}\kern-.05em}
\newrobustcmd*\doubleflat    {\kern-.05em\musicsymbol{3}\kern-.06em}
\newrobustcmd*\trebleclef    {\leadsheets@treblestrut\smash{\musicsymbol{H}}}
\newrobustcmd*\bassclef      {\strut\smash{\musicsymbol{J}}}
\newrobustcmd*\altoclef      {\leadsheets@altostrut\smash{\musicsymbol{K}}}
\newrobustcmd*\allabreve     {\strut\smash{\kern-.1em\musicsymbol[.25ex]{R}\kern.05em}}
\newrobustcmd*\meterC        {\strut\smash{\kern-.1em\musicsymbol[.25ex]{S}\kern.05em}}
\newrobustcmd*\wholerest     {\kern.05em\musicsymbol{<}\kern.05em}
\newrobustcmd*\halfrest      {\kern.05em\musicsymbol{=}\kern.05em}
\newrobustcmd*\quarterrest   {\strut\smash{\musicsymbol[-1.5ex]{>}\kern.4em}}
\newrobustcmd*\eighthrest    {\musicsymbol[-1.5ex]{?}\kern.5em}
\newrobustcmd*\sixteenthrest {\kern.05em\musicsymbol[-1.5ex]{@}\kern.5em}

\RequirePackage{amsmath}
\newrobustcmd*\meter[2]{%
  \ensuremath{%
    \genfrac{}{}{0pt}{}%
      {\text{\textbf{#1}}}%
      {\text{\textbf{#2}}}%
  }%
}

\newrobustcmd*\Break{\ensuremath{\perp}}

\newcommand*\leadsheets@size{\f@size pt}
\newlength\leadsheets@barheight

\newrobustcmd*\genericbar[1]{%
  \setlength\leadsheets@barheight\leadsheets@size
  \rule[-.2\leadsheets@barheight]{#1}{\leadsheets@barheight}%
}

\newcommand*\normalbarwidth{.02em}
\newcommand*\thickbarwidth{.15em}
\newcommand*\interbarwidth{.1em}

\newrobustcmd*\leadsheets@thickbar{%
  \genericbar{\thickbarwidth}%
}

\newrobustcmd*\leadsheets@repeatcolon{%
  \leavevmode
  \setlength\leadsheets@barheight\leadsheets@size
  \raise.1\leadsheets@barheight\hbox{\textup{:}}%
}

\newrobustcmd*\leadsheets@interbar{\kern\interbarwidth\relax}

\newrobustcmd*\leadsheets@normalbar{%
  \genericbar{\normalbarwidth}%
}
\newrobustcmd*\normalbar{\leadsheets@normalbar}

\newrobustcmd*\leftrepeat{%
  \leadsheets@thickbar
  \leadsheets@interbar
  \leadsheets@normalbar
  \leadsheets@repeatcolon
}

\newrobustcmd*\rightrepeat{%
  \leadsheets@repeatcolon
  \leadsheets@normalbar
  \leadsheets@interbar
  \leadsheets@thickbar
}

\newrobustcmd*\leftrightrepeat{%
  \leadsheets@repeatcolon
  \leadsheets@thickbar
  \leadsheets@interbar
  \leadsheets@thickbar
  \leadsheets@repeatcolon
}

\newrobustcmd*\doublebar{%
  \leadsheets@normalbar
  \leadsheets@interbar
  \leadsheets@normalbar
}

\newrobustcmd*\stopbar{%
  \leadsheets@normalbar
  \leadsheets@interbar
  \leadsheets@thickbar
}

\endinput

2014/08/10 - initial release
2015/07/13 - scale musix font by 1.5 => else the symbols are rather small!
2016/01/15 - \Break; improvements of bars