parent
03c774f77f
commit
c2a9ac34a2
@ -1,63 +1,76 @@ |
|||||||
// Fix 1 to n problem Bob Larkin June 2020
|
/* Fix 1 to n problem Bob Larkin June 2020
|
||||||
// Need to convert to TYmpan routine??
|
* Adapted to Chip Audette's Tympan routine. Allows random channels. |
||||||
|
* Class name does not have "_OA" to be backward compatible. |
||||||
|
*
|
||||||
|
* MIT License. use at your own risk. |
||||||
|
*/ |
||||||
|
|
||||||
#include "AudioMixer_F32.h" |
#include "AudioMixer_F32.h" |
||||||
|
|
||||||
void AudioMixer4_F32::update(void) { |
void AudioMixer4_F32::update(void) { |
||||||
audio_block_f32_t *in, *out=NULL; |
audio_block_f32_t *in, *out=NULL; |
||||||
|
int channel = 0; |
||||||
|
|
||||||
out = receiveWritable_f32(0); |
//get the first available channel
|
||||||
if (!out) return; |
while (channel < 4) { |
||||||
|
out = receiveWritable_f32(channel); |
||||||
arm_scale_f32(out->data, multiplier[0], out->data, out->length); |
if (out) break; |
||||||
|
channel++; |
||||||
for (int channel=0; channel < 4; channel++) { // Was 1 to 3 RSL June 2020
|
|
||||||
in = receiveReadOnly_f32(channel); |
|
||||||
if (!in) { |
|
||||||
continue; |
|
||||||
} |
|
||||||
|
|
||||||
audio_block_f32_t *tmp = allocate_f32(); |
|
||||||
|
|
||||||
arm_scale_f32(in->data, multiplier[channel], tmp->data, tmp->length); |
|
||||||
arm_add_f32(out->data, tmp->data, out->data, tmp->length); |
|
||||||
|
|
||||||
AudioStream_F32::release(tmp); |
|
||||||
AudioStream_F32::release(in); |
|
||||||
} |
} |
||||||
|
if (!out) return; //there was no data output array available, so exit.
|
||||||
|
arm_scale_f32(out->data, multiplier[channel], out->data, out->length); |
||||||
|
|
||||||
if (out) { |
//add in the remaining channels, as available
|
||||||
AudioStream_F32::transmit(out); |
channel++; |
||||||
AudioStream_F32::release(out); |
while (channel < 4) { |
||||||
|
in = receiveReadOnly_f32(channel); |
||||||
|
if (in) { |
||||||
|
audio_block_f32_t *tmp = allocate_f32(); |
||||||
|
|
||||||
|
arm_scale_f32(in->data, multiplier[channel], tmp->data, tmp->length); |
||||||
|
arm_add_f32(out->data, tmp->data, out->data, tmp->length); |
||||||
|
|
||||||
|
AudioStream_F32::release(tmp); |
||||||
|
AudioStream_F32::release(in); |
||||||
|
} else { |
||||||
|
//do nothing, this vector is empty
|
||||||
|
} |
||||||
|
channel++; |
||||||
} |
} |
||||||
|
AudioStream_F32::transmit(out); |
||||||
|
AudioStream_F32::release(out); |
||||||
} |
} |
||||||
|
|
||||||
void AudioMixer8_F32::update(void) { |
void AudioMixer8_F32::update(void) { |
||||||
audio_block_f32_t *in, *out=NULL; |
audio_block_f32_t *in, *out=NULL; |
||||||
|
|
||||||
out = receiveWritable_f32(0); //try to get the first input channel
|
//get the first available channel
|
||||||
if (!out) return; //if it's not there, return immediately
|
int channel = 0; |
||||||
|
while (channel < 8) { |
||||||
arm_scale_f32(out->data, multiplier[0], out->data, out->length); //scale the first input channel
|
out = receiveWritable_f32(channel); |
||||||
|
if (out) break; |
||||||
//load and process the rest of the channels
|
channel++; |
||||||
for (int channel=0; channel < 8; channel++) { // Was 1 to 7 RSL June 2020
|
|
||||||
in = receiveReadOnly_f32(channel); |
|
||||||
if (!in) { |
|
||||||
continue; |
|
||||||
} |
|
||||||
|
|
||||||
audio_block_f32_t *tmp = allocate_f32(); |
|
||||||
|
|
||||||
arm_scale_f32(in->data, multiplier[channel], tmp->data, tmp->length); |
|
||||||
arm_add_f32(out->data, tmp->data, out->data, tmp->length); |
|
||||||
|
|
||||||
AudioStream_F32::release(tmp); |
|
||||||
AudioStream_F32::release(in); |
|
||||||
} |
} |
||||||
|
if (!out) return; //there was no data output array. so exit.
|
||||||
|
arm_scale_f32(out->data, multiplier[channel], out->data, out->length);
|
||||||
|
|
||||||
if (out) { |
//add in the remaining channels, as available
|
||||||
AudioStream_F32::transmit(out); |
channel++; |
||||||
AudioStream_F32::release(out); |
while (channel < 8) { |
||||||
|
in = receiveReadOnly_f32(channel); |
||||||
|
if (in) { |
||||||
|
audio_block_f32_t *tmp = allocate_f32(); |
||||||
|
|
||||||
|
arm_scale_f32(in->data, multiplier[channel], tmp->data, tmp->length); |
||||||
|
arm_add_f32(out->data, tmp->data, out->data, tmp->length); |
||||||
|
|
||||||
|
AudioStream_F32::release(tmp); |
||||||
|
AudioStream_F32::release(in); |
||||||
|
} else { |
||||||
|
//do nothing, this vector is empty
|
||||||
|
} |
||||||
|
channel++; |
||||||
} |
} |
||||||
|
AudioStream_F32::transmit(out); |
||||||
|
AudioStream_F32::release(out); |
||||||
} |
} |
||||||
|
Loading…
Reference in new issue