7 kyu

Music Theory: Find the Melodic Interval Between Two Notes

107 of 210joekotvas
Description
Loading description...
Algorithms
Strings
  • Please sign in or sign up to leave a comment.
  • ejini战神 Avatar

    Description should be language-agnostic

  • Blind4Basics Avatar

    Hi,

    The unit used for "intervals" is not given. Tones ? semi tones? ...? Currently, someone not familiar with music theory will have to retro-engineer the logic to solve the kata.

    Cheers

    • joekotvas Avatar

      Hi! The unit is neither tones nor semitones, but rather letter note names. This is the standard way to refer to melodic and harmonic intervals in every music theory class I have taken.

      C to a E has four semitones (or two whole tones), and is called a 3rd, specifically a major third, because it comprehends three note names.

      E to G has three semitones, or 1.5 whole tones, but is also called a 3rd, specifically a minor third, because it also comprehends three note names.

      I've added a note in the description to emphasize this concept; hopefully it will be helpful.

      Issue marked resolved by joekotvas 2 years ago
    • Jam14man Avatar

      Your test ('A0', 'B0', 2). From 'A0' to 'B0' or 1 note(!), or 2 semitones. ('F4', 'B4', 4). From 'B4' to 'F4' or 4 notes(!), or 6 semitones. So what we searching???

    • joekotvas Avatar

      Melodic and harmonic intervals are named for the distance from one letter name to the other letter name, first and last note inclusive

      ('A0', 'A0') => 1 (unison) ('A0', 'B0') => 2 (second)

      This is standard convention for musicians. The ordinal number is then paired with a modifier such as 'major', 'minor', 'perfect', etc... but that is beyond the scope of this kata

    • dfhwze Avatar

      It measures Degree intervals (of the Major Scale), regardless of the Pitch intervals between degrees, starting with value 1 for the zero distance interval. As author mentioned, each letter represents such degree. Octave numbers are added to be able to measure degree intervals across octaves.

    • Blind4Basics Avatar

      well, the wording is still totally awful, for non musicians... XD

      Intervals are named for the distance, first note inclusive, between the lower note and the higher note. >>> This distance is measured not in semitones or whole tones, but rather in note names spanned. <<<

  • Voile Avatar

    If the input is exactly 2 notes, why it is supplied as an array? This will make a lot of other languages unhappy.

    • JohanWiltink Avatar

      This will make a lot of other languages unhappy.

      How?

      It's not ideal, it's not necessary, but I fail to see how this is an Issue. It doesn't break the kata, does it?

    • Voile Avatar

      If your standard is as low as "it doesn't break the kata" then everything is fine (it also explains why beta katas are so horrible I suppose). However katas are also meant to teach good practices: when a kata can't even use the most natural, sense making input format this cannot be count as good practice.

      Note that in almost all strongly typed languages there are no way to specify your input is an array with exactly 2 elements (and no, tuple isn't one, that's a completely different construct). Once this happens, you're opening a massive source of error for everyone: Will the tests accidentally put more or less elements? Do I need to validate this as a user? Will some translator decide to do a dick move and make users mandatory to validate this? Given the average quality of CW katas, especially translations, these can all happen, and they're all solved by choosing a type that isn't literally retarded for the job. So I don't see why this issue has to be put under the rug for the general desire of "pushing every beta kata past approval ASAP".

    • joekotvas Avatar

      Thanks for your (rather pointed 😅) feedback. I've updated the kata to accept exactly two arguments. Unfortunately this has invalidated all previous solutions, but I guess that is part of the beta process.

      Issue marked resolved by joekotvas 2 years ago
  • mauro-1 Avatar
  • dfhwze Avatar
    • How about making much more octaves available? This is very easy to hardcode at the moment.
    • Introducing accidentals (flat, sharp, ..) could also make this kata more interesting, and harder to solve
    • JohanWiltink Avatar

      I was already worried about all that stuff for this one. Fortunately, it didn't assume prior knowledge, didn't go beyond every existing piano in the world, and didn't expect me to deal with those ridiculous irregular half note intervals. Also, simple input parsing. Sometimes I just don't want all those complications, you know?

      It's not a bad idea, but it's a different kata, and it needs specs on par with this one.

      Other opinions are undoubtedly available. :]

    • dfhwze Avatar

      sure, but author had estimated rank of 6 kyu, so I hinted about options to make this actually a 6 ;)

    • JohanWiltink Avatar

      I just voted 7 :P

    • dfhwze Avatar

      agreed to have a simple kata for beginners

      Suggestion marked resolved by dfhwze 2 years ago
  • dfhwze Avatar

    I would change the name to Find the Pitch Interval Between Two Notes, because there are several types of intervals.

    • joekotvas Avatar

      From a quick scan of the internet, it seems most authors who use the term "Pitch Interval" are referring to an interval measured in semitones, whereas here I am referring to the interval size measured across note letter names (typically stated as an ordinal number such as 3rd or 4th), which is generally paired with an interval quality (such as major or perfect).

      I understand you want to differentiate between rhythm intervals and pitch intervals. How about "Find the Letter Note Interval Between Two Notes"? Or "Find the Melodic Interval Between Two Notes"?

    • dfhwze Avatar

      melodic interval seems fine

    • dfhwze Avatar

      EDIT: I was mistaken, not "Pitch", but better "Degree" intervals.

      Suggestion marked resolved by dfhwze 2 years ago
  • JohanWiltink Avatar

    Tests use a different argument format than description text, examples, and initial code. It doesn't really matter what it is, but it should be consistent .

  • JohanWiltink Avatar

    Tests are not written very maintainably. Reference solution is unnecessarily complicated ( apart from being incorrect ), there is an undeclared, therefore global (!), variable, and even though notes are simply an enumeration you have also found a way to complicate generating those.

    Please do better.

  • rowcased Avatar

    Random tests expect negative results.

    Random test: B6, D6
    expected 6 to deeply equal -4
    

    Yet here the interval from D6 up to B6 is a major sixth. Or if you wish, you could say it's a major sixth from B6 down to D6. Either way, -4 makes no sense.

    • joekotvas Avatar

      Thanks for taking the time to make a note of this! I've improved the testing function; it should be good to go now.

      Issue marked resolved by joekotvas 2 years ago