VOGONS


Emulating MT-32 on an RPi2

Topic actions

Reply 100 of 292, by McCarthy

User metadata
Rank Newbie
Rank
Newbie

Oh, no no, I've recently bought a cheap usb to midi converter also mentioned here. I've soldered an optocoupler on it, removed the resistor R11 and added a 270ohm one. Then I took a pcb and soldered a connector for gnd, Midi out and 5V onto it. I added a hex inverter and another 270 ohm resistor to the 5V line which both do into the cheap usb adapter which also sits on the pcb. The usb cable of the adapter then goes into the Rpi2 with fluidsynth on it.
I've added a brief sketch. Don't expect correct wiring, it's only for visualisation purposes. My sources were: http://www.arvydas.co.uk/2013/07/cheap-usb-mi … ay-be-required/ as well as posts from the vogons forum.
I have no idea what's wrong, because some type of connection is being made, but the wrong notes appear I guess.
Thanks in advance.
Daniel

Attachments

  • Emulator.png
    Filename
    Emulator.png
    File size
    78.84 KiB
    Views
    3372 views
    File license
    Fair use/fair dealing exception

Reply 101 of 292, by blougaville

User metadata
Rank Newbie
Rank
Newbie

I'm experimenting with gdjacobs prebuilt images. I've tested both on a RPi2 and Rpi3 and when sending MIDI from my retro PC to Munt via the UM-ONE, Munt throws an underrun message every minute or two:

snd_pcm_writei failed: Broken pipe -> recovering...
ALSA lib pcm.c:7843:(snd_pcm_recover) underrun occurred

I am sending MIDI info from my retro PC via the UM-ONE. I tried different CPU speeds and I seem to get about the same amount of underruns whether I'm running games at 550mhz or 200mhz. If I simply play a MIDI file through Munt, I will also get an occasional underrun, but not as often as when sending MIDI data through the UM-ONE. In my testing, the RPi2 seemed to do this a bit more than the RPi3 is. Are there any settings I can try tweaking to minimize these underruns?

Reply 102 of 292, by gdjacobs

User metadata
Rank l33t++
Rank
l33t++

Buffer underruns are an indication that Munt is being CPU starved. What are you using the the power supply on your Pi? It might be undervolting and the Pi downclocking in response.

All hail the Great Capacitor Brand Finder

Reply 103 of 292, by blougaville

User metadata
Rank Newbie
Rank
Newbie

I've tried two different power supplies and am getting the same results. The second is one I just bought for the Pi3 that is 5V 2.5A.

I'll try to monitor the CPU activity when the underruns occur.

Reply 104 of 292, by gdjacobs

User metadata
Rank l33t++
Rank
l33t++

Use htop as it's more revealing. Also, I recommend double checking the supply voltage with a DMM.

All hail the Great Capacitor Brand Finder

Reply 105 of 292, by blougaville

User metadata
Rank Newbie
Rank
Newbie

My multimeter is reading 5.2V from the power supply. I used htop and watched for 30 minutes and never saw the mt32emu-qt process go over 80% cpu utilization and didn't see any of the cores max out at any time. I also watched the current cpu frequency (with: watch -n 0.1 cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq) and never saw it change from 900000. Over 30 minutes I had 12 buffer underruns (mixture of playing a MIDI file in Munt and sending Dark Forces from retro PC through UM-ONE). When the underruns occurred, the mt32emu-qt process was sometimes reporting fairly low cpu utilization in htop.

Reply 107 of 292, by blougaville

User metadata
Rank Newbie
Rank
Newbie
gdjacobs wrote:

Alrighty. What is your current audio output device?

It's the onboard audio (headphone jack). I enabled it in the config.txt with the line: dtparam=audio=on
Then I changed audio output from HDMI to headphone jack in raspi-config
I was planning to test with the headphone jack audio before purchasing another sound card for the RPi3.

Reply 108 of 292, by gdjacobs

User metadata
Rank l33t++
Rank
l33t++

Could you please update via raspi-config and post your .asoundrc file? Let me know what you're testing with and I will try to duplicate the problem.

I don't have a UM-One, but I have two other MIDI input devices to try with.

All hail the Great Capacitor Brand Finder

Reply 109 of 292, by blougaville

User metadata
Rank Newbie
Rank
Newbie
gdjacobs wrote:

Could you please update via raspi-config and post your .asoundrc file? Let me know what you're testing with and I will try to duplicate the problem.

Sure, thanks for your help with this! I updated, but I can't find the .asoundrc file. I looked all over, including the /home/pi/ folder.

I have been testing with Dark Forces, Loom, and Monkey Island from my retro PC, but I also experience occasional underruns when playing the monkey island sound track .mid file found in the MIDI folder of your RPi3 image.

Reply 110 of 292, by gdjacobs

User metadata
Rank l33t++
Rank
l33t++

Okey doke. I'll first try Monkey Island -> DOSBox -> LInux MIDI out -> USB MIDI -> USB MIDI -> Pi 3 MIDI in -> Munt -> ALSA -> USB DAC and see what happens.

Edit:
I had an issue with cord length that I had to address, but my voltages are back in spec. So far everything seems perfect, although at present I'm using my standard setup with jackd as the mixing sound server. I'll do a full run through of the Monkey Island MIDI file played from a DOSBox session on another machine and see if anything shows up. Can you identify any particular passages or game locations which seemed to be problematic so I can test them directly?

Edit:
The full length of the Monkey Island MIDI file played through without issue. Just to confirm, was 5.2V the open circuit voltage or load voltage measured directly from the back of the Pi? Have you tried a robust, minimal length USB cable?

Edit:
The Pi 2 seems fine with the USB DAC. Approximately 60% CPU load and there doesn't appear to be USB bus contention. I have also set smsc95xx.turbo_mode=N in cmdline.txt for my Pi 2 which is a recommended fix for some USB bus contention issues.

All hail the Great Capacitor Brand Finder

Reply 111 of 292, by blougaville

User metadata
Rank Newbie
Rank
Newbie

Thanks for trying that. I did not know how to measure the load right from the pi so I'll look into how to do that. The 5.2V is what was coming right off of the supply. Like I said before, I'm getting this issue with the Pi2 and 3 and have tried two different power supplies (both had a longish cord, I'll try a short one).

I did some more tests so hopefully this can give you a better idea of when I'm seeing this issue:

1) Monkey Island Complete Soundtrack MIDI file - The first time I powered up the Pi3 and played through it in Munt, I got two underruns when playing it all the way through. I then immediately played it twice more and got no underruns. On the fourth complete playthrough I got two more underruns. Not bad when compared with #2.

2) Monkey Island from retro PC via UM-ONE - I've started this game a heck of a lot and I usually get 4-6 underruns before the opening theme song concludes. I don't think the opening theme has ever played all the way through without getting at least a couple underruns.

Thanks again for all your help with this!

Reply 112 of 292, by gdjacobs

User metadata
Rank l33t++
Rank
l33t++

Okay. The Monkey Island intro plays clean for me.

You can test input voltage on the GPIO pins or on the reverse of the Pi, near the USB power input.

All hail the Great Capacitor Brand Finder

Reply 113 of 292, by DieKatzchen

User metadata
Rank Newbie
Rank
Newbie

So, if I wanted to put this in a box, with a midi in socket and a 16 column display, what do I need? I'm pretty sure I need an optocoupler in there, but that's the extent of my knowledge. I'm using a raspberry pi 3.

[Edit]make that 20 column. Just counted. [/Edit]

Reply 114 of 292, by gdjacobs

User metadata
Rank l33t++
Rank
l33t++

I'm currently working on integrating a Pi 3 with the X3M from Serdaco along with breakouts for control switches and an LCD module. I want everything to fit together in roughly the size of a 3.5" drive bay, either internal to a PC or in an external enclosure.

sandwich.png
Filename
sandwich.png
File size
205.19 KiB
Views
2336 views
File license
Fair use/fair dealing exception

All hail the Great Capacitor Brand Finder

Reply 115 of 292, by DieKatzchen

User metadata
Rank Newbie
Rank
Newbie

I don't know if I'd go that far. If it costs anywhere near the X3M, I might as well buy a real MT-32. I just want to hook up the usb to midi cable I bought and the 20x2 display I already have, maybe with some pushbuttons and a rotary encoder for menus. If the cable has the proper optoisolator in it, do I need another between the uart and the socket, or would that be bad, or would it be an optional safety precaution? I have only vague understanding of the circuit. Somebody mentioned using a hex inverter? what is that for?

Reply 116 of 292, by gdjacobs

User metadata
Rank l33t++
Rank
l33t++

Hex inverters are used for driving MIDI outputs and MIDI through ports (two inverters back to back). You can also use Schmitt triggers (74xxx14) for a somewhat cleaner build.

Edit: My apologies to Dr. Otto Schmitt.

Last edited by gdjacobs on 2017-05-31, 15:55. Edited 1 time in total.

All hail the Great Capacitor Brand Finder