fbpx
Skip to main content

MIDI Forum

Sending MIDI signal...
 
Notifications
Clear all

Sending MIDI signals to Raspberry Issue

6 Posts
3 Users
0 Reactions
17.5 K Views
Dominik Schumann
Posts: 2
New Member
Topic starter
 

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?

 
Posted : 09/10/2017 11:19 am
Geoff
Posts: 1039
Noble Member
 

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

 
Posted : 09/10/2017 1:43 pm
Bavi_H
Posts: 266
Reputable Member
 

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.

 
Posted : 09/10/2017 8:56 pm
Bavi_H
Posts: 266
Reputable Member
 

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.

 
Posted : 10/10/2017 10:19 pm
Dominik Schumann
Posts: 2
New Member
Topic starter
 

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.

[code type=markup]
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 = 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'
[/code]
Thanks in advance

Dominik

 
Posted : 14/10/2017 1:41 am
Geoff
Posts: 1039
Noble Member
 

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

 
Posted : 14/10/2017 4:57 am
Share: