Home Page
F-Zero Central Community Update (Mar.) Championships General Forum Players Photo Album
F-Zero Climax
F-Zero GP Legend
F-Zero MV
F-Zero X
F-Zero GX
F-Zero SNES
F-Zero Climax F-Zero GP Legend F-Zero MV F-Zero X F-Zero GX F-Zero SNES
Twitter Facebook YouTube Twitch
GX Rules Resources Videos Ladders Your Times Latest Times Records Forum
   « View previous topic | View next topic »  
    Index » F-Zero GX » How to create a custom .ADX music file?
NM64
Golden Fox
Posts: 55
View user's profile
Send private message
How to create a custom .ADX music file?
Reply to this Post

I had mentioned in an existing thread of mine that I like running GX through the Dolphin emulator at speeds other than 100% for various reasons, and while there is a gecko code to alter the speed and therefore pitch of sound effects in order to compensate for the difference in emulation speed, there is no code to do something similar for music.

So the next best thing is to straight-up replace the existing .ADX music files with versions that have their speed altered to compensate for the difference in emulation speed.  Luckily for me, I'm extremely experienced in the field of digital audio waveform editing, so altering the speed and pitch of any given waveform is easy-peasy for me.  Similarly I'm already well-versed in how to actually replace files and/or compile a whole new game ISO, so that too is not an issue.

The issue is that I've no idea how to actually encode a waveform into the .ADX format that GX uses.  I know it's possible because the mod "GX Unleashed" includes some custom .ADX music files, so I'd love for insight as to how to actually achieve that.

 

Alternatively a way to slow down the speed of the machines in multiplayer would also work and would avoid the need to even run the entire game at less than 100% speed and therefore all of the sounds and music would maintain their correct speed and pitch, but AFAICT there's only gecko codes that let you speed up, not slow down.  Furthermore, this could cause difficulty with some jumps and stuff on some tracks, but it might also possibly be fine.

Lastly, a code to actually alter the speed of the music, specifically to speed it up, would certainly be a much more ideal method of achieving all of this and would similarly not require any custom .ADX music files.  However, once again, I've only seen a code to alter the speed of sound effects, not music...

Uchiha Madao
Staff Ghost
Posts: 2023
View user's profile
Send private message
Re: How to create a custom .ADX music file?
Reply to this Post

 the game is playing an audio stream when it plays music. a code to alter music pitch won't be possible because of this because the game is not processing these sounds in real time. it's just playing a recording.

about creating ADX files, there's a program called PES Sound File Converter capable of that (google it). you feed it mp3 files and it will produce the ADX files as requested. this is how i've put all the various music in my version of the mod.

it can make the songs loop too but to get a good loop you need to cut and edit the music so that it loops properly and naturally. the game just loops to the very start and there's no cue points like in brstms.

the program does accept wav files but won't loop those properly, which is why mp3 is used.

"Patience is useful in any moment"
NM64
Golden Fox
Posts: 55
View user's profile
Send private message
Re: How to create a custom .ADX music file?
Reply to this Post
Uchiha Madao wrote:

 the game is playing an audio stream when it plays music. a code to alter music pitch won't be possible because of this because the game is not processing these sounds in real time. it's just playing a recording.

Err, the "SFX speed" geckocode also applies to the announcer voice-over, like "3, 2, 1, Go!" countdown as well as the "You've got boost power!" sound clip, and those are obviously streamed recordings just like the .ADX music files.

Uchiha Madao wrote:

 about creating ADX files, there's a program called PES Sound File Converter capable of that (google it). you feed it mp3 files and it will produce the ADX files as requested. this is how i've put all the various music in my version of the mod.

it can make the songs loop too but to get a good loop you need to cut and edit the music so that it loops properly and naturally. the game just loops to the very start and there's no cue points like in brstms.

the program does accept wav files but won't loop those properly, which is why mp3 is used.

Turns out that PES Sound File Converter is merely a frontend for various commandline programs which you can find in its included "convert" folder.  In particular, both the MP3->ADX and WAV->ADX conversion processes rely on "WAV2ADX.EXE" (you can confirm this by renaming that EXE to something like "WAV2ADX.EXE_BAK" - it'll bork out the conversion process even for MP3), implying that the lack of looping functionality is a bug in the front-end itself.

So playing around directly with the commandline "WAV2ADX.EXE" program directly, it looks like all of the limitations you spoke of do not actually truly exist and, once again, are only a limitation or bug in the front-end GUI.  In particular, not only was I able to make a .WAV file loop, but I was even able to make it loop back to a point in the middle of the song.  However, in order to do any kind of looping via "WAV2ADX.EXE" (even if it's just looping back to the beginning), you have to know the actual sample points including how long a song is in samples (something one can easily find out via Audacity).

While this is kind of a tedious process to do for lots of songs, it's at least something I've very familiar with as it's extremely similar to the process I've had to do for creating custom loops for various songs in the Fate/stay night Ultimate Edition fan project that I help out with as their resident audio guru among other things.

 

So here's an example command for "WAV2ADX.EXE" (since its built-in documentation is in Japanese) on a 48KHz WAV file that is 3249156 samples long (around 1m 08s) that, on loop, makes it resume at 10 seconds (480000 samples for a 48KHz WAV) from the beginning of the file:

  • wav2adx.exe input.wav output.adx -lps480000 -lpe3249156

The value after lps = the sample at where looping should resume from (10 seconds into the song in this example), and the value after lpe is the sample at where looping should end (the end of the song in this example)

There are other commands as well for downsampling the sample rate and downmixing channels and the like, but I would highly recommend doing that in an actual audio editor or converter like Audacity or foobar2000 that supports 32bit floating point for much more lossless processing (which is also extremely useful for adjusting and balancing the volume and/or gain of waveforms whether manually or via ReplayGain / Wave Gain / R128gain, etc), and then exporting to dithered 16bit for the final ADX conversion (because WAV2ADX.EXE unfortunately does not seem to support bitdepths greater than 16bit).

 

On the subject of minimizing lossy audio processing, I know that 99.99% of GameCube and Wii games output their audio at 32KHz and, according to Dolphin, F-Zero GX downsamples its audio to 32029Hz (not a typo) despite it's 44.1KHz music...at some point I'll need to do some audio tests to determine what would be higher quality - encoding at a higher sampling rate (even if that required upsampling, perhaps at a multiple of 32029 such as 64058Hz or 96087Hz) to allocate greater bitrate for the ADX encode and then having the game or console downsample, or downsampling with a high-quality offline downsampler like SoX to exactly 32029Hz to avoid any real-time downsampling that's likely of lower quality than what something like SoX can achieve (especially to wacky sampling rates like 32029Hz!  In fact I'm wondering if it'd be even higher quality to downsample to 32000Hz and then losslessly slightly speed up the waveform to 32029Hz as I've sometimes noticed lower quality results with SoX when resampling to or from really weird sampling rates vs more "whole number" sampling rates).

Uchiha Madao
Staff Ghost
Posts: 2023
View user's profile
Send private message
Re: How to create a custom .ADX music file?
Reply to this Post

 if you knew all that, why bother asking here.

"Patience is useful in any moment"
NM64
Golden Fox
Posts: 55
View user's profile
Send private message
Re: How to create a custom .ADX music file?
Reply to this Post
Uchiha Madao wrote:

 if you knew all that, why bother asking here.

...because I didn't initially?

All that information I just posted was discovered on my own through simply looking at PES Sound File Converter and its files combined with my general understanding of computers and digital audio.  What got the ball rolling is that an MP3 would only sometimes be looped, not always, despite the according looping setting being checked in the program - with a fresh copy of the program it would loop without issue, but after using it a bit and additionally converting some WAV files, it would then end up not looping any MP3s even if I used the exact same MP3 that successfully looped before, forcing me to then delete the program and re-extract the program from the .RAR file I originally downloaded.

From there I simply noticed that there was a "convert" folder and I looked what was inside of it, thinking it might have been like a cache or something for during the actual conversion process, so maybe clearing it could solve my MP3 looping issue.  Instead I found a bunch of commandline .EXE files, and sure enough there was no mention of MP3 but yet a mention of "WAV2ADX".  This then gave me the hunch that all MP3s are actually being pre-converted to LPCM, so I tested that by simply renaming WAV2ADX to WAV2ADX_BAK and, sure enough, both the MP3 and WAV conversion processes would throw up the same error.  This implied that there should be no reason for WAV files to not also be able to be looped, and since it seems to rely on WAV2ADX regardless, I tried opening that EXE inside of a command line...which revealed that it is in-fact actually a stand-alone WAV2ADX converter and listed all of and more of its functions (albeit in Japanese) that I described in my previous post in hopes of enlightening anybody else that may run into a similar situation as me.

Uchiha Madao
Staff Ghost
Posts: 2023
View user's profile
Send private message
Re: How to create a custom .ADX music file?
Reply to this Post

 it never crossed my mind to check how the program worked when the glitch happened since i have no knowledge about that kind of stuff.

i just focused on getting the custom songs in the game and doing it in a way that worked good enough.

i guess it's just a different mindset.

"Patience is useful in any moment"
NM64
Golden Fox
Posts: 55
View user's profile
Send private message
Re: How to create a custom .ADX music file?
Reply to this Post

If the bug that was causing MP3 files to not loop didn't occur, then I'm not so sure I myself would have discovered all of that stuff.

It was less of trying to figure out how the program worked and more of trying to figure out a consistant way to keep the program working correctly. I mean, I can't do software and coding kind of things worth a darn (it's hardware that's my expertise), so I think I naturally feel compelled to do my best in terms of testing and figuring out how to replicate bugs in order to compensate for my lack of coding knowledge.

 

I admitteddly did have some amount of skepticism that MP3s could be looped and WAVs couldn't, because MP3 is inherently not a gapless format (one of multiple reasons that OGG vorbis is popular for use with video games - it's a gapless audio format).  I imagine that at least helped my curiosity once I saw no mention of MP3 in the "convert" folder.

   Index » F-Zero GX » How to create a custom .ADX music file?
 
Display posts from previous: