Circular Keyboard
Author
Senan Sekhon
Last Updated
3 years ago
License
Creative Commons CC BY 4.0
Abstract
Circular Keyboard with Major Scales
Circular Keyboard with Major Scales
\documentclass[10pt]{extarticle}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
%\usepackage[dvipsnames]{xcolor}
\usepackage[a4paper,top=0.5in,bottom=0.2in,left=0.5in,right=0.5in,footskip=0.3in,includefoot]{geometry}
%\usepackage[most]{tcolorbox}
\usepackage{tikz}
%Colors from https://simple.wikipedia.org/wiki/Color_wheel#The_12_major_color_wheel_colors_color_comparison_chart
\definecolor{Ccol}{HTML}{FF0000} %Red
\definecolor{Gcol}{HTML}{FF7F00} %Orange
\definecolor{Dcol}{HTML}{FFFF00} %Yellow
\definecolor{Acol}{HTML}{7FFF00} %Chartreuse Green
\definecolor{Ecol}{HTML}{00FF00} %Green
\definecolor{Bcol}{HTML}{00FF7F} %Spring Green
\definecolor{Gbcol}{HTML}{00FFFF} %Cyan
\definecolor{Dbcol}{HTML}{007FFF} %Azure
\definecolor{Abcol}{HTML}{0000FF} %Blue
\definecolor{Ebcol}{HTML}{7F00FF} %Violet
\definecolor{Bbcol}{HTML}{FF00FF} %Magenta
\definecolor{Fcol}{HTML}{FF007F} %Rose
\newcommand{\whites}[2][red]{ %fill individual white key
\fill[#1] ({\sr-360/133*#2}:\wa) arc({\sr-360/133*#2}:{\sr-360/133*(#2+1)}:\wa)--({\sr-360/133*(#2+1)}:\wc) arc({\sr-360/133*(#2+1)}:{\sr-360/133*#2}:\wc)--cycle; %fill the key
}
\newcommand{\blacks}[2][red]{ %fill individual black key
\fill[#1] ({\sr-360/133*(#2-1/3)}:\wb) arc({\sr-360/133*(#2-1/3)}:{\sr-360/133*(#2+1/3)}:\wb)--({\sr-360/133*(#2+1/3)}:\wc) arc({\sr-360/133*(#2+1/3)}:{\sr-360/133*(#2-1/3)}:\wc)--cycle; %fill the key
\draw ({\sr-360/133*(#2-1/3)}:\wc)--({\sr-360/133*(#2-1/3)}:\wb) arc({\sr-360/133*(#2-1/3)}:{\sr-360/133*(#2+1/3)}:\wb)--({\sr-360/133*(#2+1/3)}:\wc); %draw the border around the key
}
%Created by Senan Sekhon
%Created August 13, 2021
\begin{document}
\phantom{.} %invisible . to allow \vfill to work
\vfill %To vertically center the picture
\begin{center}
\begin{tikzpicture}
\def\wa{7.5} %radius at base of white keys
\def\wb{8.25} %radius at base of black keys
\def\wc{9} %radius at top of (white and black) keys
\def\sr{90+180/19} %starting angle
\def\lr{6.7}
% Labels for scales
\begin{scope}[every node/.style={font=\fontsize{24}{24}\sffamily\bfseries}]
\node at (90:\lr) {C};
\node at (60:\lr) {G};
\node at (30:\lr) {D};
\node at (0:\lr) {A};
\node at (-30:\lr) {E};
\node at (-60:\lr) {B};
\node at (-90:\lr) {G$\flat$};
\node at (-120:\lr) {D$\flat$};
\node at (-150:\lr) {A$\flat$};
\node at (180:\lr) {E$\flat$};
\node at (150:\lr) {B$\flat$};
\node at (120:\lr) {F};
\end{scope}
% C major
\foreach \k in {0,1,2,3,4,5,6}
\whites[Ccol]{\k};
% G major
\foreach \k in {11,12,13,14,15,16}
\whites[Gcol]{\k};
\foreach \k in {18}
\blacks[Gcol]{\k};
% D major
\foreach \k in {22,23,25,26,27}
\whites[Dcol]{\k};
\foreach \k in {25,29}
\blacks[Dcol]{\k};
% A major
\foreach \k in {33,34,36,37}
\whites[Acol]{\k};
\foreach \k in {36,39,40}
\blacks[Acol]{\k};
% E major
\foreach \k in {44,47,48}
\whites[Ecol]{\k};
\foreach \k in {46,47,50,51}
\blacks[Ecol]{\k};
% B major
\foreach \k in {55,58}
\whites[Bcol]{\k};
\foreach \k in {57,58,60,61,62}
\blacks[Bcol]{\k};
% G-flat major
\foreach \k in {69,73}
\whites[Gbcol]{\k};
\foreach \k in {67,68,69,71,72}
\blacks[Gbcol]{\k};
% D-flat major
\foreach \k in {79,83}
\whites[Dbcol]{\k};
\foreach \k in {78,79,81,82,83}
\blacks[Dbcol]{\k};
% A-flat major
\foreach \k in {91,94,95}
\whites[Abcol]{\k};
\foreach \k in {89,90,92,93}
\blacks[Abcol]{\k};
% E-flat major
\foreach \k in {100,101,104,105}
\whites[Ebcol]{\k};
\foreach \k in {99,102,103}
\blacks[Ebcol]{\k};
% B-flat major
\foreach \k in {112,113,115,116,117}
\whites[Bbcol]{\k};
\foreach \k in {111,114}
\blacks[Bbcol]{\k};
% F major
\foreach \k in {122,123,124,126,127,128}
\whites[Fcol]{\k};
\foreach \k in {125}
\blacks[Fcol]{\k};
% Fill remaining black keys
\foreach \k in {1,2,4,5,6,8,9,11,12,13,15,16,19,20,22,23,26,27,30,32,33,34,37,41,43,44,48,53,54,55,64,65,74,75,76,85,86,88,95,96,97,100,104,106,107,109,110,113,116,117,118,120,121,123,124,127,128,130,131,132}
\blacks[black]{\k};
\draw (0:0) circle (\wa); %inner circle (base of white keys)
\draw (0:0) circle (\wc); %outer circle (top of white keys)
% Draw borders between white keys
\foreach \k in {0,7,...,126}
{\foreach \l in {\k+1,\k+2,\k+4,\k+5,\k+6}
\draw ({\sr-360/133*(\l)}:\wa)--({\sr-360/133*(\l)}:\wb); %borders between white keys separated by a black key
\foreach \l in {\k,\k+3}
\draw ({\sr-360/133*(\l)}:\wa)--({\sr-360/133*(\l)}:\wc); %borders between white keys not separated by a black key
}
\draw (0:0) circle (0.1); %center hole
%%% Description labels
\node[font=\huge\sffamily\bfseries] at (0,1.3) {Circular Keyboard};
\node[font=\large\sffamily\bfseries] at (0,0.6) {with Major Scales};
\node[font=\large\sffamily\bfseries] at (0,-0.8) {Designed by Senan Sekhon};
\end{tikzpicture}
\end{center}
\vfill %To vertically center the picture
\end{document}
%%% EXTRA CODE, USED FOR PREVIOUS VERSIONS OF THIS FILE
\begin{tikzpicture}
\def\wl{2} %length of white key
\def\ww{0.6} %width of white key
\def\bl{1} %length of black key
\def\bw{0.4} %width of black key
\foreach \i in {0,1,...,6} %white keys
\draw ({\i*\ww},0) rectangle ({(\i+1)*\ww},-\wl);
\foreach \j in {1,2,4,5,6} %black keys
\fill ({\j*\ww-\bw/2},0) rectangle ({\j*\ww+\bw/2},-\bl);
\end{tikzpicture}
\begin{tikzpicture}
\def\n{168} %total number of white keys (MUST be a multiple of 7)
\def\wa{7.5} %radius at base of white keys
\def\wb{8.25} %radius at base of black keys
\def\wc{9} %radius at top of (white and black) keys
\foreach \i in {0,1,...,\number\numexpr\n-1\relax} %white keys
\draw ({90-360/\n*\i}:\wa) arc({90-360/\n*\i}:{90-360/\n*(\i+1)}:\wa)--({90-360/\n*(\i+1)}:\wc) arc({90-360/\n*(\i+1)}:{90-360/\n*\i}:\wc)--cycle;
\foreach \j in {0,7,...,\number\numexpr\n-7\relax}
\foreach \k in {\j+1,\j+2,\j+4,\j+5,\j+6} %black keys
\fill ({90-360/\n*(\k-1/3)}:\wb) arc({90-360/\n*(\k-1/3)}:{90-360/\n*(\k+1/3)}:\wb)--({90-360/\n*(\k+1/3)}:\wc) arc({90-360/\n*(\k+1/3)}:{90-360/\n*(\k-1/3)}:\wc)--cycle;
%% Starting angle set to 90, this can be changed to any angle
\end{tikzpicture}