@@ -78,6 +78,7 @@ import backgroundImagePath from '~/assets/image/login4.png';
import {useUserStore} from '@/stores/user';
import {mapState,mapActions} from "pinia";
import BandProcessor from "@/components/BandProcessor";
+import ChannelStreamer from "@/pages/ChannelStreamer";
export default {
setup() {
@@ -90,7 +91,7 @@ export default {
}
},
//Components BEGIN
- components: {BandProcessor},
+ components: {BandProcessor,ChannelStreamer},
//Components END
mounted() {
// if (this.is_login){
diff --git a/public/scripts/aweight.js b/public/scripts/aweight.js
new file mode 100644
index 0000000..e69de29
diff --git a/public/scripts/octave.js b/public/scripts/octave.js
index 660480f..d1c202c 100644
--- a/public/scripts/octave.js
+++ b/public/scripts/octave.js
@@ -2,11 +2,13 @@ class OctaveBandProcessor extends AudioWorkletProcessor {
constructor() {
super()
// Define center frequencies for 9 octave bands
+
this.centerFrequencies = [63, 125, 250, 500, 1000, 2000, 4000, 8000, 16000]
this.filters = []
this.lastUpdateTimestamp = 0
this.updateInterval = 0.125 // Update every 0.125 seconds
-
+ this.filteredMicSignal =[]
+
// Create an A-weighting filter for specific frequencies
this.createAWeightingFilter()
@@ -47,22 +49,28 @@ class OctaveBandProcessor extends AudioWorkletProcessor {
}
process(inputs, outputs) {
- const numOutputChannels = outputs.length
- for (let i = 0; i < numOutputChannels; i++) {
- const outputChannel = outputs[i][0]
- const inputChannel = inputs[i][0]
+ const numOutputoctaves = filters.length
+ for (let i = 0; i < numOutputoctaves; i++) {
+ // const outputChannel = outputs[i][0]
- // Apply the filter to the input channel
- const filteredSignal = this.filters[i].process(inputChannel)
+ const mic = inputs[0]
+ const maskingsig = inputs[1]
+ const harmonic = inputs[2]
+
+ // Apply the filter to the input channel
+ 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)
- if (i === 0) {
- const aWeightedSignal = this.aWeightingFilter.process(filteredSignal)
+
+ const aWeightedSignal[i] = this.aWeightingFilter.process(filteredMicSignal)
+ this.calculateRMSLevel(aWeightedSignal)
outputChannel.set(aWeightedSignal)
- } else {
+
// For other channels, pass the signal without A-weighting
outputChannel.set(filteredSignal)
- }
+
// Check if it's time to update percentiles
const currentTime = this.currentTime
@@ -86,8 +94,8 @@ class OctaveBandProcessor extends AudioWorkletProcessor {
updatePercentiles(channelIndex) {
for (let i = 0; i < this.centerFrequencies.length; i++) {
- const analyzer = this.analyzers[i][channelIndex]
- const levelData = new Float32Array(analyzer.frequencyBinCount)
+ //const analyzer = this.analyzers[i][channelIndex]
+ //const levelData = new Float32Array(analyzer.frequencyBinCount)
analyzer.getFloatFrequencyData(levelData)
// Calculate percentiles for each octave band and each channel
@@ -114,59 +122,59 @@ class OctaveBandProcessor extends AudioWorkletProcessor {
] //David
// 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,
feedback: [1],
})
}
- combineAndCalculate() {
- let LAF10_90_total = 0 // Initialize the total LAF10%-90%
+ // combineAndCalculate() {
+ // let LAF10_90_total = 0 // Initialize the total LAF10%-90%
- for (let i = 0; i < this.centerFrequencies.length; i++) {
- const micAnalyzer = this.analyzers[i][0] // Analyzer for microphone audio (identifier 0)
- const audioFile1Analyzer = this.analyzers[i][3] // Analyzer for audioFile1 (identifier 3)
- const audioFile2Analyzer = this.analyzers[i][4] // Analyzer for audioFile2 (identifier 4)
+ // for (let i = 0; i < this.centerFrequencies.length; i++) {
+ // const micAnalyzer = this.analyzers[i][0] // Analyzer for microphone audio (identifier 0)
+ // const audioFile1Analyzer = this.analyzers[i][3] // Analyzer for audioFile1 (identifier 3)
+ // const audioFile2Analyzer = this.analyzers[i][4] // Analyzer for audioFile2 (identifier 4)
- // Calculate percentiles for the microphone audio
- const micPercentile10 = this.calculatePercentile(micAnalyzer, 10)
- const micPercentile90 = this.calculatePercentile(micAnalyzer, 90)
+ // // Calculate percentiles for the microphone audio
+ // const micPercentile10 = this.calculatePercentile(micAnalyzer, 10)
+ // const micPercentile90 = this.calculatePercentile(micAnalyzer, 90)
- // Calculate percentiles for audioFile1
- const audioFile1Percentile10 = this.calculatePercentile(
- audioFile1Analyzer,
- 10,
- )
- const audioFile1Percentile90 = this.calculatePercentile(
- audioFile1Analyzer,
- 90,
- )
+ // // Calculate percentiles for audioFile1
+ // const audioFile1Percentile10 = this.calculatePercentile(
+ // audioFile1Analyzer,
+ // 10,
+ // )
+ // const audioFile1Percentile90 = this.calculatePercentile(
+ // audioFile1Analyzer,
+ // 90,
+ // )
- // Calculate percentiles for audioFile2
- const audioFile2Percentile10 = this.calculatePercentile(
- audioFile2Analyzer,
- 10,
- )
- const audioFile2Percentile90 = this.calculatePercentile(
- audioFile2Analyzer,
- 90,
- )
+ // // Calculate percentiles for audioFile2
+ // const audioFile2Percentile10 = this.calculatePercentile(
+ // audioFile2Analyzer,
+ // 10,
+ // )
+ // const audioFile2Percentile90 = this.calculatePercentile(
+ // audioFile2Analyzer,
+ // 90,
+ // )
- // Calculate LAF10%-90% for microphone audio, audioFile1, and audioFile2 separately
- const micLAF10_90 = micPercentile10 - micPercentile90
- const audioFile1LAF10_90 = audioFile1Percentile10 - audioFile1Percentile90
- const audioFile2LAF10_90 = audioFile2Percentile10 - audioFile2Percentile90
+ // // Calculate LAF10%-90% for microphone audio, audioFile1, and audioFile2 separately
+ // const micLAF10_90 = micPercentile10 - micPercentile90
+ // const audioFile1LAF10_90 = audioFile1Percentile10 - audioFile1Percentile90
+ // const audioFile2LAF10_90 = audioFile2Percentile10 - audioFile2Percentile90
- // Calculate combined LAF10%-90% for microphone audio, audioFile1, and audioFile2
- const combinedLAF10_90 =
- micLAF10_90 + audioFile1LAF10_90 + audioFile2LAF10_90
+ // // Calculate combined LAF10%-90% for microphone audio, audioFile1, and audioFile2
+ // const combinedLAF10_90 =
+ // micLAF10_90 + audioFile1LAF10_90 + audioFile2LAF10_90
- // Add the combined LAF10%-90% to the total
- LAF10_90_total += combinedLAF10_90
- }
+ // // Add the combined LAF10%-90% to the total
+ // LAF10_90_total += combinedLAF10_90
+ // }
- // return LAF10_90_total;
- }
+ // // return LAF10_90_total;
+ // }
}
registerProcessor("octave", OctaveBandProcessor)