Welcome to %s forums

BrainModular Users Forum

Login Register

Super Simple Beginners Question

Create your own modules in C++
Post Reply
sephult
Member
Posts: 1144
Contact:

Unread post by sephult » 21 Sep 2017, 13:03

Hello All!

So finally decided to dive in the SDK.

I am just looking now with some examples and trial and error...but mostly error.
I took the MIDI Transpose demonstration and was looking at how to start adding nodes/parameters.
I copied the following from case 2 of the

Code: Select all

void MidiTransposeExampleExample::onGetParamInfo (int ParamIndex, TParamInfo* pParamInfo)

Code: Select all

	case 3:
		pParamInfo->ParamType = ptDataFader;
		pParamInfo->Caption = "velo";
		pParamInfo->IsInput = TRUE;
		pParamInfo->IsOutput = FALSE;
		pParamInfo->MinValue = 0.0f;
		pParamInfo->MaxValue = 127.0f;
		pParamInfo->DefaultValue = 85.0f;
		pParamInfo->Symbol = "v";
		pParamInfo->Format = "%.0f";
		pParamInfo->IsStoredInPreset = TRUE;
		pParamInfo->CallBackType = ctImmediate;
		pParamInfo->EventPtr = &fdrVelo;
		break;
My assumption is I am declaring this node here. At first I rebuilt the solution and the node did not show up in my module.
I also went further to read in the value maybe thinking since I did not access it, for some reason it was not created. so OnProcess I put the following:

Code: Select all

int velo = (int)sdkGetEvtData(fdrVelo);
Doing a quick reference to how the &fdrPitch is being done, I could not find much difference in how I added the &fdrVelo.

Am I doing something wrong, or missing something?
Like I said I literally just jumped back in on the SDK, it's been many years (since the first HH SDKs, that I even messed around with).

-s
"Every act of creation is first an act of destruction." -Picasso

sephult
Member
Posts: 1144
Contact:

Unread post by sephult » 21 Sep 2017, 13:13

I was not finding the # of parameters....but I just found it finally!
Funny how you write a message for some help, and then solve it.

Well regardless here is some beginner information for adding your first parameter to a module:
Here you will define the number of node parameters:

Code: Select all

void MidiTransposeExampleExample::onGetModuleInfo (MasterInfo* pMasterInfo, ModuleInfo* pModuleInfo)

Code: Select all

pModuleInfo->NumberOfParams     = 4;
When you add the additional Switch Case(s), you can then just modify the onGetParamInfo

Code: Select all

void MidiTransposeExampleExample::onGetParamInfo (int ParamIndex, TParamInfo* pParamInfo)
by adding your new Switch Case Declaration:

Code: Select all

    case 3:
        pParamInfo->ParamType = ptDataFader;
        pParamInfo->Caption = "velo";
        pParamInfo->IsInput = TRUE;
        pParamInfo->IsOutput = FALSE;
        pParamInfo->MinValue = 0.0f;
        pParamInfo->MaxValue = 127.0f;
        pParamInfo->DefaultValue = 85.0f;
        pParamInfo->Symbol = "v";
        pParamInfo->Format = "%.0f";
        pParamInfo->IsStoredInPreset = TRUE;
        pParamInfo->CallBackType = ctImmediate;
        pParamInfo->EventPtr = &fdrVelo;
        break;

Code: Select all

SOLVED
-s
"Every act of creation is first an act of destruction." -Picasso

23fx23
Member
Posts: 2545
Contact:

Unread post by 23fx23 » 21 Sep 2017, 14:23

niice :) welcome to the big rabbit hole ;)

User avatar
nay-seven
Site Admin
Posts: 5684
Location: rennes France
Contact:

Unread post by nay-seven » 21 Sep 2017, 14:30

Great sephult ! if you have fun with it and a bit of time, could be a great idea to note all your progressions this way to create a "my first module with Usine SDK" manual ?
you have the best place for this job ? what do you think ?

sephult
Member
Posts: 1144
Contact:

Unread post by sephult » 21 Sep 2017, 16:12

I completely agree Nay, I will expand the SDK tutorials and help make it easier for others hopefully to follow. I feel like I'm cheating on my scripts though....hahaha
"Every act of creation is first an act of destruction." -Picasso

User avatar
nay-seven
Site Admin
Posts: 5684
Location: rennes France
Contact:

Unread post by nay-seven » 21 Sep 2017, 16:33

Cool !

User avatar
oli_lab
Member
Posts: 1261
Location: Brittany, France
Contact:

Unread post by oli_lab » 22 Sep 2017, 12:56

Welcome To the spleeness nights.
http://oli-lab.org

Win11 Ryzen9/32GB RAM - RME MADIFACE - SSL alpha link 4-16 - OSC capable interfaces

follow OLI_LAB adventures on Mastodon
@olivar_premier@mastodon.social

sephult
Member
Posts: 1144
Contact:

Unread post by sephult » 22 Sep 2017, 12:57

ugg, I'm already at it guys....already at it....haha
"Every act of creation is first an act of destruction." -Picasso

sephult
Member
Posts: 1144
Contact:

Unread post by sephult » 23 Sep 2017, 01:18

Hello!!!!

Question #2

MIDI Array Sizing:
I'm slicing and dicing and found that this was a slightly different method.

I am wondering....is the MIDI Out Size handled as a part of the SDK functions now?
I do see where the stream is clamped off like normal before the input size detection.

Interesting though, if this is the case....is there any way to get rid of the clamp as well?
I assume no that we still have the issue where they cannot co-exist....is this right?

Code: Select all

1.	Read Input Size
2.	Loop Looking for Size to be Greater than 0. (MIDI Message has Arrived!)
3.	Enter Processing Loop and copy the MIDI Input to the MIDI Output
4.	Read the Value of the Fader
5.	Enter “For" Loop. Process on each of the MIDI Messages Received.
6.	Get the MIDI Message copied to the MIDI Output earlier and use to modify ‘code’
7.	Only make changes to MIDI Messages that are Note ON/OFF Messages
8.	MIDI Messages contain Data1 and Data2, Data2 in this case is velocity.
9.	Change the velocity equal to the fader value that was placed in  ‘velo’
10.	Set the MIDI Output with the ‘code’ that was just modified.

// Process
void MidiTransposeExampleExample::onProcess () 
{
    int sizeMidiIn = sdkGetEvtSize (midiIn); //===============Get size of MIDI place in sizeMidiIn

    sdkSetEvtSize (midiOut, 0); //=============================Set MIDI Out stream to Off

    if (sizeMidiIn > 0) //=====================================Only do if sizeMidiIn is active
    {
        sdkCopyEvt (midiIn, midiOut); //=====Copy MIDI Input to the MIDI Output
   
		int velo = (int)sdkGetEvtData(fdrVelo); //=======Read fader and place in ‘velo’

	    for &#40;int i = 0; i < sizeMidiIn; i++&#41;//==============Do this while the count is less
        &#123;                                     //=========than ‘i’. &#40;i.e. Do for all incoming MIDI&#41; 

            UsineMidiCode code = sdkGetEvtArrayMidi &#40;midiOut, i&#41;; //======Get MIDI, put in code

           if &#40;code.Msg ==  MIDI_NOTEON || code.Msg ==  MIDI_NOTEOFF&#41; //====Only for Note ON/OFF
           &#123;
                code.Data2 = velo; //=======set the Data2&#40;velocity&#41; code equal to the fader value

                sdkSetEvtArrayMidi &#40;midiOut, i, code&#41;; //====== &#40;Send MIDI!&#41;
           &#125;
        &#125;
    &#125;
&#125;
-s
"Every act of creation is first an act of destruction." -Picasso

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests