Trigger input

Discussion about the Bidule SDK, post your questions, feature request and plugins here.

Moderators: davidv, seb@plogue

boonier
Posts: 984
Joined: Wed Sep 14, 2005 6:34 am
Location: Brighton, UK

Trigger input

Postby boonier » Thu Nov 25, 2010 7:08 am

HI again,

When an input receives a trigger, from say the Trigger bidule, I want it to fire a function to generate and output a random number.

How does one capture the trigger from the input. I'm guessing something like:

Code: Select all

if(sampleIn[0] == 1) {
sampleOut[0] = rand() % myMaxNumber ; // myMaxNumber is taken from a gui number box parameter btw
}

C++ and plugin sdks and new to me, but I think I 'get it'

cheers

seb@plogue
Site Admin
Posts: 9592
Joined: Tue Mar 02, 2004 7:23 pm
Location: Montreal
Contact:

Re: Trigger input

Postby seb@plogue » Thu Nov 25, 2010 9:50 am

couple of things :

- sampleIn[x] and sampleOut[y] are pointers, your pseudo-code checks for pointing at 1 and reassigns the pointer for the output randomly
- trigger will not necessarily occur on the first sample
- checking against 1.f instead of 1 would be preferable and make sure the compiler does not automatically convert sampleIn to int to do the comparison (which can be a costly operation)

boonier
Posts: 984
Joined: Wed Sep 14, 2005 6:34 am
Location: Brighton, UK

Re: Trigger input

Postby boonier » Thu Nov 25, 2010 12:11 pm

Oops, yeh sorry i assumed they were input/output indices of the _numAudioIns/_numAudioOuts array. Need to read the code more.

trigger will not necessarily occur on the first sample


OK, so that makes sense with regard to the above then. How does it test for the '1' at any sample? I assume this is how the Note Creator / MIDI Event / Value List etc works right?

thx

seb@plogue
Site Admin
Posts: 9592
Joined: Tue Mar 02, 2004 7:23 pm
Location: Montreal
Contact:

Re: Trigger input

Postby seb@plogue » Thu Nov 25, 2010 1:44 pm

Typically you would do something similar to this (it can be made in less lines but I'm going for clarity):

Code: Select all

    Sample* in0  = _samplesIn[0];
    Sample* out0  = _samplesOut[0];
    int32_t sampleFrames = _dspInfo.bufferSize
        while(--sampleFrames >= 0) {
             Sample inVal = (*in0++); //get value for sample and increment pointer
             Sample outVal = 0.0f;
             if(inVal == 1.f)
                 outVal = rand() % myMaxNumber;
             (*out0++) = outVal; //set value for sample and increment pointer
        }


Return to “Bidule SDK”

Who is online

Users browsing this forum: No registered users and 1 guest