Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 3 of 3

Thread: is posible to read AudioSynthWaveform out as data?

  1. #1
    Junior Member
    Join Date
    Sep 2019
    Location
    Sevilla, Spain
    Posts
    2

    is posible to read AudioSynthWaveform out as data?

    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.
    Click image for larger version. 

Name:	4xLFO.png 
Views:	23 
Size:	125.1 KB 
ID:	18082
    first column of mixers controls the frequency modulation, second the amplitude and third the offset
    Last edited by M4ngu; 11-01-2019 at 10:34 PM.

  2. #2
    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.

  3. #3
    Junior Member
    Join Date
    Sep 2019
    Location
    Sevilla, Spain
    Posts
    2
    thanks a lot for the answer, must try this and see how it works

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •