Compare commits
No commits in common. "90cc6ba0347d12ab0139f682c0c21835aadc268d" and "c231a9097e9bf816a5661e82c43c6e7ed1a49a4e" have entirely different histories.
90cc6ba034
...
c231a9097e
3 changed files with 10 additions and 26 deletions
15
Audio/ThirdParty/deadbeef/fft_accelerate.c
vendored
15
Audio/ThirdParty/deadbeef/fft_accelerate.c
vendored
|
@ -60,24 +60,19 @@ static void
|
|||
_init_buffers(int fft_size) {
|
||||
if(fft_size != _fft_size) {
|
||||
fft_free();
|
||||
_fft_size = 0;
|
||||
|
||||
_dftSetup = vDSP_DFT_zrop_CreateSetup(NULL, fft_size * 2, vDSP_DFT_FORWARD);
|
||||
if(!_dftSetup) return;
|
||||
|
||||
_dftBuffer.realp = _memalign_calloc(fft_size, sizeof(Float32), 16);
|
||||
_dftBuffer.imagp = _memalign_calloc(fft_size, sizeof(Float32), 16);
|
||||
if(!_dftBuffer.realp || !_dftBuffer.imagp) return;
|
||||
|
||||
_window = _memalign_calloc(fft_size * 2, sizeof(Float32), 16);
|
||||
if(!_window) return;
|
||||
vDSP_blkman_window(_window, fft_size * 2, 0);
|
||||
|
||||
Float32 normFactor = 2.0f / (fft_size * 2);
|
||||
vDSP_vsmul(_window, 1, &normFactor, _window, 1, fft_size * 2);
|
||||
|
||||
_rawSpectrum = (struct SpectrumData *) _memalign_calloc(sizeof(struct SpectrumData) + sizeof(Float32) * fft_size, 1, 16);
|
||||
if(!_rawSpectrum) return;
|
||||
_rawSpectrum->length = fft_size;
|
||||
|
||||
_fft_size = fft_size;
|
||||
|
@ -85,14 +80,7 @@ _init_buffers(int fft_size) {
|
|||
}
|
||||
|
||||
void fft_calculate(const float *data, float *freq, int fft_size) {
|
||||
if(!freq || !fft_size) return;
|
||||
_init_buffers(fft_size);
|
||||
if(!_fft_size || !data) {
|
||||
// Decibels
|
||||
float kZeroLevel = -128.0;
|
||||
vDSP_vfill(&kZeroLevel, freq, 1, fft_size);
|
||||
return;
|
||||
}
|
||||
|
||||
// Split the waveform
|
||||
DSPSplitComplex dest = { _dftBuffer.realp, _dftBuffer.imagp };
|
||||
|
@ -123,7 +111,7 @@ void fft_calculate(const float *data, float *freq, int fft_size) {
|
|||
cblas_scopy(fft_size, rawSpectrum, 1, freq, 1);
|
||||
}
|
||||
|
||||
void __attribute__((destructor)) fft_free(void) {
|
||||
void fft_free(void) {
|
||||
free(_dftBuffer.realp);
|
||||
free(_dftBuffer.imagp);
|
||||
free(_window);
|
||||
|
@ -135,5 +123,4 @@ void __attribute__((destructor)) fft_free(void) {
|
|||
_dftBuffer.imagp = NULL;
|
||||
_window = NULL;
|
||||
_rawSpectrum = NULL;
|
||||
_dftSetup = NULL;
|
||||
}
|
||||
|
|
|
@ -11,8 +11,6 @@
|
|||
|
||||
#import <Metal/Metal.h>
|
||||
|
||||
#import <Accelerate/Accelerate.h>
|
||||
|
||||
#import "analyzer.h"
|
||||
|
||||
#import "Logging.h"
|
||||
|
@ -418,14 +416,16 @@ 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 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);
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
SCNNode *node = nodes[i + 1];
|
||||
|
|
3
Visualization/ThirdParty/deadbeef/analyzer.h
vendored
3
Visualization/ThirdParty/deadbeef/analyzer.h
vendored
|
@ -23,8 +23,6 @@
|
|||
#ifndef analyzer_h
|
||||
#define analyzer_h
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
@ -54,7 +52,6 @@ typedef struct {
|
|||
float xpos;
|
||||
float peak_ypos;
|
||||
float bar_height;
|
||||
uint32_t unused;
|
||||
} ddb_analyzer_draw_bar_t;
|
||||
|
||||
typedef struct {
|
||||
|
|
Loading…
Reference in a new issue