This is a kind of follow-up to this question. I'd like to reproduce with tikz the following image.
I have no idea of how I could "synchronize" the output of musictex
and tikz
. Maybe I'd better stick with tikz
but then I don't know how to draw realistic notes, staves and keys (borrowing them from musictex
)?
Here is what I've done so far in tikz.
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}
\tikzset{%
White/.style = {%
node distance = 0cm and 0cm,
draw,
minimum width = .25cm,
minimum height = 1.25cm,
inner sep = 0pt},
Black/.style = {%
fill = black,
minimum width = .15cm,
minimum height = .75cm,
inner sep = 0pt,
anchor = north},
}
\node[White] (White--1-6) {};
\node[font = \tiny,above] at (White--1-6.north)
{$\mathrm{A}_{-1}$};
\node[font = \tiny,below] at (White--1-6.south)
{1};
\pgfmathsetmacro\frequency{round(440 * 2^(((1)-49)/12))}
\node[font = \tiny,above,rotate = 90,transform shape,anchor = west] at
(White--1-6.south) {\frequency};
\node[White,right = of White--1-6] (White--1-7) {};
\node[font = \tiny,above] at (White--1-7.north)
{$\mathrm{B}_{-1}$};
\node[font = \tiny,below] at (White--1-7.south)
{3};
\pgfmathsetmacro\frequency{round(440 * 2^(((3)-49)/12))}
\node[font = \tiny,above,rotate = 90,transform shape,anchor = west] at
(White--1-7.south) {\frequency};
\def\noteindex{4}%
\foreach \octave [remember = \octave as \lastoctave (initially -1)]
in {0,...,6}{%
\foreach \White/\note [remember = \White as \lastWhite (initially 7)]
in {1/C,2/D,3/E,4/F,5/G,6/A,7/B} {%
\ifnum\White=1\relax
\node[%
White,
right = of White-\lastoctave-\lastWhite]
(White-\octave-\White) {};
\else
\node[%
White,
right = of White-\octave-\lastWhite]
(White-\octave-\White) {};
\fi
\node[font = \tiny,above] at (White-\octave-\White.north)
{$\mathrm{\note}_{\octave}$};
\node[font = \tiny,below] at (White-\octave-\White.south)
{\noteindex};
\pgfmathsetmacro\frequency{round(440 * 2^(((\noteindex)-49)/12))}
\node[font = \tiny,above,rotate = 90,transform shape,anchor = west] at
(White-\octave-\White.south) {\frequency};
\ifcase\White\relax
\or% next is D
\xdef\noteindex{\number\numexpr\noteindex+2\relax}%
\or% next is E
\xdef\noteindex{\number\numexpr\noteindex+2\relax}%
\or% next is F
\xdef\noteindex{\number\numexpr\noteindex+1\relax}%
\or% next is G
\xdef\noteindex{\number\numexpr\noteindex+2\relax}%
\or% next is A
\xdef\noteindex{\number\numexpr\noteindex+2\relax}%
\or% next is B
\xdef\noteindex{\number\numexpr\noteindex+2\relax}%
\or% next is C
\xdef\noteindex{\number\numexpr\noteindex+1\relax}%
\fi
}
}
\node[White,right = of White-6-7] (White-7-1) {};
\node[font = \tiny,above] at (White-7-1.north)
{$\mathrm{C}_{7}$};
\node[font = \tiny,below] at (White-7-1.south)
{\noteindex};
\pgfmathsetmacro\frequency{round(440 * 2^(((\noteindex)-49)/12))}
\node[font = \tiny,above,rotate = 90,transform shape,anchor = west] at
(White-7-1.south) {\frequency};
\begin{scope}[every node/.style = {%
Black,
}]
\node at (White--1-6.north east) {};
\foreach \octave in {0,...,6}{%
\foreach \White in {1,2,4,5,6} {%
\node at (White-\octave-\White.north east) {};
}
}
\end{scope}
\end{tikzpicture}
\end{document}
Best Answer
Not properly worked through, but hopefully shows how to "integrate" (in a very loose sense)
musixtex
andtikz
.EDIT: added keyboard and tonic sol-fa labels. Still a bit of mess though.
OK, here's a much better version...