disabled pitch detection for Safari, so at least the other microphone features work

pull/89/head
jmoenig 2019-03-12 16:15:48 +01:00
rodzic 5bc0829a32
commit 4a95cbae8a
2 zmienionych plików z 19 dodań i 13 usunięć

Wyświetl plik

@ -57,6 +57,7 @@
* Objects, Threads: added "^" reporter (power of) in the Operators category
* Objects: updated relabel-dictionary
* updated Animation und AudioComp libraries with new powerOf primitive
* disabled pitch detection for Safari, so at least the other microphone features work
### 2019-03-11
* added note / hz conversion blocks to audioComp library

Wyświetl plik

@ -8920,6 +8920,9 @@ function Microphone() {
// idling control:
this.isAutoStop = (location.protocol !== 'file:');
this.lastTime = Date.now();
// pitch detection capability - Safari bug
this.canDetectPitch = false;
}
Microphone.prototype.isOn = function () {
@ -9016,6 +9019,10 @@ Microphone.prototype.createAnalyser = function () {
freqBufLength = this.analyser.frequencyBinCount;
this.freqBuffer = new Uint8Array(freqBufLength);
this.pitchBuffer = new Float32Array(freqBufLength);
if (this.analyser.getFloatTimeDomainData instanceof Function) {
// Safari flunks this, sigh
this.canDetectPitch = true;
}
};
Microphone.prototype.createProcessor = function () {
@ -9066,21 +9073,19 @@ Microphone.prototype.stepAudio = function (event) {
this.volume = Math.max(rms, this.volume * this.processor.averaging);
// pitch:
this.analyser.getFloatTimeDomainData(this.pitchBuffer);
this.pitch = this.detectPitch(
this.pitchBuffer,
this.audioContext.sampleRate
);
if (this.canDetectPitch) {
this.analyser.getFloatTimeDomainData(this.pitchBuffer);
this.pitch = this.detectPitch(
this.pitchBuffer,
this.audioContext.sampleRate
);
// note:
if (this.pitch > 0) {
this.note = Math.round(
12 * (Math.log(this.pitch / 440) / Math.log(2))
) + 69;
/*
} else {
this.note = -1;
*/
if (this.pitch > 0) {
this.note = Math.round(
12 * (Math.log(this.pitch / 440) / Math.log(2))
) + 69;
}
}
this.isReady = true;