I managed to create a new parameter 'SLOOP' thanks to the rather excellent guide on the wiki but I can't seem to get the sample buffer refresh to recognise the parameter, or possibly it's not getting set from the midi parser code (but I don't think that's true....read on)
I've added a parameter to the OscInfo structure:
typedef struct OscStruct
{
int16_t output;
uint32_t phaseInc;
uint32_t phase; // the current phase of the osc 8bit indexing 24 interpolation
float freq; // frequency in [Hz]
uint8_t waveform; // the selected waveform of the osc
uint8_t tableOffset; //overtone table
float pitchMod; // modulation value for frequency
float fmMod;
float modNodeValue;
//for midi
uint16_t midiFreq; //upper 8 bit coarse, lower 8 bit fine -> the sound edit freq offset
uint8_t baseNote; // the last played midi note
uint32_t startPhase; // the OSC is reset to this phase on retrigger
uint8_t sloop;
} OscInfo;
In MIDIPARSER.C I'm doing this:
case CC2_PAR_SLOOP1:
{
//voiceArray[0].vol = msg.data2/127.f;
voiceArray[0].osc.sloop = msg.data2;
}
In OSCILLATOR.C in the sample buffer update code I'm doing this:
if(itg < info.size)
{
osc->phase = oscPhase + osc->phaseInc;
} else {
if (osc->sloop > 63)
{
osc->phase = 0;
}
}
buf[i] = oscOut * gain;
If I remove the osc->sloop > 63 condition, the looping works. With the condition in place it's always off.
In the MIDIPARSER code, the line that is commented out that sets the oscillator volume was put in as a test to check if the value is getting set at that point. With this line in, the oscillator volume gets set as you'd expect.
hmmm looks good. are you using the main oscillator as sample player? just asking because voiceArray[0].volattenuates the voice output at the very end of the chain (final VCA so to say), but your voiceArray[0].osc.sloop only sets the sloop parameter for the main oscillator, not the fm mod osc or the transient osc.
Oh, and Julian, yes, using the main osc as a sample player though I might try to expand that to the second oscillator too as it might yield some interesting results.
Working now, thanks guys. Not really sure what happened: I guess I must've done the classic 'changing more than one thing when debugging' and somehow mixed up the 0/1 logic when I wasn't sure what values were used for a ON_OFF parameter.
I'll do some work on it tonight to code the features properly (especially the MIDI parser bit which was just a test with one single case for voice 0)
It certainly opens up some interesting possibilities: I've got mine loaded with a bunch of single-cycle waveforms which you can now use as an alternative oscillator shape.
@Julian: I'm a bit confused by the implementation. I have it working fine on Drum 1 to 3 but some of the other synthesis methods, even though you can select a user sample as the oscillator, don't seem to respond to the same looping.
Are there different fetch/fill buffer methods for each synthesis type?
hmmm normally each voice is using the same OscInfo struct for its oscillators. you should be able to set it accordingly.
there is a difference between fm and non fm oscillators though. there are two functions: calcNextOscSampleBlock() and calcNextOscSampleFmBlock() regarding the samples: calcUserSampleOscFmBlock() and calcUserSampleOscBlock()
Julian: can you confirm that you're able to use user samples as the FM secondary oscillator? You can select a sample but my looping trick doesn't work and I was wondering if it was the looping at fault or whether you've not implemented that yet?
Comments
stupid question, how is setup the CC2_PAR_SLOOP1 parameter?
is it an : DTYPE_1B16, DTYPE_ON_OFF, DTYPE_0B127, etc ?
it could be that SLOOP nevers reach 64.. because it is a ON OFF parameter (1 and 0) ... or CC2..SLOOP is set to 1 to 16 (DTYPE_1B16) , no?
tell me :-)
regards.
are you using the main oscillator as sample player?
just asking because voiceArray[0].volattenuates the voice output at the very end of the chain (final VCA so to say), but your voiceArray[0].osc.sloop only sets the sloop parameter for the main oscillator, not the fm mod osc or the transient osc.
then you should change
if (osc->sloop > 63)
to
if (osc->sloop)
to make it work
and give us later a github link ;-)
regards.
you should be able to set it accordingly.
there is a difference between fm and non fm oscillators though.
there are two functions: calcNextOscSampleBlock() and calcNextOscSampleFmBlock()
regarding the samples: calcUserSampleOscFmBlock() and calcUserSampleOscBlock()
maybe you only implemented it in one of those?
Thanks Julian
>:D<