is posible to read AudioSynthWaveform out as data?

Status
Not open for further replies.

M4ngu

Well-known member
hi, I'm working in a multiple LFO eurorack module with cross modulation, sadly the AudioSynthWaveform does not have a read(); function (like AudioSynthWaveformDc has) so if I want to control the amount of modulation for pitch, amplitude and offset lots of mixers are needed. Checked AudioRecordQueue but this gives a read of 128 samples, in that case there will be a latency of 2,9 milliseconds. If there was a way read each waveform as data, it would be much easier as all the parameters I would like to modulate are already functions of AudioSynthWaveform.
4xLFO.png
first column of mixers controls the frequency modulation, second the amplitude and third the offset
 
Last edited:
I did something like this:

Edit synth_waveform.cpp around line 175:
Code:
// Hack to get amplitude for LFO purposes.
	last_amplitude = static_cast<float>(block->data[AUDIO_BLOCK_SAMPLES-1]) / 32767.0f;

Edit synth_waveform.h around line 117 to add last_amplitude and a getter for it:

Code:
	float getLastAmplitude(void) {
		return last_amplitude;
	}

private:
	uint32_t phase_accumulator;
	uint32_t phase_increment;
	uint32_t phase_offset;
	int32_t  magnitude;
	uint32_t pulse_width;
	const int16_t *arbdata;
	int16_t  sample; // for WAVEFORM_SAMPLE_HOLD
	short    tone_type;
	int16_t  tone_offset;
	float last_amplitude=0.0;

last_amplitude will only be updated every 128 samples, so the max frequency it could measure would be something like 20000 / 128 = 156Hz which is perfectly fine for LFO usage.

If you don't want to hack up the Audio library, you can use the Peak Analyzer, but I prefer not to since it consumes valuable CPU cycles. Anyway, hope that helps, good luck.
 
I did something like this:

Edit synth_waveform.cpp around line 175:
Code:
// Hack to get amplitude for LFO purposes.
	last_amplitude = static_cast<float>(block->data[AUDIO_BLOCK_SAMPLES-1]) / 32767.0f;

Edit synth_waveform.h around line 117 to add last_amplitude and a getter for it:

Code:
	float getLastAmplitude(void) {
		return last_amplitude;
	}

private:
	uint32_t phase_accumulator;
	uint32_t phase_increment;
	uint32_t phase_offset;
	int32_t  magnitude;
	uint32_t pulse_width;
	const int16_t *arbdata;
	int16_t  sample; // for WAVEFORM_SAMPLE_HOLD
	short    tone_type;
	int16_t  tone_offset;
	float last_amplitude=0.0;

last_amplitude will only be updated every 128 samples, so the max frequency it could measure would be something like 20000 / 128 = 156Hz which is perfectly fine for LFO usage.

If you don't want to hack up the Audio library, you can use the Peak Analyzer, but I prefer not to since it consumes valuable CPU cycles. Anyway, hope that helps, good luck.

ok i Hack the AudioSynthWaveform.h AudioSynthWaveform.cpp to get amplitude for LFO purposes
I have written an LFO type AudioSynthWaveform,
and I call it with lfo1.getLastAmplitude() and i only get zeros, where may be in error?

Image1.jpg
 
Status
Not open for further replies.
Back
Top