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

Implementing a custom file format is annoying #40

Open
DCNick3 opened this issue Jan 6, 2023 · 4 comments
Open

Implementing a custom file format is annoying #40

DCNick3 opened this issue Jan 6, 2023 · 4 comments

Comments

@DCNick3
Copy link

DCNick3 commented Jan 6, 2023

I am writing a game engine that has to support some custom audio format that wouldn't make sense to include in the library, so I am trying to make my own types to implement SoundData and Sound traits.

It does seem possible to implement it, but I have to duplicate a lot of code from kira: managing volume, panning, resampling audio... Ideally I would like to implement some trait that returns sample rate & decodes audio packets on demand, without copying half of kira into my impls.

One simple solution would be to use StaticSoundData, but I need to use streaming for better loading latency.

@tesselode
Copy link
Owner

My original intention was that people who need support for different formats should just contribute to Symphonia, but in the case of custom formats that wouldn't make sense. IIRC the current streaming sound implementation does have a Decoder interface, so I'll likely expose that in the next version of Kira.

@tesselode
Copy link
Owner

@DCNick3 following up on this, can you tell me about your game engine? Why do you have a custom audio format?

@DCNick3
Copy link
Author

DCNick3 commented Apr 3, 2023

It's a re-implementation of an existing commercial VN game engine, to make it possible run games written for it on new platforms (PC and maybe web). I want it to work on purely original game files, without any conversions, hence the need for custom format support.

The audio format is just a weird container for opus btw, nothing fancy.

The kira glue is implemented here: https://github.com/DCNick3/shin/tree/master/shin-audio/src. It duplicates a lot of functionality...

As a side note, IDK if it's a good idea, but I do audio decoding in the audio thread. Seems to work fine and has an added bonus of being more easy to port to wasm

@tesselode
Copy link
Owner

Kira v0.8.0 exposes the Decoder trait, although streaming sounds do still create an extra thread for scheduling the decoder, so that won't work on wasm just yet.

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

No branches or pull requests

2 participants