mirror of
https://github.com/vsariola/sointu.git
synced 2025-07-18 21:14:31 -04:00
feat: add the ability to use Sointu as a sync-tracker
There is a new "sync" opcode that saves the top-most signal every 256 samples to the new "syncBuffer" output. Additionally, you can enable saving the current fractional row as sync[0], avoiding calculating the beat in the shader, but also calculating the beat correctly when the beat is modulated.
This commit is contained in:
@ -1,10 +1,13 @@
|
||||
function(regression_test testname)
|
||||
|
||||
if(${ARGC} LESS 6)
|
||||
if(${ARGC} LESS 4)
|
||||
if(ARGV5)
|
||||
set(source ${ARGV5})
|
||||
add_executable(${testname} ${source} test_renderer.c)
|
||||
else()
|
||||
if(ARGV3)
|
||||
set(source ${ARGV3}.yml)
|
||||
else()
|
||||
set(source ${testname}.yml)
|
||||
else()
|
||||
set(source ${ARGV3}.yml)
|
||||
endif()
|
||||
|
||||
set(asmfile ${testname}.asm)
|
||||
@ -19,7 +22,7 @@ function(regression_test testname)
|
||||
add_executable(${testname} test_renderer.c ${asmfile})
|
||||
target_compile_definitions(${testname} PUBLIC TEST_HEADER=<${testname}.h>)
|
||||
|
||||
if (NODE AND WAT2WASM AND NOT ${testname} MATCHES "sample")
|
||||
if (NODE AND WAT2WASM AND NOT ${testname} MATCHES "sample" AND NOT ${testname} MATCHES "sync")
|
||||
set(wasmfile ${CMAKE_CURRENT_BINARY_DIR}/${testname}.wasm)
|
||||
set(watfile ${CMAKE_CURRENT_BINARY_DIR}/${testname}.wat)
|
||||
set(wasmtarget wasm_${testname})
|
||||
@ -29,31 +32,29 @@ function(regression_test testname)
|
||||
DEPENDS sointu-compiler
|
||||
)
|
||||
add_test(${wasmtarget} ${NODE} ${CMAKE_CURRENT_SOURCE_DIR}/wasm_test_renderer.es6 ${wasmfile} ${CMAKE_CURRENT_SOURCE_DIR}/expected_output/${testname}.raw)
|
||||
endif()
|
||||
else()
|
||||
set(source ${ARGV5})
|
||||
add_executable(${testname} ${source} test_renderer.c)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
add_test(${testname} ${testname} ${CMAKE_CURRENT_SOURCE_DIR}/expected_output/${testname}.raw)
|
||||
if (${testname} MATCHES "sync")
|
||||
add_test(${testname} ${testname} ${CMAKE_CURRENT_SOURCE_DIR}/expected_output/${testname}.raw ${CMAKE_CURRENT_SOURCE_DIR}/expected_output/${testname}_syncbuf.raw)
|
||||
else()
|
||||
add_test(${testname} ${testname} ${CMAKE_CURRENT_SOURCE_DIR}/expected_output/${testname}.raw)
|
||||
endif()
|
||||
target_link_libraries(${testname} ${HEADERLIB})
|
||||
|
||||
target_include_directories(${testname} PUBLIC ${CMAKE_CURRENT_BINARY_DIR})
|
||||
target_compile_definitions(${testname} PUBLIC TEST_NAME="${testname}")
|
||||
|
||||
if(ARGC GREATER 1)
|
||||
if (ARGV1)
|
||||
message("${testname} requires ${ARGV1}")
|
||||
set_tests_properties(${testname} PROPERTIES FIXTURES_REQUIRED "${ARGV1}")
|
||||
endif()
|
||||
|
||||
if (ARGV1)
|
||||
message("${testname} requires ${ARGV1}")
|
||||
set_tests_properties(${testname} PROPERTIES FIXTURES_REQUIRED "${ARGV1}")
|
||||
endif()
|
||||
|
||||
if (ARGV2)
|
||||
message("${testname} setups ${ARGV2}")
|
||||
set_tests_properties(${testname} PROPERTIES FIXTURES_SETUP "${ARGV2}")
|
||||
endif()
|
||||
|
||||
if(ARGC GREATER 2)
|
||||
if (ARGV2)
|
||||
message("${testname} setups ${ARGV2}")
|
||||
set_tests_properties(${testname} PROPERTIES FIXTURES_SETUP "${ARGV2}")
|
||||
endif()
|
||||
endif()
|
||||
endfunction(regression_test)
|
||||
|
||||
regression_test(test_envelope "" ENVELOPE)
|
||||
@ -157,6 +158,7 @@ regression_test(test_envelope_16bit ENVELOPE "" test_envelope "-i")
|
||||
regression_test(test_polyphony "ENVELOPE;VCO_SINE")
|
||||
regression_test(test_chords "ENVELOPE;VCO_SINE")
|
||||
regression_test(test_speed "ENVELOPE;VCO_SINE")
|
||||
regression_test(test_sync "ENVELOPE" "" "" "-r")
|
||||
|
||||
regression_test(test_render_samples ENVELOPE "" "" "" test_render_samples.c)
|
||||
target_link_libraries(test_render_samples ${STATICLIB})
|
||||
|
BIN
tests/expected_output/test_sync.raw
Normal file
BIN
tests/expected_output/test_sync.raw
Normal file
Binary file not shown.
BIN
tests/expected_output/test_sync_syncbuf.raw
Normal file
BIN
tests/expected_output/test_sync_syncbuf.raw
Normal file
Binary file not shown.
@ -16,6 +16,11 @@
|
||||
#include TEST_HEADER
|
||||
SUsample buf[SU_BUFFER_LENGTH];
|
||||
SUsample filebuf[SU_BUFFER_LENGTH];
|
||||
#ifdef SU_SYNC
|
||||
float syncBuf[SU_SYNCBUFFER_LENGTH];
|
||||
float fileSyncBuf[SU_BUFFER_LENGTH];
|
||||
#endif
|
||||
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
FILE* f;
|
||||
@ -36,7 +41,11 @@ int main(int argc, char* argv[]) {
|
||||
su_load_gmdls();
|
||||
#endif
|
||||
|
||||
#ifdef SU_SYNC
|
||||
su_render_song(buf, syncBuf);
|
||||
#else
|
||||
su_render_song(buf);
|
||||
#endif
|
||||
|
||||
#if defined (_WIN32)
|
||||
CreateDirectory(actual_output_folder, NULL);
|
||||
@ -49,6 +58,13 @@ int main(int argc, char* argv[]) {
|
||||
fwrite((void*)buf, sizeof(SUsample), SU_BUFFER_LENGTH, f);
|
||||
fclose(f);
|
||||
|
||||
#ifdef SU_SYNC
|
||||
snprintf(filename, sizeof filename, "%s%s%s", actual_output_folder, test_name, "_syncbuf.raw");
|
||||
f = fopen(filename, "wb");
|
||||
fwrite((void*)syncBuf, sizeof(float), SU_SYNCBUFFER_LENGTH, f);
|
||||
fclose(f);
|
||||
#endif
|
||||
|
||||
f = fopen(argv[1], "rb");
|
||||
|
||||
if (f == NULL) {
|
||||
@ -92,6 +108,42 @@ int main(int argc, char* argv[]) {
|
||||
printf("Warning: Sointu rendered almost correct wave, but a small maximum error of %f\n",max_diff);
|
||||
}
|
||||
|
||||
#ifdef SU_SYNC
|
||||
f = fopen(argv[2], "rb");
|
||||
|
||||
if (f == NULL) {
|
||||
printf("No expected sync waveform found!\n");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
fseek(f, 0, SEEK_END);
|
||||
fsize = ftell(f);
|
||||
fseek(f, 0, SEEK_SET);
|
||||
|
||||
if (SU_SYNCBUFFER_LENGTH * sizeof(float) < fsize) {
|
||||
printf("Sointu rendered shorter sync wave than expected\n");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (SU_SYNCBUFFER_LENGTH * sizeof(float) > fsize) {
|
||||
printf("Sointu rendered longer sync wave than expected\n");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
fread((void*)fileSyncBuf, fsize, 1, f);
|
||||
fclose(f);
|
||||
f = NULL;
|
||||
|
||||
max_diff = 0.0f;
|
||||
|
||||
for (n = 0; n < SU_SYNCBUFFER_LENGTH; n++) {
|
||||
diff = (float)fabs(syncBuf[n] - fileSyncBuf[n]);
|
||||
if (diff > 1e-3f || isnan(diff)) {
|
||||
printf("Sointu rendered different sync wave than expected\n");
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
|
||||
fail:
|
||||
|
20
tests/test_sync.yml
Normal file
20
tests/test_sync.yml
Normal file
@ -0,0 +1,20 @@
|
||||
bpm: 100
|
||||
rowsperbeat: 4
|
||||
score:
|
||||
rowsperpattern: 16
|
||||
length: 2
|
||||
tracks:
|
||||
- numvoices: 1
|
||||
order: [0, 0]
|
||||
patterns: [[64, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0]]
|
||||
patch:
|
||||
- numvoices: 1
|
||||
units:
|
||||
- type: envelope
|
||||
parameters: {attack: 64, decay: 64, gain: 128, release: 80, stereo: 0, sustain: 64}
|
||||
- type: sync
|
||||
- type: envelope
|
||||
parameters: {attack: 95, decay: 64, gain: 128, release: 80, stereo: 0, sustain: 64}
|
||||
- type: sync
|
||||
- type: out
|
||||
parameters: {gain: 128, stereo: 1}
|
Reference in New Issue
Block a user