Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
build*/

.focus-config
.raddbg_project
*.raddbg_project
.vscode/
.idea/

Expand Down
6 changes: 4 additions & 2 deletions chowdsp_convolution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ void create_config (Config* config, int max_block_size)

void destroy_config (Config* config)
{
fft::fft_destroy_setup (config->fft);
if (config->fft != nullptr)
fft::fft_destroy_setup (config->fft);
*config = {};
}

Expand Down Expand Up @@ -215,7 +216,8 @@ void reset_process_state (const Config* config, Process_Uniform_State* state)

void destroy_process_state (Process_Uniform_State* state)
{
fft::aligned_free (state->state_data[0].segments);
if (state->state_data != nullptr)
fft::aligned_free (state->state_data[0].segments);
*state = {};
}

Expand Down
14 changes: 9 additions & 5 deletions test/chowdsp_convolution_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -351,17 +351,20 @@ static bool test_convolution (int ir_length_samples, int block_size, int num_blo

std::vector<float> test_output (input.size());
chowdsp::convolution::Config conv_config {};
chowdsp::convolution::destroy_config (&conv_config); // destroying an empty config should be okay...
chowdsp::convolution::create_config (&conv_config, block_size);
auto* fft_scratch = (float*) chowdsp::fft::aligned_malloc (conv_config.fft_size * sizeof (float));

chowdsp::convolution::IR_Uniform conv_ir {};
chowdsp::convolution::destroy_ir (&conv_ir); // destroying an empty IR should be okay...
chowdsp::convolution::create_ir (&conv_config,
&conv_ir,
ir.data(),
(int) ir.size(),
fft_scratch);

chowdsp::convolution::Process_Uniform_State conv_state {};
chowdsp::convolution::destroy_process_state (&conv_state); // destroying an empty state should be okay...
chowdsp::convolution::create_process_state (&conv_config, &conv_ir, &conv_state);

start = std::chrono::high_resolution_clock::now();
Expand Down Expand Up @@ -577,11 +580,11 @@ static bool test_convolution_non_uniform (int ir_length_samples, int block_size,
chowdsp::convolution::Config tail_config {};
chowdsp::convolution::create_config (&tail_config, head_size);

chowdsp::convolution::IR_Non_Uniform conv_ir {
.head_config = &head_config,
.tail_config = &tail_config,
.head_size = head_size,
};
chowdsp::convolution::IR_Non_Uniform conv_ir {};
chowdsp::convolution::destroy_nuir (&conv_ir);
conv_ir.head_config = &head_config;
conv_ir.tail_config = &tail_config;
conv_ir.head_size = head_size;
auto* scratch = (float*) chowdsp::fft::aligned_malloc (chowdsp::convolution::get_required_nuir_scratch_bytes (&conv_ir));

chowdsp::convolution::create_nuir (&conv_ir,
Expand All @@ -590,6 +593,7 @@ static bool test_convolution_non_uniform (int ir_length_samples, int block_size,
scratch);

chowdsp::convolution::Process_Non_Uniform_State conv_state {};
chowdsp::convolution::destroy_nuir_process_state (&conv_state); // destroying an empty state should be okay...
chowdsp::convolution::create_nuir_process_state (&conv_ir, &conv_state);

start = std::chrono::high_resolution_clock::now();
Expand Down