Home Game Development audio – In LibGdx, how to add another music format?

audio – In LibGdx, how to add another music format?

0
audio – In LibGdx, how to add another music format?

[ad_1]

I would like to add multiple music formats to the LibGdx library, like .vgm, .mod, .s3m, .xm and so on. I already have the Java code to do so, but it’s hard to integrate it with LibGdx code.

I know there is a backend class named OpenALLwjgl3Audio that has the following code:

    registerSound("ogg", Ogg.Sound.class);
    registerMusic("ogg", Ogg.Music.class);
    registerSound("wav", Wav.Sound.class);
    registerMusic("wav", Wav.Music.class);
    registerSound("mp3", Mp3.Sound.class);
    registerMusic("mp3", Mp3.Music.class);

So it would be nice to call this registerMusic(“vgm”, Vgm.Music.class) from outside this class.

  1. Unfortunately, as it is a backend class, I can’t access it from ‘core’ project:

     ((OpenALLwjgl3Audio) Gdx.audio).registerMusic("vgm", Vgm.Music.class);
     => Error: OpenALLwjgl3Audio can't be resolved to a type
    
  2. I tried to access the audio variable in the ‘desktop’ project (DesktopLauncher.java), but it is null until the application is instantiated, and then it enter in a loop:

     ((OpenALLwjgl3Audio) Gdx.audio).registerMusic("vgm", Vgm.Music.class);
     => Nullpointer Exception, as audio is null until the code below executes:
     ...
     new Lwjgl3Application(new Game(), config);
    
  3. Creating the class Vgm.Music.class in the LibGdx library itself, along with Mp3.class, Ogg.class and so on and edit the OpenALLwjgl3Audio directly. BUT: I would need to use a particular fork of the LibGdx code, as it probably wouldn’t enter in the main develop branch, making it harder to keep my project updated.

Any guidelines to achieve this goal?

[ad_2]

Previous article RIG Headsets On Sale At Best Buy For Limited Time
Next article ASTLIBRA Revision Review (Switch eShop)
Hello there! My name is YoleeTeam, and I am thrilled to welcome you to AmazonianGames.com. As the premier destination for all things related to Amazon Games' universe, we are dedicated to providing you with the most exciting and immersive gaming experiences out there. From captivating visuals to exhilarating gameplay, our website is packed with comprehensive insights, updates, and reviews to keep you ahead of the game. Whether you're a seasoned gamer or new to the scene, I am here to guide you through this virtual frontier. If you have any questions or suggestions, feel free to reach out to me at john@yoleesolutions.com. Embark on your Amazon gaming journey today with AmazonianGames.com and let the adventure begin!