new Signal naming
parent
653b9220f8
commit
5e334d3bfd
|
@ -2,6 +2,7 @@
|
||||||
<div>
|
<div>
|
||||||
<button @click="startMicrophone">Start Microphone</button>
|
<button @click="startMicrophone">Start Microphone</button>
|
||||||
<button @click="stopMicrophone">Stop Microphone</button>
|
<button @click="stopMicrophone">Stop Microphone</button>
|
||||||
|
<canvas ref="visualizationCanvas" width="800" height="200"></canvas>
|
||||||
<div v-if="errorMessage">{{ errorMessage }}</div>
|
<div v-if="errorMessage">{{ errorMessage }}</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
poster="/images/poster.png"
|
poster="/images/poster.png"
|
||||||
>
|
>
|
||||||
<div class="container-fluid overflow-auto" >
|
<div class="container-fluid overflow-auto" >
|
||||||
<div class="row"> <BandProcessor /> </div>
|
<div class="row"> <BandProcessor /> <ChannelStreamer /> </div>
|
||||||
<div class="row ">
|
<div class="row ">
|
||||||
<div class="col-12 col-lg-4 bg-img d-none d-lg-block" style="background-image: url('/images/login.svg');background-size: cover;height: 100vh;" >
|
<div class="col-12 col-lg-4 bg-img d-none d-lg-block" style="background-image: url('/images/login.svg');background-size: cover;height: 100vh;" >
|
||||||
</div>
|
</div>
|
||||||
|
@ -78,6 +78,7 @@ import backgroundImagePath from '~/assets/image/login4.png';
|
||||||
import {useUserStore} from '@/stores/user';
|
import {useUserStore} from '@/stores/user';
|
||||||
import {mapState,mapActions} from "pinia";
|
import {mapState,mapActions} from "pinia";
|
||||||
import BandProcessor from "@/components/BandProcessor";
|
import BandProcessor from "@/components/BandProcessor";
|
||||||
|
import ChannelStreamer from "@/pages/ChannelStreamer";
|
||||||
export default {
|
export default {
|
||||||
|
|
||||||
setup() {
|
setup() {
|
||||||
|
@ -90,7 +91,7 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
//Components BEGIN
|
//Components BEGIN
|
||||||
components: {BandProcessor},
|
components: {BandProcessor,ChannelStreamer},
|
||||||
//Components END
|
//Components END
|
||||||
mounted() {
|
mounted() {
|
||||||
// if (this.is_login){
|
// if (this.is_login){
|
||||||
|
|
|
@ -2,10 +2,12 @@ class OctaveBandProcessor extends AudioWorkletProcessor {
|
||||||
constructor() {
|
constructor() {
|
||||||
super()
|
super()
|
||||||
// Define center frequencies for 9 octave bands
|
// Define center frequencies for 9 octave bands
|
||||||
|
|
||||||
this.centerFrequencies = [63, 125, 250, 500, 1000, 2000, 4000, 8000, 16000]
|
this.centerFrequencies = [63, 125, 250, 500, 1000, 2000, 4000, 8000, 16000]
|
||||||
this.filters = []
|
this.filters = []
|
||||||
this.lastUpdateTimestamp = 0
|
this.lastUpdateTimestamp = 0
|
||||||
this.updateInterval = 0.125 // Update every 0.125 seconds
|
this.updateInterval = 0.125 // Update every 0.125 seconds
|
||||||
|
this.filteredMicSignal =[]
|
||||||
|
|
||||||
// Create an A-weighting filter for specific frequencies
|
// Create an A-weighting filter for specific frequencies
|
||||||
this.createAWeightingFilter()
|
this.createAWeightingFilter()
|
||||||
|
@ -47,22 +49,28 @@ class OctaveBandProcessor extends AudioWorkletProcessor {
|
||||||
}
|
}
|
||||||
|
|
||||||
process(inputs, outputs) {
|
process(inputs, outputs) {
|
||||||
const numOutputChannels = outputs.length
|
const numOutputoctaves = filters.length
|
||||||
for (let i = 0; i < numOutputChannels; i++) {
|
for (let i = 0; i < numOutputoctaves; i++) {
|
||||||
const outputChannel = outputs[i][0]
|
// const outputChannel = outputs[i][0]
|
||||||
const inputChannel = inputs[i][0]
|
|
||||||
|
const mic = inputs[0]
|
||||||
|
const maskingsig = inputs[1]
|
||||||
|
const harmonic = inputs[2]
|
||||||
|
|
||||||
// Apply the filter to the input channel
|
// Apply the filter to the input channel
|
||||||
const filteredSignal = this.filters[i].process(inputChannel)
|
const filteredMicSignal[i] = this.filters[i].process(mic)
|
||||||
|
const filteredMaskSignal = this.filters[i].process(maskingsig)
|
||||||
|
const filteredHarmoSignal = this.filters[i].process(harmonic)
|
||||||
|
|
||||||
// Apply A-weighting only to the microphone signal (channel 0)
|
// Apply A-weighting only to the microphone signal (channel 0)
|
||||||
if (i === 0) {
|
|
||||||
const aWeightedSignal = this.aWeightingFilter.process(filteredSignal)
|
const aWeightedSignal[i] = this.aWeightingFilter.process(filteredMicSignal)
|
||||||
|
this.calculateRMSLevel(aWeightedSignal)
|
||||||
outputChannel.set(aWeightedSignal)
|
outputChannel.set(aWeightedSignal)
|
||||||
} else {
|
|
||||||
// For other channels, pass the signal without A-weighting
|
// For other channels, pass the signal without A-weighting
|
||||||
outputChannel.set(filteredSignal)
|
outputChannel.set(filteredSignal)
|
||||||
}
|
|
||||||
|
|
||||||
// Check if it's time to update percentiles
|
// Check if it's time to update percentiles
|
||||||
const currentTime = this.currentTime
|
const currentTime = this.currentTime
|
||||||
|
@ -86,8 +94,8 @@ class OctaveBandProcessor extends AudioWorkletProcessor {
|
||||||
|
|
||||||
updatePercentiles(channelIndex) {
|
updatePercentiles(channelIndex) {
|
||||||
for (let i = 0; i < this.centerFrequencies.length; i++) {
|
for (let i = 0; i < this.centerFrequencies.length; i++) {
|
||||||
const analyzer = this.analyzers[i][channelIndex]
|
//const analyzer = this.analyzers[i][channelIndex]
|
||||||
const levelData = new Float32Array(analyzer.frequencyBinCount)
|
//const levelData = new Float32Array(analyzer.frequencyBinCount)
|
||||||
analyzer.getFloatFrequencyData(levelData)
|
analyzer.getFloatFrequencyData(levelData)
|
||||||
|
|
||||||
// Calculate percentiles for each octave band and each channel
|
// Calculate percentiles for each octave band and each channel
|
||||||
|
@ -114,59 +122,59 @@ class OctaveBandProcessor extends AudioWorkletProcessor {
|
||||||
] //David
|
] //David
|
||||||
|
|
||||||
// Create a custom IIR filter node with the A-weighting coefficients
|
// Create a custom IIR filter node with the A-weighting coefficients
|
||||||
this.aWeightingFilter = new IIRFilterNode(audioContext, {
|
this.aWeightingFilter = new IIRFilterNode(audioContext, { //infinit Impuls Response
|
||||||
feedforward: aWeightingCoefficients,
|
feedforward: aWeightingCoefficients,
|
||||||
feedback: [1],
|
feedback: [1],
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
combineAndCalculate() {
|
// combineAndCalculate() {
|
||||||
let LAF10_90_total = 0 // Initialize the total LAF10%-90%
|
// let LAF10_90_total = 0 // Initialize the total LAF10%-90%
|
||||||
|
|
||||||
for (let i = 0; i < this.centerFrequencies.length; i++) {
|
// for (let i = 0; i < this.centerFrequencies.length; i++) {
|
||||||
const micAnalyzer = this.analyzers[i][0] // Analyzer for microphone audio (identifier 0)
|
// const micAnalyzer = this.analyzers[i][0] // Analyzer for microphone audio (identifier 0)
|
||||||
const audioFile1Analyzer = this.analyzers[i][3] // Analyzer for audioFile1 (identifier 3)
|
// const audioFile1Analyzer = this.analyzers[i][3] // Analyzer for audioFile1 (identifier 3)
|
||||||
const audioFile2Analyzer = this.analyzers[i][4] // Analyzer for audioFile2 (identifier 4)
|
// const audioFile2Analyzer = this.analyzers[i][4] // Analyzer for audioFile2 (identifier 4)
|
||||||
|
|
||||||
// Calculate percentiles for the microphone audio
|
// // Calculate percentiles for the microphone audio
|
||||||
const micPercentile10 = this.calculatePercentile(micAnalyzer, 10)
|
// const micPercentile10 = this.calculatePercentile(micAnalyzer, 10)
|
||||||
const micPercentile90 = this.calculatePercentile(micAnalyzer, 90)
|
// const micPercentile90 = this.calculatePercentile(micAnalyzer, 90)
|
||||||
|
|
||||||
// Calculate percentiles for audioFile1
|
// // Calculate percentiles for audioFile1
|
||||||
const audioFile1Percentile10 = this.calculatePercentile(
|
// const audioFile1Percentile10 = this.calculatePercentile(
|
||||||
audioFile1Analyzer,
|
// audioFile1Analyzer,
|
||||||
10,
|
// 10,
|
||||||
)
|
// )
|
||||||
const audioFile1Percentile90 = this.calculatePercentile(
|
// const audioFile1Percentile90 = this.calculatePercentile(
|
||||||
audioFile1Analyzer,
|
// audioFile1Analyzer,
|
||||||
90,
|
// 90,
|
||||||
)
|
// )
|
||||||
|
|
||||||
// Calculate percentiles for audioFile2
|
// // Calculate percentiles for audioFile2
|
||||||
const audioFile2Percentile10 = this.calculatePercentile(
|
// const audioFile2Percentile10 = this.calculatePercentile(
|
||||||
audioFile2Analyzer,
|
// audioFile2Analyzer,
|
||||||
10,
|
// 10,
|
||||||
)
|
// )
|
||||||
const audioFile2Percentile90 = this.calculatePercentile(
|
// const audioFile2Percentile90 = this.calculatePercentile(
|
||||||
audioFile2Analyzer,
|
// audioFile2Analyzer,
|
||||||
90,
|
// 90,
|
||||||
)
|
// )
|
||||||
|
|
||||||
// Calculate LAF10%-90% for microphone audio, audioFile1, and audioFile2 separately
|
// // Calculate LAF10%-90% for microphone audio, audioFile1, and audioFile2 separately
|
||||||
const micLAF10_90 = micPercentile10 - micPercentile90
|
// const micLAF10_90 = micPercentile10 - micPercentile90
|
||||||
const audioFile1LAF10_90 = audioFile1Percentile10 - audioFile1Percentile90
|
// const audioFile1LAF10_90 = audioFile1Percentile10 - audioFile1Percentile90
|
||||||
const audioFile2LAF10_90 = audioFile2Percentile10 - audioFile2Percentile90
|
// const audioFile2LAF10_90 = audioFile2Percentile10 - audioFile2Percentile90
|
||||||
|
|
||||||
// Calculate combined LAF10%-90% for microphone audio, audioFile1, and audioFile2
|
// // Calculate combined LAF10%-90% for microphone audio, audioFile1, and audioFile2
|
||||||
const combinedLAF10_90 =
|
// const combinedLAF10_90 =
|
||||||
micLAF10_90 + audioFile1LAF10_90 + audioFile2LAF10_90
|
// micLAF10_90 + audioFile1LAF10_90 + audioFile2LAF10_90
|
||||||
|
|
||||||
// Add the combined LAF10%-90% to the total
|
// // Add the combined LAF10%-90% to the total
|
||||||
LAF10_90_total += combinedLAF10_90
|
// LAF10_90_total += combinedLAF10_90
|
||||||
}
|
// }
|
||||||
|
|
||||||
// return LAF10_90_total;
|
// // return LAF10_90_total;
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
registerProcessor("octave", OctaveBandProcessor)
|
registerProcessor("octave", OctaveBandProcessor)
|
||||||
|
|
Loading…
Reference in New Issue