PixelTracker library as VST / MIDI playable

Pixilang programming language
Post Reply
EricTrex
Posts: 5
Joined: Mon Aug 26, 2024 12:28 am

PixelTracker library as VST / MIDI playable

Post by EricTrex »

I'd like to compose using the 16 sounds in PixiTracker using a DAW, one MIDI channel per sound. PixiTracker supports MIDI input, but it will only play the selected sound. I'd like the 16 MIDI channels to correspond to each of the 16 PixiTracker sounds.

I could open 16 instances of PixiTracker, each with a different sound selected and each set to listen on a different MIDI channel, but that's a pain in the butt.

Is it possible to use PixiLang to load PixiTracker's sound library, listen to MIDI, and play the appropriate sounds? Has someone already done this?
EricTrex
Posts: 5
Joined: Mon Aug 26, 2024 12:28 am

Re: PixelTracker library as VST / MIDI playable

Post by EricTrex »

So I started writing it, but it looks like the timing of events from midi_get_event is janky.

It's impossible to search this forum, because it removes underscores from search strings. So it turns "midi_get_event" into "midi get event", then rejects all those words because they're too common.

Does anyone know info about midi_get_event and why the timing of events is off?
User avatar
NightRadio
Site Admin
Posts: 3996
Joined: Fri Jan 23, 2004 12:28 am
Location: Ekaterinburg. Russia
Contact:

Re: PixelTracker library as VST / MIDI playable

Post by NightRadio »

Hi!
The timing accuracy of midi_get_event() depends on the system and selected audio driver.
What about the timings in PixiTracker itself? Is it ok?
By the way, PixiTracker ignores the event timestamp and starts processing it immediately after it arrives in the audio callback.
EricTrex
Posts: 5
Joined: Mon Aug 26, 2024 12:28 am

Re: PixelTracker library as VST / MIDI playable

Post by EricTrex »

I did some more testing and found that the MIDI messages are coming in at the right time.

However, I then send them to pta_set_event_nolock($track, $note, $channel, $vel) for playback, and that seems to have some internal step/quantization so that notes don't playback in time.
EricTrex
Posts: 5
Joined: Mon Aug 26, 2024 12:28 am

Re: PixelTracker library as VST / MIDI playable

Post by EricTrex »

Here's the actual code I'm using. This is a modified version of the pixitracker_player which has a MIDI input thread and dispatches the notes to the sample engine. But the MIDI input on the PixiTracker has the same issue.

Here's a video showing:

1. MIDI being received by Reaper and playing through a simple synth. You can see the timing of the notes is every ~200ms and sounds very even.
2. The same MIDI being received by pixitracker_player. The "delta" shows the time delta in milliseconds between MIDI notes, and that timing is accurate. However, the note playback doesn't have that same timing.
User avatar
NightRadio
Site Admin
Posts: 3996
Joined: Fri Jan 23, 2004 12:28 am
Location: Ekaterinburg. Russia
Contact:

Re: PixelTracker library as VST / MIDI playable

Post by NightRadio »

Thank you for the video and source code!

1. In Pixilang settings set the audio output driver to ASIO. Default DirectSound latency is too long for MIDI.

2. Don't call pta_set_event_nolock() outside the main audio callback. Or protect it with pta_lock() / pta_unlock()
pta_midi_input_thread may produce additional latency.
I recommend you to receive MIDI and call pta_midi_in_handler() inside the pta_audio_callback()
EricTrex
Posts: 5
Joined: Mon Aug 26, 2024 12:28 am

Re: PixelTracker library as VST / MIDI playable

Post by EricTrex »

Ahh... audio driver was the problem, indeed. Thanks! Spent a lot of time trying to debug that. *lol*

Side note: I think pixeltracker should work this way by default. Instead of requiring you to select the MIDI channel it's listening on, make it multitimbral. It listens to all 16 channels, and each channel corresponds to one of its 16 instrument sounds.
Post Reply