tags:

views:

199

answers:

1

i am trying to create music major scale converter. Dose anyone have info how do to it

so far i have

rootNote is scale base note like cMajor or gMajor note is note that i want to convert into major scale 0-126 if i insert rootNote 60 and note 60 the right return would be 0, if i insert rootNote 60 and note 61 the right return would be 2, if i insert rootNote 60 and note 62 the right return would be 4, if i insert rootNote 60 and note 63 the right return would be 5,

if i insert rootNote 61 and note 60 the right return would be 0, if i insert rootNote 61 and note 61 the right return would be 1, if i insert rootNote 61 and note 62 the right return would be 3, if i insert rootNote 61 and note 63 the right return would be 5,

ok i have this other one and it seems to work i want to map my sequence out put in major scale but is there some kind of formula what can i use?

.

public int getINMajorScale(int note, int rootNote)
    {

            List<int> majorScale = new List<int>();
            //int bNote = (int)_bNote.CurrentValue;

            int bNoteMpl = bNote / 12;
            bNote = 12 + (bNote - (12 * bNoteMpl)) - 7;
            majorScale.Add(bNote + (12 * bNoteMpl));
            int tBnote = bNote;
            int res = 0;
            for (int i = bNote; i < bNote + 6; i++)
            {
                //algorytm
                res = tBnote + 7;
                int mod = 0;
                if (res >= 12)
                {
                    mod = res / 12;
                    res = res - 12 * mod;
                }
                tBnote = res;
                majorScale.Add(res + (bNoteMpl * 12));
            }
            majorScale.Sort();
            int modNuller = 0;
            if (nmr >= 7)
            {
                modNuller = nmr / 7;
                nmr = nmr - 7 * modNuller;
            }
            return (majorScale[nmr] + (modNuller *12));
        }

but it's obviously faulty.

+4  A: 

Problems with the code as it stands:

  • modScaling does nothing more than rootNote % 12 as you always pass in 0 and 11
  • You define mNote but never use it
  • i is never used in the for loop and so each of the 5 iterations prints the same thing.


OK, lets translate your examples into actual notes to make it easier to understand (numbers presumably correspond to MIDI notes):

  • rootNote = 60 (C), note = 60 (C) - output 0
  • rootNote = 60 (C), note = 61 (C#) - output 2
  • rootNote = 60 (C), note = 62 (D) - output 4
  • rootNote = 60 (C), note = 63 (D#) - output 5
  • rootNote = 61 (C#), note = 60 (C) - output 0
  • rootNote = 61 (C#), note = 61 (C#) - output 1
  • rootNote = 61 (C#), note = 62 (D) - output 3
  • rootNote = 61 (C#), note = 63 (D#) - output 5

I might be being really dense but I'm afraid I can't see the pattern there.

A Major scale is of course made up of the sequence Tone, Tone, Semi-tone, Tone, Tone, Tone, Semi-tone, but how does that map to your outputs?

Mark Pim
+1 for detective work
Ed Harper
jes but there is also other majors compleat map http://en.wikipedia.org/wiki/File:MajorScales.svg
Woland
But all major scales follow the same pattern. And that chart doesn't help with the sample outputs you gave. C# (note 61) doesn't feature in a C Major scale, so why should the function return 2 in that case?
Mark Pim
ok it confuses me because major c# is actually minor C?I am no musician so forgive me.
Woland
No, C minor is a completely different scale from C# major. A major scale can start on any note and always follows the same pattern of tones and semi-tones. A minor scale can also start on any note but follows a slightly different pattern of tones and semi-tones.
Mark Pim
Maybe you could explain what you want to use this function for because it sounds like you've got the wrong idea about what a major scale means.
Mark Pim