Log in
Register

  • The MIDI Messages Forum  Ask and you shall receive

    The MIDI Messages Forum
    Ask and you shall receive

  1. Dominik Schumann
  2. MIDI Connections
  3. Monday, 09 October 2017
  4.  Subscribe via email
Hey guys,

I'm cuurently working for a connection from my PC to my Raspberry Pi via MIDI.

So yeah I bought a MIDI Interface and the components for setting up the Connection but after all if I'm sending any Signals my RPi say that the status byte is under 128.
Do you know what could be the problem?
Comment
There are no comments made yet.
Geoff Accepted Answer Pending Moderation
0
Votes
Undo
Hello,

Thanks for the bit of extra info.

Firstly, looking at your code, please note that NORMAL midi is NOT at 38,400 - it;s actually at 31.25 Khz. If your input is NORMAL midi, then this may give rise to some problem. Maybe you're using a non-standard link, which uses the standard serial bps. Your little circuit diag though suggests a normal midi connector.

Secondly, please note the previous comment about signed/unsigned numbers, which could VERY well be your problem.

In your prog, how is 'data' defined? Come compilers will default an int and a char to signed, which may lose you the top bit. Can you define your variables as 'unsigned' to make sure. If 'data' is 'int' then this will be less of a problem, but for the data, it should be 'char' (1 byte) in which case it MUST be 'unsigned'. And, connected with this, what does 'ser.read(1)' return.

Also, not clear if your prog will take account of running status. Maybe it could, but that as prev poster notes, the data will NOT show status bytes as running status assumes a repeat of a previous one.

Geoff
Comment
There are no comments made yet.
  1. more than a month ago
  2. MIDI Connections
  3. # 1
Dominik Schumann Accepted Answer Pending Moderation
0
Votes
Undo
Well, I don't know how you're making the connection, you don't say. By 'midi', are you referring to the standard midi cable (which is a serial link), or is USB involved (which is also serial) and how is the serial data established at the PC end, and how is it turned back into 8 bit data at the other end.

If the data is never more than 127, then you're losing a bit somewhere. Bit 7 (of bits 0 to 7) isn't getting through. Assuming it's being sent in the first place?

Geoff


I just send from my PC with Ableton to my Raspberry with serial MIDi.

therefore I used the connection that I send and this Python code.


import serial

ser = serial.Serial('/dev/ttyAMA0', baudrate=38400)

message = [0, 0, 0]
while True:
i = 0
while i < 3:
data = ord(ser.read(1)) # read a byte
if data >> 7 != 0:
i = 0 # status byte! this is the beginning of a midi message!
message[i] = data
i += 1
if i == 2 and message[0] >> 4 == 12: # program change: don't wait for a
message[2] = 0 # third byte: it has only 2 bytes
i = 3

messagetype = message[0] >> 4
messagechannel = (message[0] & 15) + 1
note = message[1] if len(message) > 1 else None
velocity = message[2] if len(message) > 2 else None

if messagetype == 9: # Note on
print 'Note on'
elif messagetype == 8: # Note off
print 'Note off'
elif messagetype == 12: # Program change
print 'Program change'

Thanks in advance

Dominik
Attachments (1)
Comment
There are no comments made yet.
  1. more than a month ago
  2. MIDI Connections
  3. # 2
Bavi_H Accepted Answer Pending Moderation
0
Votes
Undo
Where are you seeing the status byte? Did you write your own program? Maybe you are using a signed byte data type. In this case, values between 0 and 127 will appear as values between 0 and 127, but values between 128 and 255 will appear as values between -128 and -1. If you check for values >= 128 it will always fail since the largest value that can appear is 127. To solve that kind of issue, use an unsigned byte data type. Then the values will be between 0 and 255.
Comment
There are no comments made yet.
  1. more than a month ago
  2. MIDI Connections
  3. # 3
Bavi_H Accepted Answer Pending Moderation
0
Votes
Undo
Do you know about "running status"? For Channel messages, the status byte is allowed to be skipped if it's the same as the previous status byte. Maybe that is what you are seeing.

To read more about Running Status:

1. Go to this page: https://www.midi.org/specifications/item/the-midi-1-0-specification
2. Scroll to the bottom and click "Download the Complete MIDI 1.0 Detailed Specification Document (1996)"
3. See PDF pages 37 and 91-93.
Comment
There are no comments made yet.
  1. more than a month ago
  2. MIDI Connections
  3. # 4
Geoff Accepted Answer Pending Moderation
0
Votes
Undo
Well, I don't know how you're making the connection, you don't say. By 'midi', are you referring to the standard midi cable (which is a serial link), or is USB involved (which is also serial) and how is the serial data established at the PC end, and how is it turned back into 8 bit data at the other end.

If the data is never more than 127, then you're losing a bit somewhere. Bit 7 (of bits 0 to 7) isn't getting through. Assuming it's being sent in the first place?

Geoff
Comment
There are no comments made yet.
  1. more than a month ago
  2. MIDI Connections
  3. # 5
  • Page :
  • 1


There are no replies made for this post yet.
However, you are not allowed to reply to this post.