Author Topic: MIDI Marker repositioning (loop)  (Read 457 times)

fran

  • Guest
MIDI Marker repositioning (loop)
« on: 27 Feb '19 - 19:26 »
Hi,

I try to play a MIDI part (from the initial position to the end position of a Marker), but I've found that when I detect the EndMarker value in code (macOS and Windows, using calls to the DyLib and DLL), the code works as expected and I am able to reposition the "playing head" again to the start position of the marker.

The problem here, is that when repositioning using BASS_ChannelSetPosition(channel, position, flags) it lefts out playing the last compass for the marker.

I have found that, for some sections it works fine when adding a magic number of 1500 to the end position, but this is clearly something arbitrary… that works for one sections… but not for others…

I'm starting to thing if this is due to something related with the buffer… Don't understand well why the last part is not heard when the last position of the marker is reached (both using Ticks or Bytes, it doesn't matter)

BTW: The app is coded with Xojo. That means that I don't have the option to use Callbacks due to the fact that Xojo doesn't support Preemptive Threads).

Any idea or cue about what may be going wrong here?

Thank you!

Javier

fran

  • Guest
Re: MIDI Marker repositioning (loop)
« Reply #1 on: 27 Feb '19 - 21:04 »
Does a marker end position be calculated, instead, adding some amount of time based on the PPQN, BPM or tempo values (or a combination of these)?

Thank you!

Javier

Ian @ un4seen

  • Administrator
  • Posts: 21991
Re: MIDI Marker repositioning (loop)
« Reply #2 on: 28 Feb '19 - 14:13 »
The correct way to implement looping between 2 markers is to use a "mixtime" BASS_SYNC_POS sync set at the 2nd marker's position, and seek back to the 1st marker in the callback. If that isn't an option for you, I guess you are currently polling BASS_ChannelGetPosition to detect when the 2nd marker is reached? Unfortunately, I don't think it will be possible to get it working reliably that way. Perhaps you could create a little library to implement the callback stuff for your app?

Fran

  • Guest
Re: MIDI Marker repositioning (loop)
« Reply #3 on: 1 Mar '19 - 08:35 »
Thank you Ian,

What do you mean with "mixtime" position? How can I get that value?

Thank you in advance!

Javier

Ian @ un4seen

  • Administrator
  • Posts: 21991
Re: MIDI Marker repositioning (loop)
« Reply #4 on: 1 Mar '19 - 14:33 »
A "mixtime" BASS_SYNC_POS sync (using the BASS_SYNC_MIXTIME flag) is called as soon as the decoder reaches the sync's position. Otherwise, the sync will be called when the position is heard, which is later due to buffering (and the decoder will continue processing in the meantime). For looping purposes, you want the sync to be called as soon as the decoder reaches the position so that the decoder doesn't go any further. Please see the SYNCPROC documentation for some more detail.