When I want to sing a song with a high key in karaoke, I often don't know how much to lower the key, so I wrote a program for key adjustment in Python. [Addition] I tried riding laravel
――How much should you lower the key to match a song that is too high to sing to your highest note? --Example: How much key should be lowered for a person whose highest note of the ground voice is mid2G # (the highest note of BUMP OF CHICKEN "astronomical observation") to sing B'z's "ultra soul" (highest note hiC #) Is it okay ――By the way, the range information of the song is based on range.com.
――But, it's just the pitch difference between the song you want to sing and your highest note ^^; ――I can't deny the feeling of a long and wasteful chord in the input error handling and usage display. --Addition <2016/4/18> -Supports up to 2 octaves --Increased key types
py3.karaoke.py
#coding:utf-8
import sys
oniki = [
'lowF', 'lowF_s', 'lowG', 'lowG_s',
'mid1A', 'mid1A_s', 'mid1B', 'mid1C', 'mid1C_s', 'mid1D', 'mid1D_s', 'mid1E', 'mid1F', 'mid1F_s', 'mid1G', 'mid1G_s',
'mid2A', 'mid2A_s', 'mid2B', 'mid2C', 'mid2C_s', 'mid2D', 'mid2D_s', 'mid2E', 'mid2F', 'mid2F_s', 'mid2G', 'mid2G_s',
'hiA', 'hiA_s', 'hiB', 'hiC', 'hiC_s', 'hiD', 'hiD_s', 'hiE', 'hiF', 'hiF_s', 'hiG', 'hiG_s',
'hihiA', 'hihiA_s', 'hihiB', 'hihiC', 'hihiC_s', 'hihiD', 'hihiD_s', 'hihiF', 'hihiF_s']
def printAdjustKey(adjust_type, diff_key):
if adjust_type == '1OctaveDown': ad_oc = 12
elif adjust_type == '2OctaveDown': ad_oc = 24
elif adjust_type == '1OctaveUp' : ad_oc = -12
elif adjust_type == '2OctaveUp' : ad_oc = -24
else: ad_oc = 0
print(adjust_type + '\t:\t', diff_key + ad_oc, end='\t')
if abs(diff_key + ad_oc) > 7: print('x')
else: print('o')
def Usage():
print('Usage: python3 karaoke.py [your key] [key your want to sing]')
print('ex : python3 karaoke.py mid2G_s hiC_s')
print('Kind of range:')
cnt = 1
for key in oniki:
print(key, end = ' ')
cnt += 1
if cnt % 10 == 0: print('')
sys.exit()
def validation(argv):
if len(argv) != 3: Usage()
your_key = argv[1]
target_key = argv[2]
dict_oniki = {x:i for i, x in enumerate(oniki)}
if your_key not in dict_oniki or target_key not in dict_oniki:
Usage()
return dict_oniki, your_key, target_key
def main(argv):
dict_oniki, your_key, target_key = validation(argv)
print('Key that you can sing : ', your_key)
print('Key that you want to sing: ', target_key)
print('')
print('To adjust key')
diff_key_num = dict_oniki[your_key] - dict_oniki[target_key]
printAdjustKey('Original', diff_key_num)
printAdjustKey('1OctaveDown', diff_key_num)
printAdjustKey('1OctaveUp', diff_key_num)
print('');
printAdjustKey('2OctaveDown', diff_key_num)
printAdjustKey('2OctaveUp', diff_key_num)
if __name__ == "__main__":
main(sys.argv)
--Use command line
--Copy the above source and save it with a suitable name
--Here we assume that you saved it as karaoke.py
--For example, if a person with the highest mid2G # wants to adjust the key according to B'z "ultra soul" (highest hiC #).
Run python3 karaoke.py mid2G_s hiC_s
on the command line
--_s
means the semitone up symbol #
-# Is a special character (I don't want to use it too much), so I replaced it with _s
Execution example (* Don't miss the fact that you are not good at English)
% python3 karaoke.py mid2G_s hiC_s
Key that you can sing : mid2G_s
Key that you want to sing: hiC_s
To adjust key
Original : -5 o
1OctaveDown : 7 o
1OctaveUp : -17 x
--The output To adjust key
below is the key to adjust.
――If you get this result, you can feel comfortable by lowering 5 keys from the original song! \ High /! You can do it
――If you lower 5 as well, it may be difficult to sing ...
――By the way, the circle next to the adjustment key indicates whether or not it fits within ± 7.
――It may be easier to sing if the key to adjust is smaller.
Female song: Kana Nishino's "I want to meet you, I want to meet you" trembling song (highest note: hiE)
% python3 karaoke.py mid2G_s hiE
Key that you can sing : mid2G_s
Key that you want to sing: hiE
To adjust key
Original : -8 x
1OctaveDown : 4 o
1OctaveUp : -20 x
――This result shows that you can sing like you can by raising 4 keys and singing one octave lower.
On the contrary, I will also say the pattern when a woman wants to sing a man's song. In the case of women, think about matching the lowest notes. The lowest sound of a woman is mid1E (the lowest sound of "Ikimonogakari" SAKURA ") Consider the pattern of singing Masaharu Fukuyama's "Let's be a family" (lowest note: lowG #).
% python3 karaoke.py mid1E lowG_s
Key that you can sing : mid1E
Key that you want to sing: lowG_s
To adjust key
Original : 8 x
1OctaveDown : 20 x
1OctaveUp : -4 o
――This result shows that if you lower the 4 keys and sing one octave higher, you will feel good about becoming a family.
This time I wrote a key adjustment program that can be executed with CUI (although it simply calculates the pitch difference). Since it is a CUI, its versatility is very limited, but I think that if it is applied to laravel etc. currently being studied and can be used on the web, the versatility will expand. It would be interesting to enter your own range and song title and pull the range of the song from range.com. If you have any programming mistakes or advice such as "This is more elegant!", Please let us know in the comments m (__) m