Skip to content

Commit

Permalink
Updates to support 256-channel WFS
Browse files Browse the repository at this point in the history
  • Loading branch information
ideoforms committed Jul 22, 2024
1 parent 9e25159 commit e63d086
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 14 deletions.
2 changes: 1 addition & 1 deletion source/include/signalflow/core/constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ typedef RingBuffer<sample> SampleRingBuffer;
* TODO: Turn this into a run-time config parameter, and set default to 2
* Otherwise memory usage is very high by default
*-----------------------------------------------------------------------*/
#define SIGNALFLOW_NODE_INITIAL_OUTPUT_BUFFERS 64
#define SIGNALFLOW_NODE_INITIAL_OUTPUT_BUFFERS 256

/*------------------------------------------------------------------------
* Max supported number of FFT bins.
Expand Down
38 changes: 25 additions & 13 deletions source/src/node/processors/panning/spatial-environment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,26 +137,38 @@ void SpatialPanner::process(Buffer &out, int num_frames)
{
// m/s
float SPEED_OF_SOUND = 343.0;
float distance = sqrtf(powf(speaker->x - this->x->out[0][frame], 2) + powf(speaker->y - this->y->out[0][frame], 2) + powf(speaker->z - this->z->out[0][frame], 2));

float distance_m = distance;
float attenuation = 1.0 / (distance_m * distance_m);

if (use_delays->out[0][frame])
{
float delay_seconds = distance_m / SPEED_OF_SOUND;
// float distance = sqrtf(powf(speaker->x - this->x->out[0][frame], 2) + powf(speaker->y - this->y->out[0][frame], 2) + powf(speaker->z - this->z->out[0][frame], 2));
float dx = speaker->x - this->x->out[0][frame];
float dy = speaker->y - this->y->out[0][frame];
float dz = speaker->z - this->z->out[0][frame];
float distance_squared = dx * dx + dy * dy + dz * dz;

float MIN_DISTANCE_SQUARED = 0.1;
if (distance_squared < MIN_DISTANCE_SQUARED)
distance_squared = MIN_DISTANCE_SQUARED;

float distance = sqrtf(distance_squared);

// float attenuation = 1.0 / distance_m; // 2024-05-29
float attenuation = (1.0f / distance_squared) * 0.25f;
// float attenuation = (1.0 / powf(distance, 1.5)) * 0.1;
// float attenuation = (distance_squared) * 0.1;

// if (use_delays->out[0][frame])
// {
float delay_seconds = distance / SPEED_OF_SOUND;
float delay_samples = delay_seconds * this->graph->get_sample_rate();
if (frame == 0)
{
// printf("distance %.4fm, attenuation: %.4f, delay_samples: %.4f\n", distance, attenuation, delay_samples);
}

out[channel][frame] = this->buffer->get(-delay_samples) * attenuation;
}
else
{
out[channel][frame] = this->buffer->get(-1) * attenuation;
}
// }
// else
// {
// out[channel][frame] = this->buffer->get(-1) * attenuation;
// }
}
}
}
Expand Down

0 comments on commit e63d086

Please sign in to comment.