mirror of
https://github.com/clangen/musikcube.git
synced 2025-03-14 04:18:36 +00:00
- Adjusted default Stream buffer sizes to be more CPU friendly
- Fixed FFT buffer handling in Player
This commit is contained in:
parent
d698ea98ac
commit
e6d86517c9
2
src/3rdparty/src/fft.cpp
vendored
2
src/3rdparty/src/fft.cpp
vendored
@ -124,7 +124,7 @@ static void fft_prepare( const sound_sample *input, float * re, float * im,
|
||||
/* Get input, in reverse bit order */
|
||||
for(i = 0; i < FFT_BUFFER_SIZE; i++)
|
||||
{
|
||||
*p_real++ = input[bitReverse[i]] * MAX_SIGNED_SHORT;
|
||||
*p_real++ = (input[bitReverse[i]] * MAX_SIGNED_SHORT * 2) - MAX_SIGNED_SHORT;
|
||||
*p_imag++ = 0;
|
||||
}
|
||||
}
|
||||
|
@ -34,6 +34,7 @@
|
||||
|
||||
#include "pch.hpp"
|
||||
|
||||
#include <fft.h>
|
||||
#include <core/debug.h>
|
||||
#include <core/audio/Player.h>
|
||||
#include <core/audio/Stream.h>
|
||||
@ -42,7 +43,7 @@
|
||||
#include <algorithm>
|
||||
|
||||
#define MAX_PREBUFFER_QUEUE_COUNT 8
|
||||
#define FFT_N 512
|
||||
#define FFT_OUTPUT_SIZE (FFT_BUFFER_SIZE / 2)
|
||||
|
||||
using namespace musik::core::audio;
|
||||
using namespace musik::core::sdk;
|
||||
@ -80,7 +81,7 @@ Player::Player(const std::string &url, OutputPtr output)
|
||||
, setPosition(-1) {
|
||||
musik::debug::info(TAG, "new instance created");
|
||||
|
||||
this->spectrum = new float[FFT_N];
|
||||
this->spectrum = new float[FFT_OUTPUT_SIZE];
|
||||
|
||||
/* we allow callers to specify an output device; but if they don't,
|
||||
we will create and manage our own. */
|
||||
@ -318,8 +319,8 @@ static inline void writeToVisualizer(IBuffer *buffer, float *spectrum) {
|
||||
IPcmVisualizer* pcmVis = vis::PcmVisualizer();
|
||||
|
||||
if (specVis && specVis->Visible()) {
|
||||
if (buffer->Fft(spectrum, FFT_N)) {
|
||||
vis::SpectrumVisualizer()->Write(spectrum, FFT_N);
|
||||
if (buffer->Fft(spectrum, FFT_OUTPUT_SIZE)) {
|
||||
vis::SpectrumVisualizer()->Write(spectrum, FFT_OUTPUT_SIZE);
|
||||
}
|
||||
}
|
||||
else if (pcmVis && pcmVis->Visible()) {
|
||||
|
@ -54,8 +54,8 @@ namespace musik { namespace core { namespace audio {
|
||||
|
||||
public:
|
||||
static StreamPtr Create(
|
||||
int samplesPerChannel = 512,
|
||||
int bufferCount = 32,
|
||||
int samplesPerChannel = 1024,
|
||||
int bufferCount = 16,
|
||||
unsigned int options = 0);
|
||||
|
||||
private:
|
||||
|
Loading…
x
Reference in New Issue
Block a user