No Realtime message in Midi Component (solved)

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 8.

Moderator: Benj

Post Reply
DirkB
Posts: 116
Joined: Wed Feb 08, 2012 2:45 pm
Has thanked: 7 times
Been thanked: 11 times

No Realtime message in Midi Component (solved)

Post by DirkB »

Hello,

if i received real time message eg. 0xFE and store it in variable "Midi_In",
the result is 0x00. what goes wrong? All messages 0xF0 and below no problem.
Program-Change message are 2 bytes, in running mode 1 byte only.
Realtime message is every time only 1 byte, the status byte. Maybe a time out problem?
Using PIC 12F1840, UART hardware on Ch1.

The custom code for midi receive:

Code: Select all

MX_UINT8 idx, current_data = 0;

   %a_Received_MIDI[0] = 0;                        //Reset Status Byte
   %a_Received_MIDI[3] = 0;                        //Reset Real Time Message

     for (idx = 1; idx < 3; idx++)
     {
      %a_Received_MIDI[idx] = 255;                  //Clear old MIDI data
   }

   for (idx = 0; idx < 3; idx++)
   {
      current_data = %a_UART_Receive(cTimeout);
      if (current_data == 255)
         return 0;                              //Timeout Occurred

     if (current_data >= 0xf8)                     //If real time message received
         %a_Received_MIDI[3] = current_data;
      else                                    //Else normal message / data
         %a_Received_MIDI[idx] = current_data;
   }
   return %a_Received_MIDI[0];                       //Return status byte
is it possible the real time lines must be upper? I don't understand C+.

thanks

Dirk

Edit: the same problem on all flowcode versions
Last edited by DirkB on Wed Jan 16, 2019 3:45 pm, edited 1 time in total.

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: No Realtime message in Midi Component

Post by Benj »

Hello Dirk,

Real time messages are loaded into byte index 3.

Call the ReceiveMIDI function to receive the incoming command.

Then call ReadData with the Idx parameter set to 3 to collect the real time message data.

DirkB
Posts: 116
Joined: Wed Feb 08, 2012 2:45 pm
Has thanked: 7 times
Been thanked: 11 times

Re: No Realtime message in Midi Component

Post by DirkB »

Hello Benj,

Thank you so much for your answer. Ok, I will change my code,
but usually it's the status bytes in the midi implementation.
By the way, it is possible (better) to change the midi component
to comply with the implementation?

thanks a lot

Dirk

DirkB
Posts: 116
Joined: Wed Feb 08, 2012 2:45 pm
Has thanked: 7 times
Been thanked: 11 times

Re: No Realtime message in Midi Component

Post by DirkB »

Hi Benj,

i have changed custom code of midi component with flowcode V5 to:

Code: Select all

MX_UINT8 idx, current_data = 0;

   %a_Received_MIDI[0] = 0;                        //Reset Status Byte
  // %a_Received_MIDI[3] = 0;                        //Reset Real Time Message      //changed to nothing

     for (idx = 1; idx < 3; idx++)
     {
      %a_Received_MIDI[idx] = 255;                  //Clear old MIDI data
   }

   for (idx = 0; idx < 3; idx++)
   {
      current_data = %a_UART_Receive(cTimeout);
      if (current_data == 255)
         return 0;                              //Timeout Occurred

     if (current_data >= 0xf8)                     //If real time message received
         %a_Received_MIDI[0] = current_data;                                                      //changed to [0] 
      else                                    //Else normal message / data
         %a_Received_MIDI[idx] = current_data;
   }
   return %a_Received_MIDI[0];                       //Return status byte
now it works correctly. I think this is the better way.

for my understanding;

ReceiveMidi[4] and store into variable "Midi_In"
ReadData[0] (status byte) and store into variable "Status"
ReadData[1] and store into variable (maybe) "D1"
ReadData[2] and store into variable (maybe) "D2"

this is receiving a complete midi word and it now work's great.

Is variable "Midi_In" data byte??? I think no, it's a buffer or not?
I have used Flowcode V5 for this, the midi component is
editable. Please let me know what do you think about this.

regards

Dirk

Post Reply