Compile parameters, new API
This commit is contained in:
parent
b94aa40f84
commit
444e444b22
|
@ -14,7 +14,9 @@ if(NOT CMAKE_BUILD_TYPE)
|
|||
endif()
|
||||
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -ggdb -O0")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3")
|
||||
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -ggdb -O0")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Ofast")
|
||||
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -Ofast")
|
||||
|
||||
add_definitions(-DGABORATOR_USE_PFFFT)
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#include "gaborator/gaborator.h"
|
||||
#include <cmath>
|
||||
|
||||
const int C_ARRAY_SIZE = 300000 * 2;
|
||||
const int C_ARRAY_SIZE = 100000 * 2; //TODO: why this size
|
||||
|
||||
struct GaboratorState {
|
||||
gaborator::parameters* paramsRef;
|
||||
|
@ -16,7 +16,7 @@ struct GaboratorState {
|
|||
int sample_rate;
|
||||
int64_t anal_support;
|
||||
|
||||
float cArray[C_ARRAY_SIZE];
|
||||
gaborator_analyze_entry cArray[C_ARRAY_SIZE];
|
||||
};
|
||||
|
||||
void* gaborator_initialize(double sampleRate, int bandsPerOctave, double minimumFrequency, double referenceFrequency, double maximumFrequency){
|
||||
|
@ -49,11 +49,11 @@ long gaborator_get_anal_support(void* ptr) {
|
|||
return reinterpret_cast<GaboratorState*>(ptr)->anal_support;
|
||||
}
|
||||
|
||||
void gaborator_analyze(void* ptr, float* audio_block, int audio_block_length) {
|
||||
gaborator_analyze_entry* gaborator_analyze(void* ptr, float* audio_block, int audio_block_length) {
|
||||
auto state = reinterpret_cast<GaboratorState*>(ptr);
|
||||
|
||||
if (audio_block == nullptr) {
|
||||
return;
|
||||
return &state->cArray[0];
|
||||
}
|
||||
|
||||
std::vector<float> buf(audio_block,audio_block + audio_block_length);
|
||||
|
@ -72,9 +72,7 @@ void gaborator_analyze(void* ptr, float* audio_block, int audio_block_length) {
|
|||
//ignores everything above the max_band
|
||||
if(band >= state->min_band){
|
||||
//printf("%f %d %ld\n",std::abs(coef),band,audioSampleIndex);
|
||||
state->cArray[output_index++] = band;
|
||||
state->cArray[output_index++] = audioSampleIndex;
|
||||
state->cArray[output_index++] = std::abs(coef);
|
||||
state->cArray[output_index++] = {band, static_cast<int>(audioSampleIndex), std::abs(coef)};
|
||||
//printf("output_index: %d\n", output_index++);
|
||||
//output_index++;
|
||||
}
|
||||
|
@ -86,14 +84,11 @@ void gaborator_analyze(void* ptr, float* audio_block, int audio_block_length) {
|
|||
int64_t t_out = state->t_in - state->anal_support;
|
||||
|
||||
forget_before(*state->analyzerRef, *state->coefsRef, t_out - audio_block_length);
|
||||
}
|
||||
|
||||
float* gaborator_get_array(void* ptr) {
|
||||
auto state = reinterpret_cast<GaboratorState*>(ptr);
|
||||
return &state->cArray[0];
|
||||
}
|
||||
|
||||
int gaborator_get_array_length(void* ptr) {
|
||||
int gaborator_analyze_array_length(void* ptr) {
|
||||
auto state = reinterpret_cast<GaboratorState*>(ptr);
|
||||
return sizeof(state->cArray) / sizeof(state->cArray[0]);
|
||||
}
|
||||
|
|
|
@ -3,14 +3,18 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct gaborator_analyze_entry {
|
||||
int bandIndex;
|
||||
int sampleIndex;
|
||||
float magnitude;
|
||||
};
|
||||
|
||||
void* gaborator_initialize(double sampleRate, int bandsPerOctave, double minimumFrequency, double referenceFrequency, double maximumFrequency);
|
||||
long gaborator_get_anal_support(void* ptr);
|
||||
|
||||
void gaborator_analyze(void* ptr, float* audio_block, int audio_block_length);
|
||||
gaborator_analyze_entry* gaborator_analyze(void* ptr, float* audio_block, int audio_block_length);
|
||||
|
||||
float* gaborator_get_array(void* ptr);
|
||||
|
||||
int gaborator_get_array_length(void* ptr);
|
||||
int gaborator_analyze_array_length(void* ptr);
|
||||
|
||||
int gaborator_bandcenters_array_length(void* ptr);
|
||||
|
||||
|
|
Loading…
Reference in a new issue