Skip to content

Commit

Permalink
fix: error when generating wave forms for extremely short tracks
Browse files Browse the repository at this point in the history
  • Loading branch information
sophie authored and sophie-gilbert committed Jan 28, 2025
1 parent c1daa81 commit 6c5469b
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion FoxTunes.UI.Windows.MoodBar/Utilities/MoodBarGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ private static void Populate(IOutputStreamDataSource dataSource, IFFTDataTransfo
visualizationData.Peak = new float[1];

var length = dataSource.GetData(visualizationData.Samples, FFT_SIZE);
var interval = data.Capacity / 100;
var interval = Math.Max(data.Capacity / 100, 1);
var values = new float[BANDS.Length];
var samplesPerValue = (dataSource.Stream.Length / length) / data.Capacity;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ private static void Populate(IOutputStreamDataSource dataSource, IFFTDataTransfo
visualizationData.Peak = new float[1];

var length = dataSource.GetData(visualizationData.Samples, FFT_SIZE);
var interval = data.Capacity / 100;
var interval = Math.Max(data.Capacity / 100, 1);
var values = new float[BANDS.Length];
var samplesPerValue = (dataSource.Stream.Length / length) / data.Capacity;

Expand Down
4 changes: 2 additions & 2 deletions FoxTunes.UI.Windows.WaveBar/Utilities/WaveFormGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ private static void PopulateShort(IOutput output, IOutputStreamDataSource dataSo
{
var duration = TimeSpan.FromMilliseconds(data.Resolution);
var buffer = dataSource.GetBuffer<short>(duration);
var interval = data.Capacity / 100;
var interval = Math.Max(data.Capacity / 100, 1);

do
{
Expand Down Expand Up @@ -190,7 +190,7 @@ private static void PopulateFloat(IOutput output, IOutputStreamDataSource dataSo
{
var duration = TimeSpan.FromMilliseconds(data.Resolution);
var buffer = dataSource.GetBuffer<float>(duration);
var interval = data.Capacity / 100;
var interval = Math.Max(data.Capacity / 100, 1);

do
{
Expand Down

0 comments on commit 6c5469b

Please sign in to comment.