arnaud-carre / LSPlayer

Fastest Amiga Module player ever
MIT License
97 stars 8 forks source link

LSP_MusicGetPos always returns 0 #11

Closed Ozzyboshi closed 5 months ago

Ozzyboshi commented 6 months ago

I call jsr LSP_MusicGetPos once per frame (not inside ad interrupt), I would expect the lower word of d0 to report some number after jsr is done but I always get 0.

Of course when converting I added -getpos at the end of the command as argument and I see the following message after conversion : GetPos enabled (0 bytes)

This is how I am launching the player

  ;Init LSP and start replay using easy CIA toolbox
    lea                 LSPMusic,a0
    lea                 LSPBank,a1
    suba.l            a2,a2         ; suppose VBR=0 ( A500 )
    moveq               #0,d0           ; suppose PAL machine
    bsr.w                 LSP_MusicDriver_CIA_Start

Am I doing something wrong?

arnaud-carre commented 6 months ago

What LSP mode are you using? getpos is only supported in "standard" mode ( ie no "insane" nor new "micro" mode ). Did you double check the you're using "-getpos" command when building the data? ( and use the right .lsmusic file ). If it persists, could you send the .mod file so I can have a look?

Ozzyboshi commented 6 months ago

this is how i use lsp, dont know if it's the correct way

https://github.com/Ozzyboshi/tunnel/blob/6055c3e4eac49ab1db4dbfa60d704d12d9f43ea8/tunnel.s#L343

the modfile is this https://github.com/Ozzyboshi/tunnel/blob/lsp/music/ozzyvirgil3.mod

yes i used -getpos when launching lspconvert, i remember this resulted in 4 extra bytes inside lsmusic file or something similar.

I saw you added the micro mode, i will try also this since it's meant to be a 4k prod, if you can help with compression i would be very grateful

arnaud-carre commented 5 months ago

but your mod file has only 1 position in the sequence. So yeah getpos will always returns 0. If you add a second position in the mod sequence you'll get 0 then 1 then 0 again when music loop. ( get pos returns the position in the current mod sequence )

leifo commented 5 months ago

i think my issue is a similar, so i add to this thread. i expected something else from this function, i.e. the play position as a combination of the current pattern(or sequence) and the row in that pattern (0..63). kplayer and the player return it like that and i use that for my timing. can haz, please?

Ozzyboshi commented 5 months ago

ok , let's start to define what is a position in the sequence, for me is the row of the pattern. this piece of data would be helpful in case you want to sync your demo to the music. For what I understand this is not what getpos reports, right? Is it the pattern number? Anyway, in order to sync I added this instruction to the replayer:

https://github.com/Ozzyboshi/tunnel/blob/6055c3e4eac49ab1db4dbfa60d704d12d9f43ea8/lsp.s#L180

this will write a bit at a particular mem location whenever the sample start playing, according to the channel in use. It's up to my demo to reset the bit after it has been used.

In simple case scenarios it works, at least, it's fine for me.

arnaud-carre commented 5 months ago

it's not the pattern "id". It's the position in the music sequence, that could go only from 0 to 127 in MOD format. You can't sync within a pattern ( would bloat music data file ). If you want to fine-sync at a specific point you could also keep a music frame counter updated on your side. ( each time you call LSP_Tick you incrmeent a frame counter ). And have a hardcoded list of counter where you want to sync

Ozzyboshi commented 5 months ago

thx for your suggestion, i think this issue can be closed then