Problem with midi setup on Raspberry Pi with midi board for RPi

231 views Asked by At

I bought this one from osa electronics: https://www.osaelectronics.com/product/midi-board-for-raspberry-pi/

I followed the instructions here on how to set it up: https://www.osaelectronics.com/learn/setting-up-raspberry-pi-for-midi/

After following the setup and running this in command line:

python
import mido
mido.get_output_names()

It outputs this which seems to be correct:

['Midi Through:Midi Through Port-0 14:0', 'f_midi:f_midi 24:0']

as well as when I run this from command line:

amidi -l

outputs this:

Dir Device    Name
IO  hw:2,0    f_midi

However when I run some test applications from their webapge I get no input or output. like this one:

import mido
from mido import MidiFile
from mido import MetaMessage
port = mido.open_output('f_midi')
mid = MidiFile('mymidifile.mid')

while True:
    for msg in MidiFile('mymidifile.mid').play():
        port.send(msg)

or from this one (I tried to print the msg but it wont print it even. So doesnt seem to step into the while loop but no errormessages)

import mido
import pigpio
from numpy import interp

pi1 = pigpio.pi()

port = mido.open_input('f_midi')  # open USB port

while True:
    try:  # This filters out all non-note data
        for msg in port.iter_pending():  # if there is a message pending
            print(msg)
            if(msg.type == 'note_on'):  # if it is Note On message
                out = interp(msg.velocity, [0, 127], [0, 255])
#scale velocity from 0-127 to 0-255
                # filter the data by note number
                if(msg.note == 53):
                    pi1.set_PWM_dutycycle(2, out)
                elif(msg.note == 55):
                    pi1.set_PWM_dutycycle(3, out)
                elif(msg.note == 57):
                    pi1.set_PWM_dutycycle(4, out)
            else:  # if the message is not Note On (e.g. Note Off)
                if(msg.note == 53):
                    pi1.set_PWM_dutycycle(2, 0)
                elif(msg.note == 55):
                    pi1.set_PWM_dutycycle(3, 0)
                elif(msg.note == 57):
                    pi1.set_PWM_dutycycle(4, 0)
    except AttributeError as error:
        print("Error excepted")
        pass

I noticed there is some problems with pigpio daemon After I have been downloading and installed from this page: http://abyz.me.uk/rpi/pigpio/download.html

And then try to start the daemon with:

sudo pigpiod

I get this errormessage:

bind to port 8888 failed (Address already in use) Can't initialise pigpio library

However I have also been running through with this in command line:

aplaymidi -p f_midi myMidiTune.mid

No errormessage but no midioutput to my digital piano ...

How can I debug this?

0

There are 0 answers