Skip to content

Commit

Permalink
Update _.js
Browse files Browse the repository at this point in the history
Correct for DC offset.
  • Loading branch information
AbdulShabazz authored May 13, 2024
1 parent 4ec8765 commit 2ff5ba8
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions _.js
Original file line number Diff line number Diff line change
Expand Up @@ -2300,6 +2300,14 @@ function generateComplexSignal(

console.info("Done.");
}

// re-Calculate the average amplitude, for correcting the DC offset
const avgAmplitude = channelDataLeft.reduce((sum, sample) => sum + sample, 0) / channelDataLeft.length;

// Remove the DC offset by subtracting the average amplitude from each sample
for (let i = 0; i < channelDataLeft.length; i++) {
channelDataLeft[i] -= avgAmplitude;
}

let channelDataRight = [...channelDataLeft];

Expand Down

0 comments on commit 2ff5ba8

Please sign in to comment.