Python Forum
How to convert value to defined number?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to convert value to defined number?
#1
I am making a program that prints a piano-keyboard-diagram on the screen based on the input. I want to use text input using the 'music tracker' standard.

The example below is a basic C chord.
# User input
rightNotes = "C4 E4 G4 C5"
leftNotes = "C2 C3"
# Convert user input to numbers
rightHandNumbers = []  # Notes for the right hand
leftHandNumbers = []  # Notes for the left hand
The rightNotes and leftNotes need to be converted to numbers to rightHandNumbers and leftHandNumbers. The numbers are the piano-key-numbers(1-88). C4=(key)40, E4=44, G4=47, C5=52, C2=16, C3=28

I don't know how to do this(I think this is how to solve the problem):
  1. Making a function that cuts the rightNotes string by spaces into different values.
  2. Making a function that converts the separated values into the given numbers.
Does someone have idea's?

The conversion table looks like this for only the central octave:
C4=40
c4=41
D4=42
d4=43
E4=44
F4=45
f4=46
G4=47
g4=48
A4=49
a4=50
B4=51
Reply


Messages In This Thread
How to convert value to defined number? - by philipbergwerf - Dec-07-2019, 01:15 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  convert % to a number Nickd12 2 2,069 Sep-18-2020, 12:18 AM
Last Post: deanhystad
  python library not defined in user defined function johnEmScott 2 3,887 May-30-2020, 04:14 AM
Last Post: DT2000
  Find Average of User Input Defined number of Scores DustinKlent 1 4,331 Oct-25-2019, 12:40 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020