Skip to content

Commit

Permalink
refactor: Remove the lower end of the histogram frequency data to avo…
Browse files Browse the repository at this point in the history
…id it overcrowding the histogram
  • Loading branch information
drikusroor committed Nov 7, 2024
1 parent fc21675 commit a960ae3
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions frontend/src/components/Histogram/Histogram.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ interface HistogramProps {
}

const Histogram: React.FC<HistogramProps> = ({
bars = 10,
bars = 8,
spacing = 4,
running = true,
marginLeft = 0,
Expand All @@ -36,9 +36,11 @@ const Histogram: React.FC<HistogramProps> = ({

const updateFrequencyData = () => {
if (window.audioContext && window.analyzer) {
const data = new Uint8Array(bars);
const data = new Uint8Array(bars + 3);
window.analyzer.getByteFrequencyData(data);
setFrequencyData(data);
// Remove the lower end of the frequency data
const dataWithoutExtremes = data.slice(3, bars + 3);
setFrequencyData(dataWithoutExtremes);
}
requestRef.current = requestAnimationFrame(updateFrequencyData);
};
Expand Down

0 comments on commit a960ae3

Please sign in to comment.