Serial MIDI for Pi3 and Zero

N
Nimbo77 posted Jan 23 '17, 13:52:

Hey guys.
Are you having trouble setting up the serial MIDI on your Pi3 or Zero? So did I!
I finally got it working on my Pi Zero by following the guide by tronix at: https://openenergymonitor.org/emon/node/12412

TLDR for newbs like me: The way the pins work, that you connect your MIDI to, have changed in Pi3/Zero.

As far as I can tell, you MUST follow the steps for this to work on those boards.

Note that for Pi Zero, these lines are NOT neccessary (and won't work, because the Zero doesn't have onboard Bluetooth):

sudo systemctl disable hciuart
sudo nano /lib/systemd/system/hciuart.service
change the first ttyAMA0 in ttyS0

Good luck!

N
Nimbo77 posted Jan 23 '17, 13:55:

Note: I see my wording might be misleading (wish you could edit posts here).

To clarify, those three last lines of instructions are only part of the guide. Go read the guide!

C
Cuki posted Jan 26 '17, 13:03:

I did not understand if it did work for Pi3?

N
Nimbo77 posted Jan 27 '17, 20:26:

Hi Cuki.
While I haven't tried it on a Pi3 myself, it is supposed to work for Pi3.
Just follow all the steps in https://openenergymonitor.org/emon/node/12412. It's worth a try if your stuck!

G
Gabor Kita posted Feb 9 '17, 17:35:

Hi, I'm Gabor from Hungary.

My experiences with Pi3 and serial midi (similar to Nimbo77's solution):

The first problem was that (RPI3): Serial port not working. Some searches on google said, the bluetooth is using the uart, so need to disabled bluetooth.

In the /boot/config.txt:
dtoverlay=pi3-disable-bt

reboot, then uart start to work, but only 38400 bit/s, not 31250. (I build an easy tester with arduino, and on RPI run an easy python script, which is print the received bytes)

It is not enough:

/boot/cmdlin.txt:
bcm2708.uart_clock=3000000

/boot/config.txt: :
init_uart_clock=2441406
init_uart_baud=38400

The uart is still working only 38400 baud.

The solution:
Need an other line in the /boot/config.txt:
dtparam=uart0_clkrate=3000000

Reboot, and wow, uart is working 31250 baud, and the samplerbox have sound, when I play on the midi keyboard :) (Not with usb-midi, but raspberry's physical uart with optocoupler, like this: http://samplerbox.org/makeitelectronic)


In summary, my /boot/cmdline.txt:

root=/dev/mmcblk0p2 ro rootwait console=tty1 selinux=0 plymouth.enable=0 smsc95xx.turbo_mode=N dwc_otg.lpm_enable=0 elevator=noop bcm2708.uart_clock=3000000

and my /boot/config.txt:

device_tree_param=i2c_arm=on
init_uart_clock=2441406
init_uart_baud=38400
gpu_mem=64
boot_delay=0
disable_splash=1
disable_audio_dither=1
dtparam=audio=on
dtoverlay=pi3-disable-bt
dtparam=uart0_clkrate=3000000

arm_freq=1000

core_freq=250

disable_splash=1

force_turbo=1

boot_delay=1

G
Gabor Kita posted Feb 9 '17, 17:38:

Sorry, don't need the last 5 line

G
Gabor Kita posted Feb 9 '17, 17:45:

Some other experience:

-sometimes I cant remounted r/w the file system (when I modified files on sd card, with an other pc) : mount -o remount,rw / mount -> can't find / in /etc/fstab

solution:

mount /dev/mmcblk0p1 /boot
mount -o remount,rw /dev/mmcblk0p2 /

  • I use usb audio, but not working.

Solution:

touch /etc/asound.conf
and write into 2 lines:

defaults.pcm.card 1
defaults.ctl.card 1

(and into samplerbox.py: AUDIO_DEVICE_ID = 2)

  • when I played with piano preset, the octave was shifted.
    Solution:

def MidiCallback..:

midinote = note + 12

  • I experimented with buffer (to lower latency)
    It seems to lower:

in the open audio section (try-except): blocksize=0 (instead of 512, 128, 32 etc)

But there is still a lot of latency. I think 20-30 ms. Especially when I played piano preset. It has fast attack, and I feel the latency, and it disturb me a bit. Whit the slow attack preset (like slow string, chello etc) it isn't annoying.

Have someone ever try any real-time kernel, or very small and easy raspbian image for faster system? If someone have any idea, please write. Thanks.

P
Pavel posted Feb 10 '17, 06:38:

I've noticed the same too. Have you tried to measure delay between a midi message and sound starting to play in SB code?

Perhaps its not a kernel problem but rather an application issue (i.e. inserting a playing note in array), in which case can be optimised.

C
Cuki posted Feb 10 '17, 22:51:

Thanks Gabor,

it works for me

N
Nate posted Mar 14 '17, 21:51:

I noticed that latency got better when I lowered the polyphony. I changed it to 8, and the response is much more impressive.

N
Nate posted Mar 14 '17, 22:31:

Yeah!! I just changed those two lines like Gabor said, and bam it works on the Pi3.

...

  (not published)
  I want to post as guest
 

Post