ArrayArrayArrayArrayArray
BrainModularBrainModular Users Forum2017-08-21T23:09:02+02:00https://www.brainmodular.com/forums/app.php/feed/topic/58462017-08-21T23:09:02+02:002017-08-21T23:09:02+02:00https://www.brainmodular.com/forums/viewtopic.php?t=5846&p=37623#p37623Statistics: Posted by oli_lab — 21 Aug 2017, 23:09
]]>
2017-08-21T21:31:42+02:002017-08-21T21:31:42+02:00https://www.brainmodular.com/forums/viewtopic.php?t=5846&p=37621#p37621The 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
Statistics: Posted by oli_lab — 21 Aug 2017, 21:15
]]>2017-08-21T20:55:46+02:002017-08-21T20:55:46+02:00https://www.brainmodular.com/forums/viewtopic.php?t=5846&p=37619#p37619 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; }
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:002017-08-20T07:43:33+02:00https://www.brainmodular.com/forums/viewtopic.php?t=5846&p=37614#p37614I 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 ?
Statistics: Posted by oli_lab — 20 Aug 2017, 07:43
]]>BrainModularBrainModular Users Forum2017-08-21T23:09:02+02:00https://www.brainmodular.com/forums/app.php/feed/topic/58462017-08-21T23:09:02+02:002017-08-21T23:09:02+02:00https://www.brainmodular.com/forums/viewtopic.php?t=5846&p=37623#p37623Statistics: Posted by oli_lab — 21 Aug 2017, 23:09
]]>2017-08-21T21:31:42+02:002017-08-21T21:31:42+02:00https://www.brainmodular.com/forums/viewtopic.php?t=5846&p=37621#p37621The 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
Statistics: Posted by oli_lab — 21 Aug 2017, 21:15
]]>2017-08-21T20:55:46+02:002017-08-21T20:55:46+02:00https://www.brainmodular.com/forums/viewtopic.php?t=5846&p=37619#p37619 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; }
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:002017-08-20T07:43:33+02:00https://www.brainmodular.com/forums/viewtopic.php?t=5846&p=37614#p37614I 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 ?