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

Request: Support for ogg and mp3 soundtrack #794

Closed
aorin1 opened this issue Mar 30, 2023 · 12 comments
Closed

Request: Support for ogg and mp3 soundtrack #794

aorin1 opened this issue Mar 30, 2023 · 12 comments
Assignees
Labels
TR1 TRX bug A bug with TRX
Milestone

Comments

@aorin1
Copy link

aorin1 commented Mar 30, 2023

Currently, only FLAC is supported

@aorin1 aorin1 changed the title Suggestion: Support for ogg and mp3 soundtrack Request: Support for ogg and mp3 soundtrack Mar 30, 2023
@walkawayy
Copy link
Collaborator

I thought support for this was added in version 2.13 in #688. Did you try in the latest version?

@aorin1
Copy link
Author

aorin1 commented Mar 30, 2023

I thought support for this was added in version 2.13 in #688. Did you try in the latest version?

I did today with version 2.13.2 and tried mp3 and ogg tracks inside the music folder, only putting back the flac files reproduce jingles, background sound and music. Unless there's a very specific way to make both formats working that I'm not aware of.

@Richard-L
Copy link
Collaborator

I also couldn't get a different media container to work but thought it was likely just a naming scheme problem.

@walkawayy
Copy link
Collaborator

@carlo-bramini do you have any ideas? Tagging since you wrote the feature.

@carlo-bramini
Copy link
Contributor

@carlo-bramini do you have any ideas? Tagging since you wrote the feature.

Yes, the ogg/mp3 files have been saved in planar format.
As you can see here:
https://github.com/LostArtefacts/Tomb1Main/blob/841599c62eb2ab5047e76e8ef700547b0fb890ae/src/specific/s_audio.c#L94
at the time of writing, the engine supports:

  • AV_SAMPLE_FMT_U8
  • AV_SAMPLE_FMT_S16
  • AV_SAMPLE_FMT_S32
  • AV_SAMPLE_FMT_FLT

but it does not support these one:

  • AV_SAMPLE_FMT_U8P
  • AV_SAMPLE_FMT_S16P
  • AV_SAMPLE_FMT_S32P
  • AV_SAMPLE_FMT_FLTP

More details on those types can be found here:
https://ffmpeg.org/doxygen/3.1/group__lavu__sampfmts.html

In my opinion, if you really want to use other file formats, the fastest solution is to save the audio files with samples in interleaved mode rather than planar mode.
A more complicated solution could be to write a piece of code for manually merging the planar samples for left and right channel in interleaved mode, but I don't know if it is worth to do so.

@aorin1
Copy link
Author

aorin1 commented Apr 3, 2023

I'm not an expert, so I can't tell the difference, does the reply above mean that the user needs to convert the lossless flac to a specific mp3 or ogg container that are different than the normal converters around? I've tried three different software to convert those to either mp3 or ogg, being ffmpeg itself and Audacity without success, the engine will only reproduce the flac files.
Tomb2Main supports normal mp3 and ogg files.

@rr-
Copy link
Collaborator

rr- commented Apr 4, 2023

Since we're the only project to use ffmpeg which was a decision made to maximize compatibility with third party containers, I think it's worth pursuing adding the conversion code.

@carlo-bramini
Copy link
Contributor

Since we're the only project to use ffmpeg which was a decision made to maximize compatibility with third party containers, I think it's worth pursuing adding the conversion code.

Perhaps, libswresample can do it for us with little effort.

@rr-
Copy link
Collaborator

rr- commented Apr 5, 2023

Since we're the only project to use ffmpeg which was a decision made to maximize compatibility with third party containers, I think it's worth pursuing adding the conversion code.

Clarification, because I was in a hurry when writing the original comment – I meant that it's worth to add this function for two reasons, first being of course the usability and compatibility with various formats, and the other about paving the way for other projects that might want to fork/reference our code, to make it more thorough/universal.

@rr- rr- added the Feature New functionality label Apr 5, 2023
@Gerwin2k
Copy link

What I find odd is this:
I have set of custom ffmpeg dll libraries supporting popular game-related formats including mp3 and ogg.
When I run a dynamically linked ffplay.exe (the stock ffmpeg command line player) with those libraries: I can play mp3 and ogg, no problems.
When I have a dynamically linked Tomb1main.exe combined with those libraries: the same mp3 and ogg files give silence.

@rr- rr- self-assigned this Jul 23, 2024
@rr- rr- added this to the 4.2 milestone Jul 23, 2024
@rr- rr- added TRX bug A bug with TRX and removed Feature New functionality labels Jul 23, 2024
@rr-
Copy link
Collaborator

rr- commented Jul 23, 2024

Turns out this was a problem with the way we decoded the audio, which got fixed in LostArtefacts/libtrx@23fa947 (TR1X 4.2). Currently waiting for Danath to confirm.

@rr-
Copy link
Collaborator

rr- commented Jul 24, 2024

Danath confirmed the files work for him.

@rr- rr- closed this as completed Jul 24, 2024
@rr- rr- added the TR1 label Oct 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
TR1 TRX bug A bug with TRX
Projects
None yet
Development

No branches or pull requests

6 participants