let notes = ['C', 'C#', 'D', 'Eb', 'E', 'F', 'F#', 'G', 'G#', 'A', 'Bb', 'B'];
let octives = ['O1', 'O2', 'O3', 'O4', 'O5', 'O6', 'O7', 'O8'];
function add(notePitch, halfTones) {
let oldNote = notePitch.note;
let oldOctive = notePitch.octive;
let oldDist = octives.indexOf(oldOctive) * 12 + notes.indexOf(oldNote);
let newDist = oldDist + halfTones;
let newOctive = octives[Math.floor(newDist / 12)];
let newNote = notes[newDist % 12];
return {
note: newNote,
octive: newOctive,
};
}
function notePitchToStr(notePitch) {
return notePitch.note + `${octives.indexOf(notePitch.octive)+1}`
}
const s = [
{note: 'E', octive: 'O4'},
{note: 'B', octive: 'O3'},
{note: 'G', octive: 'O3'},
{note: 'D', octive: 'O3'},
{note: 'A', octive: 'O2'},
{note: 'E', octive: 'O2'},
]
{
let tmp = '\t';
for (let i=0;i版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Zhangzqs! 赞助
wechat
alipay