버퍼에로드 된 특정 사운드를 재생하려면 다음 코드가 필요합니다. 나는 볼륨 게인을 사용하여 작업을 얻기 위해 시도하기 전에웹 오디오 사운드가 재생되지 않습니다.
function changeVolume = function(element,soundNo){
var volume = element.value;
var fraction = parseInt(element.value)/parseInt(element.max);
// Using an x^2 progression as it gives a better sound than linear.
soundNo.gainNode.gain.value = fraction * fraction;
};
, 그것은 연주했다 : 여기
<input type="range" min="0" max="100" value="70" id="playBtn1_vol" onchange="changeVolume(this,sound1Gain)" style="display:none">
이 변경 볼륨 방법입니다 : 여기
sound1.gainNode = context.createGain();
sound1.source = context.createBufferSource();
sound1.source.buffer = soundBuffers[num];
sound1.source.connect(sound1.gainNode);
sound1.gainNode.connect(context.destination);
sound1.source.looping = true;
sound1.source.start(0);
내가 변화 볼륨 메소드를 호출 방법 그냥 괜찮아요,하지만 지금은 망가졌고, 내가 잘못한 것을 발견 할 수 없습니다. 누구든지 올바른 방향으로 나를 가리킬 수 있다면 매우 감사 할 것입니다.
onchange = "changeVolume (this, sound1Gain)"이 (가) onchange = "changeVolume (this, sound1gainNode)"입니까? –
그 변화를 시도했지만, 주된 관심사는 내가 게인을 추가하기 전에 연주하고 있던 소리가 연주되지 않는다는 것입니다. – JellyTots