2017-05-18 2 views
1

피치 탐지 프로그램을 검색했지만 필요한 지침을 제공하지 않았습니다. pitch.js를 사용하려고하지만 마이크 버퍼를 프로그램에 넣을 수 없습니다.피치 검출 프로그램 문제

가수의 피치를 사용하여 개체를 화면 위아래로 움직이는 프로그램을 만들려고합니다. 이를 위해서는 연속적인 (또는 250ms마다) 피치 감지 프로그램과 마이크에 대한 액세스가 필요합니다. 내가 사용하고있는 코드는

/* Copy samples to the internal buffer */ 

    pitch.input(inputBuffer); 

을 나는 "pitch.js"를 사용하려고하지만 "pitch.input"에 마이크 버퍼를 얻을 수 없습니다

var audioContext = new AudioContext(); 

console.log("audio is starting up ..."); 

var BUFF_SIZE = 16384; 

var audioInput = null, 
     microphone_stream = null, 
     gain_node = null, 
     script_processor_node = null, 
     script_processor_node = null, 
     analyserNode = null; 

if (!navigator.getUserMedia) 
    navigator.getUserMedia = navigator.getUserMedia || 
navigator.webkitGetUserMedia || 
          navigator.mozGetUserMedia || 
navigator.msGetUserMedia; 

if (navigator.getUserMedia) { 

    navigator.getUserMedia({ audio: true }, 
      function (stream) { 
       start_microphone(stream); 
      }, 
      function (e) { 
       alert('Error capturing audio.'); 
      } 
     ); 

} else { alert('getUserMedia not supported in this browser.'); } 

function start_microphone(stream) { 

    gain_node = audioContext.createGain(); 
    gain_node.connect(audioContext.destination); 

    microphone_stream = audioContext.createMediaStreamSource(stream); 
    microphone_stream.connect(gain_node); 

    // --- enable volume control for output speakers 

    document.getElementById('volume').addEventListener('change', function() 
    { 
     var curr_volume = this.value; 
     gain_node.gain.value = curr_volume; 

     console.log("curr_volume ", curr_volume); 
    }); 

    script_processor_node = audioContext.createScriptProcessor(2048, 1, 1); 
    script_processor_node.connect(gain_node); 

    function setPitch() { 

    var pitch = new PitchAnalyzer(4100); 

    /* Copy samples to the internal buffer */ 
    //This is where I have been having the problem. 

    pitch.input(????); 
    /* Process the current input in the internal buffer */ 

    pitch.process(); 
    var tone = pitch.findTone(); 

    if (tone === null) { 
     console.log('No tone found!'); 
    } else { 
     console.log('Found a tone, frequency:', tone.freq, 'volume:', 
tone.db); 
    } 
} 


</script> 
</body> 
</html> 
+0

데모를 보았습니까? https://github.com/audiocogs/pitch.js-demo –

+0

pitch.js 데모 작업을 여러 번 시도했지만 수행 할 수 없었습니다. 모든 라이브러리를 설치했고 콘솔에 오류가 없지만 프로그램이 방금 '플래시'에 액세스하도록 요청한 것과 동일한 작은 화면으로 화면이 정지됩니다. 플래시 문제라고 생각하지만 브라우저 (Windows 플랫폼의 Chrome)는 최신 버전 인 것 같습니다. –

+0

문제가 해결되었습니다. githum https://github.com/rserota/wad에서 "Wad"라는 리소스를 발견했으며 원하는대로했습니다. –

답변

0

문제가 해결! githum에서 "Wad"라는 리소스를 찾았습니다. https://github.com/rserota/wad 그리고 정확히 원하는대로했습니다.