- Adjusted default Stream buffer sizes to be more CPU friendly

- Fixed FFT buffer handling in Player
This commit is contained in:
casey langen 2016-11-27 23:09:31 -08:00
parent d698ea98ac
commit e6d86517c9
3 changed files with 8 additions and 7 deletions

View File

@ -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;
}
}

View File

@ -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()) {

View File

@ -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: