diff options
author | Karl Berry <karl@freefriends.org> | 2018-12-28 21:31:34 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2018-12-28 21:31:34 +0000 |
commit | f9c2c75c303e6995bd74abb76d37714d93eea864 (patch) | |
tree | 66435772b0d9baab54382c35086795550236f6c7 /Master/texmf-dist | |
parent | f8d62222fa38aff4e9606623b1f41bea14dbf643 (diff) |
chordbars (28dec18)
git-svn-id: svn://tug.org/texlive/trunk@49512 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist')
-rw-r--r-- | Master/texmf-dist/doc/latex/chordbars/README.md | 13 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/chordbars/chordbars_manual.pdf | bin | 0 -> 180419 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/latex/chordbars/chordbars_manual.tex | 218 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/chordbars/listing_HOTRS.lst | 6 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/chordbars/listing_RBP.lst | 5 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/chordbars/listing_blues.lst | 8 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/chordbars/listing_sharp_flat.lst | 6 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/chordbars/chordbars.sty | 306 |
8 files changed, 562 insertions, 0 deletions
diff --git a/Master/texmf-dist/doc/latex/chordbars/README.md b/Master/texmf-dist/doc/latex/chordbars/README.md new file mode 100644 index 00000000000..1d6c963cf68 --- /dev/null +++ b/Master/texmf-dist/doc/latex/chordbars/README.md @@ -0,0 +1,13 @@ +# chordbars +A music-related LaTeX package usful to write chord grids. + +From a given chord progression (a harmonic pattern), it draws nice rectangles (1 square per bar) with the chord name inside, and shows the number of repetitions and the bar count. +For details, see included manual. + + +Author: S. Kramm - 2018 + +Licence: The LaTeX project public license (LPPL), version 1.3c + + + diff --git a/Master/texmf-dist/doc/latex/chordbars/chordbars_manual.pdf b/Master/texmf-dist/doc/latex/chordbars/chordbars_manual.pdf Binary files differnew file mode 100644 index 00000000000..a7d1875f385 --- /dev/null +++ b/Master/texmf-dist/doc/latex/chordbars/chordbars_manual.pdf diff --git a/Master/texmf-dist/doc/latex/chordbars/chordbars_manual.tex b/Master/texmf-dist/doc/latex/chordbars/chordbars_manual.tex new file mode 100644 index 00000000000..35b6b9e1f1a --- /dev/null +++ b/Master/texmf-dist/doc/latex/chordbars/chordbars_manual.tex @@ -0,0 +1,218 @@ +%% chordbars_manual.tex +%% Copyright 2018 M. Sebastien Kramm +% +% 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 M. Sebastien Kramm +% +% This work consists of the files chordbars.sty and chordbars_manual.tex + +% Home page: https://github.com/skramm/chordbars + +\documentclass[11pt]{article} +\usepackage[utf8]{inputenc} +\usepackage{hyperref} +\usepackage[left=2.00cm,vmargin=1cm]{geometry} +\usepackage{mathcomp} % for \textdiscount +\usepackage{listings} + +\lstset{ + frame=single + ,language=TeX + ,basicstyle=\ttfamily + ,escapechar=\* +} +\usepackage{chordbars} + +% Bold + tt +\newcommand{\btt}{\bfseries \ttfamily } + +% shorthand +\newcommand{\tbs}{\textbackslash{}} + + +\title{The chordbars Package} +\author{S. Kramm} +\date{\today - release 1.0} +\begin{document} +\maketitle + +\begin{abstract} +This Tikz-based musical notation related package is targeted at guitar / bass / piano / whatever players that are playing "popular music" accompaniment. +They usually need only the chords and the song structure. +This package produces rectangular song patterns with "1 square per bar", with the chord shown inside the square. +It also handles the song structure by showing the bar count, and the repetitions of the patterns. +\end{abstract} + +Package home page: \url{https://github.com/skramm/chordbars} + +\section{Motivation} + +This type of acompaniment notation is used when you don't need the melody, but you do need the exact chord and bar count. +In that case, the full musical sheet is useless, although it can be used to print the chords. +So some people like to write down the requested song/chord structure in a graphical view (see below). +To produce these, some people use GUI software such as word processors, but this has a lot of drawbacks. +The aim of this package is to have a \LaTeX way of producing these, with minimal effort. + + +\section{Usage} +This package provides a single environnment, named {\ttfamily chordbar}, that has 2 mandatory arguments. +The first argument is the number of bars, and the second is the pattern name. +The latter one can be empty. +Inside this environment, you can use several commands, the most basic one is +\verb|\chordf| (for "Chord Full bar") that has as unique argument the chord name. +This argument will just be printed out "as is", usually something like "Cm7", Db9, FMaj7", etc. + +For example, the classical 12-bar blues progression will be written as: + +\lstinputlisting{listing_blues.lst} + + +This will be rendered as: + +\input{listing_blues.lst} + +As usual, spaces and line-feeds are ignored. + +The default behavior is to have 4-bars long lines, but you can change this anytime with the command + +\begin{lstlisting} +\def\NumberOfBarsPerLine{3} +\end{lstlisting} + +This will print out the same 12-bars blues as above, but printed out in a rather awkward view with 6 bars per line\footnote{Don't do this, of course!}. + +\def\NumberOfBarsPerLine{6} +\input{listing_blues.lst} + +This package can also be used to print out the song structure, by showing the number of repetitions of each part and by counting the bars. +The number of repetitions of the part can be given as an optional argument to the environment. +To enable this, you need to activate this option, with this inserted after the \verb!\begin{document}! : + +\begin{lstlisting} +\countbarsYes +\end{lstlisting} + +Then, this: +\lstinputlisting{listingA.lst} + +will give the following output, correctly printing out '13' as the initial bar number of the second part (part 1 is 4 bars long and is repeated 3 times). + +\def\NumberOfBarsPerLine{4} +\resetchordbars +\countbarsYes +%\mbox{ +\input{listingA.lst} +%} + +\paragraph{Two chords per bar.} +The command \verb|\chordh| enables printing two chords per bar, as this happens quite often. +Its two arguments are the two chords of the bar. +For example, the well-know tune "House of the Rising Sun"\footnote{The Animals} chord structure can be printed as this: + +\lstinputlisting{listing_HOTRS.lst} + +This will be rendered as: +\resetchordbars +\countbarsNo +\input{listing_HOTRS.lst} + +\paragraph{Sharps and flats.} If you know \LaTeX, you may know that the {\btt \#} character is a "reserved character" and as such you should'nt be able to use it inside your source file. +However a special trick has been used here so you can directly type {\btt \tbs chordf\{C\#\}}. + +Warning: this {\bf may} lead to some problems in "some" situations, that are not yet clearly identified\footnote{See \url{https://tex.stackexchange.com/a/467566/11083} for details.}. +If you encounter an issue, please report it on the home page of this package and post an MCVE\footnote{Minimal, Complete, and Verifiable Example}. + +The alternate solution is either to escape the \# or to use the {\btt \tbs sharp} and {\btt \tbs flat} symbols, that have been "textified" so you don't need to enter math mode. +This has the advantage of being also a bit "prettier", although maybe less readable (?). +You can see below the compared renderings of the two alternatives: + +\vspace{1em} + +\noindent +\begin{minipage}{0.54\textwidth} +\lstinputlisting{listing_sharp_flat.lst} +\end{minipage} +% +\begin{minipage}{0.42\textwidth} +\input{listing_sharp_flat.lst} +\end{minipage} + +\section{Configuration} + +Several commands allow to customize the way the grids are printed out. + +\begin{itemize} + +\item The size of the grids can be adjusted with the internal variable +{\btt \tbs barsize}. +The default value is 1.6, but you can adjust it anytime inside your document, for example with:\\ +{\btt \tbs def\tbs barsize\{1.8\}} + +The font size is at present fixed. + +\item The command {\btt \tbs countbarsYes} enables counting the bars of the song: +each grid will have printed on the left side the number of the first bar of the grid. +It also enables printing the number of repetitions of this part on the right side of the grid. + +This command is useful in the sense that this package can be used in two ways: +it can provide the whole structure of a song. +In that case, it is useful to have for each part the number of repetitions and the bar count, so that when the band leader says "lets start again at bar 75", everybody can find it easily. + +On the other side, this package can be used also to provide a quick way to show the harmony of the different parts, without any structure or bar count. +This, printing the bar number becomes useless. + +To stop this behaviour (anytime), the command is {\btt \tbs countbarsNo}. + +\item Additionaly, if the above command is issued, then the package can compute the total number of bars and the duration of the song. +This is done by issuing the command {\btt \tbs printNbBars} at the end of the file. +The duration of the song depends on both the {\em tempo} of the song, expressed in BPM, and the number of beats per bar. +The latter can be given with the command {\btt \tbs bpm}, for example: +{\btt \tbs bpm\{120\}}. + +The number of beats per bar is limited at present at two values, 3 or 4, with the two commands +{\btt \tbs bpbfour} or {\btt \tbs bpbthree}. +The default value is 4 beats per bar. + +\item As you have seen above, the command {\btt \tbs repeatBar} will be rendered as \textdiscount{} and means "repeat last chord". +In some situations, it can be useful to show a repetitions spanning two bars. +Fo this you can use {\btt \tbs repeatBarPair}. +For example, see the source below showing a classical II/V-I pattern played twice and its rendering: + +\noindent +\begin{minipage}{0.45\textwidth} +\lstinputlisting{listing_RBP.lst} +\end{minipage} +% +\begin{minipage}{0.42\textwidth} +\input{listing_RBP.lst} +\end{minipage} + + + +%\end{itemize} + +%\section{Additional commands} + +%Besides the commands that can be used inside the chordbar environment, this package provides the following commands: + +%\begin{itemize} +\item {\ttfamily \textbackslash resetchordbars}: this will reset the bar and part counters, useful if you want to print two songs in the same document. +\end{itemize} + + +\section{Reference} + +This section is useful for those who want to contribute or expand this package. + +(TO BE EXPANDED) + +\end{document} diff --git a/Master/texmf-dist/doc/latex/chordbars/listing_HOTRS.lst b/Master/texmf-dist/doc/latex/chordbars/listing_HOTRS.lst new file mode 100644 index 00000000000..d16edc4c198 --- /dev/null +++ b/Master/texmf-dist/doc/latex/chordbars/listing_HOTRS.lst @@ -0,0 +1,6 @@ +\begin{chordbar}{4}{House of the Rising sun} +\chordh{Am}{C} +\chordh{D}{F} +\chordh{Am}{E} +\repeatBar +\end{chordbar} diff --git a/Master/texmf-dist/doc/latex/chordbars/listing_RBP.lst b/Master/texmf-dist/doc/latex/chordbars/listing_RBP.lst new file mode 100644 index 00000000000..8db632b0462 --- /dev/null +++ b/Master/texmf-dist/doc/latex/chordbars/listing_RBP.lst @@ -0,0 +1,5 @@ +\begin{chordbar}{4}{} +\chordh{G}{C7} +\chordf{FMaj7} +\repeatBarPair +\end{chordbar} diff --git a/Master/texmf-dist/doc/latex/chordbars/listing_blues.lst b/Master/texmf-dist/doc/latex/chordbars/listing_blues.lst new file mode 100644 index 00000000000..bfb1ba80c59 --- /dev/null +++ b/Master/texmf-dist/doc/latex/chordbars/listing_blues.lst @@ -0,0 +1,8 @@ +\begin{chordbar}{12}{Classical 12 bar E blues} +\chordf{E} \chordf{A} +\chordf{E} \repeatBar +\chordf{A} \repeatBar +\chordf{E} \repeatBar +\chordf{B} \chordf{A} +\chordf{E} \chordf{B} +\end{chordbar} diff --git a/Master/texmf-dist/doc/latex/chordbars/listing_sharp_flat.lst b/Master/texmf-dist/doc/latex/chordbars/listing_sharp_flat.lst new file mode 100644 index 00000000000..c8777e3a29b --- /dev/null +++ b/Master/texmf-dist/doc/latex/chordbars/listing_sharp_flat.lst @@ -0,0 +1,6 @@ +\begin{chordbar}{4}{Sharps and flats} +\chordf{E#} +\chordf{E\sharp} +\chordf{Eb} +\chordf{E\flat} +\end{chordbar} diff --git a/Master/texmf-dist/tex/latex/chordbars/chordbars.sty b/Master/texmf-dist/tex/latex/chordbars/chordbars.sty new file mode 100644 index 00000000000..13e4f49642b --- /dev/null +++ b/Master/texmf-dist/tex/latex/chordbars/chordbars.sty @@ -0,0 +1,306 @@ +%% chordbars.sty +%% Copyright 2018 M. Sebastien Kramm +% +% 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 M. Sebastien Kramm +% +% This work consists of the files chordbars.sty and chordbars_manual.tex + +% Home page: https://github.com/skramm/chordbars + +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{chordbars}[2017-12-28 version 1.0] + +\RequirePackage{tikz} +\RequirePackage{pgfmath} +\RequirePackage{tkz-euclide} + +\usetikzlibrary{math,shapes} + +\RequirePackage{calc} +\RequirePackage{ifthen} +%\RequirePackage{fixltx2e} + +\def\vspacebefore{1ex} +\def\vspaceafter{1ex} + +\newcommand{\songtitle} +{ + \begin{center}% + \begin{tikzpicture}[line width=1.5pt] + \tikzstyle{block} = [rectangle, draw, text width=20em, text centered, minimum height=4em] + \node [block,font=\fontsize{20}{28}\selectfont\bfseries] (init) { \@title~-~\@author }; + \end{tikzpicture} + \end{center}% + \par + \vskip 1.5em +} + +\newcounter{NumMesure} +\newcounter{NumPart} +\newcounter{CurrentBarInLine} +\newcounter{CurrentBar} +\newcounter{CurrentLine} + +\newcommand{\bpm}[1] +{ + \xdef\tempoBPM{#1} + \rightline{Tempo=#1 BPM} +} + +% "Beats Per Bar" +% default value +\xdef\bpb{4} + +\newcommand{\bpbfour} +{ + \xdef\bpb{4} +} +\newcommand{\bpbthree} +{ + \xdef\bpb{3} +} + +\newcommand{\resetchordbars} +{ + \setcounter{NumMesure}{0} + \setcounter{NumPart}{0} + \setcounter{CurrentBarInLine}{0} +} + +\newcommand{\printNbBars} +{ + \ifthenelse{\boolean{printBarNumber}} + { + Total number of bars: \arabic{NumMesure}, duration=\pgfmathparse{\theNumMesure/\tempoBPM*60*\bpb}\pgfmathresult {} s. + }{} +} + +\newboolean{printBarNumber} + +\newcommand{\countbarsYes} +{ + \setboolean{printBarNumber}{true} +} + +\newcommand{\countbarsNo} +{ + \setboolean{printBarNumber}{false} +} + +\def\barsize{1.6}% + + +\xdef\NumberOfBarsPerLine{4} + +%========================================================================== +% main environment, has 2 mandatory arguments +% arg 1: total number of 4 beat bars (4, 8, ...) +% arg 2: part name (can be empty) +% optional arg: nb of repetitions (default is 1) + +\newenvironment{chordbar}[3][1] +{ + \newcommand{\newchordline} + { + \setcounter{CurrentBarInLine}{0} + \refstepcounter{CurrentLine} + } + + \newcommand{\chordf}[1]% + { + \ifthenelse + {\theCurrentBarInLine=\NumberOfBarsPerLine} + { + \refstepcounter{CurrentLine} + \setcounter{CurrentBarInLine}{0} + } + {} + \refstepcounter{CurrentBarInLine}% + \pgfmathsetmacro{\x}{-\barsize/2+\theCurrentBarInLine*\barsize} + \pgfmathsetmacro{\y}{\value{CurrentLine})*\barsize+\barsize/2} + \draw (\x,\y) node {##1};% + }% + + \newcommand{\chordh}[2]% + { + \ifthenelse + {\theCurrentBarInLine=\NumberOfBarsPerLine} + { + \refstepcounter{CurrentLine} + \setcounter{CurrentBarInLine}{0} + } + {} + \refstepcounter{CurrentBarInLine}% + \typeout{CurrentBarInLine=\theCurrentBarInLine} + \draw ( % + {\barsize*(\theCurrentBarInLine-1)}, % + {(\theCurrentLine+1)*\barsize} % + ) % + -- % + ( % + {\theCurrentBarInLine*\barsize}, % + {\theCurrentLine*\barsize} % + ); + \draw ( + {-3*\barsize/4+\theCurrentBarInLine*\barsize}, + {\theCurrentLine*\barsize+1*\barsize/4} + ) node {##1}; + \draw ( + {-\barsize/4+\theCurrentBarInLine*\barsize}, + {\theCurrentLine*\barsize+3*\barsize/4} + ) node {##2};% + + } + + \newcommand{\repeatBar}% + { % + \ifthenelse + {\theCurrentBarInLine=\NumberOfBarsPerLine} + { + \refstepcounter{CurrentLine} + \setcounter{CurrentBarInLine}{0} + } + {} + \refstepcounter{CurrentBarInLine}% + + \def\delta{0.36} + \pgfmathsetmacro{\Axa}{(\theCurrentBarInLine-1)*\barsize+\delta*\barsize} + \pgfmathsetmacro{\Axb}{\theCurrentBarInLine*\barsize-\delta*\barsize} + \pgfmathsetmacro{\Aya}{(1-\delta)*\barsize+\theCurrentLine*\barsize} + \pgfmathsetmacro{\Ayb}{\delta*\barsize+\theCurrentLine*\barsize} + + \coordinate (A) at (\Axa,\Ayb); + \coordinate (B) at (\Axb,\Aya); + + \fill (A) circle[radius=2pt]; + \fill (B) circle[radius=2pt]; + \draw [thick] (\Axa,\Aya) -- (\Axb,\Ayb); % + }% + + \newcommand{\repeatBarPair}% + { % + \def\delta{0.36} + \pgfmathsetmacro{\Axa}{\theCurrentBarInLine*\barsize+\delta*\barsize} + \pgfmathsetmacro{\Axb}{(\theCurrentBarInLine+2)*\barsize-\delta*\barsize} + \pgfmathsetmacro{\Aya}{(1-\delta)*\barsize+\theCurrentLine*\barsize} + \pgfmathsetmacro{\Ayb}{\delta*\barsize+\theCurrentLine*\barsize} + + \coordinate (A) at (\Axa,\Ayb); + \coordinate (B) at (\Axb,\Aya); + + \fill (A) circle[radius=2pt]; + \fill (B) circle[radius=2pt]; + \draw [thick] (\Axa,\Aya) -- (\Axb,\Ayb); % + % + \refstepcounter{CurrentBarInLine} + \refstepcounter{CurrentBarInLine} + \ifnum\value{CurrentBarInLine}=#2 + { + \refstepcounter{CurrentLine} + \setcounter{CurrentBarInLine}{0} + } + \fi + }% + + \typeout{chordbarl: START #2} + + \fontfamily{phv}\selectfont + \setcounter{CurrentLine}{0} + \setcounter{CurrentBarInLine}{0} + \setcounter{CurrentBar}{0} + + \refstepcounter{NumPart}% + \refstepcounter{NumMesure}% + \noindent\ignorespaces % + \vspace{\vspacebefore} +%\resizebox{8cm}{!} { +% \scalebox{2}{ + \begin{tikzpicture}[line width=1pt,x=1cm,y=-1cm] %,scale=2] + + \ifthenelse + {\boolean{printBarNumber}} + {\draw (-.3,.5*\barsize) node{\bf \theNumMesure};} + {} + +% compute the number of bars of the first line + \xdef\NbBarsInitialLine{\NumberOfBarsPerLine} + \ifthenelse + {#2<\NumberOfBarsPerLine} + {\xdef\NbBarsInitialLine{#1}} + {} + +% initial horizontal line + \draw (0,0) -- (\NbBarsInitialLine*\barsize,0); + +% draw part title + \ifthenelse + {\boolean{printBarNumber}} + {\draw (0,-\barsize*.2) node [anchor=west, align=left] {\bf Part \theNumPart: #3};} + {\draw (0,-\barsize*.2) node [anchor=west, align=left] {\bf #3};} + + \pgfmathtruncatemacro{\nblines}{(#2-1)/\NumberOfBarsPerLine+1} + \typeout{chordbarl: nblines=\nblines} + \foreach \line in {1,...,\nblines} + { + + \draw (0,{\barsize*(\line-1)}) -- (0,\line*\barsize); % first vertical line + \xdef\nbbars{\NumberOfBarsPerLine} + \ifnum\line=\nblines + { + \pgfmathtruncatemacro{\nbbars}{#2-\NumberOfBarsPerLine*(\nblines-1)} + \xdef\nbbars{\nbbars} + } + \fi + \typeout{chordbarl: nbbars=\nbbars} + \foreach \k in {1,...,{\nbbars}} + { + \draw (\k*\barsize,{(\line-1)*\barsize}) -- (\k*\barsize,{\line*\barsize}); + \draw (0,{\line*\barsize}) -- (\k*\barsize,{\line*\barsize}); + + \refstepcounter{CurrentBar}% + } + } + \setcounter{NumMesure}{#1*#2+\value{NumMesure}-1} + +% print the number of repetitions + \ifnum#1=1 {} + \else + \ifthenelse + {\boolean{printBarNumber}} + {\draw (\NbBarsInitialLine*\barsize+1,0.5*\barsize) node {\Large \bf x~#1};} + {} + \fi +}% +{ +\typeout{chordbar: END} + \end{tikzpicture} +% } % +% \par\noindent% +% \ignorespacesafterend + \vspace{\vspaceafter} +} + +% so the user can use # without escaping +% see https://tex.stackexchange.com/questions/467562 +\AtBeginDocument{\catcode`#=12 } + +% additional code: redefine sharp and flat in text mode +% from https://tex.stackexchange.com/a/422249/11083 +\let\OLDsharp\sharp +\renewcommand{\sharp}{\ensuremath{\OLDsharp}} +\let\OLDflat\flat +\renewcommand{\flat}{\ensuremath{\OLDflat}} + + +\endinput + |