Looping Samples?

edited July 2014 in General
Is it possible already with the current firmware?

I was going to start hacking around in the code to make it work but I thought I'd better ask first!

:)

Comments

  • edited July 2014
    Edit: sorry, didn't read you question right.
  • It was easy enough to get it working but I guess it could do with a 'Loop Yes/No' parameter as you wouldn't want it on for transient samples.

    There's a space on the OSC page to have a parameter next to 'WAV'' but it's going to take me a lot longer to figure that bit out!
     
    The alternative would be to somehow encode it into the sample so that it can be interpreted by the sample loading routine.

  • edited July 2014
    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.

    Any ideas?
  • Hello :-)
    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.
  • 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.
  • if you set it to DTYPE_ON_OFF it will be either 0 or 1.
    then you should change
    if (osc->sloop > 63)
    to
    if (osc->sloop)
    to make it work
  • Thanks Julian, egnouf

    It is DTYPE_ON_OFF but I'd also tried it with DTYPE_0B127 when I was debugging the values.

    I'll give it another try with that logic in the buffer streaming changed.

  • 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.

  • YES!  :-))

    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. 
    :D
  • Youahhhh , I am looking forward to seeing your new feature :-)
    and give us later a github link ;-)
    regards.
  • edited July 2014
    @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()

    maybe you only implemented it in one of those?
  • Not at computer now but will check later. I definitely only implemented it in 2 functions so you're probably correct.

    Thanks Julian
  • waiting for your github
    >:D<
  • 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?

    Neil
Sign In or Register to comment.