Debian Codegraph @

texmf-dist/doc/latex/fretplot/doc_fretplot.tex

raw
1 %% doc_fretplot.tex
2 %% fretplot v1.0.0
3 %% Copyright 2025 Soumendra Ganguly
4 %
5 % This work may be distributed and/or modified under the
6 % conditions of the LaTeX Project Public License, either version 1.3
7 % of this license or (at your option) any later version.
8 % The latest version of this license is in
9 % https://www.latex-project.org/lppl.txt
10 % and version 1.3c or later is part of all distributions of LaTeX
11 % version 2008 or later.
12 %
13 % This work has the LPPL maintenance status `author-maintained'.
14 %
15 % The Current Maintainer of this work is Soumendra Ganguly.
16 %
17 % This work consists of the files fretplot.sty, fretplot.lua,
18 % doc_fretplot.tex, doc_fretplot.pdf, README.md, and LICENSE.
19
20 %----------------------------------------------------------------------------
21 %% Batch generation of scale and chord diagrams for guitar-like instruments.|
22 %----------------------------------------------------------------------------
23
24 \documentclass[12pt,letterpaper]{article}
25 \usepackage{./fretplot}
26
27 \usepackage[letterpaper,top=1.5cm,bottom=1.5cm]{geometry} % Adjust 'bottom' as needed
28
29 \usepackage{tikz}
30 \usetikzlibrary{shapes.misc}
31 \newcommand*\circled[1]{\tikz[baseline=(char.base)]{ % \circled
32 \node[shape=circle,draw,inner sep=2pt] (char) {#1};}}
33
34 \usepackage{fancyhdr}
35 \pagestyle{fancy}
36 \fancyfoot[C]{\circled{\tiny\thepage}} % Center page number in footer
37 \fancyhead{} % Clear header
38 \renewcommand{\headrulewidth}{0pt} % Remove header line
39 \renewcommand{\footrulewidth}{0pt} % Remove footer line
40
41 \usepackage[colorlinks=true,linkcolor=blue,urlcolor=blue,citecolor=blue]{hyperref} % for links in TOC and web URLs
42 \usepackage{ulem} % for \uline
43 \usepackage{float} % for [H] placement specifier in tables and figures
44 \usepackage{caption} % for caption font size via \captionsetup
45
46 \usepackage{listings}
47 \usepackage{xcolor}
48
49 \lstdefinelanguage{fretplot}{
50 emph={include,flip,void},
51 morekeywords={onf0,sovf,zoom,rotn,numfrt,numstr,frets,strings,notes,barres,fx,sx,bx,nx,fl,sl,nl},
52 sensitive=true,
53 morecomment=[l]{\#}
54 }
55
56 \lstset{
57 keywordstyle=\color{blue}\bfseries,
58 emphstyle=\color{brown}\bfseries,
59 commentstyle=\color{purple},
60 backgroundcolor=\color{white},
61 numbers=left,
62 columns=flexible,
63 basicstyle=\scriptsize\ttfamily
64 }
65
66 % \newcommand{\fpdocexample}[1]{
67 % \captionsetup{font=scriptsize}
68
69 % \begin{minipage}[t]{0.65\textwidth}
70 % {\scriptsize \uline{Save source below as \texttt{include/#1/src.fp}:}}
71 % \lstinputlisting[language=fretplot]{include/#1/src.fp}
72
73 % {\scriptsize \uline{Run \texttt{lualatex --shell-escape #1.tex} after saving source below as \texttt{#1.tex} to get output on the right:}}
74 % \lstinputlisting[language={[LaTeX]TeX},emphstyle=]{include/#1/full.tex}
75 % \end{minipage}
76 % \hfill
77 % \begin{minipage}[t]{0.35\textwidth}
78 % \input{include/#1/body.tex}
79 % \end{minipage}
80
81 % \captionsetup{font=normalsize}
82 % }
83
84 \newcommand{\fpdocexample}[1]{
85 \captionsetup{font=scriptsize}
86
87 {\scriptsize \raisebox{1pt}{\bullet}\ Save source below as \texttt{\color{purple} proj/include/#1/src.fp}:}
88 \lstinputlisting[language=fretplot]{include/#1/src.fp}
89 {\scriptsize \raisebox{1pt}{\bullet}\ Save source below as \texttt{\color{purple} proj/#1.tex}:}
90 \lstinputlisting[language={[LaTeX]TeX},emphstyle=]{include/#1/full.tex}
91 {\scriptsize \raisebox{1pt}{\bullet}\ Run \texttt{\color{purple} lualatex\,\,\,--shell-escape\,\,\,#1.tex} in \texttt{\color{blue} proj/} to get the following output:}
92 \input{include/#1/body.tex}
93
94 \captionsetup{font=normalsize}
95 }
96
97 \title{The \texttt{fretplot} package\\\large Version 1.0.0}
98 \author{Author and maintainer: Soumendra Ganguly\\\href{https://soumendraganguly.com}{\texttt{soumendraganguly.com}}}
99 \date{Copyright 2025 Soumendra Ganguly}
100
101 \begin{document}
102 \maketitle
103 \thispagestyle{empty}
104 \tableofcontents
105
106 \newpage
107
108 \section{Introduction}
109
110 The \textit{fretplot} Lua\TeX\ package provides batch generation of scale and chord diagrams for plucked string instruments, such as the guitar.\\
111
112 It is designed for high flexibility, automation, and customization via simple yet powerful custom file formats for describing fretboard diagrams, which allow for easy batch generation of diagrams. To complement the high customizability, the package also comes with sensible yet attractive default settings for the diagrams.\\
113
114 The package also provides some easy-to-use \LaTeX\ macros that understand the underlying music theory, allowing one to render, for example, a guitar scale diagram by specifying the musical scale or scale type via built-in macros, or even more directly via degree, pitch class, or interval formulae.\\
115
116 The companion project \href{https://github.com/8vasu/fretplot-mcp}{\texttt{fretplot-mcp}} implements a Model Context Protocol (MCP) server that allows MCP clients to generate fretplot-specific code from natural language descriptions of musical scales and chord voicings.\\
117
118 The fretplot package was \href{https://publications.gutenberg-asso.fr/lettre/article/view/131}{\texttt{featured}} in \textit{La Lettre GUTenberg}.
119
120 \newpage
121
122 \section{\LaTeX\ macros}
123
124 This package defines the following user-facing macros:
125
126 \begin{itemize}
127 \item \verb|\fptotikz|
128 \item \verb|\fptemplate|
129 \item \verb|\fpstemplate|
130 \item \verb|\fpscale|
131 \end{itemize}
132
133 \subsection{\texttt{\textbackslash fptotikz}}
134
135 \begin{itemize}
136 \item[] \textbf{\color{blue} Syntax:} \texttt{\textbackslash fptotikz[OUTPUT\_TIKZ\_FILE]\{INPUT\_FP\_FILE\}}
137 \item[] \textbf{\color{blue} Description:} compile an input fretplot file to Ti\textit{k}Z.
138 \item[] \textbf{\color{blue} Arguments:}
139 \begin{itemize}
140 \item \texttt{INPUT\_FP\_FILE}: path to input fretplot file.
141 \item \texttt{OUTPUT\_TIKZ\_FILE} (optional): path to output file to which generated Ti\textit{k}Z will be written. If \texttt{OUTPUT\_TIKZ\_FILE} is not specified, then the output Ti\textit{k}Z code will be included inline at the location of the \texttt{\textbackslash fptotikz} invocation.
142 \end{itemize}
143 \end{itemize}
144
145 \subsection{\texttt{\textbackslash fptemplate}}
146
147 \begin{itemize}
148 \item[] \textbf{\color{blue} Syntax:} \texttt{\textbackslash fptemplate\{OUTPUT\_FP\_FILE\}}
149 \item[] \textbf{\color{blue} Description:} generate a template fretplot file.
150 \item[] \textbf{\color{blue} Arguments:} \texttt{OUTPUT\_FP\_FILE}: path to output fretplot file.
151 \end{itemize}
152
153 \subsection{\texttt{\textbackslash fpstemplate}}
154
155 \begin{itemize}
156 \item[] \textbf{\color{blue} Syntax:} \texttt{\textbackslash fpstemplate\{OUTPUT\_FPS\_FILE\}}
157 \item[] \textbf{\color{blue} Description:} generate a template fretplot scale style file.
158 \item[] \textbf{\color{blue} Arguments:} \texttt{OUTPUT\_FPS\_FILE}: path to output fretplot scale style file.
159 \end{itemize}
160
161 \subsection{\texttt{\textbackslash fpscale}}
162
163 \begin{itemize}
164 \item[] \textbf{\color{blue} Syntax:} \texttt{\textbackslash fpscale\{ARGS\}}
165 \item[] \textbf{\color{blue} Description:} render diagram of (mode of) scale based on input scale formula (degree, pitch class, or interval) or generate corresponding fretplot file or Ti\textit{k}Z code.
166 \item[] \textbf{\color{blue} Arguments:} \texttt{ARGS}: \texttt{|} and/or \texttt{|\textbackslash n}-delimited list (possibly empty) of named argument assignments of the form \texttt{key=value} (with no surrounding spaces) in any order. Some of the subsequent pages of this section contain 2 tables:
167 \begin{itemize}
168 \item A complete table of keys for \texttt{ARGS} and their respective default and possible values. If a key does not have a default value, then the corresponding entry in the table is empty.
169 \begin{itemize}
170 \item In the table, a \textit{pitch class} refers to any element of the set
171 \begin{center}
172 \texttt{\{C, C\#, D, Eb, E, F, F\#, G, Ab, A, Bb, B\}}.
173 \end{center}
174 \item In the table, a \textit{degree} is any element of the set
175 \begin{center}
176 \texttt{\{1, b2, 2, b3, 3, 4, b5, 5, b6, 6, b7, 7\}}.
177 \end{center}
178 \item In the table, an \textit{interval} is a positive integer representing the number of semitones in a musical interval.
179 \end{itemize}
180 \item A table containing a list of macros that expand to interval formulas for popular scale types.
181 \end{itemize}
182 \end{itemize}
183
184 \subsection{Examples}
185
186 Create a directory titled \texttt{proj}. Create subdirectories \texttt{proj/include} and \texttt{proj/tikz}. Create a file \texttt{proj/macro-demo.tex}. So your project directory structure is as follows:
187
188 \begin{verbatim}
189 proj/
190 |-- include/
191 |-- tikz/
192 |-- macro-demo.tex
193 \end{verbatim}
194
195 Copy the following code into \texttt{proj/macro-demo.tex}:
196
197 \lstinputlisting[language={[LaTeX]TeX},emphstyle=]{include/macro-demo/full.tex}
198
199 Run the following command in \texttt{proj/} to compile \texttt{proj/macro-demo.tex}: \begin{center}\texttt{lualatex --shell-escape macro-demo.tex}\end{center}
200
201 You should get the following output in the compiled PDF file \texttt{proj/macro-demo.pdf}:
202
203 \input{include/macro-demo/body.tex}
204
205 Play around with the generated files \texttt{proj/include/sclinclude.fp} and\\\texttt{proj/include/styles.fps} to customize the B Dorian figure. You can also edit the generated Ti\textit{k}Z code \texttt{proj/tikz/sclinclude.tex} directly.
206
207 % Old experiments:
208 %------------------
209
210 % \usetikzlibrary{external}
211 % \tikzexternalize % activate
212 % \tikzsetexternalprefix{figures/}
213
214 % 1 newline allowed immediately after |
215
216 % \begingroup
217 % \catcode`\#=11
218 % \directlua{
219 % fretplot.scale_i([[A]], [[2 2 1 2 2 2 1]], [[E B G D A E]], 12, [[d]], [[d]], [[styles.fps]], [[sclnote.fp]], [[sclinclude.fp]])
220 % }
221 % \endgroup
222
223 % \scl{root=A|formulatype=d|formula=1 2 3 4 5 6 7|
224 % tuning=E B G D A E|numfrets=12|styletype=d|
225 % labeltype=d|stylefile=styles.fps|outfpfile=sclnote.fp|
226 % includefile=sclinclude.fp}
227
228 % \fretplot{sclnote.fp}
229
230 % \input{oout.tex}
231
232 % \scl{root=A|formulatype=d|formula=1 2 3 4 5 6 7|
233 % tuning=E B G D A E|numfrets=12|styletype=d|
234 % labeltype=d|stylefile=styles.fps|outtikzfile=oo.tex|
235 % includefile=sclinclude.fp}
236
237 % \input{oo.tex}
238
239 % \begin{figure}[H]
240 % \centering
241 % \begin{minipage}{0.5\textwidth}
242 % \fbox{\fretplot{template.fp}}
243 % \end{minipage}
244 % \begin{minipage}{0.5\textwidth}
245 % \fbox{\scl{root=A|formulatype=d|formula=1 b2 2 b3 3 4 b5 5 b6 6 b7 7|
246 % tuning=E B G D A E|numfrets=12|styletype=p|
247 % labeltype=p|stylefile=styles.fps|
248 % includefile=sclinclude.fp}}
249 % \end{minipage}
250 % \end{figure}
251
252 % \begin{figure}[h]
253 % \hspace{-0.5in}
254 % \begin{minipage}{0.4\textwidth}
255 % \fbox{\fretplot{testtemplate.fp}}
256 % \caption{A major triad barre chord}
257 % \end{minipage}
258 % \hspace{1.2in}
259 % \begin{minipage}{0.4\textwidth}
260 % \fbox{\fretplot{testtemplate.fp}}
261 % \caption{A major triad barre chord}
262 % \end{minipage}
263 % \end{figure}
264
265 \subsection{Tables}
266
267 \begin{table}[H]\tiny\begin{tabular}{|l|l|p{8cm}|}
268 \hline
269
270 &&\\
271 KEY & DEFAULT VALUE & VALUE\\
272 &&\\
273
274 \hline
275
276 &&\\
277 \texttt{parentroot} & \texttt{C} & Root of parent scale. This can be any pitch class. This is ignored if \texttt{formulatype=p} or if \texttt{moderoot} is specified. Please see the description of \texttt{mode} for more details.\\
278 &&\\
279
280 \hline
281
282 &&\\
283 \texttt{formulatype} & \texttt{d} & Type of the formula specified in the key named \texttt{formula}. Possible values are \texttt{\{d, p, i\}}. Here \texttt{d} stands for \textit{degree}, \texttt{p} stands for \textit{pitch class}, and \texttt{i} stands for \textit{interval}.\\
284 &&\\
285
286 \hline
287
288 &&\\
289 \texttt{formula} & \texttt{1 2 3 4 5 6 7} & Formula of parent scale. This should be a list of degrees or pitch classes or intervals delimited by single ordinary space characters (ASCII 32). The type of this formula is indicated by specifying \texttt{formulatype}.\\
290 &&\\
291
292 \hline
293
294 &&\\
295 \texttt{mode} & \texttt{1} & Mode index of scale. This is specified as a positive integer. This mode will be rendered by \texttt{\textbackslash fpscale}. Examples: if \texttt{formulatype=p}, \texttt{formula=C D E F G A B}, and \texttt{mode=3}, then the 3rd mode of the C major scale (E Phrygian) will be rendered. If \texttt{formulatype=d}, \texttt{formula=1 2 3 4 5 6 7}, \texttt{mode=2}, \texttt{parentroot=A}, and \texttt{moderoot} is not specified, then the 2nd mode of the A major scale (which is B Dorian) will be rendered. In the above scenario, if \texttt{moderoot=A}, then A Dorian will be rendered instead.\\
296 &&\\
297
298 \hline
299
300 &&\\
301 \texttt{moderoot} & & Optional root of mode of scale. This can be any pitch class. This is ignored if \texttt{formulatype=p}. Please see the description of \texttt{mode} for more details.\\
302 &&\\
303
304 \hline
305
306 &&\\
307 \texttt{tuning} & \texttt{E B G D A E} & Tuning of strings of the instrument. This is specified as a list of pitch classes delimited by single ordinary space characters (ASCII 32).\\
308 &&\\
309
310 \hline
311
312 &&\\
313 \texttt{numfrets} & \texttt{12} & Number of frets on the fingerboard. If the instrument does not have frets, then one can style them to be transparent in the render.\\
314 &&\\
315
316 \hline
317
318 &&\\
319 \texttt{styletype} & \texttt{d} & Specify if the styling of notes should be degree-indexed or pitch class-indexed. Possible values are \texttt{\{d, p\}}. Here \texttt{d} stands for \textit{degree} and \texttt{p} stands for \textit{pitch class}. The user can customize the actual styles by specifying the key \texttt{scalestylefile}.\\
320 &&\\
321
322 \hline
323
324 &&\\
325 \texttt{labeltype} & \texttt{d} & Specify if the labelling of notes should be degree-indexed or pitch class-indexed. Possible values are \texttt{\{d, p\}}. Here \texttt{d} stands for \textit{degree} and \texttt{p} stands for \textit{pitch class}. The user can customize the actual labels by specifying the key \texttt{scalestylefile}.\\
326 &&\\
327
328 \hline
329
330 &&\\
331 \texttt{outfpfile} & & Optional path to output fretplot file describing (mode of) scale. If this is specified, then no Ti\textit{k}Z code will be generated by \texttt{\textbackslash fpscale} (neither inline nor to \texttt{outtikzfile}). One can then make modifications to the output fretplot file and then generate Ti\textit{k}Z code (inline or external file) from the fretplot file using \texttt{\textbackslash fptotikz}. The keys \texttt{includefpfile} and \texttt{scalestylefile} are used to further customize the rendering. In particular, \texttt{includefpfile} is included at the end of \texttt{outfpfile}. Even if \texttt{outfpfile} is not specified, \texttt{\textbackslash fpscale} still internally creates a temporary fretplot file which is then converted to Ti\textit{k}Z. This temporary fretplot file also includes \texttt{includefpfile} at its end, which allows one to customize their render via \texttt{includefpfile} without specifying \texttt{outfpfile}. The same fretplot file can serve as the \texttt{includefpfile} for multiple \texttt{\textbackslash fpscale} invocations, which allows for batch manipulation of scale plots. Temporary fretplot files created by \texttt{\textbackslash fpscale} internally are deleted later automatically.\\
332 &&\\
333
334 \hline
335
336 &&\\
337 \texttt{outtikzfile} & & Optional path to output file containing Ti\textit{k}Z code describing (mode of) scale. This will be ignored if \texttt{outfpfile} is specified. If \texttt{outfpfile} is not specified and \texttt{outtikzfile} is specified, then \texttt{\textbackslash fpscale} will not generate inline Ti\textit{k}Z code. One can then make modifications to the output Ti\textit{k}Z code and use \texttt{\textbackslash input} to use it in their document.\\
338 &&\\
339
340 \hline
341
342 &&\\
343 \texttt{includefpfile} & & Optional path to input fretplot file to be included at the end of \texttt{outfpfile} or an equivalent temporary fretplot file created by \texttt{\textbackslash fpscale} for internal use. If there does not exist a file at the path specified by \texttt{includefpfile}, then a new empty file will be created at that path; one can then edit this new file for use in subsequent compilations. For more details, please see \texttt{outfpfile}.\\
344 &&\\
345
346 \hline
347
348 &&\\
349 \texttt{scalestylefile} & & Optional path to input fretplot scale style file. This can be used to customize degree and/or pitch class-based styling and labelling for scale notes. Please see \texttt{styletype} and \texttt{labeltype} for additional details.\\
350 &&\\
351
352 \hline
353 \end{tabular}\caption{Key-value pairs for \texttt{\textbackslash fpscale}}\end{table}
354 \normalsize
355
356 \begin{table}[H]\tiny\begin{tabular}{|l|l|l|}
357 \hline
358
359 &&\\
360 MACRO & INTERVAL FORMULA IN SEMITONES & DESCRIPTION\\
361 &&\\
362
363 \hline
364
365 &&\\
366 \texttt{\textbackslash fpmpent} & 3 2 2 3 2 & Minor pentatonic scale\\
367 \texttt{\textbackslash fpblues} & 3 2 1 1 3 2 & Blues scale\\
368 &&\\
369
370 \hline
371
372 &&\\
373 \texttt{\textbackslash fpmaj} & 2 2 1 2 2 2 1 & Major scale\\
374 \texttt{\textbackslash fpjmin} & 2 1 2 2 2 2 1 & Jazz minor scale (ascending melodic minor scale)\\
375 \texttt{\textbackslash fphmin} & 2 1 2 2 1 3 1 & Harmonic minor scale\\
376 &&\\
377
378 \hline
379
380 &&\\
381 \texttt{\textbackslash fphmaj} & 2 2 1 2 1 3 1 & Harmonic major scale\\
382 \texttt{\textbackslash fpdhmaj} & 1 3 1 2 1 3 1 & Double harmonic major scale\\
383 \texttt{\textbackslash fpnmaj} & 1 2 2 2 2 2 1 & Neapolitan major scale\\
384 \texttt{\textbackslash fpnmin} & 1 2 2 2 1 3 1 & Neapolitan minor scale\\
385 \texttt{\textbackslash fphunmaj} & 3 1 2 1 2 1 2 & Hungarian major scale\\
386 &&\\
387
388 \hline
389
390 &&\\
391 \texttt{\textbackslash fpbmaj} & 2 2 1 2 1 1 2 1 & Bebop major scale\\
392 \texttt{\textbackslash fpbmin} & 2 1 2 2 2 1 1 1 & Bebop minor scale\\
393 \texttt{\textbackslash fpbdom} & 2 2 1 2 2 1 1 1 & Bebop dominant scale\\
394 \texttt{\textbackslash fpldbeb} & 2 2 2 1 2 1 1 1 & Lydian dominant bebop scale\\
395 \texttt{\textbackslash fppdbeb} & 1 3 1 2 1 2 1 1 & Phrygian dominant bebop scale\\
396 &&\\
397
398 \hline
399
400 &&\\
401 \texttt{\textbackslash fpchr} & 1 1 1 1 1 1 1 1 1 1 1 1 & Chromatic scale\\
402 \texttt{\textbackslash fpwt} & 2 2 2 2 2 2 & Whole tone scale\\
403 \texttt{\textbackslash fptwowt} & 4 4 4 & Two whole tones scale\\
404 \texttt{\textbackslash fpthreewt} & 6 6 & Three whole tones scale\\
405 \texttt{\textbackslash fpmon} & 12 & Monotonic scale\\
406 &&\\
407
408 \hline
409
410 &&\\
411 \texttt{\textbackslash fpaug} & 3 1 3 1 3 1 & Augmented scale\\
412 \texttt{\textbackslash fptrit} & 1 3 2 1 3 2 & Tritone scale\\
413 \texttt{\textbackslash fpwhdim} & 2 1 2 1 2 1 2 1 & Whole half diminished scale\\
414 &&\\
415
416 \hline
417
418 &&\\
419 \texttt{\textbackslash fpmajsevenarp} & 4 3 4 1 & Major seventh arpeggio\\
420 \texttt{\textbackslash fpdomsevenarp} & 4 3 3 2 & Dominant seventh arpeggio\\
421 \texttt{\textbackslash fpminsevenarp} & 3 4 3 2 & Minor seventh arpeggio\\
422 \texttt{\textbackslash fphdimsevenarp} & 3 3 4 2 & Half diminished seventh arpeggio\\
423 \texttt{\textbackslash fpdimsevenarp} & 3 3 3 3 & Diminished seventh arpeggio\\
424 \texttt{\textbackslash fpminmajsevenarp} & 3 4 4 1 & Minor major seventh arpeggio\\
425 &&\\
426
427 \hline
428 \end{tabular}\caption{Macros for interval formulae of popular scale types}\end{table}
429 \normalsize
430
431 \newpage
432
433 \section{The fretplot file format}
434
435 A \textit{fretplot file}, \textit{fp file}, or \texttt{.fp} file describes the layout and appearance of a fretboard diagram.
436
437 \subsection{Syntax}
438
439 \begin{itemize}
440 \item Comment lines start with \texttt{\#}. Comment lines and empty lines are ignored.
441 \item Every other line of a fretplot file will have lines of form \texttt{firstword lots of data}, where \texttt{firstword} and \texttt{lots of data} must be separated by a single ordinary space character (ASCII 32), \texttt{lots of data} cannot be empty, and the first character of \texttt{lots of data} cannot be a whitespace character (space, tab, newline, or anything that matches \texttt{\%s} in Lua).
442 \item
443 \begin{itemize}
444 \item Note notation: \texttt{<STRINGINDEX,FRETINDEX>}\\Example: \texttt{<6,5>}
445
446 \item Barre notation: \texttt{<STARTSTRINGINDEX-ENDSTRINGINDEX,FRETINDEX>}\\Example: \texttt{<1-6,5>}
447 \end{itemize}
448 \item Barres never have labels. Frets, strings, and notes by default have no labels, but can be specified as follows:
449 \begin{itemize}
450 \item Frets: \texttt{flFRETINDEX LABEL}\\Example: \texttt{fl3 3}
451 \item Strings: \texttt{slSTRINGINDEX LABEL}\\Example: \texttt{sl1 \{\textbackslash Large e\}}
452 \item Notes: \texttt{nl<STRINGINDEX,FRETINDEX> LABEL}\\Example: \texttt{nl<6,5> \{\textbackslash Large A\}}
453 \end{itemize}
454 \item To include another fretplot file at the current location of a fretplot file, use \texttt{include FILEPATH}.
455 \end{itemize}
456
457 \subsection{Parameters}
458
459 All available parameters that can be used in a fretplot file are listed in the table on the next page. Operations are case-sensitive and must be written exactly as shown.
460
461 \begin{table}[H]\tiny\hspace{-2.5cm}\begin{tabular}{|l|p{1.5cm}|l|p{2.5cm}|p{1pt}|l|p{2.5cm}|l|}
462 \hline
463
464 &&&&&&&\\
465 TYPE & POSSIBLE VALUES & OPERATIONS & OP DESCRIPTION & & PARAMETERS & PARAM DESC & DEFAULT PARAM VALUE\\
466 &&&&&&&\\
467
468 \hline
469
470 &&&&&&&\\
471 Boolean & \texttt{True}, \texttt{False} & \texttt{flip PARAMETER} & negate Boolean parameter named \texttt{PARAMETER} & & \texttt{onf0} & draw notes directly on top of fret 0 (nut of guitar) if \texttt{True} and not if \texttt{False}&\texttt{False}\\
472 &&&&&&&\\
473 \cline{6-8}
474 &&&&&&&\\
475 &&&&&\texttt{sovf}& draw strings over frets if \texttt{True} and frets over strings if \texttt{False}&\texttt{True}\\
476 &&&&&&&\\
477
478 \hline
479
480 &&&&&&&\\
481 &&\texttt{+PARAMETER VALUE} & add literal numerical value \texttt{VALUE} to numerical parameter named \texttt{PARAMETER}&&&&\\
482 &&&&&&&\\
483 \cline{3-4}
484 &&&&&&&\\
485 &&\texttt{-PARAMETER VALUE} & subtract literal numerical value \texttt{VALUE} from numerical parameter named \texttt{PARAMETER}&&&&\\
486 &&&&&\texttt{zoom}&Factor by which the diagram will be scaled&\texttt{1.0}\\
487 \cline{3-4}
488 &&&&&&&\\
489 \cline{6-8}
490 Numerical & Any numerical value & \texttt{*PARAMETER VALUE} & multiply numerical parameter named \texttt{PARAMETER} by literal numerical value \texttt{VALUE}&&&&\\
491 &&&&&\texttt{rotn}&Angle (in degrees) by which the diagram will be rotated &\texttt{0}\\
492 \cline{3-4}
493 &&&&&&&\\
494 \cline{6-8}
495 &&\texttt{/PARAMETER VALUE} & divide numerical parameter named \texttt{PARAMETER} by literal numerical value \texttt{VALUE}&&&&\\
496 &&&&&\texttt{numfrt}& Number of frets &\texttt{12}\\
497 \cline{3-4}
498 &&&&&&&\\
499 \cline{6-8}
500 &&\texttt{\%PARAMETER VALUE} & mod numerical parameter named \texttt{PARAMETER} by literal numerical value \texttt{VALUE}&&&&\\
501 &&&&&\texttt{numstr}& Number of strings &\texttt{6}\\
502 \cline{3-4}
503 &&&&&&&\\
504 &&\texttt{\textasciicircum PARAMETER VALUE} & raise numerical parameter named \texttt{PARAMETER} to the power of literal numerical value \texttt{VALUE}&&&&\\
505 &&&&&&&\\
506
507 \hline
508
509 &&&&&&&\\
510 &&&&&\texttt{frets}&List of fret indices&\texttt{0 1 2 3 4 5 6 7 8 9 10 11 12}\\
511 &&&&&&&\\
512 \cline{6-8}
513 && \texttt{void PARAMETER} & empty the list parameter named \texttt{PARAMETER}&&&&\\
514 &&&&&&&\\
515 \cline{3-4}
516 &&&&&\texttt{strings}&List of string indices&\texttt{1 2 3 4 5 6}\\
517 &&&&&&&\\
518 \cline{6-8}
519 List& List of items delimited by single ordinary space characters (ASCII 32), or the \textit{empty list} &\texttt{>PARAMETER VALUE} & extend list parameter named \texttt{PARAMETER} by literal list value \texttt{VALUE}&&&&\\
520 \cline{3-4}
521 &&&&&\texttt{notes}&List of notes &empty list\\
522 &&&&&&&\\
523 \cline{6-8}
524 &&\texttt{<PARAMETER VALUE} & remove values in literal list value \texttt{VALUE} from list parameter named \texttt{PARAMETER}&&&&\\
525 &&&&&&&\\
526 &&&&&\texttt{barres}& List of barres &empty list\\
527 &&&&&&&\\
528
529 \hline
530
531 &&&&&&&\\
532 &&&&&\texttt{fx}&Fret style&\texttt{solid,line width=0.6,color=black}\\
533 &&&&&&&\\
534 \cline{6-8}
535 &&&&&&&\\
536 &&&&&\texttt{sx}&String style &\texttt{solid,line width=0.6,color=black}\\
537 &&&&&&&\\
538 \cline{6-8}
539 &&&&&&&\\
540 Style& List of PGF/Ti\textit{k}Z styles delimited by single \texttt{,} (comma) characters &\texttt{\&PARAMETER VALUE} & extend style parameter named \texttt{PARAMETER} by literal comma-delimited collection of styles \texttt{VALUE}&&&&\\
541 &&&&&&&\\
542 &&&&&\texttt{bx}&Barre style &\texttt{fill=black,draw=black}\\
543 &&&&&&&\\
544 \cline{6-8}
545 &&&&&&&\\
546 &&&&&\texttt{nx}& Note style &\texttt{shape=rectangle,draw=black,text=white,fill=black}\\
547 &&&&&&&\\
548
549 \hline
550 \end{tabular}\caption{Parameters for fretplot files}\end{table}
551 \normalsize
552
553 \subsection{Batch processing using operations on parameters}
554
555 The operations are particularly useful for batch manipulation of diagrams.\\
556
557 For example, say, you are writing a book containing 100 chord diagrams. Each of those diagrams is described using its own fretplot file. Now you want to scale/enlarge each of them to 1.5 times of their respective original sizes, and additionally you want to rotate all of them by 30 degrees.\\
558
559 To do this, in each of those 100 fretplot files you can include another common fretplot file, say, \texttt{common.fp} by writing \texttt{include common.fp} \textit{at the end} of all of those 100 fretplot files, and then in \texttt{common.fp} you can write the following two lines:\\
560
561 \begin{lstlisting}[language=fretplot]
562 +rotn 30
563 *zoom 1.5
564 \end{lstlisting}
565
566 This will rotate all those 100 diagrams by 30 degrees and zoom in by a factor of 1.5, without you having to edit each of those 100 files individually.\\
567
568 \textit{Please note} that lines in a fretplot file are interpreted sequentially, so the location where you write \texttt{include common.fp} in a fretplot file matters due to non-commutativity of certain operations. For instance, if the parameter \texttt{rotn} was \texttt{10} and you wanted to multiply it by \texttt{2} and subtract \texttt{5} from it, the order in which you performed those operations would matter.\\
569
570 The following is an example fretplot file that demonstrates the use of some parameters and some operations on them:\\
571
572 \lstinputlisting[language=fretplot]{include/operations-demo.fp}
573
574 \subsection{Example: barre chord diagram}
575
576 \fpdocexample{amaj}
577
578 \subsection{Example: fretless guitar diagram}
579
580 \fpdocexample{fretless}
581
582 \subsection{Example: custom instrument diagram}
583
584 \fpdocexample{custom-instrument}
585
586 \newpage
587
588 \section{The fretplot scale style file format}
589
590 A \textit{fretplot scale style file}, \textit{fps file}, or \texttt{.fps} file customizes the appearance and labels of notes in a scale, based on pitch class or degree.
591
592 \subsection{Syntax}
593
594 \begin{itemize}
595 \item A \textit{pitch class} is any element of the set
596
597 \begin{center}
598 \texttt{\{C, C\#, D, Eb, E, F, F\#, G, Ab, A, Bb, B\}}.
599 \end{center}
600 \item A \textit{degree} is any element of the set
601
602 \begin{center}
603 \texttt{\{1, b2, 2, b3, 3, 4, b5, 5, b6, 6, b7, 7\}}.
604 \end{center}
605
606 \item Each line assigns a style or label to a pitch class or degree:
607
608 \begin{itemize}
609 \item Label based on pitch class: \texttt{lPITCHCLASS LABEL}.
610 \item Label based on degree: \texttt{lDEGREE LABEL}.
611 \item PGF/Ti\textit{k}Z style based on pitch class: \texttt{xPITCHCLASS STYLE}.
612 \item PGF/Ti\textit{k}Z style based on degree: \texttt{xDEGREE STYLE}.
613 \end{itemize}
614 \end{itemize}
615
616 \subsection{An example}
617
618 \begin{lstlisting}[commentstyle=]
619 lC {\scriptsize C}
620 lC# {\tiny C$\sharp$}
621 lD {\scriptsize D}
622 lEb {\tiny E$\flat$}
623
624 xC shape=circle,draw=red,text=blue,fill=white,inner sep=1.0
625 xC# shape=circle,draw=red,text=blue,fill=white,inner sep=1.0
626
627 l1 {\scriptsize 1}
628 lb2 {\tiny $\flat$2}
629
630 x1 shape=circle,draw=red,text=white,fill=red,inner sep=1.0
631 xb2 shape=circle,draw=red,text=blue,fill=white,inner sep=1.0
632 \end{lstlisting}
633 \end{document}