This commit is contained in:
wataru 2023-03-24 16:18:05 +09:00
parent 3c1c785dfa
commit 807120201f
2 changed files with 30 additions and 27 deletions

File diff suppressed because one or more lines are too long

View File

@ -36,9 +36,9 @@ class VoiceChangerWorkletProcessor extends AudioWorkletProcessor {
private initialized = false; private initialized = false;
private volume = 0 private volume = 0
private numTrancateTreshold = 150 private numTrancateTreshold = 150
private volTrancateThreshold = 0.0005 // private volTrancateThreshold = 0.0005
private volTrancateLength = 32 // private volTrancateLength = 32
private volTrancateCount = 0 // private volTrancateCount = 0
private isRecording = false private isRecording = false
@ -70,8 +70,8 @@ class VoiceChangerWorkletProcessor extends AudioWorkletProcessor {
const request = event.data as VoiceChangerWorkletProcessorRequest const request = event.data as VoiceChangerWorkletProcessorRequest
if (request.requestType === "config") { if (request.requestType === "config") {
this.numTrancateTreshold = request.numTrancateTreshold this.numTrancateTreshold = request.numTrancateTreshold
this.volTrancateLength = request.volTrancateLength // this.volTrancateLength = request.volTrancateLength
this.volTrancateThreshold = request.volTrancateThreshold // this.volTrancateThreshold = request.volTrancateThreshold
console.log("[worklet] worklet configured", request) console.log("[worklet] worklet configured", request)
return return
} else if (request.requestType === "start") { } else if (request.requestType === "start") {
@ -132,28 +132,31 @@ class VoiceChangerWorkletProcessor extends AudioWorkletProcessor {
} }
//// 一定期間無音状態が続いている場合はスキップ。 //// 一定期間無音状態が続いている場合はスキップ。
let voice: Float32Array | undefined // let voice: Float32Array | undefined
while (true) { // while (true) {
voice = this.playBuffer.shift() // voice = this.playBuffer.shift()
if (!voice) { // if (!voice) {
break // break
} // }
this.volume = this.calcVol(voice, this.volume) // this.volume = this.calcVol(voice, this.volume)
if (this.volume < this.volTrancateThreshold) { // if (this.volume < this.volTrancateThreshold) {
this.volTrancateCount += 1 // this.volTrancateCount += 1
} else { // } else {
this.volTrancateCount = 0 // this.volTrancateCount = 0
} // }
// // V.1.5.0よりsilent skipで音飛びするようになったので無効化
// if (this.volTrancateCount < this.volTrancateLength || this.volTrancateLength < 0) {
// break
// } else {
// break
// // console.log("silent...skip")
// }
// }
let voice = this.playBuffer.shift()
// V.1.5.0よりsilent skipで音飛びするようになったので無効化
if (this.volTrancateCount < this.volTrancateLength || this.volTrancateLength < 0) {
break
} else {
break
// console.log("silent...skip")
}
}
if (voice) { if (voice) {
const volumeResponse: VoiceChangerWorkletProcessorResponse = { const volumeResponse: VoiceChangerWorkletProcessorResponse = {