Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

Hotfix for negative values in peaks #1148

Merged
merged 3 commits into from
Mar 21, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/components/VAudioTrack/VWaveform.vue
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ export default defineComponent({
peaks: {
type: Array,
required: false,
validator: (val) => val.every((item) => item >= 0 && item <= 1),
validator: (val) => val.every((item) => item >= -0.3 && item <= 1),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's not set this arbitrary limit and maybe just check for type of number.

},
/**
* the message to display instead of the waveform; This is useful when
Expand Down Expand Up @@ -348,7 +348,9 @@ export default defineComponent({
samples = downsampleArray(samples, required)
}

return samples.map((peak) => peak * waveformDimens.value.height)
return samples.map(
(peak) => Math.max(peak, 0) * waveformDimens.value.height
)
})

/* SVG drawing */
Expand Down