MIDI API 1.15.5


SP4CEBAR 2023-09-11 16:23 (Edited)

click here to read what's new

MIDI tools has been cleaned up:

API reference:

Right below it, you'll find some subprograms that are called from various places within the program, within these subprograms, you can call other subprograms:


This program will be updated together with MIDI tools because they are essentially the same program, the only difference being that MIDI tools will have user input enabled and it has a user manual, and this program won't have user input enabled and it has an API reference.

MIDI API 1.15.3.nx | Open in app
2024-01-12 22:19
MIDI API 1.15.2.nx | Open in app
2024-01-12 19:27
MIDI API 1.15.1.nx | Open in app
2024-01-12 15:42
MIDI API 1.15.0.nx | Open in app
2024-01-07 00:06
MIDI API 1.14.0.nx | Open in app
2023-10-09 19:11
MIDI API 1.13.8.nx | Open in app
2023-10-09 16:24
MIDI API 1.13.7.nx | Open in app
2023-10-09 15:26
MIDI API 1.13.6.nx | Open in app
2023-10-09 13:07
MIDI API 1.13.5.nx | Open in app
2023-10-08 12:34
MIDI API 1.13.4.nx | Open in app
2023-10-07 22:03
MIDI API 1.13.3.nx | Open in app
2023-10-07 15:20
MIDI API 1.13.3.nx | Open in app
2023-10-07 15:14
MIDI API 1.13.2.nx | Open in app
2023-10-07 11:30
MIDI API 1.13.nx | Open in app
2023-10-07 08:50
MIDI API 1.13.nx | Open in app
2023-10-04 14:54
MIDI API.nx | Open in app
2023-10-04 09:16
MIDI API.nx | Open in app
2023-09-29 13:32
MIDI API.nx | Open in app
2023-09-16 07:52
MIDI API.nx | Open in app
2023-09-16 07:48
MIDI API.nx | Open in app
2023-09-13 19:31
MIDI API.nx | Open in app
2023-09-13 19:28
MIDI API.nx | Open in app
2023-09-13 17:26
MIDI API.nx | Open in app
2023-09-11 16:23

McPepic 2023-09-13 00:48

Been messing around with it and it works really well!

Could you possibly make the program first check to make sure that there's enough room to load the data to prevent errors when copying the data?

SP4CEBAR 2023-09-13 06:51

I'm glad you like it
You mean enough room in RAM, it should do that already: The RAM_PEEK function maintains the cache in RAM, whenever it's called with an address that isn't cached, it will copy bytes from the file to RAM, it shouldn't be able to copy more than $4000 bytes at once

McPepic 2023-09-13 14:12

Okay. It would still be worth it to check, because I was getting an error at the line where the program uses the copy command when the file was too big. I could send you an example of the program doing this if it would help.

SP4CEBAR 2023-09-13 17:49

I can't seem to reproduce the error with my collection of NX data midi files, so it's probably something specific to that midi file. So it would likely also occur on older versions of this program.

McPepic 2023-09-13 18:04

Does the music template do anything, or is it safe to delete?

SP4CEBAR 2023-09-13 18:05

It's used for writing NX files after converting midi files to NX files, it holds some default NX instruments

McPepic 2023-09-13 18:09

This is the error that I'm getting when the file is too big:

SP4CEBAR 2023-09-13 19:04 (Edited)

Since $A000 is fixed, and both ROM(-1) and ROM(16) would say "invalid parameter" instead of "illegal memory access", and I think it's impossible for ROM(F) go beyond $7FFF (and even if it could, it would still be reading legal data), I can assume that the value of S must be too big for some reason
$5001 Is the first illegal size

SP4CEBAR 2023-09-13 19:15

In the program, S is defined as SIZE(F), so SIZE(F) returned a value greater than $5000, which is indeed possible. It seems like this bit of code is different and likely older than the aforementioned function, so I should merge them

SP4CEBAR 2023-09-13 19:28 (Edited)

you should replace S with MIN(S,$4000)

SP4CEBAR 2023-09-13 19:33 (Edited)


SP4CEBAR 2023-09-29 14:03

@McPepic has the issue been resolved?

SP4CEBAR 2023-10-04 16:19 (Edited)

For everyone wanting to tinker with MIDI files, I've just added the MIDI_SCRAPE subprogram

It defines three arrays: TIMES, TONES, and TRACKS, and it fills them with MIDI data scraped from your file (in time-chronological order). These arrays are then played. Feel free to modify (a copy of) the PLAY_SCRAPED_MIDI subprogram or the SCRAPE_MIDI subprogram, or the MIDI_PLAY subprogram to figure out how they work, or to encode the MIDI file to a format of your liking. Currently, the scraper takes as long as it would normally take to play the file due to the interpreter still being dependent on NX's TIMER variable, but that'll change in a future version.

McPepic 2023-10-06 00:36

I was stress testing the program a bit and here's what I found after completely filling the ROM:

The audio sounds really good, maybe a little fast
After a while, the program got stuck on a really high note for a bit
It also restarted the audio and layered it on top of what was already playing
The meters that show the activity of the sound channels completely disappeared

Cutting down the audio (I trimmed it to line 250) got rid of the issues.
Program's looking really good BTW. Keep up the good work!

SP4CEBAR 2023-10-06 06:39

Thank you!
I know that the playback speed may not always be correct, to fix that I'll need to research that part in the MIDI protocol a bit more
I also know that some files cause some notes to get stuck, I don't know how to fix that though
I'm not sure what happened when the meters disappeared, I think the playback ended, but then you should see a "playback ended" message
Cutting data off the midi file probably removed the problematic note in your case

Log in to reply.