Question about getting note numbers from Property Diffs

This forum is for developers of Rack Extensions to discuss the RE SDK, share code, and offer tips to other developers.
Post Reply
wendallsan
Posts: 45
Joined: 10 Dec 2017

16 Jun 2021

I'm trying to get the note number of the 1st detected note that is being played in a method called HandleNotePressed, which is called during RenderBatch, and then set an output Note CV jack to this note number value. I THINK I have to use the fKey property to get this, but it is type 'char *' and I don't know how to convert this to a TJBox_Float64 so I can store it in the MOM. Let me know if anyone can help me figure out whether fKey is indeed what I should be using and how to do the data type conversion. Many thanks for any help!

Here is what I currently have:

Code: Select all

void CTriggerHappy::HandleNotePressed( const TJBox_PropertyDiff iPropertyDiffs[], TJBox_UInt32 iDiffCount ){
	for( TJBox_UInt32 i = 0; i < iDiffCount; ++i ){
        if( iPropertyDiffs[ i ].fPropertyRef.fObject == fNoteStates ){
			TJBox_Float64 velocity = JBox_GetNumber( iPropertyDiffs[ i ].fCurrentValue );
			if( velocity > 0.f ){
                                JBox_StoreMOMProperty( fNoteOutCVJackRef, JBox_MakeNumber( iPropertyDiffs[ i ].fPropertyRef.fKey ) );
				break;
			}
		}
	}
}

Here are the current build errors:

Code: Select all

TriggerHappy.cpp:52:44: error: no matching function for call to 'JBox_MakeNumber'
        JBox_StoreMOMProperty( fNoteOutCVJackRef, JBox_MakeNumber( noteNumber ) );
                                                  ^~~~~~~~~~~~~~~
..\..\..\..\Public\Documents\ReasonStudios\JukeboxSDK_4.2.0\SDK\API\Jukebox.h:758:13: note: candidate function not
      viable: no known conversion from 'char *' to 'TJBox_Float64' (aka 'double') for 1st argument; dereference the
      argument with *
TJBox_Value JBox_MakeNumber(TJBox_Float64 iNumber);
            ^
TriggerHappy.cpp:61:23: error: cannot initialize a parameter of type 'char *' with an lvalue of type
      'const TJBox_PropertyKey' (aka 'char const[36]')
                                SetNoteOutCVJack( iPropertyDiffs[ i ].fPropertyRef.fKey );
                                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
TriggerHappy.cpp:51:57: note: passing argument to parameter 'noteNumber' here
void CTriggerHappy::SetNoteOutCVJack( TJBox_PropertyKey noteNumber ){
                                                        ^
2 errors generated.
Build ERROR!
Last edited by wendallsan on 16 Jun 2021, edited 1 time in total.

User avatar
rcbuse
RE Developer
Posts: 1175
Joined: 16 Jan 2015
Location: SR388
Contact:

16 Jun 2021

void CRackExtension::HandleNoteOnNoteOffDiff(const TJBox_PropertyDiff &iPropertyDiff)
{
TJBox_NoteEvent noteEvent = JBox_AsNoteEvent( iPropertyDiff );

....

typedef struct {
/** @brief The note number of the event, valid values are between 0 and 127. */
TJBox_UInt8 fNoteNumber;
/** @brief The velocity of the event, valid values are between 0 and 127. 0 velocity means that the note is turned off.*/
TJBox_UInt8 fVelocity;
/**
@brief The frame in the batch where the event took place.
This value must be between 0 and 63.
*/
TJBox_UInt16 fAtFrameIndex;
} TJBox_NoteEvent;

wendallsan
Posts: 45
Joined: 10 Dec 2017

16 Jun 2021

Thanks! I had not found the TJBox_NoteEvent class yet.

I've updated my method to use this class, and the extension now builds without errors and In the Recon Tools > Inspect properties I can see that the Note Out jack is indeed changing values as I feed different notes into it and is the note numbers look correct as I expect. However, when I connect a device up to my device's gate and note outs and then play notes into my rack extension, the output played by the connected device is a high pitched note that doesn't change pitch as I play different notes. What am I doing wrong in the process of sending this note data out the Note CV out jack and into other devices?

Here is my updated method:

Code: Select all

void CTriggerHappy::HandleNotePressed( const TJBox_PropertyDiff iPropertyDiffs[], TJBox_UInt32 iDiffCount ){
	for( TJBox_UInt32 i = 0; i < iDiffCount; ++i ){
        if( iPropertyDiffs[ i ].fPropertyRef.fObject == fNoteStates ){
			TJBox_Float64 velocity = JBox_GetNumber( iPropertyDiffs[ i ].fCurrentValue );
			if( velocity > 0.f ){
				TJBox_NoteEvent noteEvent = JBox_AsNoteEvent( iPropertyDiffs[ i ] );
				JBox_StoreMOMProperty( fNoteOutCVJackValue, JBox_MakeNumber( noteEvent.fNoteNumber ) );				
				break;
			}
		}
	}
}

User avatar
orthodox
RE Developer
Posts: 2286
Joined: 22 Jan 2015
Location: 55°09'24.5"N 37°27'41.4"E

16 Jun 2021

See Sequencer integration chapter "CV standard in Reason". It describes the convention on the pitch values for CV transport.

wendallsan
Posts: 45
Joined: 10 Dec 2017

16 Jun 2021

Many thanks! I just needed to divide the note number by 127 to get a value in a range between 0 and 1. Thanks for the tip!

Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 0 guests