dev-audioprocessing/pages/index1/index.vue

109 lines
2.9 KiB
Vue
Raw Permalink Normal View History

2022-12-24 16:36:24 +00:00
<template>
<div>
<div class="container">
<div class="row pt-3">
<div class="col-12 text-center">
2022-12-31 20:05:12 +00:00
<!-- <img src="~/assets/image/Cloudsoftware.png" class="img-fluid">-->
2022-12-30 18:54:59 +00:00
<client-only>
<!-- <av-waveform-->
<!-- src="/maskin2.wav"-->
<!-- :played-line-width="3"-->
<!-- :noplayed-line-width="3"-->
<!-- ></av-waveform>-->
</client-only>
2022-12-24 16:36:24 +00:00
<h4 class="fw-bold ">Focus</h4>
<div class="pt-3">
2022-12-31 20:05:12 +00:00
<img src="~/assets/image/Frame19439.png" class="img-fluid" />
2022-12-24 16:36:24 +00:00
</div>
<div class="d-flex justify-content-center pt-3">
</div>
</div>
</div>
</div>
<canvas id="audioSignalChart" width="400" height="200"></canvas>
2022-12-24 16:36:24 +00:00
</div>
</template>
<script>
// import BandpassProcessor from '~/plugin/octav.js'; // Adjust the path
// import Chart from 'chart.js';
2022-12-27 20:47:47 +00:00
2022-12-24 16:36:24 +00:00
export default {
name: 'HomePage',
data() {
return {
bandpassProcessor: null,
audioContext: null,
oscillator: null,
};
},
mounted() {
// Initialize the BandpassProcessor
this.bandpassProcessor = new BandpassProcessor();
// Initialize the AudioContext
this.audioContext = new AudioContext();
// Create an oscillator
this.oscillator = this.audioContext.createOscillator();
this.oscillator.type = 'sine'; // You can change the waveform type
this.oscillator.frequency.setValueAtTime(440, this.audioContext.currentTime); // Set the initial frequency
// Connect the oscillator to the BandpassProcessor
this.oscillator.connect(this.bandpassProcessor);
// Start the oscillator
this.oscillator.start();
// Send parameters to the BandpassProcessor
this.bandpassProcessor.port.postMessage({
frequency: 1000, // Adjust the frequency value as needed
Q: 5, // Adjust the Q value as needed
});
// Listen for processed data from the BandpassProcessor
this.bandpassProcessor.port.onmessage = (event) => {
const { rms, dbValues, percentile10, percentile90 } = event.data;
// Use the processed data as needed
};
// Create a line chart
const ctx = document.getElementById('audioSignalChart').getContext('2d');
this.audioSignalChart = new Chart(ctx, {
type: 'line',
data: {
labels: [], // You can add time labels or use an array index
datasets: [
{
label: 'Audio Signal',
data: [], // Populate this with your audio signal data
borderColor: 'rgb(75, 192, 192)',
borderWidth: 2,
fill: false,
},
],
},
options: {
responsive: true,
maintainAspectRatio: false,
scales: {
x: {
title: {
display: true,
text: 'Time',
},
},
y: {
title: {
display: true,
text: 'Amplitude',
},
},
},
},
});
2022-12-24 16:36:24 +00:00
}
};
2022-12-24 16:36:24 +00:00
</script>