programming a trigger
Hi,
So I'm playing around with the C++ SDK. I'm very slowly building understanding of things but already getting somewhere...
Anyways, a question - I've posed this question before but for pascal-scripting:
What's the correct way to program a user module outlet to give a trigger (like for example a button-module gives), i.e. a rapid 1 and then 0, in the Process-function?
Cheers,
antwan
So I'm playing around with the C++ SDK. I'm very slowly building understanding of things but already getting somewhere...
Anyways, a question - I've posed this question before but for pascal-scripting:
What's the correct way to program a user module outlet to give a trigger (like for example a button-module gives), i.e. a rapid 1 and then 0, in the Process-function?
Cheers,
antwan
-
martignasse
- Site Admin
- Posts: 611
- Location: Lyon, FRANCE
- Contact:
hi antwan,
sorry for the lag....
The process function is equivalent of the main proc in script, i believe, it's called each audio engine cycle by Usine.
so yes, it's the place to go, here a basic example :
where :
pTriggerButtonTest is your module class
bWantTrigger is the boolean flag used to manage the trigger, putted to TRUE by whatever you want
PTriggerOut is a button outlet
hope it help
sorry for the lag....
do you refer to this thread ?I've posed this question before but for pascal-scripting
The process function is equivalent of the main proc in script, i believe, it's called each audio engine cycle by Usine.
so yes, it's the place to go, here a basic example :
Code: Select all
void Process (void* pModule) {
TTriggerButtonTest* pTriggerButtonTest = ((TTriggerButtonTest*)pModule);
if (pTriggerButtonTest->bWantTrigger) {
if (pTriggerButtonTest->PTriggerOut->value == 1) {
pTriggerButtonTest->PTriggerOut->value = 0;
pTriggerButtonTest->bWantTrigger = FALSE;
}
else {
pTriggerButtonTest->PTriggerOut->value = 1;
}
}
}pTriggerButtonTest is your module class
bWantTrigger is the boolean flag used to manage the trigger, putted to TRUE by whatever you want
PTriggerOut is a button outlet
hope it help
Martin FLEURENT - Usine Developer - SDK maintainer
Hi Martin,
Thank you, I got it to work!
I wasn't far off actually but non-the-less I was making some stupid mistakes. Now I got it.
I'll take the liberty to hijack my own thread for another question:
How to use the VstTimeInfo flags. I was trying to read about this, but didn't quite understand. For instance if I'm interested in for example kVstTransportPlaying (as its called in the VST SDK... not sure if that constant is available in Usine SDK)?
Let's say I want to "make" my own boolean flag from that piece of information, how do I go about it?
Thanks for all your help!
antwan
Thank you, I got it to work!
I wasn't far off actually but non-the-less I was making some stupid mistakes. Now I got it.
I'll take the liberty to hijack my own thread for another question:
How to use the VstTimeInfo flags. I was trying to read about this, but didn't quite understand. For instance if I'm interested in for example kVstTransportPlaying (as its called in the VST SDK... not sure if that constant is available in Usine SDK)?
Let's say I want to "make" my own boolean flag from that piece of information, how do I go about it?
Thanks for all your help!
antwan
-
martignasse
- Site Admin
- Posts: 611
- Location: Lyon, FRANCE
- Contact:
Hi antwan,
...but you can do it if needed by adding the following code before your YourModule class definition, in the YourModule.h file.
Directly from the VST SDK 2.4, in the plugin interface file aeffectx.h :
The way to use it is not Usine or SDK related, but more C language knowledge 
To understand and using it, it's little more complex, i'll try to stay simple
kVstXXXXXXXX in the enum are bite mask, coded with the Bitwise Left Shift operator. I let you follow the link for precisions...
but finally, the kVstTransportPlaying variable contain '000000000000010' (so, one bite left shifted by on), ok ?
And to extract the info from the flags, you use the Bitewise AND operator (link for precisions)
so :
where pTriggerButtonTest->pMasterInfo->pTimeInfo->flags & kVstTransportPlaying is TRUE if the flags second bite from the right contain 1, that is.
Hope it's not too complex, welcome in C world
It's not finish, but i have a question.
Now, we have a test who return true when the host sequencer is playing, but what you want to do exactly, detecting when it begin to play ?
The VstTimeInfoFlags enumeration isn't actually defined in the Usine SDK...antwan wrote:How to use the VstTimeInfo flags. I was trying to read about this, but didn't quite understand. For instance if I'm interested in for example kVstTransportPlaying (as its called in the VST SDK... not sure if that constant is available in Usine SDK)?
...but you can do it if needed by adding the following code before your YourModule class definition, in the YourModule.h file.
Directly from the VST SDK 2.4, in the plugin interface file aeffectx.h :
Code: Select all
//-------------------------------------------------------------------------------------------------------
/** Flags used in #VstTimeInfo. */
//-------------------------------------------------------------------------------------------------------
enum VstTimeInfoFlags
{
//-------------------------------------------------------------------------------------------------------
kVstTransportChanged = 1, ///< indicates that play, cycle or record state has changed
kVstTransportPlaying = 1 << 1, ///< set if Host sequencer is currently playing
kVstTransportCycleActive = 1 << 2, ///< set if Host sequencer is in cycle mode
kVstTransportRecording = 1 << 3, ///< set if Host sequencer is in record mode
kVstAutomationWriting = 1 << 6, ///< set if automation write mode active (record parameter changes)
kVstAutomationReading = 1 << 7, ///< set if automation read mode active (play parameter changes)
kVstNanosValid = 1 << 8, ///< VstTimeInfo::nanoSeconds valid
kVstPpqPosValid = 1 << 9, ///< VstTimeInfo::ppqPos valid
kVstTempoValid = 1 << 10, ///< VstTimeInfo::tempo valid
kVstBarsValid = 1 << 11, ///< VstTimeInfo::barStartPos valid
kVstCyclePosValid = 1 << 12, ///< VstTimeInfo::cycleStartPos and VstTimeInfo::cycleEndPos valid
kVstTimeSigValid = 1 << 13, ///< VstTimeInfo::timeSigNumerator and VstTimeInfo::timeSigDenominator valid
kVstSmpteValid = 1 << 14, ///< VstTimeInfo::smpteOffset and VstTimeInfo::smpteFrameRate valid
kVstClockValid = 1 << 15 ///< VstTimeInfo::samplesToNextClock valid
//-------------------------------------------------------------------------------------------------------
};To understand and using it, it's little more complex, i'll try to stay simple
kVstXXXXXXXX in the enum are bite mask, coded with the Bitwise Left Shift operator. I let you follow the link for precisions...
but finally, the kVstTransportPlaying variable contain '000000000000010' (so, one bite left shifted by on), ok ?
And to extract the info from the flags, you use the Bitewise AND operator (link for precisions)
so :
Code: Select all
if (pTriggerButtonTest->pMasterInfo->pTimeInfo->flags & kVstTransportPlaying) {
...
}Hope it's not too complex, welcome in C world
It's not finish, but i have a question.
Now, we have a test who return true when the host sequencer is playing, but what you want to do exactly, detecting when it begin to play ?
Martin FLEURENT - Usine Developer - SDK maintainer
Hi!
Thanks once again!
Actually I hacked it meanwhile after reading the definition of the flags enum somewhere online. So without understanding what I was doing I got it right by typing
if (pMyUserModule->pMasterInfo->pTimeInfo->flags & 1 << 1) {
So I was just coming back to change my question to: What did I just do? What does this mean?
So thanks for already answering that and thanks for the clarification and the links, I will read through it. I have read about shift operators and such before, but I didn't understand it. With the help of this case study I'm sure I'll understand it better.
I hope to have my first simple user module complete tomorrow so you should get your answer about what it's for tomorrow - if all goes well
thanks again!
antwan
Thanks once again!
Actually I hacked it meanwhile after reading the definition of the flags enum somewhere online. So without understanding what I was doing I got it right by typing
if (pMyUserModule->pMasterInfo->pTimeInfo->flags & 1 << 1) {
So I was just coming back to change my question to: What did I just do? What does this mean?
So thanks for already answering that and thanks for the clarification and the links, I will read through it. I have read about shift operators and such before, but I didn't understand it. With the help of this case study I'm sure I'll understand it better.
I hope to have my first simple user module complete tomorrow so you should get your answer about what it's for tomorrow - if all goes well
thanks again!
antwan
-
martignasse
- Site Admin
- Posts: 611
- Location: Lyon, FRANCE
- Contact:
cool, cant wait to see that
Martin FLEURENT - Usine Developer - SDK maintainer
Hi,
I've got (at least) one remaining problem with all this: I can't seem to be getting any reading from BarStartPos or CycleStartPos. Any idea why?
Cheers,
antwan
I've got (at least) one remaining problem with all this: I can't seem to be getting any reading from BarStartPos or CycleStartPos. Any idea why?
Cheers,
antwan
-
martignasse
- Site Admin
- Posts: 611
- Location: Lyon, FRANCE
- Contact:
hi,
cant help on this, i even don't know what they mean, what kind of infos should they display ?
cant help on this, i even don't know what they mean, what kind of infos should they display ?
Martin FLEURENT - Usine Developer - SDK maintainer
They should contain the PpqPos of the start (beat 1) of the current bar or cycle. This is probably a question for Olivier then 
Cheers,
antwan
Cheers,
antwan
Who is online
Users browsing this forum: No registered users and 4 guests
