
Originally Posted by
vincentiuș
i just want to control the amount of the offset as on the code on msg# 12 but when going for from 0.00 to 1.00 the positive (+5v) part to stay untouched (like it's half rectified) and the negative part (-5V) to shrink to 0 as the amount is given by the encoder (pic)
You can use the waveshape effect to get the half wave rectified behavior. Create 2 of them, one for the positive half of the waveform and another for the negative half.
Then add the 2 halves back together with a mixer, where you can control the gain on each channel. To get "from 0.00 to 1.00 the positive (+5v) part to stay untouched" set the gain to 1.0. For the encoder to control the amount of the negative part "the negative part (-5V) to shrink to 0 as the amount is given by the encoder (pic)", just write some code for the encoder to adjust the gain of the other mixer input.

Here is very simple code which sets the negative half gain to 0.33.
Code:
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>
// GUItool: begin automatically generated code
AudioSynthWaveform waveform1; //xy=167,118
AudioEffectWaveshaper waveshape1; //xy=389,77
AudioEffectWaveshaper waveshape2; //xy=396,160
AudioMixer4 mixer1; //xy=628,112
AudioOutputAnalog dac1; //xy=833,121
AudioConnection patchCord1(waveform1, waveshape1);
AudioConnection patchCord2(waveform1, waveshape2);
AudioConnection patchCord3(waveshape1, 0, mixer1, 0);
AudioConnection patchCord4(waveshape2, 0, mixer1, 1);
AudioConnection patchCord5(mixer1, dac1);
// GUItool: end automatically generated code
float positiveOnly[3] = {0.0, 0.0, 1.0};
float negativeOnly[3] = {-1.0, 0.0, 0.0};
void setup() {
AudioMemory(16);
waveform1.begin(WAVEFORM_SINE);
waveform1.frequency(110);
waveform1.amplitude(1.00);
waveshape1.shape(positiveOnly, 3);
waveshape2.shape(negativeOnly, 3);
mixer1.gain(0, 1.0);
mixer1.gain(1, 0.33);
}
void loop() {
// put your main code here, to run repeatedly:
}
Here is the resulting waveform. You can see the positive half is unaltered, but the negative half is reduced in amplitude. Hopefully that is what you wanted?