[solved] Another bug: recording midi from plugin

MusE is a DAW for Linux with both MIDI and Audio editing. https://muse-sequencer.github.io

Moderators: MattKingUSA, khz, spamatica

Post Reply
User avatar
Impostor
Established Member
Posts: 1298
Joined: Wed Aug 17, 2022 1:55 pm
Has thanked: 134 times
Been thanked: 334 times

[solved] Another bug: recording midi from plugin

Post by Impostor »

Recording midi from a plugin is bugged, with both MusE 4.1 and the master appimages:

Sending midi from track 1 into Carla Rack VST, and recording the midi output on midi track 2. No plugins loaded in Carla, signal should be unaltered.

Made a screenshot during recording: it seems no note-off message gets through. And when stopping the recording, all recorded events get placed at the very start, and all have length 2 instead of 384.

Retried it with different plugin, NoteSpace instead of Carla, making sure signal is unaltered, and routing it further into Pianoteq. Turns out note-off messages do get to Pianoteq, yet are not recorded. Again, screenshot made during recording. Stopping the recording again places the notes, with very short length, at the beginning.

The source and recorded parts will be attached in the next post.

Attachments
recording2.png
recording2.png (44.14 KiB) Viewed 588 times
recording.png
recording.png (28.63 KiB) Viewed 588 times
Last edited by Impostor on Fri Apr 14, 2023 11:33 pm, edited 3 times in total.
User avatar
Impostor
Established Member
Posts: 1298
Joined: Wed Aug 17, 2022 1:55 pm
Has thanked: 134 times
Been thanked: 334 times

Re: Another bug: recording midi from plugin

Post by Impostor »

Source part:

Code: Select all

<part uuid="{412fc4d5-61a8-4f13-8153-58268376c0a0}">
  <name>Track 1</name>
  <viewState xscroll="-5" yscroll="2" xscale="-10" yscale="2">
    <ctrlViewState num="262146" />
    </viewState>
  <poslen tick="0" len="3072" />
  <selected>1</selected>
  <color>0</color>
  <event tick="0" len="384" a="36" b="70" />
  <event tick="384" len="384" a="48" b="70" />
  <event tick="768" len="384" a="60" b="70" />
  <event tick="1152" len="384" a="72" b="70" />
  <event tick="1536" len="384" a="84" b="70" />
  <event tick="1920" len="384" a="96" b="70" />
  <event tick="2304" len="384" a="108" b="70" />
  <event tick="2688" len="384" a="120" b="70" />
  </part>

Recorded part:

Code: Select all

<part uuid="{e67d8487-7c2d-471d-b571-e1f9495b9f2b}">
  <name>Track 2</name>
  <viewState xscroll="0" yscroll="200" xscale="2" yscale="1">
    <ctrlViewState num="262146" />
    </viewState>
  <poslen tick="0" len="768" />
  <selected>1</selected>
  <color>0</color>
  <event tick="0" len="2" a="36" b="70" />
  <event tick="0" len="2" a="48" b="70" />
  <event tick="0" len="2" a="60" b="70" />
  <event tick="0" len="2" a="72" b="70" />
  <event tick="0" len="2" a="84" b="70" />
  <event tick="0" len="2" a="96" b="70" />
  <event tick="0" len="2" a="108" b="70" />
  <event tick="0" len="2" a="120" b="70" />
  </part>
User avatar
Impostor
Established Member
Posts: 1298
Joined: Wed Aug 17, 2022 1:55 pm
Has thanked: 134 times
Been thanked: 334 times

Re: Another bug: recording midi from plugin

Post by Impostor »

Attached is a screenshot with Pianoteq's midi monitor visible during recording to show that note-off's are sent via midi track 2:

Attachments
monitored.png
monitored.png (194.99 KiB) Viewed 580 times
Tim E. Real
Established Member
Posts: 658
Joined: Sat Sep 15, 2012 12:36 am
Has thanked: 36 times
Been thanked: 105 times

Re: Another bug: recording midi from plugin

Post by Tim E. Real »

Ha! I am one step ahead of you this time! I noticed the problem yesterday.

It's a booboo in my VST code, the wrong event recording timestamp was used:

Code: Select all

// REMOVE Tim. buf. Changed. Oops, using wrong base time!
//       event.setTime(MusEGlobal::audio->pos().frame() + ev->deltaFrames);
      const unsigned int abs_ft = MusEGlobal::audio->curSyncFrame() + ev->deltaFrames;

Also regarding recording of midi out from synths: I noticed yet another problem yesterday.
Allow me to try and explain with a bit of technical talk:

Let us assume that your audio driver (Jack say) is using a large buffer size, say 2048 samples. Much latency there.
When using an arpeggiator or sequencer synthesizer, the notes and the sound that comes out of it are late by 2048 samples.
When compared with the metronome for example, in play mode, the sounds and notes do not align with the metronome.
So when I wrote all of the latency correction/compensation code (enabled in Settings), I used a trick to get the
output of the synth to align correctly so that it is perfectly in time with the metronome so that you can play along.
The trick I used was to artificially shift the transport time that is sent to the arpeggiator/sequencer synth, so that
the resulting notes and sound output from the synth is perfectly aligned with the metronome.
It is unknown from the synth whether this trick should be applied in all cases, there is no way to tell if it should be applied.
Therefore there is a user setting in the 'Quirks' section of our plugin generic UI, called 'transport affects latency'
that can be enabled if you know that the synth is indeed an arpeggiator or sequencer.

So far so good. It sounds perfect to play along with.
Unfortunately if you then record these notes or sounds, they are misaligned in the recording because the recording processor
is expecting them to be late and tries to compensate - but they have already been compensated,
resulting in too much shift in the recording times.

So an oversight there. Ugh... I'm trying to correct it right now...

Cheers.

User avatar
Impostor
Established Member
Posts: 1298
Joined: Wed Aug 17, 2022 1:55 pm
Has thanked: 134 times
Been thanked: 334 times

Re: Another bug: recording midi from plugin

Post by Impostor »

Tim E. Real wrote: Sat Apr 01, 2023 8:12 pm

Ha! I am one step ahead of you this time! I noticed the problem yesterday.

It's a booboo in my VST code, the wrong event recording timestamp was used:

Code: Select all

// REMOVE Tim. buf. Changed. Oops, using wrong base time!
//       event.setTime(MusEGlobal::audio->pos().frame() + ev->deltaFrames);
      const unsigned int abs_ft = MusEGlobal::audio->curSyncFrame() + ev->deltaFrames;

Good, you found the source of the problem! I noticed it when I tried to make a drumbeat in time with an arpeggio of rather odd signature. It was hopeless to do so manually, so I drove AVL Drums with the same arpeggio, and after some playing with the transpose setting in the midi strip, I got a beat that almost made sense, so then I wanted to record the arpeggio midi for further manual editing.

Tim E. Real wrote: Sat Apr 01, 2023 8:12 pm

Also regarding recording of midi out from synths: I noticed yet another problem yesterday.
Allow me to try and explain with a bit of technical talk.

Solving a problem always leads to a new one! You wouldn't ever want to be left without an avocation, right:)

Post Reply