Before you leave, you do not have to understand much musical notation to do this challenge.
EXPLANATION
In standard sheet music, double clefs go across the page serving as reference points to the notes, letting you know what note should be played. If you are not already familiar with the treble and bass clef, here is a description from Wikipedia:
A clef is a musical symbol used to indicate the pitch of written notes. Placed on one of the lines at the beginning of the stave, it indicates the name and pitch of the notes on that line. This line serves as a reference point by which the names of the notes on any other line or space of the stave may be determined.
In the image above, the top half of the lines is the Treble clef, denoted with a
The bottom half is the Bass clef, denoted with a
As you can see on the treble clef a note on the bottom-most line is an E. (I am not counting notes outside of the clef lines for this challenge) On the bass clef, the lowest line is a G. To complete this challenge, you must do the following:
CHALLENGE
Given an input in one of the following forms (your choice), convert it to the opposite clef. Whether it is the Treble or Bass clef can be a Truthey/Falsey value in your language (not just any two values), e.g.
F# T or F# True or F# Treble
but not
F# -1 or F# 4
Spaces and capitalization are optional, Flats will not appear, and trailing whitespace is not allowed.
Input Expected Output
E Treble G
F Treble A
F# Treble A#
G Treble B
G# Treble C
A Treble C
A# Treble C#
B Treble D
C Treble E
C# Treble F
D Treble F
D# Treble F#
E Treble G
F Treble A
F# Treble A#
G Bass E
G# Bass F
A Bass F
A# Bass F#
B Bass G
C Bass A
C# Bass A#
D Bass B
D# Bass C
E Bass C
F Bass D
F# Bass D#
G Bass E
G# Bass F
A Bass F
A# Bass F#
Be forewarned, this is not a trivial constant difference challenge. Look closely at the inputs and outputs. If you look at a piano,
the black keys are sharps, denoted by #. Note that there is not an E# or a B#. This means that if you are given G# on the Bass clef, instead of returning E#, you need to return F
This is code-golf, so the smallest byte-count wins.
C
instead ofC
) okay? \$\endgroup\$1
and-1
(or even say,4
and-4
) for the clef indicator input allowed or would this only be acceptable if they are truthy/falsey values in our language? \$\endgroup\$