c-gaborator/test.cpp

38 lines
852 B
C++
Raw Permalink Normal View History

2022-01-25 12:59:02 +00:00
#include "cgaborator.h"
#include <cstdio>
#define BLOCK_SIZE 8192
2023-10-15 14:47:12 +00:00
int main(int argc, char *argv[]) {
if (argc < 2) {
return 1;
}
2022-01-25 12:59:02 +00:00
2023-10-15 14:47:12 +00:00
auto fp = fopen(argv[1], "r");
2022-01-25 12:59:02 +00:00
if (fp == nullptr){
return 1;
}
2022-01-30 02:52:21 +00:00
auto ptr = gaborator_initialize(1024 * 64, 16000, 85, 110, 440, 7040, 128);
2022-01-25 12:59:02 +00:00
float audioData[BLOCK_SIZE];
2022-07-13 15:54:16 +00:00
size_t return_size, slice_size;
2022-01-25 12:59:02 +00:00
while (true){
auto read = fread(&audioData[0], sizeof(audioData[0]), sizeof(audioData) / sizeof(audioData[0]), fp);
2022-07-13 15:54:16 +00:00
gaborator_transform(ptr, &audioData[0], sizeof(audioData) / sizeof(audioData[0]), &return_size, &slice_size);
2022-01-30 02:52:21 +00:00
if (read < sizeof(audioData) / sizeof(audioData[0])) { //EOF
break;
}
2022-01-25 12:59:02 +00:00
}
2022-07-13 15:54:16 +00:00
gaborator_transform(ptr, nullptr, 0, &return_size, &slice_size);
2022-01-30 02:52:21 +00:00
2022-01-25 12:59:02 +00:00
fclose(fp);
gaborator_release(ptr);
return 0;
}