Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9004611
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:56:05+00:00 2026-06-16T00:56:05+00:00

The code in my answer below converts musical notes in strings, such as C#-4

  • 0

The code in my answer below converts musical notes in strings, such as C#-4 or F-3, to their corresponding MIDI note values.

I am posting this because I am tired of trying to dig it up online every time I need it. I’m sure I’m not the only one who can find a use for it. I just wrote this up — it is tested and correct. It’s in Python, but I feel that it pretty close to universally understandable.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T00:56:06+00:00Added an answer on June 16, 2026 at 12:56 am
    #Input is string in the form C#-4, Db-4, or F-3. If your implementation doesn't use the hyphen, 
    #just replace the line :
    #    letter = midstr.split('-')[0].upper()
    #with:
    #    letter = midstr[:-1]
    def MidiStringToInt(midstr):
        Notes = [["C"],["C#","Db"],["D"],["D#","Eb"],["E"],["F"],["F#","Gb"],["G"],["G#","Ab"],["A"],["A#","Bb"],["B"]]
        answer = 0
        i = 0
        #Note
        letter = midstr.split('-')[0].upper()
        for note in Notes:
            for form in note:
                if letter.upper() == form:
                    answer = i
                    break;
            i += 1
        #Octave
        answer += (int(midstr[-1]))*12
        return answer
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Answer solved in edit below I had this piece of code Dictionary<Merchant, int> remaingCards
I am having trouble finding an answer to this. Consider the clipping code below:
I had an exam where I should look at this code and answer the
I was able to use the code in this answer to access a value
I'm having trouble figuring out how to implement the code from this answer. Android:
While trying to answer this question I found that the code int* p =
Notes: The answer is NOT clojurescript. I want to code in Clojure, not ClojureScript.
i have seen this block of code in this Stackoverflow as a answer of
Please answer with the shortest possible source code for a program that converts an
In my answer from yesterday I called the following piece of code a hack:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.