Lair Posted January 9, 2017 Share Posted January 9, 2017 Here's one of the files with the buzzing Link to comment Share on other sites More sharing options...
grappigegovert Posted January 9, 2017 Author Share Posted January 9, 2017 I just noticed I get the buzzing too when I convert it directly to wav instead of ogg. I'm looking into it. Lair 1 Link to comment Share on other sites More sharing options...
ZANTHERA Posted January 9, 2017 Share Posted January 9, 2017 Just used this to convert all of my PC songs into OGG so I can listen to them, thanks for this, now that I know what the random files are called I'll change their names. There are even a few here that are not on my PS1 list so I'll add those. Also what is with the freaky looking waveforms? They look so odd compared to my PS1 rips, they go in the plus and minus in such large blocks. Link to comment Share on other sites More sharing options...
Sunchipp Posted February 28, 2018 Share Posted February 28, 2018 On 2/8/2015 at 6:32 PM, grappigegovert said: Preview: (old version) The download must feature the newer version or something then I can't get this to work Link to comment Share on other sites More sharing options...
grappigegovert Posted February 28, 2018 Author Share Posted February 28, 2018 12 hours ago, Sunchipp said: The download must feature the newer version or something then I can't get this to work The new version works almost identical (visually), which is why I haven't updated the gif. What kind of problem are you running into? Link to comment Share on other sites More sharing options...
Sunchipp Posted February 28, 2018 Share Posted February 28, 2018 1 hour ago, grappigegovert said: The new version works almost identical (visually), which is why I haven't updated the gif. What kind of problem are you running into? that makes sense cause it's mostly everything that was shown on the gif. I've done what that has instructed but the exe just shuts off after a second when the TUN file is imported Link to comment Share on other sites More sharing options...
grappigegovert Posted February 28, 2018 Author Share Posted February 28, 2018 So, you dragged a .tun file on the 'from tun' bat file, but it did not generate an ogg file? Link to comment Share on other sites More sharing options...
grappigegovert Posted July 29, 2020 Author Share Posted July 29, 2020 Per @EnvyNival's request, the source code of this tool is now public (Check the OT) Keep in mind that the conversion done by this tool isn't 100% accurate (see the buzzing and weird waveform issues above). I think the game uses a custom audio format. Luckily the ADPCM IMA Westwood codec this program assumes it to be is close enough to get semi-usable results. Link to comment Share on other sites More sharing options...
grappigegovert Posted August 2, 2020 Author Share Posted August 2, 2020 I sent this in response to a message I've received inquiring about this tool and figured I might as well post it in this topic: The tool is fairly simple: When converting a tun/pcm file to something it reads the samplerate (in pcm files) and the number of channels from the header and (if stereo) split the audio data into two files. These two files are then fed into sox with the command line: sox -M -t ima -r <samplerate> <channel1path> -t ima -r <samplerate> <channel2path> <outputfile> or, if there is only one channel: sox -t ima -r <samplerate> <channel1path> <outputfile> Now for the conversion from an arbitrary format to tun/pcm I, for some reason, decided to let the program do the conversion in-memory instead of via an intermediary file. This makes the source code a little confusing I'll explain how to do it via an intermediary file as it's easier. Given that the input file is stereo, the two channels are extracted with these two commands: sox <inputfile> -r <samplerate> -t ima <channel1output> remix 1 sox <inputfile> -r <samplerate> -t ima <channel2output> remix 2 These two channels are then merged into one file, and an appropriate header is added to it. The sample rate is set to 22050 for tun files, and for pcm files the sample rate of the input file is used. The header of a tun file looks like this: 41 4C 50 20 08 00 00 00 41 44 50 43 4D 00 00 02 The first four bytes are the characters "ALP " Next is a four-byte integer indicating the offset to the data The last byte, '0x02' is the number of audio channels in the file. The header of a pcm file looks like this: 41 4C 50 20 0C 00 00 00 41 44 50 43 4D 00 00 01 11 2B 00 00 This header is 4 bytes longer, as indicated by the data-offset. The last four bytes that are pcm-exclusive indicate the sample rate (in this example 11025) The data (as interpreted by this tool) is, as stated in a few posts back Westwood IMA ADPCM, with the channels interleaved per-byte. If you strip the header, you can use ffmpeg to decode the files with this command: ffmpeg -f u8 -acodec adpcm_ima_ws -ar <samplerate> -ac <channelamount> -i <inputfile> <outputfile> ffmpeg doesn't support encoding in this codec, unfortunately. Link to comment Share on other sites More sharing options...
mumboking Posted May 23, 2021 Share Posted May 23, 2021 Turns out that FFmpeg does support conversion of LEGO Racers tun and pcm audio, as of these releases: Quote June 15th, 2020, FFmpeg 4.3 "4:3" FFmpeg 4.3 "4:3", a new major release, is now available! Some of the highlights: High Voltage Software ADPCM decoder LEGO Racers ALP (.tun & .pcm) demuxer Quote April 8th, 2021, FFmpeg 4.4 "Rao" FFmpeg 4.4 "Rao", a new major release, is now available! Some of the highlights: High Voltage Software ADPCM encoder LEGO Racers ALP (.tun & .pcm) muxer (I cut out the rest of the highlights) According to the FFmpeg source code, we have this person to thank: Quote High Voltage Software ALP decoder by Zane van Iperen https://github.com/FFmpeg/FFmpeg/blob/master/libavcodec/adpcm.c https://github.com/FFmpeg/FFmpeg/blob/master/libavformat/alp.c grappigegovert 1 Link to comment Share on other sites More sharing options...
grappigegovert Posted May 23, 2021 Author Share Posted May 23, 2021 3 hours ago, mumboking said: Turns out that FFmpeg does support conversion of LEGO Racers tun and pcm audio, as of these releases: [...] That's great news! I didn't know about this. I've added a notice to the OP. Link to comment Share on other sites More sharing options...
Recommended Posts