我有前例。字符串t0意味着在高音譜號在的位置。 在間距的符號是B4將字符串轉換爲javascript中的音高表示法
所以T1 = C5,T1 = A4,T-2 = G4 ...
我應該創建陣列的每一個串映射所有筆記,還是可以輕鬆完成? Thx。
我有前例。字符串t0意味着在高音譜號在的位置。 在間距的符號是B4將字符串轉換爲javascript中的音高表示法
所以T1 = C5,T1 = A4,T-2 = G4 ...
我應該創建陣列的每一個串映射所有筆記,還是可以輕鬆完成? Thx。
這是你在找什麼?
let curT = -22;
const letters = ['A', 'B', 'C', 'D', 'E', 'F', 'G'];
let result = {};
for (let i=0; i < 52; i++) {
const letNum = `${letters[i % 7]}${(parseInt(i/7) + 1)}`;
result[`t${curT}`] = letNum;
curT += 1;
}
console.log(result);
是的...這就是正確的只是改變位置,因爲八度開始於C 'let curT = -27;常數字母= ['C','D','E','F','G','A','B']; let result = {}; (let i = 0; i <52; i ++){let35} result ['t $ {curT}'] = letNum; curT + = 1; } console.log(result);' –
好吧,我明白了。我從A開始就是因爲大多數鋼琴都有A作爲最低音符:D – Zevgon
我的音樂理論絕對不符合標準,但如果我得到你要求的東西,那更多的是關於如何處理音符本身的識別和轉換成不同的格式。
你絕對不需要映射所有筆記。我會通過創建一個音符數組,然後計算八度和基本音符的偏移量。從那裏它是一個簡單的數組查找和字符串連接來獲取八度音程。
事情是這樣的:
var notes = ['B','C','D','E','F','G','A'];
function stringtopitch(input)
{
// get the base value
num = parseInt(input.substr(1));
mod = 0
// correct for octaves as needed and identify them
while (num < 0) { num+=7; mod -=1; }
while (num > 7) { num-=7; mod +=1; }
return notes[num] + (mod+4);
}
我不知道你在問什麼。請注意,並非每個人都熟悉音樂符號。請閱讀[我如何提出一個好問題?](https://stackoverflow.com/help/how-to-ask) –