14
2
The trumpet is a valved aerophone instrument, usually pitched in B♭
. The sound is made when the player vibrates their lips to displace air inside the instrument. That vibration is acquired by setting one's mouth in a specific way, called the embouchure. Different embouchures, with tighter or looser lips, produce different pitches.
Furthermore, each valve in the trumpet also changes the pitch of the instrument. When depressed, a valve closes a path inside the tubing of the instrument, making the air flow through a longer path, thus lowering the pitch of the original sound. For the purposes of this challenge, we'll consider the standard, B♭
trumpet, in which the first valve lowers the pitch by a full step, the second lowers the pitch by a half-step, and the third lowers the pitch by one and a half step.
The Challenge
Your challenge is to create a program or function that, given two inputs embouchure
and valves
, determines the pitch of the note being played.
For the purposes of this challenge, the notes will follow the sequence:
B♭, B, C, C♯, D, E♭, E, F, F♯, G, G♯, A.
Rules
- I/O can be taken/given in any reasonable method.
- Standard loopholes apply.
- You're allowed to use
b
and#
instead of♭
and♯
if you wish to. - Input for
valves
can be taken as a list of depressed valves (1, 3
) or a boolean list (1, 0, 1
). - This is code-golf, so shortest code in each language wins.
Test Cases:
Valves
in these test cases is given as a boolean list, where 0 means depressed and 1 means pressed.
Embouchure: Valves: Output:
B♭ 0 0 0 B♭
B♭ 0 1 0 A
B♭ 1 0 1 F
C♯ 0 0 1 B♭
C♯ 1 1 1 G
E♭ 1 0 0 C♯
G 0 1 1 E♭
G♯ 1 0 0 F♯
G♯ 0 0 1 F
G 1 0 0 F
F♯ 1 0 0 E
D 1 0 1 A
A 1 1 1 E♭
E 1 1 0 C♯
E 0 0 1 C♯
Disclaimer: I'm not much of a musician yet, so I do apologize for any butchering I might've made on the test cases. Corrections are appreciated.
Sandbox – J. Sallé – 2018-03-15T14:26:16.017
2Percussionist here. Wait wait, that's how you spell embouchure. Always thought it started with an a ;-) – MayorMonty – 2018-03-15T14:39:16.153
Some of these test cases don't seem to match the problem. For example,
G#, 1, 1, 0
should beF
, notF#
, andC#, 1, 1, 1
should beG
, notF#
. – vasilescur – 2018-03-15T15:42:00.1471@vasilescur you're right. I'll fix those and review any other possible mistakes. Thanks for the heads up. – J. Sallé – 2018-03-15T15:44:10.613
1As someone who's played trumpet a long time, I'm really confused by the Embouchure measurement... For example what is a C# Embouchure? – bendl – 2018-03-15T18:39:26.960
@bendl I’m still beginning my studies on the trumpet, so I can’t really tell if those are particularly accurate or not. I tried to gather as much information as possible, and inferred some of that information from what I had available. Does that change whether or not the challenge is viable? If not, I think I’ll leave it as it is. As I said in the disclaimer, I’m not much of a musician yet and apologize for any inaccuracies. – J. Sallé – 2018-03-15T19:19:26.577
1Should
F# 100
be E not F? – Level River St – 2018-03-15T19:47:00.823I don't think it changes the viability, I was just totally confused by the concept. – bendl – 2018-03-15T19:50:46.090
@LevelRiverSt yes, thanks! – J. Sallé – 2018-03-15T20:01:11.310
2@bendl There's no such thing. You can't play a
C#
on a trumpet without pressing down any valves. Just specific notes (B♭-F-B♭-D-F-A♭-B♭...
), the overtone series ofB♭
. Still, even if it doesn't reflect a real instrument the challenge is perfectly well defined. – Chris – 2018-03-16T02:23:13.847@bendl Same, got confused there – ericw31415 – 2018-03-17T17:42:47.650
@bendl playing only on the mouthpiece, sure you can have a C# embouchure. Attach the instrument and it won't work so well, as noted in other comments, unless you play in a high enough octave... :) – Oliphaunt - reinstate Monica – 2018-08-10T22:09:57.403