ArrayArrayArrayArrayArray BrainModular BrainModular Users Forum 2017-08-21T23:09:02+02:00 https://www.brainmodular.com/forums/app.php/feed/topic/5846 2017-08-21T23:09:02+02:00 2017-08-21T23:09:02+02:00 https://www.brainmodular.com/forums/viewtopic.php?t=5846&p=37623#p37623 <![CDATA[midi out]]> Statistics: Posted by oli_lab — 21 Aug 2017, 23:09


]]>
2017-08-21T21:31:42+02:00 2017-08-21T21:31:42+02:00 https://www.brainmodular.com/forums/viewtopic.php?t=5846&p=37621#p37621 <![CDATA[midi out]]> The main problem is that the bloc length is being calculated incorrectly. sdkGetBlocSize() returns the number of samples in a bloc. To get the bloc length in seconds you must do ((double)sdkGetBlocSize() / sdkGetSampleRate ()).
There is only one tick per bloc.

Simon.

Statistics: Posted by sm_jamieson — 21 Aug 2017, 21:31


]]>
2017-08-21T21:15:58+02:00 2017-08-21T21:15:58+02:00 https://www.brainmodular.com/forums/viewtopic.php?t=5846&p=37620#p37620 <![CDATA[midi out]]> that helps !
cheers
Olivar

Statistics: Posted by oli_lab — 21 Aug 2017, 21:15


]]>
2017-08-21T20:55:46+02:00 2017-08-21T20:55:46+02:00 https://www.brainmodular.com/forums/viewtopic.php?t=5846&p=37619#p37619 <![CDATA[midi out]]>
If you set the midi array in onCallback() you must not clear the array in the following onProcess() but in the call of onProcess() after that (so the midi array remains set for a whole bloc). It seems that during a given bloc processing period, onCallback() is called just before onProcess(), since the method I have described is totally reliable.

If you are setting the midi array in onCallback(), bear in mind that you can get several onCallback() during a bloc, and if this happens you have to not clear the midi array, and may have to add the new midi message as a second entry in the array, etc.

This sounds a bit complicated but the way I do it is this:

At the start of onCallback() this code:

if (! hadCallback) {
sdkSetEvtSize(midiArrayEvent, 0);
hadCallback = true;
}

At the start of onProcess() have this code:

if (hadCallback) {
hadCallback = false;
}
else {
sdkSetEvtSize(midiArrayEvent, 0);
}

Then to send a midi message from onProcess() or onCallback() use this:

int size = sdkGetEvtSize(midiArrayEvent);
if (size < 0) size = 0;
sdkSetEvtSize(midiArrayEvent, size + 1);
sdkSetEvtArrayMidi(midiArrayEvent, size, code);


All this could have been hidden behind some stuff in the SDK I suppose.

Similarly if you want to send a trigger output, you can do the same sort of thing to make sure it stays
set for one bloc.

Simon.

Statistics: Posted by sm_jamieson — 21 Aug 2017, 20:55


]]>
2017-08-20T07:43:33+02:00 2017-08-20T07:43:33+02:00 https://www.brainmodular.com/forums/viewtopic.php?t=5846&p=37614#p37614 <![CDATA[midi out]]> I had a try at midi out.
I found out that the output array should be resized before sending a message and closed afterwards

If the array size is set to zero just after the array is filled with the midicode, the message is not send

if I wait few ticks before emptying the output array (a whole blocksize), the message is sent but during that time, the message is sent many times (roughly once every 5 clock ticks).

What is the proper way to send midi message out of a module ?

thanx

Olivar

...
else if (m_mode == 1) {
onTime = clock();
midiCode.Msg = MIDI_CONTROLCHANGE;
midiCode.Data1 = 123;
midiCode.Data2 = 0;
sdkSetEvtSize(midiOut, 1);
sdkSetEvtArrayMidi(midiOut, 0, midiCode);
m_create = 0;
}
...

int passed = clock() - onTime;
if (passed > sdkGetBlocSize() && token == 1) {
sdkSetEvtSize(midiOut, 0);
token = 0;
}

Statistics: Posted by oli_lab — 20 Aug 2017, 07:43


]]>
BrainModular BrainModular Users Forum 2017-08-21T23:09:02+02:00 https://www.brainmodular.com/forums/app.php/feed/topic/5846 2017-08-21T23:09:02+02:00 2017-08-21T23:09:02+02:00 https://www.brainmodular.com/forums/viewtopic.php?t=5846&p=37623#p37623 <![CDATA[midi out]]> Statistics: Posted by oli_lab — 21 Aug 2017, 23:09


]]>
2017-08-21T21:31:42+02:00 2017-08-21T21:31:42+02:00 https://www.brainmodular.com/forums/viewtopic.php?t=5846&p=37621#p37621 <![CDATA[midi out]]> The main problem is that the bloc length is being calculated incorrectly. sdkGetBlocSize() returns the number of samples in a bloc. To get the bloc length in seconds you must do ((double)sdkGetBlocSize() / sdkGetSampleRate ()).
There is only one tick per bloc.

Simon.

Statistics: Posted by sm_jamieson — 21 Aug 2017, 21:31


]]>
2017-08-21T21:15:58+02:00 2017-08-21T21:15:58+02:00 https://www.brainmodular.com/forums/viewtopic.php?t=5846&p=37620#p37620 <![CDATA[midi out]]> that helps !
cheers
Olivar

Statistics: Posted by oli_lab — 21 Aug 2017, 21:15


]]>
2017-08-21T20:55:46+02:00 2017-08-21T20:55:46+02:00 https://www.brainmodular.com/forums/viewtopic.php?t=5846&p=37619#p37619 <![CDATA[midi out]]>
If you set the midi array in onCallback() you must not clear the array in the following onProcess() but in the call of onProcess() after that (so the midi array remains set for a whole bloc). It seems that during a given bloc processing period, onCallback() is called just before onProcess(), since the method I have described is totally reliable.

If you are setting the midi array in onCallback(), bear in mind that you can get several onCallback() during a bloc, and if this happens you have to not clear the midi array, and may have to add the new midi message as a second entry in the array, etc.

This sounds a bit complicated but the way I do it is this:

At the start of onCallback() this code:

if (! hadCallback) {
sdkSetEvtSize(midiArrayEvent, 0);
hadCallback = true;
}

At the start of onProcess() have this code:

if (hadCallback) {
hadCallback = false;
}
else {
sdkSetEvtSize(midiArrayEvent, 0);
}

Then to send a midi message from onProcess() or onCallback() use this:

int size = sdkGetEvtSize(midiArrayEvent);
if (size < 0) size = 0;
sdkSetEvtSize(midiArrayEvent, size + 1);
sdkSetEvtArrayMidi(midiArrayEvent, size, code);


All this could have been hidden behind some stuff in the SDK I suppose.

Similarly if you want to send a trigger output, you can do the same sort of thing to make sure it stays
set for one bloc.

Simon.

Statistics: Posted by sm_jamieson — 21 Aug 2017, 20:55


]]>
2017-08-20T07:43:33+02:00 2017-08-20T07:43:33+02:00 https://www.brainmodular.com/forums/viewtopic.php?t=5846&p=37614#p37614 <![CDATA[midi out]]> I had a try at midi out.
I found out that the output array should be resized before sending a message and closed afterwards

If the array size is set to zero just after the array is filled with the midicode, the message is not send

if I wait few ticks before emptying the output array (a whole blocksize), the message is sent but during that time, the message is sent many times (roughly once every 5 clock ticks).

What is the proper way to send midi message out of a module ?

thanx

Olivar

...
else if (m_mode == 1) {
onTime = clock();
midiCode.Msg = MIDI_CONTROLCHANGE;
midiCode.Data1 = 123;
midiCode.Data2 = 0;
sdkSetEvtSize(midiOut, 1);
sdkSetEvtArrayMidi(midiOut, 0, midiCode);
m_create = 0;
}
...

int passed = clock() - onTime;
if (passed > sdkGetBlocSize() && token == 1) {
sdkSetEvtSize(midiOut, 0);
token = 0;
}

Statistics: Posted by oli_lab — 20 Aug 2017, 07:43


]]>