# How to make or add options for packages or functions

I'm using at this moment the Piano Package. This Package is a little limited so I want to change a few things. The standard color of the dots is orange. I want to change this in different situations. But I don't want to edit the sty file every time. I want to change the options prefered in

\keyboard[color = … ]…


or

\usepackage[color = … ]{piano}


How can I change this? The first option is my prefered option but the standard code is "\keyboard[Dso][Fso][Aso][Dst]" So i hav to change this to \keyboard{Dso}{Fso}{Aso}{Dst} and I don't know if this is possible… can anybody help me? Thanks

-
Welcome to TeX.sx :) –  clemens Feb 24 '14 at 22:11
Sorry but I really don't understand your question. It sounds as if you'd like to type \keyboard{Dso}{Fso}{Aso}{Dst} rather than \keyboard[Dso][Fso][Aso][Dst] (curly brackets vs. square brackets) but I don't know (1) why you would want to do that, or (2) how that is meant to help provide greater flexibility. Posting a Minimum (non-)Working Example (i.e. minimal but complete code) should help you make your question clearer and encourage people to help. –  cfr Feb 24 '14 at 22:25
You can't change the package options without having to edit the .sty file. It is sometimes more feasible to patch existing commands to suit your needs, or to write user-level interface macros that support your needs (like switching colour, say). –  Werner Feb 24 '14 at 22:29

With the following redefinition of \keyboard now you have an optional first argument delimited by parentheses, allowing you to change the color at will:

So, for example, now you can say:

\keyboard[Co][Eo][Gso][Ct][Et]

\keyboard(cyan)[Co][Eo][Gso][Ct][Et]

\keyboard(olive)[Co][Eo][Gso][Ct][Et]


The code:

\documentclass[11pts]{article}
\usepackage{xcolor}
\usepackage{piano}
\usepackage{xparse}

\makeatletter
\RenewDocumentCommand{\keyboard}{D(){orange}O{0}O{0}O{0}O{0}O{0}O{0}O{0}}{

%% Clavier 2 octaves
\setlength{\unitlength}{0.5cm}
\begin{picture}(15,4.5)
%Touches blanches
\multiput(0,0)(1,0){14}%
{\line(0,1){4}}

%Contour
\put(0,0){\line(0,1){4}}
\put(0,0){\line(1,0){14}}
\put(14,0){\line(0,1){4}}
\put(0,4){\line(1,0){14}}

%Touches noires
\linethickness{3mm}
\multiput(1,4)(1,0){2}%
{\line(0,-1){3}}

\multiput(4,4)(1,0){3}%
{\line(0,-1){3}}

\linethickness{3mm}
\multiput(8,4)(1,0){2}%
{\line(0,-1){3}}

\multiput(11,4)(1,0){3}%
{\line(0,-1){3}}

%Rond de note
{\color{#1}

\ifthenelse{\equal{#2}{Co}}{\put(0.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#2}{Do}}{\put(1.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#2}{Eo}}{\put(2.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#2}{Fo}}{\put(3.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#2}{Go}}{\put(4.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#2}{Ao}}{\put(5.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#2}{Bo}}{\put(6.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#2}{Ct}}{\put(7.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#2}{Dt}}{\put(8.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#2}{Et}}{\put(9.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#2}{Ft}}{\put(10.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#2}{Gt}}{\put(11.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#2}{At}}{\put(12.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#2}{Bt}}{\put(13.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#2}{Cso}}{\put(1,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#2}{Dso}}{\put(2,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#2}{Fso}}{\put(4,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#2}{Gso}}{\put(5,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#2}{Aso}}{\put(6,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#2}{Cst}}{\put(8,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#2}{Dst}}{\put(9,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#2}{Fst}}{\put(11,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#2}{Gst}}{\put(12,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#2}{Ast}}{\put(13,1.5){\circle*{0.5}}}}{}}}}}}}}}}}}}}}}}}}}}}}

\ifthenelse{\equal{#3}{Co}}{\put(0.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#3}{Do}}{\put(1.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#3}{Eo}}{\put(2.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#3}{Fo}}{\put(3.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#3}{Go}}{\put(4.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#3}{Ao}}{\put(5.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#3}{Bo}}{\put(6.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#3}{Ct}}{\put(7.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#3}{Dt}}{\put(8.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#3}{Et}}{\put(9.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#3}{Ft}}{\put(10.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#3}{Gt}}{\put(11.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#3}{At}}{\put(12.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#3}{Bt}}{\put(13.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#3}{Cso}}{\put(1,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#3}{Dso}}{\put(2,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#3}{Fso}}{\put(4,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#3}{Gso}}{\put(5,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#3}{Aso}}{\put(6,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#3}{Cst}}{\put(8,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#3}{Dst}}{\put(9,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#3}{Fst}}{\put(11,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#3}{Gst}}{\put(12,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#3}{Ast}}{\put(13,1.5){\circle*{0.5}}}}{}}}}}}}}}}}}}}}}}}}}}}}

\ifthenelse{\equal{#4}{Co}}{\put(0.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#4}{Do}}{\put(1.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#4}{Eo}}{\put(2.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#4}{Fo}}{\put(3.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#4}{Go}}{\put(4.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#4}{Ao}}{\put(5.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#4}{Bo}}{\put(6.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#4}{Ct}}{\put(7.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#4}{Dt}}{\put(8.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#4}{Et}}{\put(9.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#4}{Ft}}{\put(10.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#4}{Gt}}{\put(11.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#4}{At}}{\put(12.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#4}{Bt}}{\put(13.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#4}{Cso}}{\put(1,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#4}{Dso}}{\put(2,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#4}{Fso}}{\put(4,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#4}{Gso}}{\put(5,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#4}{Aso}}{\put(6,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#4}{Cst}}{\put(8,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#4}{Dst}}{\put(9,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#4}{Fst}}{\put(11,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#4}{Gst}}{\put(12,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#4}{Ast}}{\put(13,1.5){\circle*{0.5}}}}{}}}}}}}}}}}}}}}}}}}}}}}

\ifthenelse{\equal{#5}{Co}}{\put(0.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#5}{Do}}{\put(1.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#5}{Eo}}{\put(2.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#5}{Fo}}{\put(3.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#5}{Go}}{\put(4.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#5}{Ao}}{\put(5.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#5}{Bo}}{\put(6.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#5}{Ct}}{\put(7.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#5}{Dt}}{\put(8.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#5}{Et}}{\put(9.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#5}{Ft}}{\put(10.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#5}{Gt}}{\put(11.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#5}{At}}{\put(12.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#5}{Bt}}{\put(13.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#5}{Cso}}{\put(1,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#5}{Dso}}{\put(2,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#5}{Fso}}{\put(4,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#5}{Gso}}{\put(5,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#5}{Aso}}{\put(6,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#5}{Cst}}{\put(8,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#5}{Dst}}{\put(9,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#5}{Fst}}{\put(11,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#5}{Gst}}{\put(12,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#5}{Ast}}{\put(13,1.5){\circle*{0.5}}}}{}}}}}}}}}}}}}}}}}}}}}}}

\ifthenelse{\equal{#6}{Co}}{\put(0.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#6}{Do}}{\put(1.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#6}{Eo}}{\put(2.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#6}{Fo}}{\put(3.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#6}{Go}}{\put(4.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#6}{Ao}}{\put(5.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#6}{Bo}}{\put(6.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#6}{Ct}}{\put(7.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#6}{Dt}}{\put(8.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#6}{Et}}{\put(9.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#6}{Ft}}{\put(10.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#6}{Gt}}{\put(11.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#6}{At}}{\put(12.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#6}{Bt}}{\put(13.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#6}{Cso}}{\put(1,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#6}{Dso}}{\put(2,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#6}{Fso}}{\put(4,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#6}{Gso}}{\put(5,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#6}{Aso}}{\put(6,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#6}{Cst}}{\put(8,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#6}{Dst}}{\put(9,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#6}{Fst}}{\put(11,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#6}{Gst}}{\put(12,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#6}{Ast}}{\put(13,1.5){\circle*{0.5}}}}{}}}}}}}}}}}}}}}}}}}}}}}

\ifthenelse{\equal{#7}{Co}}{\put(0.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#7}{Do}}{\put(1.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#7}{Eo}}{\put(2.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#7}{Fo}}{\put(3.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#7}{Go}}{\put(4.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#7}{Ao}}{\put(5.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#7}{Bo}}{\put(6.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#7}{Ct}}{\put(7.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#7}{Dt}}{\put(8.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#7}{Et}}{\put(9.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#7}{Ft}}{\put(10.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#7}{Gt}}{\put(11.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#7}{At}}{\put(12.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#7}{Bt}}{\put(13.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#7}{Cso}}{\put(1,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#7}{Dso}}{\put(2,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#7}{Fso}}{\put(4,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#7}{Gso}}{\put(5,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#7}{Aso}}{\put(6,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#7}{Cst}}{\put(8,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#7}{Dst}}{\put(9,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#7}{Fst}}{\put(11,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#7}{Gst}}{\put(12,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#7}{Ast}}{\put(13,1.5){\circle*{0.5}}}}{}}}}}}}}}}}}}}}}}}}}}}}

\ifthenelse{\equal{#8}{Co}}{\put(0.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#8}{Do}}{\put(1.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#8}{Eo}}{\put(2.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#8}{Fo}}{\put(3.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#8}{Go}}{\put(4.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#8}{Ao}}{\put(5.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#8}{Bo}}{\put(6.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#8}{Ct}}{\put(7.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#8}{Dt}}{\put(8.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#8}{Et}}{\put(9.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#8}{Ft}}{\put(10.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#8}{Gt}}{\put(11.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#8}{At}}{\put(12.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#8}{Bt}}{\put(13.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#8}{Cso}}{\put(1,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#8}{Dso}}{\put(2,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#8}{Fso}}{\put(4,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#8}{Gso}}{\put(5,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#8}{Aso}}{\put(6,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#8}{Cst}}{\put(8,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#8}{Dst}}{\put(9,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#8}{Fst}}{\put(11,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#8}{Gst}}{\put(12,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#8}{Ast}}{\put(13,1.5){\circle*{0.5}}}}{}}}}}}}}}}}}}}}}}}}}}}}
}

\end{picture}
}
\makeatother

\begin{document}

\keyboard[Co][Eo][Gso][Ct][Et]

\keyboard(cyan)[Co][Eo][Gso][Ct][Et]

\keyboard(olive)[Co][Eo][Gso][Ct][Et]

\end{document}


The output:

-
Much more elegant than my solution! –  onewhaleid Feb 24 '14 at 22:52
That series of \ifthenelse is incredibly complicated and should be defined once with an auxiliary macro. Of course, loading piano is useless. –  egreg Feb 24 '14 at 23:04
@egreg it is, indeed! –  Gonzalo Medina Feb 24 '14 at 23:07

Changing the way the arguments are input is not recommendable, the square bracket notation is better since the seven arguments are optional.

For changing the color the simplest way is to load xcolor and change the definition of orange:

\documentclass{article}
\usepackage{piano}
\usepackage{xcolor}
\colorlet{orange}{red!20}
\begin{document}
\keyboard[Co][Eo][Gso][Ct][Et]
\end{document}


The \colorlet command acts locally, so you can change the color in some environment or group in order not to clobber the default color.

## Alternative version

Save the following file as xpiano.sty

\ProvidesPackage{xpiano}[2014/02/24 from piano.sty by Émile Daneault]
\RequirePackage{xcolor}
\usepackage{xparse}

\definecolor{pianodefault}{RGB}{255,127,0}

\ExplSyntaxOn
\NewDocumentCommand{\keyboard}{ m }
{
\piano_keyboard:n { #1 }
}

\keys_define:nn { piano }
{
color .tl_set:N = \l_piano_color_tl,
one   .tl_set:N = \l_piano_one_tl,
two   .tl_set:N = \l_piano_two_tl,
three .tl_set:N = \l_piano_three_tl,
four  .tl_set:N = \l_piano_four_tl,
five  .tl_set:N = \l_piano_five_tl,
six   .tl_set:N = \l_piano_six_tl,
seven .tl_set:N = \l_piano_seven_tl,
color .initial:n = {pianodefault},
one   .initial:n = {},
two   .initial:n = {},
three .initial:n = {},
four  .initial:n = {},
five  .initial:n = {},
six   .initial:n = {},
seven .initial:n = {},
}

\cs_new_protected:Npn \piano_keyboard:n #1
{
\group_begin:
\keys_set:nn { piano } { #1 }
%% Clavier 2 octaves
\setlength{\unitlength}{0.5cm}
\begin{picture}(15,4.5)
%Touches blanches
\multiput(0,0)(1,0){14}{\line(0,1){4}}

%Contour
\put(0,0){\line(0,1){4}}
\put(0,0){\line(1,0){14}}
\put(14,0){\line(0,1){4}}
\put(0,4){\line(1,0){14}}

%Touches noires
\linethickness{3mm}
\multiput(1,4)(1,0){2}{\line(0,-1){3}}
\multiput(4,4)(1,0){3}{\line(0,-1){3}}
\multiput(8,4)(1,0){2}{\line(0,-1){3}}
\multiput(11,4)(1,0){3}{\line(0,-1){3}}
%Rond de note
\color{\l_piano_color_tl}
\__piano_do_key:N \l_piano_one_tl
\__piano_do_key:N \l_piano_two_tl
\__piano_do_key:N \l_piano_three_tl
\__piano_do_key:N \l_piano_four_tl
\__piano_do_key:N \l_piano_five_tl
\__piano_do_key:N \l_piano_six_tl
\__piano_do_key:N \l_piano_seven_tl

\end{picture}
\group_end:
}

\cs_new_protected:Npn \__piano_do_key:N #1
{
\str_case:Vn #1
{
{}{}% initial case
{Co}{\put(0.5,0.5){\circle*{0.5}}}
{Do}{\put(1.5,0.5){\circle*{0.5}}}
{Eo}{\put(2.5,0.5){\circle*{0.5}}}
{Fo}{\put(3.5,0.5){\circle*{0.5}}}
{Go}{\put(4.5,0.5){\circle*{0.5}}}
{Ao}{\put(5.5,0.5){\circle*{0.5}}}
{Bo}{\put(6.5,0.5){\circle*{0.5}}}
{Ct}{\put(7.5,0.5){\circle*{0.5}}}
{Dt}{\put(8.5,0.5){\circle*{0.5}}}
{Et}{\put(9.5,0.5){\circle*{0.5}}}
{Ft}{\put(10.5,0.5){\circle*{0.5}}}
{Gt}{\put(11.5,0.5){\circle*{0.5}}}
{At}{\put(12.5,0.5){\circle*{0.5}}}
{Bt}{\put(13.5,0.5){\circle*{0.5}}}
{Cso}{\put(1,1.5){\circle*{0.5}}}
{Dso}{\put(2,1.5){\circle*{0.5}}}
{Fso}{\put(4,1.5){\circle*{0.5}}}
{Gso}{\put(5,1.5){\circle*{0.5}}}
{Aso}{\put(6,1.5){\circle*{0.5}}}
{Cst}{\put(8,1.5){\circle*{0.5}}}
{Dst}{\put(9,1.5){\circle*{0.5}}}
{Fst}{\put(11,1.5){\circle*{0.5}}}
{Gst}{\put(12,1.5){\circle*{0.5}}}
{Ast}{\put(13,1.5){\circle*{0.5}}}
}
}

\cs_generate_variant:Nn \str_case:nn { V }
\ExplSyntaxOff


Now you can input your keyboards with a key-value syntax:

\documentclass{article}
\usepackage{xpiano}
\begin{document}
\keyboard{
color=red!20,
one=Co,
two=Eo,
three=Gso,
four=Ct,
five=Et
}

\bigskip

\keyboard{
one=Cso,
two=Fso,
}

\end{document}


The allowed keys are color for setting a color and one two three four five six seven for marking the keys; the value to color must be a color name in the syntax of xcolor, either predefined or given as a tint like in the example.

You can also globally changing the default color by redefining pianodefault, say

\definecolor{pianodefault}{RGB}{255,0,0}


or

\colorlet{pianodefault}{red}


for having red as the default color.

-

The piano.sty package defines the colour orange for all the dots. If you redefine the colour orange, you can change the appearance of each keyboard you insert. I'm not sure how you would change the colour for each individual dot though...

\documentclass{minimal}
\usepackage{piano}

\begin{document}

% red dots
\definecolor{orange}{RGB}{255,0,0}
\keyboard[Co][Eo][Gso][Ct][Et]

% green dots
\definecolor{orange}{RGB}{0,127,0}
\keyboard[Co][Eo][Gso][Ct][Et]

% blue dots
\definecolor{orange}{RGB}{0,0,255}
\keyboard[Co][Eo][Gso][Ct][Et]

\end{document}


-