Skip to content

adl: Add crude loop detection#126

Merged
miller-alex merged 1 commit into
adplug:masterfrom
miller-alex:issue-122
Dec 4, 2022
Merged

adl: Add crude loop detection#126
miller-alex merged 1 commit into
adplug:masterfrom
miller-alex:issue-122

Conversation

@miller-alex

Copy link
Copy Markdown
Contributor

Trying to avoid endlessly playing .adl files. Detecting loops properly would be way too complex, so I'm using a simple heuristics instead. Some testing wouldn't hurt.

In my tests with the music from Dune II, Legend of Kyrandia, and the playertest files all endless loops were eliminated, but I haven't checked whether some parts are missing now. If someone wants to check, the previously endless songs (and their new length) are:

  • DUNE1.ADL, subsong 2 (49 s)
  • DUNE7.ADL, subsong 2 (61 s), subsong 3 (49 s), subsong 4 (134 s), subsong 6 (59 s)
  • DUNE8.ADL, subsong 2 (24 s), subsong 3 (44 s), subsong 71 (24 s), subsong 72 (24 s), subsong 73 (24 s)
  • DUNE9.ADL, subsong 2 (118 s), subsong 3 (164 s), subsong 4 (154 s)
  • DUNE16.ADL, subsong 7 (43 s)
  • DUNE17.ADL, subsong 4 (49 s)
  • KYRA1B.ADL, subsong 2 (96 s), subsong 4 (36 s), subsong 8 (122 s), subsong 12 (43 s), subsong 13 (118 s), subsong 14 (65 s), subsong 92 (54 s)
  • KYRA2A.ADL, subsong 2 (136 s), subsong 3 (50 s), subsong 5 (68 s), subsong 7 (64 s)
  • KYRA3A.ADL, subsong 3 (192 s), subsong 4 (164 s)
  • KYRA4A.ADL, subsong 2 (174 s), subsong 3 (81 s), subsong 7 (70 s), subsong 8 (50 s)
  • KYRA4B.ADL, subsong 12 (187 s)
  • KYRA5B.ADL, subsong 5 (58 s)
  • KYRAMISC.ADL, subsong 2 (61 s), subsong 3 (326 s)
  • LOREINTR.ADL, subsong 6 (55 s)
    (The Kyra files contain very long subsongs up to 75 min. They repeat a finite number of times and I deliberately left them as is.)

@miller-alex miller-alex linked an issue Dec 11, 2020 that may be closed by this pull request
The adl driver doesn't detect looping songs and plays them
forever.

In theory, the file format allows for quite complex channel
control flow, and a reliable detection whether a song is
endlessly repeating previously played parts is not feasible.
In practice, for the music actually released in this format,
a simple check seems to be good enough (although it's easy to
craft malicious examples where this check fails; both false
positives and false negatives):

Let's assume a song is repeating if all channels which are
still playing have jumped back or are (transitively) waiting
on channels which have jumped back.

Bug: adplug#122
@mywave82

mywave82 commented Feb 6, 2022

Copy link
Copy Markdown
Contributor

Might another approach be to do the same as for IMF. Make a database for limiting the length per subsong, and we could also add hiding of non-used subsongs.

@Malvineous

Copy link
Copy Markdown
Member

How is this one going, do you think it's ready to merge?

@miller-alex

Copy link
Copy Markdown
Contributor Author

Haven't been working on adplug for a while (real life…)

I think the PR is ready to merge if you like the approach.

Didn't merge myself because I'm not sure whether it's the right thing to do to deal with the issue. It's not a perfect solution, but well, it's an improvement; nobody complained or proposed a better solution, so I'd say go ahead.

@miller-alex miller-alex merged commit ca06570 into adplug:master Dec 4, 2022
@miller-alex miller-alex deleted the issue-122 branch December 4, 2022 20:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CPlayer runs DUNE1.ADL forever

4 participants