Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3.6.0: AudioChannel.Position not working correctly for all sound types #1695

Open
2 of 4 tasks
ivan-mogilko opened this issue Jun 18, 2022 · 5 comments
Open
2 of 4 tasks
Assignees
Labels
backend: sdl2 related to sdl2 library context: audio context: script api type: bug unexpected/erroneous behavior in the existing functionality

Comments

@ivan-mogilko
Copy link
Contributor

ivan-mogilko commented Jun 18, 2022

According to the manual AudioChannel.Position:

What position represents depends on the FileType of the audio clip:

MIDI - the beat number
MOD/XM/S3M - the pattern number
WAV/VOC - the sample number (e.g. in a 22050 Hz sound, 22050 = 1 second)
OGG/MP3 - milliseconds offset

This was never fully reimplemented in 3.6.0 after audio subsystem rewrite.

Latest state:

  • - MIDI - not working;
  • - MOD - not working;
  • - WAV - done;
  • - OGG/MP3 - done

Same refers to the AudioChannel.Seek function.

@ivan-mogilko ivan-mogilko added type: bug unexpected/erroneous behavior in the existing functionality context: audio context: script api labels Jun 18, 2022
@ivan-mogilko ivan-mogilko added this to the 3.6.0 milestone Jun 18, 2022
@ivan-mogilko ivan-mogilko self-assigned this Jul 25, 2022
@ivan-mogilko ivan-mogilko added the backend: sdl2 related to sdl2 library label Aug 9, 2022
@ericoporto
Copy link
Member

Is the midi and mod not working a non-implemented part in SDL_Sound too, like it was in the more case?

@ivan-mogilko
Copy link
Contributor Author

ivan-mogilko commented Aug 15, 2022

Is the midi and mod not working a non-implemented part in SDL_Sound too

No, it's not something non-implemented, but simply a restriction of the interface design. SDL_Sound's interface is fully opaque so there's no way to know the actual sound format, or do any format specific operations. We may seek and get position in milliseconds for all these sound types, but not in the special position kind required by AGS.

With the WAV it is possible to get sample count since we know duration in ms and frequency, but I don't yet know if anything similar is possible to do with MIDI and MOD.

@ericoporto
Copy link
Member

I imagine with MIDI it should be possible, but the pattern number for mod is an odd one, I need to look into the code to see what that really means.

@ivan-mogilko
Copy link
Contributor Author

ivan-mogilko commented Aug 15, 2022

If this cannot be done with the available data, then it may be worth asking SDL_Sound author(s) if they see this acceptable to add format-specific functions into the library API. Or as some kind of extension.

@ericoporto
Copy link
Member

ok, read a bit on the old code, there were jgmod and aldumb builds of ags apparently, am considering only aldumb. Aldumb clips returns current order for position. From reading the loaded data, I think the mod clip is made of orders which index a specific pattern, which is it made of different ordered samples in different channels.

Looking into SDL_sound, the modplug used there doesn't have an interface internally too. It has an interesting comment on seeking using milliseconds, which is why I think ags/aldumb used the order instead.
https://github.com/icculus/SDL_sound/blob/495e948b455af48eb45f75cccc060498f1e0e8a2/src/libmodplug/modplug.h#L40-L46

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend: sdl2 related to sdl2 library context: audio context: script api type: bug unexpected/erroneous behavior in the existing functionality
Projects
None yet
Development

No branches or pull requests

2 participants