TIMING_CLOCK status byte giving strange result

Post Reply
boonier
Posts: 30
Joined: Thu Apr 21, 2022 1:23 pm

TIMING_CLOCK status byte giving strange result

Post by boonier »

In an attempt to handle midi clock messages myself in a module, I'm getting an unexpected value of 240 for the clock status byte.

image of debug: https://www.dropbox.com/s/ikqw31ax0kyxn ... k.jpg?dl=0

contents of ProcessSample():

Code: Select all

      ArrayList<ShortMessage> events = midiIn.GetMessages();
      
      // events will be non-null if there are
      // MIDI events to process
      if (events != null)
      {
         int numEvents = events.size();
         for (int ix = 0; ix < numEvents; ix++)
         {
            ShortMessage event = events.get(ix);
            
            // print result to Text Label
            //evNum.SetText(String.valueOf( event.getCommand() ) );
            
            
            // 
            if (event.getCommand() == ShortMessage.TIMING_CLOCK) { // should be 248??
               Log("clock message");
            }
            //
            else if (event.getCommand() == ShortMessage.START)
            {
               Log("start message");
            }
            else if (event.getCommand() == ShortMessage.STOP)
            {
               Log("stop message");
            }
         }
      }
does this seem normal?

I can confirm the status byte being sent is 248. Also START(250) an STOP(252) don't seem to be captured. Is this related to the bug the other day? viewtopic.php?p=9939#p9939
Steve W
Posts: 758
Joined: Thu Jul 16, 2020 5:55 pm

Re: TIMING_CLOCK status byte giving strange result

Post by Steve W »

I only understand bytes in hex. I tried memorizing decimal equivalents, but they don't stick in my brain. Fortunately, the Windows calculator has a programmer mode that shows hex. Also, Andrew Macaulay was kind enough to add hex options for a couple of his parameters. 240 = F0 = the start of sysex.

Andrew Macaulay's MIDI Display module shows the F0 as the command byte and the second half as the channel (decimal, 1-16 based only). Not sure if that's a VM thing or a midi library thing or if that's just the way he did it for his display.

I don't program any more, but I am wondering if either VM or the programming library separates the two halves of the status byte into command status [F0] and command type [08].

Update: I don't really understand Java and newer languages, but in looking up event.getCommand(), it seems that Command just refers to the first half, for example 9n for note on and 8n for Note on and Note off where n is zero for single byte structures. For two-byte and three-byte structure, n is the channel (00-0F or 1 to 16) and seems to be returned as channel.

Just guessing here. Can a programmer of contemporary languages confirm or deny this?
Attachments
VM Dec to Hex.png
VM Dec to Hex.png (120.25 KiB) Viewed 762 times
boonier
Posts: 30
Joined: Thu Apr 21, 2022 1:23 pm

Re: TIMING_CLOCK status byte giving strange result

Post by boonier »

This is a dump of the monitor output sending the clock to an IAC midi bus (from Bidule)

Code: Select all

00103380 000 FA 00 00 0B Misc Sysex
00103380 000 F8 00 00 09 Misc Sysex
00103F00 037 F8 00 00 09 Misc Sysex
00104A80 06F F8 00 00 09 Misc Sysex
00105680 027 F8 00 00 09 Misc Sysex
00106200 05F F8 00 00 09 Misc Sysex
00106E00 017 F8 00 00 09 Misc Sysex
00107980 04F F8 00 00 09 Misc Sysex
00108580 007 F8 00 00 09 Misc Sysex
00109100 03F F8 00 00 09 Misc Sysex
00109300 000 FC 00 00 0D Misc Sysex
FA = 250 START
F8 = 248 CLOCK TICK
FC = 252 STOP

++

Ahh, so from what you deduced, it looks as though I'm only fetching the start of the sysex message, that the rest is found elsewhere perhaps?
Steve W
Posts: 758
Joined: Thu Jul 16, 2020 5:55 pm

Re: TIMING_CLOCK status byte giving strange result

Post by Steve W »

https://docs.oracle.com/javase/8/docs/a ... ssage.html
A number of ShortMessage methods have integer parameters by which you specify a MIDI status or data byte. If you know the numeric value, you can express it directly. For system common and system real-time messages, you can often use the corresponding fields of ShortMessage, such as SYSTEM_RESET. For channel messages, the upper four bits of the status byte are specified by a command value and the lower four bits are specified by a MIDI channel number. To convert incoming MIDI data bytes that are in the form of Java's signed bytes, you can use the conversion code given in the MidiMessage class description.
Again, have a almost no experience looking into the JAVA API. Maybe someone else can help.

Update: Try getStatus() instead of getCommand(). https://docs.oracle.com/javase/8/docs/a ... etStatus--
boonier
Posts: 30
Joined: Thu Apr 21, 2022 1:23 pm

Re: TIMING_CLOCK status byte giving strange result

Post by boonier »

Awesome, thank you, I was looking at the ShortMessage class which is a sub class of MidiMessage :oops:

still learning..haha
Post Reply

Return to “Module Designer”