Adding serial MIDI support to Uzesynth

This forum is for artists to post their music and graphics or discuss artistic matters that could be used in Uzebox games.
Post Reply
User avatar
danboid
Posts: 347
Joined: Sun Jun 14, 2020 12:14 am

Adding serial MIDI support to Uzesynth

Post by danboid » Sun Jan 15, 2023 3:15 am

It's sad that the Uzebox is almost 15 years old but we still don't have an easy way to compose music for it.

As I suggested elsewhere, it seems one of the easiest ways to fix this would be add JACK support to Uzebox patch studio but Artcfox tells me that the latest version doesn't sound very accurate so maybe that isn't the best solution, although as I said we should be able to try the earlier revisions of it from its git repo then fork it from the commit that sounds the closest.

Uzesynth supports MIDI IN but very few people have the MIDI input on their UB and Uze said it will be dropped from future revisions. On top of that neither uzem nor cuzebox support emulating the MIDI port so it seems the best bet for an easy-ish fix to our music composing problem is to add MIDI IN via UART to uzesynth. This should allow users to use a real or emulated Uzebox as a sound playback device via a (USB) serial port.

The hairless MIDI to serial bridge might suffice as a guide for how we might implement serial MIDI in Uzesynth. It seems to have to arduino support too which has got to be a good sign.

https://projectgus.github.io/hairless-midiserial/

Hopefully we'll be able to use MIDI sysex commands to send the patch / instrument data to the Uzebox?

Does anyone more familar with the Uzebox see any holes in this plan?

User avatar
Artcfox
Posts: 1146
Joined: Thu Jun 04, 2015 5:35 pm
Contact:

Re: Adding serial MIDI support to Uzesynth

Post by Artcfox » Sun Jan 15, 2023 3:50 am

I'm not sure if that is accurate. It might be that most of my games use custom waves to gain back the extra space, and that might have been what caused the sound differences.

What would having MIDI in support in the emulator get you? Does that mean a music composing program could interface with the emulator and have it play the patches as they would sound on the Uzebox?

Maybe it is just a case of I don't know what I am missing, but all I do now is just compose music in Rosegarden, export it, type make && cuzebox and then I hear my music in the emulator exactly as it sounds on real hardware.

I don't have any instruments that can output MIDI, though I did go over a friend's house who did, and she played something on a keyboard and I recorded it in Rosegarden and then exported it to a MIDI and then converted it to a song on the Uzebox.

If you use the new streaming music engine in your Uzebox game, you can stream sound data from flash, spi ram, the SD card, or anywhere else if you put it into the correct buffer. Look at the readme in the tools/mconvert directory. That might be an option.

User avatar
Artcfox
Posts: 1146
Joined: Thu Jun 04, 2015 5:35 pm
Contact:

Re: Adding serial MIDI support to Uzesynth

Post by Artcfox » Sun Jan 15, 2023 5:55 am

Look for "#if MIDI_IN == ENABLED" in uzebox/kernel/uzeboxSoundEngine.c it is already setup to read MIDI commands from the UART.

User avatar
danboid
Posts: 347
Joined: Sun Jun 14, 2020 12:14 am

Re: Adding serial MIDI support to Uzesynth

Post by danboid » Sun Jan 15, 2023 2:09 pm

Oh that sounds like a good find Artcfox! So do you think Uzesynth might already work with UART MIDI input as-is?

I've never tried UART MIDI before but ttymidi should in theory enable us to connect qtractor or whatever up to uzesynth via ALSA MIDI and get rid of the need to rebuild your project every time you want to playback your song.

https://github.com/cjbarnes18/ttymidi

User avatar
danboid
Posts: 347
Joined: Sun Jun 14, 2020 12:14 am

Re: Adding serial MIDI support to Uzesynth

Post by danboid » Sun Jan 15, 2023 2:14 pm

I think uzem supports UART but cuzebox doesn't? Is there any difference in the accuracy of the sound emulation between the two?

User avatar
danboid
Posts: 347
Joined: Sun Jun 14, 2020 12:14 am

Re: Adding serial MIDI support to Uzesynth

Post by danboid » Sun Jan 15, 2023 2:27 pm

I just remembered I'd started another thread on here asking about UART support in the emulators and it isn't supported so I won't be able to test UART MIDI until I have built my Uzebox it seems, if Uzesynth works with the UART.

User avatar
danboid
Posts: 347
Joined: Sun Jun 14, 2020 12:14 am

Re: Adding serial MIDI support to Uzesynth

Post by danboid » Sun Jan 15, 2023 2:39 pm

I've just had a quick look uzesynth (musicdemo) and it seems it would need some work before we could use it as I intend.

We would need to extend it to implement a patch editing screen. The user should be able to upload a patch per channel or a set of patches for a song via UART instead of having to edit them with the Uzebox controller.

Has anyone ever tested the MIDI input on uzesynth? I presume it must use the patch config of the currently selected demo song to playback the MIDI input notes, if MIDI input works at all?

EDIT

Looking at the source it seems all of the demo songs use the same set of patches.

Maybe we could extend Uzebox Patch Studio to have UART support so that it can send the patch data to Uzesynth?

Presuming that I don't need to start over with my Uzebox, getting this sorted will be my next UB project. I should be able to get my Uzebox built within the next couple of weeks.

User avatar
Artcfox
Posts: 1146
Joined: Thu Jun 04, 2015 5:35 pm
Contact:

Re: Adding serial MIDI support to Uzesynth

Post by Artcfox » Mon Jan 16, 2023 6:10 am

I have very little experience with MIDI stuff. I learned enough about the file format to rewrite the MIDI -> Uzebox MIDI converter tool in C++, but I used a library for that. I found my post on the issues with Uzebox Patch Studio: https://uzebox.org/forums/viewtopic.php?p=18498#p18498

User avatar
danboid
Posts: 347
Joined: Sun Jun 14, 2020 12:14 am

Re: Adding serial MIDI support to Uzesynth

Post by danboid » Sat Jan 21, 2023 12:57 am

Me:

"Hi Alec

So are you saying you 'hardcoded' your patches into Uzesynth, rebuilt/loaded it then played your song via MIDI to your a custom Uzebox build and rebuilt Uzesynth every time you wanted to change a patch? There doesn't seem to be any support in Uzesynth at present for editing or loading patches eg from SD card.

You say the MIDI support is still present in the UB kernel but does the current code support MIDI IN via UART or would this need to be written before I can use Uzesynth via UART MIDI IN?"

Uze:

"Hi Dan,

Yeah, I found it simpler in the end to just bake the patches and samples in the rom. Didn't have to code custom stuff that would not be used in the final rom anyway. The idea is just to automate the thing. I made a batch script that recompiled everything and flashed it on the uzebox at the press of a button. For me, that was a pretty simple and efficient workflow. Most time is spent composing music than tweaking instruments. :)

Yes the code is still present and can be activated by simply adding this compile switch to the makefile:

Code: Select all

KERNEL_OPTIONS += -DMIDI_IN=ENABLED
When you recompile and flash it will listen automatically on the UART for MIDI data and trigger patches accordingly."

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests