MIDI NES

breakbeatscientist
Posts: 22
Joined: Tue Mar 16, 2021 11:29 pm
Has thanked: 3 times
Been thanked: 3 times

MIDI NES

Unread post by breakbeatscientist »

I see that midi support had been implemented for certain cores. My question is would it be possible to implement midi for the NES? I have an old WayFar MIDINES cart that I use to play my NES as a synth, there were other carts produced that allowed midi control of the NES like the Chip Maestro and the latest Famimimidi cart that allow you to connect a midi keyboard or sequencer to the NES. Is this a possibilty?
breakbeatscientist
Posts: 22
Joined: Tue Mar 16, 2021 11:29 pm
Has thanked: 3 times
Been thanked: 3 times

Re: MIDI NES

Unread post by breakbeatscientist »

After thinking about this for a few days I've come to the conclusion that it would be pretty hard to implement this on the MiSTer NES core. I'm not sure if it's even possible to achieve a project like this. At the very least a custom rom would have to be written. It would definitely take someone with the right set of skills and passion to take on a project like this that maybe .5% of MiSTer users would ever use.
breakbeatscientist
Posts: 22
Joined: Tue Mar 16, 2021 11:29 pm
Has thanked: 3 times
Been thanked: 3 times

Re: MIDI NES

Unread post by breakbeatscientist »

I'm not giving up on this and I have been doing a lot of research into seeing if this could someday become a possibility. I think the MiSTer could be the ultimate chiptune synth. I'm also hoping that someone with much more knowledge than me sees this. I don't have the skills to begin to think about trying to make this work myself. I'll share what I've found so far. There are trackers people have programmed that allow you to control the RP2A03, one rom that I have already tried on the MiSTer and can confirm works is called NTRQ. Another rom I found which is open source allows you to control the RP2A03 with a NES controller called livenes. There's a few different versions of the rom, one that gives you crude control of the RP2A03, another adds FDS control, and another that supports VRC6. https://github.com/plgDavid/livenes. I have tried all three of those roms on the MiSTer and they work. Also in the thread named "Miracle Piano on NES Core" GreyRogue recently made a post saying

https://github.com/MiSTer-devel/NES_MiS ... 50eb8d7431

I added a conversion from USB MIDI to the NES controller. It worked with both an original Miracle Piano and a Yamaha MIDI keyboard which I tested with a cheapo USB MIDI adapter (I've heard they can be built cheaply and possibly dangerously to use with some hardware; use at your own risk).
I haven't tried it in months, and it's possible it's broken by the recent overhaul to MIDI/serial communications. But builds back before the recent changes absolutely worked. The setup for the MiSTer_Main was identical to (for example) what was needed for Amiga (I also tried the Amiga version of the Miracle Piano software connected the same way).

The key addition needed is the NES header. It needs to have the Default Expansion Device set to MIracle Piano (byte 0xF=15 be set to 0x19=25):

http://wiki.nesdev.com/w/index.php/NES_ ... ion_Device
https://github.com/MiSTer-devel/NES_MiS ... S.sv#L1277
I'm not a programmer and I have no idea if utilizing the available open source resources could result in a custom rom that would allow midi control over the NES core, it's all guessing for me but it seems like there's a possibility this can be done.
breakbeatscientist
Posts: 22
Joined: Tue Mar 16, 2021 11:29 pm
Has thanked: 3 times
Been thanked: 3 times

Re: MIDI NES

Unread post by breakbeatscientist »

In my quest to gather as much info on this as I can I found that the creator of the Chip Maestro cartridge Jarek Lupinski made all of his work public on Github. He has some interesting projects on there. I figured I would post them here as a reference.
Chip-Maestro https://github.com/jareklupinski/chip-maestro
There's a couple other projects on his Github that may be of use like this Raspberry Pi hat that lets you control the NES sound hardware directly
NES-Forever https://github.com/jareklupinski/nes-forever
He even created a standalone NES synth
Standalone-NES-Synth https://github.com/jareklupinski/standalone-nes-synth
breakbeatscientist
Posts: 22
Joined: Tue Mar 16, 2021 11:29 pm
Has thanked: 3 times
Been thanked: 3 times

Re: MIDI NES

Unread post by breakbeatscientist »

I found another project that turns the NES into a midi controlled synthesizer. I found minimal info on the project but it looks like the author of it took an NES with a USB copyNES installed in it and wrote a custom midi driver to control the RP2A03. I found it on NesDev and the author calls it Nessy.
Nessy http://forums.nesdev.com/viewtopic.php?f=6&t=17839
breakbeatscientist
Posts: 22
Joined: Tue Mar 16, 2021 11:29 pm
Has thanked: 3 times
Been thanked: 3 times

Re: MIDI NES

Unread post by breakbeatscientist »

I found another interesting project, it's not for the NES but actually for the Genesis/Megadrive. It allows you to use the USB serial port on a Mega Everdrive flash cart to control the Genesis YM2612 FM sound chip via Midi. It utilizes a custom rom, a program named Hairless MIDI to Serial Bridge and a virtual midi passthrough driver named loopMIDI. The creator also made some Max for Live devices that give you control over the Genesis YM2612 chip and polyphony. I wonder if this Hairless MIDI to Serial Bridge program and the virtual midi passthrough driver loopMIDI can be used with the MiSTer? If there's a way for the MiSTer to show up as a serial device when connected to a computer could this possibly work?
Here's the Mega Drive Midi Interface Project
https://github.com/rhargreaves/mega-dri ... -interface
and here is the Hairless Midi to Serial Bridge Program
https://projectgus.github.io/hairless-midiserial/
User avatar
meauxdal
Posts: 140
Joined: Mon Nov 23, 2020 3:28 am
Location: atlanta
Has thanked: 33 times
Been thanked: 103 times
Contact:

Re: MIDI NES

Unread post by meauxdal »

I'm very interested in these sorts of applications myself. Edit: I see you've linked most of what I was looking at sharing, lol. I'll just reiterate that I'm very interested in the results of this stuff. I've played around with using MIDI in the computer cores, but using the console sound chips is exciting too.
breakbeatscientist
Posts: 22
Joined: Tue Mar 16, 2021 11:29 pm
Has thanked: 3 times
Been thanked: 3 times

Re: MIDI NES

Unread post by breakbeatscientist »

meauxdal wrote: Thu Apr 01, 2021 4:52 pm I'm very interested in these sorts of applications myself. Edit: I see you've linked most of what I was looking at sharing, lol. I'll just reiterate that I'm very interested in the results of this stuff. I've played around with using MIDI in the computer cores, but using the console sound chips is exciting too.
Yes! I think some of the people using old console sound chips to make music would quickly become users of the MiSTer. Just imagine being able to control all of the different consoles sound chips through midi without having to buy all the extras just to make it happen on original hardware, plus clean digital output. I know many people love the sound of the SID chip from the C64, Gameboy is another one, lots of people using that to make music. I'm going to try an experiment with the Genesis core. I ordered a genMDM from Catskull Electronics and I was going to use it with my Mega SG but I'm going to try it on the MiSTer with the Genesis SNAC adapter. I'm curious to see if it will work. As soon as I try it out I'll post up my results here.
User avatar
Kitrinx
Core Developer
Posts: 185
Joined: Sat May 23, 2020 2:14 am
Location: NYC
Has thanked: 1 time
Been thanked: 147 times
Contact:

Re: MIDI NES

Unread post by Kitrinx »

Midi for any console is not very difficult to do, in terms of implementing a hardware interface. It does, however, require that someone write software for each of them to use them. If you have some kind of rom that's looking for midi input, let me know, and we can add the uart interface.
MorkMikael
Posts: 96
Joined: Thu Jun 04, 2020 9:01 pm
Has thanked: 16 times
Been thanked: 19 times

Re: MIDI NES

Unread post by MorkMikael »

on the test builds on mister discord.com there a nes core with NSF player accepting Midi commands.
dont have any midi so cant test it out.
GreyRogue
Core Developer
Posts: 14
Joined: Sun May 24, 2020 8:57 pm
Been thanked: 12 times

Re: MIDI NES

Unread post by GreyRogue »

Here is a video of me demoing it with a Miracle Piano. I think any MIDI source the MiSTer recognizes would work, but the interface isn't super robust, so avoid sending it anything too weird. It really only supports note on/off (with freq number and volume) and patch commands that switch between the pulse duty cycles.
https://www.youtube.com/watch?v=kSvDvj6Li9M
MorkMikael
Posts: 96
Joined: Thu Jun 04, 2020 9:01 pm
Has thanked: 16 times
Been thanked: 19 times

Re: MIDI NES

Unread post by MorkMikael »

updated nes midi core https://github.com/MiSTer-unstable-nigh ... 018878.rbf

[greyrogue 2022-02-21 8878755]
NSF/MIDI phase complete (#297)

-All expansion audio visualizers working
-MIDI can now switch between controlling APU Pulse/Triangle split, APU Pulse, APU Triangle, MMC5 Pulse and MMC5 Pulse/APU Triangle split with C0 (patch commands)
-- If patch bit 6 ($40-$7F), APU Triangle only and uses normal octaves.
-- If patch bit 3 ($8). Then behaves like below, but uses MMC5 pulses in place of APU pulses
-- If patch bit 2 ($4). Then only pulses used. If not set, triangle is used at G#3 and is up one octave. iei G3->G4 for the triangle.
-- Patch bits 0 and 1 ($0-$03) set the pulse duty cycle.
MorkMikael
Posts: 96
Joined: Thu Jun 04, 2020 9:01 pm
Has thanked: 16 times
Been thanked: 19 times

Re: MIDI NES

Unread post by MorkMikael »

Midi for the nsf player is now in the main nes core.
Lightwave
Posts: 238
Joined: Sun May 24, 2020 10:06 pm
Has thanked: 115 times
Been thanked: 68 times

Re: MIDI NES

Unread post by Lightwave »

Is it possible to plug a keyboard controller (with class-compliant USB MIDI-out) directly into my MiSTer USB hub to “play” notes in the nsf player?

Or does this require some custom hardware MIDI interface plugged into the user port on the I/O board?
GreyRogue
Core Developer
Posts: 14
Joined: Sun May 24, 2020 8:57 pm
Been thanked: 12 times

Re: MIDI NES

Unread post by GreyRogue »

Lightwave wrote: Sat Mar 26, 2022 6:09 pm Is it possible to plug a keyboard controller (with class-compliant USB MIDI-out) directly into my MiSTer USB hub to “play” notes in the nsf player?
Yes. I tested with a MIDI keyboard using a USB MIDI cable plugged into a standard USB port. Just set the UART mode to MIDI, MidiLink to USB, and open an NSF file (one that isn't continuous [e.g. sfx] if you only want your notes playing, otherwise it will be continuously playing over your notes). Avoid sending complex commands as the MIDI parser isn't super resilient. e.g. Sysex commands larger than the buffer (16 bytes) will likely break it. And NSF files that are actively using the sample channel while receiving MIDI data will likely corrupt the MIDI parser/buffer.
20220327_034511-mmc5.png
20220327_034511-mmc5.png (91.84 KiB) Viewed 11542 times
You should see MIDI commands coming in (see the boxes in the pic showing note on/off commands [supports both 0x90 and 0x80] with note # [frequency] and volume), which is highlighting the two lines that show the 16 byte MIDI ring-buffer (starts overwriting the beginning when it reaches the end). If the two values in purple are ever mismatched (they should both be pointing to the next spot to put new MIDI data - in the pic they are pointing to the last value in the buffer 00, which hasn't been set yet), the MIDI parser has likely confused itself. Load a new NSF to reset it. Only note on/off (with note # and volume) and patch commands (0xC0 with special values) are currently supported. The value in pink should show the current patch. Other commands should be skipped (but, again, the parser isn't particularly robust).

-- If patch bit 6 ($40-$7F), APU Triangle only and uses normal octaves.
-- If patch bit 3 ($8). Then behaves like below, but uses MMC5 pulses in place of APU pulses
-- If patch bit 2 ($4). Then only pulses used. If not set, triangle is used at G#3 and is up one octave. ie MIDI note G3-> will play as G4 for the triangle.
-- Patch bits 0 and 1 ($0-$03) set the pulse duty cycle.
Or does this require some custom hardware MIDI interface plugged into the user port on the I/O board?
SNAC using the I/O board with a Miracle Piano should also work, but is currently untested. As mentioned above, it isn't required.
Lightwave
Posts: 238
Joined: Sun May 24, 2020 10:06 pm
Has thanked: 115 times
Been thanked: 68 times

Re: MIDI NES

Unread post by Lightwave »

Excellent, thank you for the detailed info. I’ll be giving this a go tomorrow.
lu_source
Posts: 29
Joined: Tue May 18, 2021 2:13 pm
Has thanked: 10 times
Been thanked: 7 times

Re: MIDI NES

Unread post by lu_source »

Does this MIDI support allow for a keyboard to work with the Miracle Piano ROM? I can get my keyboard to work with the NSF player, but it does not work when I try to use it with Miracle Piano ROM.
GreyRogue
Core Developer
Posts: 14
Joined: Sun May 24, 2020 8:57 pm
Been thanked: 12 times

Re: MIDI NES

Unread post by GreyRogue »

lu_source wrote: Sat Apr 16, 2022 4:48 pm Does this MIDI support allow for a keyboard to work with the Miracle Piano ROM? I can get my keyboard to work with the NSF player, but it does not work when I try to use it with Miracle Piano ROM.
Yes it works. It requires the Miracle Piano nes file to have a NES 2.0 header, with the Miracle Piano option set in the controller byte.
https://www.nesdev.org/wiki/NES_2.0#Def ... ion_Device
The header I'm using for Miracle Piano looks like this:
4E 45 53 1A 10 08 10 08 00 00 07 00 00 00 00 19
The 0x19 at the end tells it to use the Miracle Piano.
If you're updating using the NES 2.0 database, it should have this line it, which should force the last byte to 25 = 0x19.

Code: Select all

<expansion type="25" />
I haven't actually checked if this works or not with the script, but I assume it does.
If this isn't set, it won't work. Loading nsf files, forces this value to 0x19 to make those work.

I've tested this with a cheap Yamaha MIDI keyboard (YPT-210) and it "works". Note that the music is generated by the keyboard when using the Miracle Piano cart, and it was released before General MIDI standard instruments were defined, so it will use wrong instruments. When it's only trying to play default piano, it will be fine. However, for example, the demo song that plays on the second screen (shows a picture of the Miracle Piano keyboard) sounds awful because of wrong instruments, but is clearly trying to play music. This is especially noticeable for sound effects (ducks/applause/etc) and drums which don't line up at all. In theory, it should be possible to patch the ROMs to use different instruments, or build a translation table in the MIDI code in MiSTer to fix or at least improve this, but I haven't attempted it. Indeed, I don't think it would be all that hard to build a converter to use on an actual NES with a Yamaha keyboard with the same limitations/needed fixes. Something like an arduino or microcontroller just needs to parse the MIDI commands and replace some intelligently.

Anyway, the controls themselves work fine, though, and I completed some of the harder songs using it, including the broken ones. Read about broken songs and my initial messing around with Miracle Piano using FCEUX before I had a MiSTer here:
https://forums.nesdev.org/viewtopic.php ... 89#p214989
lu_source
Posts: 29
Joined: Tue May 18, 2021 2:13 pm
Has thanked: 10 times
Been thanked: 7 times

Re: MIDI NES

Unread post by lu_source »

Thanks! I'll try this out!
breakbeatscientist
Posts: 22
Joined: Tue Mar 16, 2021 11:29 pm
Has thanked: 3 times
Been thanked: 3 times

Re: MIDI NES

Unread post by breakbeatscientist »

I have a few MIDINES carts that I'm trying to dump the roms from but I'm having trouble because of the custom mapper they use. I did get a partial dump and was able to have the MIDINES screen display but that's all I was able to do. Also this is the first cart I've ever attempted to dump. I have two different hardware revisions of the MIDINES and the lastest revision 1.1.1 is using this custom squeedo board and mapper 124 from https://membler-industries.com/squeedo/2004_version/

I have limited experience when it comes to dumping carts so I'm assuming the custom mapper is the issue. I have a USB CopyNES and a Open Source Cartridge Reader, if anyone has the knowledge to help me get this cart dumped I would greatly appreciate it.

Can this mapper be implemented into the NES core? I'm assuming the MIDINES used the PIC microcontroller for processing incoming and outgoing midi data, so if midi is already implemented in the NES core would adding this mapper allow the rom to run like an NES with an MIDINES cart?

Imagine if we got MIDINES running on MiSTer. I'm hoping we can make this happen.

Memblers
Posts: 1
Joined: Mon May 13, 2024 4:52 pm

Re: MIDI NES

Unread post by Memblers »

Hi, I designed and supplied those Squeedo boards used on some MIDINES revisions.

breakbeatscientist wrote: Mon Apr 22, 2024 1:38 pm

Can this mapper be implemented into the NES core? I'm assuming the MIDINES used the PIC microcontroller for processing incoming and outgoing midi data, so if midi is already implemented in the NES core would adding this mapper allow the rom to run like an NES with an MIDINES cart?

Yes, but not easily. You need to either:
A) Implement the PIC and run its program. One issue is that the MIDINES PIC is probably code protected, so it won't be dumped easily. I could ask if he wants to release it, maybe.
B) Reverse-engineer and reimplement what the PIC is doing. If I recall correctly, more of the logic in processing is done on the PIC side. Though I could be wrong. Just saying, it might not be so simple to recreate it.

Mr Mister
Posts: 2
Joined: Fri Dec 08, 2023 10:05 pm
Been thanked: 1 time

Re: MIDI NES

Unread post by Mr Mister »

Weird. I was just attempting to do the same with all of my console MIDI carts. I dumped the NES Famimimidi cart, but didn't get very far on the mister due to the mapper/PIC. I thought about just going the way of Chip Maestro since that's all open. Fingers crossed for MIDINES.

There must be something in the air, because just as I started thinking "midi functionality ought to be possible on console cores", GbMIDI_Mister was released, proving that it in fact could be done. I'm not sure how presets/samples would be created/saved/loaded, but one step at a time I suppose. ;)

Post Reply