Hi,
Added the initial frequencydividercode as part of the effect_granular code (will split these into a separate library as soon as I can). The code is shown below, its a raw implementation that changes the audiooutput to be the same for 10 samples in a row. Since the total amount of samples coming in is 128 its not yet really ready I think. The output when listening to my artifical bat was tonally not very interesting. If that is due to the artificial bat (gives blips at different frequencies that last about 2 ms) or due to the setup I dont know. A longer stretched tone (200ms blip) at 35kHz clearly heard but still not a pure tone. Since we have the option to for instance interpolate the quality can possibly be improved on. Amplitude this way is allready preserved and thus a lot better than a simple digital divider.
Will test it this evening, I tested the time-expansion code yesterday and it works as expected. Every now and then a bat-call gets passed and you can hear a slowed-down call. I think this can be a lot improved by waiting for a signal that has an ultrasonic peak and play that and stop play as soon as the signal falls away. Then catch the next etc etc.
Cor
as part of effect_granular.h
Code:
void beginDivider(float grain_length) {
if (grain_length <= 0.0) return;
beginDivider_int(grain_length);
}
and added to effect_granular.cpp
Code:
void AudioEffectGranular::beginDivider_int(int grain_samples)
{
__disable_irq();
grain_mode = 4;
if (allow_len_change) {
if (grain_samples > max_sample_len) {
grain_samples = max_sample_len;
}
glitch_len = grain_samples;
}
sample_loaded = false;
write_en = false;
sample_req = true;
__enable_irq();
}
and inside void AudioEffectGranular::update(void)
Code:
else if (grain_mode == 4) {
//DIVIDER
int8_t subsample=0;
int16_t current_input=block->data[0];
for (int k = 0; k < AUDIO_BLOCK_SAMPLES; k++)
{
subsample++;
if (subsample%10==0)
{current_input = block->data[k];
}
block->data[k] = current_input;
}
}