diff --git a/Visualization/SpectrumViewSK.m b/Visualization/SpectrumViewSK.m index 012d2a8fb..03ca1d6b6 100644 --- a/Visualization/SpectrumViewSK.m +++ b/Visualization/SpectrumViewSK.m @@ -11,6 +11,8 @@ #import +#import + #import "analyzer.h" #import "Logging.h" @@ -416,16 +418,14 @@ extern NSString *CogPlaybackDidStopNotificiation; for(int i = 0; i < 11; ++i) { float maxValue = 0.0; float maxMax = 0.0; - for(int j = 0; j < maxBars; ++j) { + { const int barBase = i * barStep; - const int barIndex = barBase + j; - if(barIndex < _draw_data.bar_count) { - if(bar[barIndex].bar_height > maxValue) { - maxValue = bar[barIndex].bar_height; - } - if(bar[barIndex].peak_ypos > maxMax) { - maxMax = bar[barIndex].peak_ypos; - } + const int barEnd = (barBase + maxBars) <= _draw_data.bar_count ? (barBase + maxBars) : _draw_data.bar_count; + { + const int stride = sizeof(ddb_analyzer_draw_bar_t) / sizeof(Float32); + const int barCount = barEnd - barBase + 1; + vDSP_maxv(&bar[barBase].bar_height, stride, &maxValue, barCount); + vDSP_maxv(&bar[barBase].peak_ypos, stride, &maxMax, barCount); } } SCNNode *node = nodes[i + 1]; diff --git a/Visualization/ThirdParty/deadbeef/analyzer.h b/Visualization/ThirdParty/deadbeef/analyzer.h index a1d2e2714..3675264be 100644 --- a/Visualization/ThirdParty/deadbeef/analyzer.h +++ b/Visualization/ThirdParty/deadbeef/analyzer.h @@ -23,6 +23,8 @@ #ifndef analyzer_h #define analyzer_h +#include + #ifdef __cplusplus extern "C" { #endif @@ -52,6 +54,7 @@ typedef struct { float xpos; float peak_ypos; float bar_height; + uint32_t unused; } ddb_analyzer_draw_bar_t; typedef struct {