Skip to content

Commit

Permalink
add a bench_test and make both benches run for only 60s worth of samples
Browse files Browse the repository at this point in the history
  • Loading branch information
Ulf Hammarqvist committed Apr 17, 2024
1 parent bc31614 commit dbe688c
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
4 changes: 4 additions & 0 deletions core/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ add_executable(bench_synthvoice bench_synthvoice.cpp ${TEST_COMMON_SRC})
set_property(TARGET bench_synthvoice PROPERTY FOLDER core/test)
target_link_libraries( bench_synthvoice ${CMAKE_THREAD_LIBS_INIT} ${CMAKE_DL_LIBS})

add_executable(bench_effectchain bench_effectchain.cpp ${TEST_COMMON_SRC})
set_property(TARGET bench_effectchain PROPERTY FOLDER core/test)
target_link_libraries( bench_effectchain ${CMAKE_THREAD_LIBS_INIT} ${CMAKE_DL_LIBS})

add_executable(run_module run_module.cpp ${TEST_COMMON_SRC})
set_property(TARGET run_module PROPERTY FOLDER core/test)
target_link_libraries( run_module ${CMAKE_THREAD_LIBS_INIT} ${CMAKE_DL_LIBS})
Expand Down
30 changes: 30 additions & 0 deletions core/test/bench_effectchain.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#include <cstdio>
#include <cstdint>

// #include "phasephdgr/synth.hpp"
#include "phasephdgr/examples.hpp"

#include "effectchain.hpp"

using namespace PhasePhdgr;

int main()
{
const int s = 60; // ~1 minutes
const float fs = 48000;
float bufferL[SYNTH_VOICE_BUFFER_LENGTH];
float bufferR[SYNTH_VOICE_BUFFER_LENGTH];

EffectChain e(PhasePhdgr::getExampleEffectChain(), PhasePhdgr::ComponentRegister(), nullptr);
GlobalData g;

for (int j = 0; j < s; j++)
{
for (int i = 0; i < (int)fs; i += SYNTH_VOICE_BUFFER_LENGTH)
{
memset(bufferL, 0, sizeof(float) * SYNTH_VOICE_BUFFER_LENGTH);
memset(bufferR, 0, sizeof(float) * SYNTH_VOICE_BUFFER_LENGTH);
e.update(bufferL, bufferR, SYNTH_VOICE_BUFFER_LENGTH, fs, g);
}
}
}
2 changes: 1 addition & 1 deletion core/test/bench_synthvoice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ using namespace PhasePhdgr;

int main()
{
const int s = 60 * 30; // ~30 minutes
const int s = 60; // ~1 minutes
const float fs = 48000;
float bufferL[SYNTH_VOICE_BUFFER_LENGTH];
float bufferR[SYNTH_VOICE_BUFFER_LENGTH];
Expand Down

0 comments on commit dbe688c

Please sign in to comment.