Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stb_hexwave: Initialize output buffers before freq handling #1706

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
8 changes: 4 additions & 4 deletions stb_hexwave.h
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,10 @@ STB_HEXWAVE_DEF void hexwave_generate_samples(float *output, int num_samples, He
// convert parameters to times and slopes
hexwave_generate_linesegs(vert, hex, dt);

// clear the output and temporary buffers before processing
memset(output, 0, sizeof(float)*num_samples);
memset(temp_output, 0, 2*hexblep.width*sizeof(float));

if (hex->prev_dt != dt) {
// if frequency changes, add a fixup at the derivative discontinuity starting at now
float slope;
Expand All @@ -446,10 +450,6 @@ STB_HEXWAVE_DEF void hexwave_generate_samples(float *output, int num_samples, He
hex->prev_dt = dt;
}

// copy the buffered data from last call and clear the rest of the output array
memset(output, 0, sizeof(float)*num_samples);
memset(temp_output, 0, 2*hexblep.width*sizeof(float));

if (num_samples >= hexblep.width) {
memcpy(output, hex->buffer, buffered_length);
} else {
Expand Down