我正在尝试创建音乐主要规模转换器.任何人都有信息如何做到这一点
到目前为止我有
root注意是像cMajor或gMajor注意的基本注释注意我想要转换成主刻度0-126如果我插入rootNote 60和注释60右边的返回将是0,如果我插入rootNote 60和注释61正确的返回将是2,如果我插入rootNote 60和注释62,则右边的返回值为4,如果我插入rootNote 60,则注释63右边的返回值为5,
如果我插入rootNote 61和注释60,则右返回将为0,如果我插入rootNote 61并且注释61右侧返回将为1,如果我插入rootNote 61并且注释62右侧返回将为3,如果我插入rootNote 61和注释63右边的回报是5,
好吧,我有这另一个,它似乎工作,我想把我的序列映射到大规模,但有一些公式我可以使用什么?
.
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));
}
Run Code Online (Sandbox Code Playgroud)
但这显然是错误的.
代码问题:
modScaling除了rootNote % 12你总是传递0和11 之外什么也没做mNote但从不使用它i从不在for循环中使用,因此5次迭代中的每一次都打印相同的东西.好的,让我们将您的示例翻译成实际音符,以便更容易理解(数字可能与MIDI音符相对应):
rootNote = 60(C),note = 60(C) - 输出0rootNote = 60(C),note = 61(C#) - 输出2rootNote = 60(C),note = 62(D) - 输出4rootNote = 60(C),note = 63(D#) - 输出5rootNote = 61(C#),note = 60(C) - 输出0rootNote = 61(C#),note = 61(C#) - 输出1rootNote = 61(C#),note = 62(D) - 输出3rootNote = 61(C#),note = 63(D#) - 输出5我可能真的很密集,但我恐怕我看不到那里的模式.
主要音阶当然由音调,音调,半音,音调,音调,音调,半音调组成,但是如何映射到您的输出?