Skip to content

[idea] using kissfft for general OF fft, all players. #8492

Description

@dimitre

so it can serve as a placeholder until proper per platforms options are developed (if)
It is not hard to build Kiss for all platforms. I'm already building it in ofLibs
https://github.com/ofWorks/ofLibs/releases

soundPlayers can have an ofSoundFFT object inside

sketch: ofSoundFFT.h

#pragma once

#include <kissfft/kiss_fft.h>
#include <kissfft/kiss_fftr.h>
#include <vector>

class ofSoundFFT {
public:
	ofSoundFFT();
	~ofSoundFFT();

	void setup(int bands);
	void process(const float* input, int size);
	const std::vector<float>& getSpectrum() const { return spectrum; }
	
	static std::vector<float> createWindow(int size, int type = 0);
	static void applyWindow(std::vector<float> &signal, const std::vector<float> &window);

private:
	kiss_fftr_cfg fftCfg = nullptr;
	int fftSize = 0;
	std::vector<float> windowedSignal;
	std::vector<kiss_fft_cpx> cx_out;
	std::vector<float> spectrum;
	std::vector<float> window;
	float windowSum = 0.0f;
	
	float computeWindowSum(const std::vector<float>& window);
};

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions