Hatari MIDI for OSX and Windows

A forum about the Hatari ST/STE/Falcon emulator - the current version is v2.2.0

Moderators: simonsunnyboy, thothy, Moderator Team

jariseon
Atarian
Atarian
Posts: 4
Joined: Mon Sep 25, 2017 3:54 pm

Hatari MIDI for OSX and Windows

Postby jariseon » Mon Sep 25, 2017 4:20 pm

I've implemented MIDI support for OSX and Windows Hatari. Eero has been most helpful and is reviewing the patch.

MIDI support has been tested in OSX and it seems to work ok, including sysex. However, there's a weird periodic 12 ms jitter in Hatari MIDI output, at least in OSX. It is present in current Mercurial tip midi.c (i.e., even without my code, which I first suspected to be the reason). The attached graphs illustrate the issue. Vertical axis is latency time in msecs, and horizontal axis is time in midi packets. Positive vertical value indicates that a noteOn command is generated late, and negative that it is generated early. The expected ideal curve would be a flat horizontal line at 0.

I don't know anything about timing in the emulator internals. Can someone please jump in and figure out what is going on? I can provide the related code used to make the measurements. Would be great to get MIDI timing tight as there are really good sequencers available for ST. And Hatari can run them all. It's awesome.

Thanks,
Jari
You do not have the required permissions to view the files attached to this post.

lokki
Atarian
Atarian
Posts: 1
Joined: Thu Nov 17, 2016 11:55 am

Re: Hatari MIDI for OSX and Windows

Postby lokki » Mon Oct 02, 2017 7:11 am

i did a lot of tests with hatari on Linux and sysex sent to a hardware synth and i get crashes regularily on the synth if i send big sysex packages. so it might well be the same jitter. anybody else sending big amount of sysex on linux?

User avatar
npomarede
Atari God
Atari God
Posts: 1280
Joined: Sat Dec 01, 2007 7:38 pm
Location: France

Re: Hatari MIDI for OSX and Windows

Postby npomarede » Mon Oct 02, 2017 8:17 am

Hi
IIRC when I improved Hatari MIDI support at the ACIA level, I noticed some MIDI programs like cubase or others had some code to compensate for a possible clock drift, adjusting their rate to keep timings in a desired window.
Isn't that what we are seeing ? Does it have any negative impact on the MIDI device connected on the other side (lag, missing notes ?)
Depending on how the MFP timers are used by Cubase, it's also possible they chose a frequency that is not an exact multiple of the expected freq, so you need to have this adjustement steps, made by Cubase midi logic.
How did you measure this drift ? By measuring delay between each byte output on /dev/midi (or equivalent) ? Is so maybe cubase needs a real device on the other side to ack each byte and compute some kind of clock where jitter would be lower.

It could also be a bug in Hatari :) But as some midi programs ('M' and 'Notator) had big issues at some points (loosing notes, getting stuck, ...), I really had the feeling accuracy was now correct.

Nicolas

jariseon
Atarian
Atarian
Posts: 4
Joined: Mon Sep 25, 2017 3:54 pm

Re: Hatari MIDI for OSX and Windows

Postby jariseon » Mon Oct 02, 2017 10:02 pm

Hi and thanks for the comments.

On OSX MIDI works great except for the jitter. No stuck notes and sysex at least up to 63kB works well. No bytes dropped. Hope the PortMidi version will work also in Linux to help with large sysex dumps.

I tested with Cubase 2.01, Cubase 3.01 and MasterTracks Pro 3.6, using latest tip and 1.04 ROMs, OSX Sierra as host. Thought first that cracked versions do some funny business behind the scenes, but the jitter was also produced in MTPro (which is legit). However, I noticed that the tempos were slightly off from the set 120 bpm (119.88 bpm in both Cubases and 120.47 in MTPro). I try to find Notator and see how it performs.

Maybe those tempo offsets are related to MFP timer freqs? I can't exactly remember how tight Cubase and MTPro were on hardware ST. IIRC, ST was pretty tight though and jitter was around 1 ms. But my memory might fail on this as periodic jitter indeed suggests drift compensation.

I used the code below to capture the jitter (in midi.c, Midi_Data_WriteByte(), line 289 onwards). Did not have a device connected during the capture. But when I recorded Hatari MIDI out in Ableton, Bitwig and in Snoize's excellent Midi Monitor at OSX side, the jitter was there as well in a similar periodic form. I used a simple 16th note drum pattern in tests, single pitch at 120 bpm. Maybe I'm just doing something stupid or there's something weird in my setup.

Code: Select all

#include <CoreAudio/HostTime.h>
static double onsetBuff[150];
static int onsetCount = 0;
...

if (onsetCount == 150) {
   for (int i=0; i<150; i++)
      printf("%f\n",onsetBuff[i]);
   onsetCount++;
}
else if (onsetCount < 150 && nTxDataByte == 0x90) {
   Uint64 t = AudioGetCurrentHostTime();
   double timestamp = t / AudioGetHostClockFrequency();
   onsetBuff[onsetCount] = timestamp;
   onsetCount++;
}
return;


The code collects noteon event onset times into onsetBuff[] array. Once it has captured 150 of them, it prints them out. I suspected that printf might influence the results, so I collected the events into the array first. I then copy-pasted the printed timestamps into Excel, subtracted the values from theoretical onset times (computed from an ideal 16th note pattern and taking into account the tempo offset), and plotted the graph.

Would be great if someone can capture the onset timestamps and post them here. I can then crunch the numbers in Excel.

Thanks again,
Jari

User avatar
npomarede
Atari God
Atari God
Posts: 1280
Joined: Sat Dec 01, 2007 7:38 pm
Location: France

Re: Hatari MIDI for OSX and Windows

Postby npomarede » Tue Oct 03, 2017 8:19 am

Hi
thanks for the details and your patch for Hatari. As you say, it would be interesting if someone could check behaviour on real HW, because it's quite possible jitter was already present due to some MFP limitations. Although I'm not sure people used to push 63 kB of data on real ST ? Or maybe this is a limitation of Cubase.
There could be some bugs in MIDI emulation, but I'd like to be sure it worked better on real HW before looking into this.

Nicolas

User avatar
cb170
Atari User
Atari User
Posts: 32
Joined: Wed Oct 11, 2017 11:04 pm

Re: Hatari MIDI for OSX and Windows

Postby cb170 » Wed Oct 11, 2017 11:59 pm

Holy crap, MIDI in Hatari *finally* works in OSX - huzzah!

Thanks for everyone for implementing this - made me really happy!

I just had Snoize Sysex librarian transmitting sysex from OSX into my old "Dump It!" sysex program running in Hatari, and vice versa - it works great!

User avatar
edingacic
Captain Atari
Captain Atari
Posts: 259
Joined: Mon Sep 07, 2015 5:16 pm
Location: Austria
Contact:

Re: Hatari MIDI for OSX and Windows

Postby edingacic » Sat Nov 04, 2017 5:11 am

I have Atari TT030 running last Cubase Score 2.0 r7 and I can check those timings if you tell me how I can do it. If you provide me with some tool to give you this data? I also have expanders midex+, soundpool mo4 and we can do tests on those midi outs too. Lets see how tight really stuff is :)

jmax
Atarian
Atarian
Posts: 1
Joined: Wed Jan 10, 2018 4:10 pm

Re: Hatari MIDI for OSX and Windows

Postby jmax » Wed Jan 10, 2018 4:14 pm

Hello,

I've just joined this forum. I've been looking for MIDI implementation for ST emulation for a very long time and it looks as if you may have exactly what I've been looking for!

Where can I find a download of the patched version of Hatari with MIDI support?

Thanks,

-John

User avatar
Foxie
Captain Atari
Captain Atari
Posts: 354
Joined: Wed Feb 03, 2016 7:12 pm

Re: Hatari MIDI for OSX and Windows

Postby Foxie » Wed Jan 10, 2018 6:53 pm

jmax wrote:Hello,
I've just joined this forum.


*gives you a welcoming wetnose*

The thing to remember about jitter and MIDI is that USB is an absolute disaster in the jitter department. People have done measurements on USB MIDI interfaces and found jitter well over 10ms routinely with Windows and OS X. That's with mainstream sequencers like Logic and Cubase. The theoretical best USB can perform is 1ms, which still stinks to be honest (considering MIDI is capable of 0.032ms jitter).

So, if measuring total system jitter from Hatari through to a physical MIDI output, don't be surprised if you see > 10ms jitter. The proper way to do it is using a Real Atari. No jitter problems there (with correctly-written software).

If the jitter shows up entirely with internal MIDI, then that's obviously a Hatari problem. Weird that it's 12ms though, not 14ms (the framerate). Moot if you're using a USB interface since that will add worse jitter.

siriushardware
Captain Atari
Captain Atari
Posts: 417
Joined: Thu Aug 21, 2014 7:55 pm
Location: UK

Re: Hatari MIDI for OSX and Windows

Postby siriushardware » Thu Jan 24, 2019 4:49 pm

What's the current state of play with MIDI on Windows versions of Hatari? What sort of interfaces does it support, for example,

-Old school PCI / PCIe cards based on Roland MPU-401, typically found at I/O address 330H?
-'Game port' MIDI interfaces, which typically emulate the above interface and are found at the same address?
-USB to 5-DIN MIDI interface cables?

User avatar
Eero Tamminen
Atari God
Atari God
Posts: 1862
Joined: Sun Jul 31, 2011 1:11 pm

Re: Hatari MIDI for OSX and Windows

Postby Eero Tamminen » Thu Jan 24, 2019 10:59 pm

Whatever PortMidi library Windows version happens to support.

I didn't find anything specific on that by Googling. On Linux it offers the interfaces available in the system, so if you have Windows drivers for those MIDI interfaces installed, it's possible that those works as-is (barring any Windows bugs).

Just try it and report here! :-)

siriushardware
Captain Atari
Captain Atari
Posts: 417
Joined: Thu Aug 21, 2014 7:55 pm
Location: UK

Re: Hatari MIDI for OSX and Windows

Postby siriushardware » Sat Jan 26, 2019 8:01 pm

I actually use the Linux version of Hatari on which MIDI implementation has been flawless for my purposes since about midway through V1.9.x. I'm trying to help someone else whose USB midi interface does not appear to be detected or used by Windows Hatari although it is identified in Windows Control Panel / System / Device Manager as a USB MIDI cable.

I suppose my question, and this is probably aimed more at Jari, is, does the Windows build / binary of Hatari include this portmidi library in its mainstream version or would I have to go looking specifically for this version which has had MIDI support incorporated?

User avatar
Eero Tamminen
Atari God
Atari God
Posts: 1862
Joined: Sun Jul 31, 2011 1:11 pm

Re: Hatari MIDI for OSX and Windows

Postby Eero Tamminen » Sun Jan 27, 2019 7:16 pm

I checked the Windows ZIP files and they don't have any DLL for PortMidi (neither have the daily builds). Unless that's statically linked, they're not built with it, even in latest 2.2-beta release:
http://download.tuxfamily.org/hatari/beta/

Btw. I would strongly recommend using the 2.2-beta release instead of 2.1 one, it has a *lot* of bug fixes compared to 2.1:
https://hg.tuxfamily.org/mercurialroot/ ... -notes.txt

siriushardware
Captain Atari
Captain Atari
Posts: 417
Joined: Thu Aug 21, 2014 7:55 pm
Location: UK

Re: Hatari MIDI for OSX and Windows

Postby siriushardware » Mon Jan 28, 2019 9:59 am

So it looks as though what I would call the 'Mainstream Binary' for Windows does not currrently include the portmidi patch, even in the latest build.

Sorry to have to ask because I know Windows is not used by any of the devs, but what are the steps to build Hatari for Windows with the portmidi library included?

I know how to build Hatari from source on Linux using Linux's built in compiler but I have no 'c' programming toolchain for Windows. Does anyone, to your knowledge, maintain a ready to install Windows Hatari which includes this patch?

User avatar
npomarede
Atari God
Atari God
Posts: 1280
Joined: Sat Dec 01, 2007 7:38 pm
Location: France

Re: Hatari MIDI for OSX and Windows

Postby npomarede » Mon Jan 28, 2019 10:04 am

Hi
Christer Solskogen who maintains his own version of the windows version of Hatari on antartica.no has added support for portaudio and said recently he will try to add support for portmidi too.
So, you might want to check his builds in the next days, maybe he will have time to do the change.

Nicolas

siriushardware
Captain Atari
Captain Atari
Posts: 417
Joined: Thu Aug 21, 2014 7:55 pm
Location: UK

Re: Hatari MIDI for OSX and Windows

Postby siriushardware » Mon Jan 28, 2019 6:23 pm

I went to antarctica.no which seems to be a generic family interest website / blog run by Christer and his good lady - even after letting my browser translate the site to English I did not manage to find anything there related to Hatari - the closest I got was finding a folder in 'stuff' called 'Atari' in which there seemed to be a few YM music files. I felt like I was intruding, to be honest.

I'll try a little bit harder later to see if I can find a contact email, unless he is a forum member here?

By the way, when you said we should favour the beta release, did you just mean from a MIDI point of view, or are there problems with V2.1.0 generally?

darwinmac
Captain Atari
Captain Atari
Posts: 201
Joined: Sat Aug 06, 2011 2:49 pm
Location: San Jose, USA

Re: Hatari MIDI for OSX and Windows

Postby darwinmac » Mon Jan 28, 2019 7:15 pm

Try this URL:
http://antarctica.no/~hatari/

I saw a list of Hatari Windows binaries.

As to your other question, the devs have been making fixes to Hatari. It sounds like version 2.2 might be released this week. However, right now, it looks like portmidi isn’t included with the Windows binaries.

Bob C

User avatar
npomarede
Atari God
Atari God
Posts: 1280
Joined: Sat Dec 01, 2007 7:38 pm
Location: France

Re: Hatari MIDI for OSX and Windows

Postby npomarede » Mon Jan 28, 2019 7:16 pm

Sorry, I thought you already knew the site, it's http://antarctica.no/~hatari/latest/ :)
As for favouring the beta version, it's just that hatari 2.1 is nearly 1 year old and lot of things were changed since.
From a general point of view, the beta are rather stable, so you can use them safely.

Nicolas

EDIT : darwinmac replied faster than me :)

siriushardware
Captain Atari
Captain Atari
Posts: 417
Joined: Thu Aug 21, 2014 7:55 pm
Location: UK

Re: Hatari MIDI for OSX and Windows

Postby siriushardware » Tue Jan 29, 2019 8:59 pm

Thanks both, although you both seem to agree that Christer hasn't yet incorporated portmidi into his Windows 'spin' of Hatari, so I will just have to be patient and wait until he or someone else is able to do that.

User avatar
Eero Tamminen
Atari God
Atari God
Posts: 1862
Joined: Sun Jul 31, 2011 1:11 pm

Re: Hatari MIDI for OSX and Windows

Postby Eero Tamminen » Thu Jan 31, 2019 10:44 pm

siriushardware wrote:So it looks as though what I would call the 'Mainstream Binary' for Windows does not currrently include the portmidi patch, even in the latest build.

Sorry to have to ask because I know Windows is not used by any of the devs, but what are the steps to build Hatari for Windows with the portmidi library included?

I know how to build Hatari from source on Linux using Linux's built in compiler but I have no 'c' programming toolchain for Windows. Does anyone, to your knowledge, maintain a ready to install Windows Hatari which includes this patch?


Portmidi "patch" is there, but Portmidi Windows library & headers needs to be in the build environment for it to be enabled / configured by CMake, and the DLL included into the resulting Hatari package.

You don't need programming toolchain for Windows, AFAIK Hatari Windows builds are done on Linux using MinGW. See "apt search mingw" and the packages listed by it.

I don't know whether there are ready-made Windows binaries & headers forPortmidi, or would one need to build that too.

As to testing, I assume some Windows testing can be done on Linux with Wine, but if one doesn't have Windows otherwise, there's not much motivation for that.

jariseon
Atarian
Atarian
Posts: 4
Joined: Mon Sep 25, 2017 3:54 pm

Re: Hatari MIDI for OSX and Windows

Postby jariseon » Tue Feb 05, 2019 8:08 pm

hi,

i compiled Hatari 2.2.0 for OSX with midi support, and uploaded it at [1]. Seems to work at least in High Sierra. The app was built using changeset 7326 (ddb0dc920798), sdl 2.0.9 and portmidi.

[1] https://1drv.ms/f/s!AtGaAPvKqUHEsXZ3Bynk6lE1rvv5

best, Jari


Social Media

     

Return to “Hatari”

Who is online

Users browsing this forum: No registered users and 3 guests