0
有沒有辦法擺脫就行了這個關鍵字:調用與工廠函數上相同的組成功能的其他功能
this.getOscillatorConfig(oscNumber);
下面?:
const oscPlayer = (audioContext, voiceConfig) => ({
getOscillatorConfig(oscNumber)
{
return voiceConfig.oscillators[oscNumber];
},
getOscillator(oscNumber)
{
this.getOscillatorConfig(oscNumber);
let vco = audioContext.createOscillator();
vco.type = oscConfig.waveform;
return vco;
},
start: (vco, time, noteLength, frequency) => {
vco.frequency.value = frequency;
vco.start(time);
vco.stop(time + noteLength);
}
});
const octave =() => ({
applyPipeLength: (frequency, pipeLength) => {
return frequency/(parseInt(pipeLength, 10)/8);
}
});
const Voice = (audioContext, voiceConfig) => {
return Object.assign(
{},
oscPlayer(audioContext, voiceConfig),
octave()
)
}
如果我不去使用它,我有getOscillatorConfig是未定義的。
或其他任何建議如何構造這?
_「是有辦法......」爲什麼_你想擺脫'this'嗎? – Cerbrus