Author Topic: [SOLVED] .IT "BXX" command not being followed  (Read 261 times)

Offline ryansupak

  • Shy artist
  • Posts: 7
[SOLVED] .IT "BXX" command not being followed
« on: May 08, 2020, 19:46:27 »
Hi! I've got an .IT file that does not seem to be respecting a "BXX" (Jump to Order) command. I have attached a file which reproduces the issue.

Expected Behavior:
1) File Starts
2) File Plays Order 0 (Pattern 001)
3) File Plays Order 1 (Pattern 003)
4) Playhead hits "B01" command in the final row of Order 1 (Pattern 003), loops-back over Order 1 indefinitely

Actual libopenmpt behavior using "hello world" example code for C++:
1) File Starts
2) File Plays Order 0 (Pattern 001)
3) File Plays Order 1 (Pattern 003)
4) Song stops after completion of Order 1 (Pattern 003), after only a single play of it

EDIT: I found this, which implies that this "non-looping" might be expected behavior. If so, is the idea that any "looping" behavior is, instead, intended to be marshalled by the audio-controlling code?
https://bugs.openmpt.org/view.php?id=1146

Still pretty new to this, so I might be missing something. But this is not behaving how I'd expect it to...
rs
« Last Edit: May 08, 2020, 20:30:31 by ryansupak »

Offline Saga Musix

  • OpenMPT Developers
  • *****
  • Posts: 7,003
  • aka Jojo
    • Download music, samples, VST plugins: Saga Musix Website
  • Operating System: Windows 10 x64
Re: [Potential Bug?] .IT "BXX" command not being followed
« Reply #1 on: May 08, 2020, 20:04:04 »
If you want modules to loop, you need to specify the loop count or tell it to loop indefinitely, using openmpt::module::set_repeat_count. By default, modules won't loop (unless they end up in some very specific edge cases, which that issue you found is about).
» No support, bug reports, feature requests via private messages - they will not be answered. Use the forums and the issue tracker so that everyone can benefit from your post.

Offline ryansupak

  • Shy artist
  • Posts: 7
Re: [Potential Bug?] .IT "BXX" command not being followed
« Reply #2 on: May 08, 2020, 20:06:13 »
Saga Musix: thanks for replying! I am grateful for this library. :)

So, is libopenmpt designed to explicitly disregard in-pattern "Jump to Order" commands that would ultimately cause looping?

rs

Offline Saga Musix

  • OpenMPT Developers
  • *****
  • Posts: 7,003
  • aka Jojo
    • Download music, samples, VST plugins: Saga Musix Website
  • Operating System: Windows 10 x64
Re: [Potential Bug?] .IT "BXX" command not being followed
« Reply #3 on: May 08, 2020, 20:13:58 »
No, it is designed to loop the song as many times as the library caller specified, which by default is zero times. If you want songs to loop indefinitely, pass -1 to the function mentioned above.

There is currently no simple way to determine if a song is most likely meant to loop or not at the end (and in the end, this is not a problem that can be solved in a 100% satisfactory way because there are many modules that just loop some rows of silence at the end, which clearly should not be played forever). If you want to write a program that loops songs that should most likely loop but stops songs that most likely should not loop, you could do the following:
1. Initialize playback with the ctl "play.at_end" set to "continue"
2. If a read() call returns 0 (this means that the song end or loop point was reached), look at the content of the last buffer. If it seems like the song is done playing (i.e. the buffer is full of silence or near-silence), stop playback. Otherwise, if there is no silence, continue rendering.
» No support, bug reports, feature requests via private messages - they will not be answered. Use the forums and the issue tracker so that everyone can benefit from your post.

Offline ryansupak

  • Shy artist
  • Posts: 7
Re: [Potential Bug?] .IT "BXX" command not being followed
« Reply #4 on: May 08, 2020, 20:20:53 »
Saga Musix: Thanks, and it did indeed seem unlikely to me that libopenmpt would try to "guess" whether a song would loop indefinitely, and then assume I'd want something done about that if it were the case. :)

Since that's not the case, I can only conclude that libopenmpt is NOT paying attention to my BXX command at the end of Pattern 003. If it was: then I think it would, in effect, keep looping my song indefinitely (and increasing the tempo of the Pattern a little each time).

I'll also do a little more testing on this point, on my end...

EDIT: I tried adding an additional "shim Order" on the end of my file. It didn't alter the behavior in any way.

rs
« Last Edit: May 08, 2020, 20:24:46 by ryansupak »

Offline Saga Musix

  • OpenMPT Developers
  • *****
  • Posts: 7,003
  • aka Jojo
    • Download music, samples, VST plugins: Saga Musix Website
  • Operating System: Windows 10 x64
Re: [Potential Bug?] .IT "BXX" command not being followed
« Reply #5 on: May 08, 2020, 20:24:35 »
Again: libopenmpt is not ignoring the Bxx command. It just stops playing the song because you told it to play the song one time (or rather because you didn't tell it to not do so). You can just set the repeat count to -1 for any song you load and any Bxx commands will be respected, and the song will keep repeating infinitely like you want it to. Or if you set the repeat count to 100, it will loop that last pattern a hundred times. But with the default settings, it will detect that the Bxx jumps to a row that has already been played and will thus stop playback.
» No support, bug reports, feature requests via private messages - they will not be answered. Use the forums and the issue tracker so that everyone can benefit from your post.

Offline ryansupak

  • Shy artist
  • Posts: 7
Re: [Potential Bug?] .IT "BXX" command not being followed
« Reply #6 on: May 08, 2020, 20:29:56 »
OK, got it now! I didn't comprehend that any in-pattern commands -- regardless of what they were -- and the "global" repeat-count command would/should interact with each other at all.

But, sure enough, adding the following line:
Code: [Select]
mod.set_repeat_count(-1);...solved the problem and now it works as I expected.

Thanks again!
rs