Closed Tannister closed 6 months ago
same happen with stereo files
same happen with stereo files
What do you mean? Aren't we able to import stereo files just fine usually? The error message is about needing to have at least two channels (which I can try and have accept mono), so what does it say when feeding it stereo files?
Same error message with a stereo file (both with ogg and wav)
Can you send the stereo file you're getting the error with, please? (can send on Discord in case there might be copyright infringements)
song.zip Should be good, unmodified audio from ExileLord's Soulless 1
It works for me! Are you sure that's the audio file you're using? In the CallMeWhenYoureSober folder?
Attached is the successfully created hwas: Main_song.zip
Are there any other audio files in the folder? Vocals (those would be merged with song)? Crowd?
Pretty sure your problem is caused by your vocals file:
I don't have any vocal file in the directory.
the song.ogg is the only audio file present. In this image, audio file is from Too Much, Too Young, Too Fast (GHWT), same error.
ModdingTool recompiled today from the main branch
I just recompiled from main, and used song.ogg from Too Much, Too Young, Too Fast, and it's working just fine:
Can you possibly try on Windows 10?
sadly, no. i don't have any win10 installations here.
same thing happens when i try to import guitar & rhythm audio file. :/
But you have no issue when using the last release?
There's been no change in main that affects the conversion of OGG or WAV files since, so I can only assume that it's a problem somehow caused at compilation time on Windows 11, since I have no issues after compiling the tool myself on Windows 10, with the same source code you're using...
same thing happens when i try to import guitar & rhythm audio file. :/
100% exact same error message? The guitar & rhythm audio files should be OGG to begin with and should be decoded and recoded to the correct format, but that's not handled by NAudio.Wave, so that error message should not apply.
Could you check the temp audio file (oggtool_audio.temp) in the GHDS_ModdingTool_resources folder, and send it over, please?
100% Identical error message with latest exe found in releases.
100% Identical message for all audio files (song, drums, rhythm and guitar)
That one is with one of the audio files found in embedded_resources from this repo
oggtool_audio.zip This one with Soulless 1 Song.ogg Audio
oggtool_audio.zip This one with Soulless 1 Song.ogg Audio
It's properly converted to a stereo WAV file (if you rename it to .WAV or open it with an hex editor), not sure what the issue is here...
100% Identical message for all audio files (song, drums, rhythm and guitar)
Can you please try the following:
Mhhh...
Can you uncomment these lines: https://github.com/AntonioDePau/GHDS_ModdingTool/blob/main/gh/audio/encoding.cs#L92-L94
And copy paste them at line: https://github.com/AntonioDePau/GHDS_ModdingTool/blob/main/gh/audio/encoding.cs#L76
Rebuild, try again, and share the screenshot (or copy paste the output of the 3 uncommented/copied lines).
So, it does happen at NAudio.Wave level because of the volume increase during OGG => OGG conversion (where oggdec converts to WAV first, then volume increase happens, and then it should be converted back to OGG, but you're crashing before that).
With the uncommented Console.WriteLine lines, we should be able to know what WAV format the tool is getting.
All 0 ? does not seem correct
Added 2 lines to see where we are in the code, we don't hit Encode()
Length of WAV byte array is 0 ?
Added 2 lines to see where we are in the code, we don't hit Encode()
Yeah, OGG to OGG doesn't use Encode, just IncreaseVolume. 0 for channels (and the other 2 values) explains why you're getting the error. As to why you're getting 0...
Try to print the oggFile byte array length here: https://github.com/AntonioDePau/GHDS_ModdingTool/blob/main/gh/audio/OGG/OGG.cs#L79
Oh, and print the output's length as well: https://github.com/AntonioDePau/GHDS_ModdingTool/blob/main/gh/audio/OGG/OGG.cs#L82
That one seems valid
Not the output one.
*side note, i put back the old Command Prompt as the default cmd, as it is still available on win11 through developper settings
reading the code, shouldnt you read the output file instead of getting the results from StartProcess ?
Damned... This will be so much easier if/when Evan manages to give us a fully C# solution for decoding and encoding OGGs.
Okay, we may need to have oggdec write the output to a file and read that file rather than expecting oggdec to feed us back a byte array...
Can you try to update the Ogg.Decode method like so:
public static byte[] Decode(byte[] oggFile){
string tempFile = Path.Combine(ToolsPath, "oggtool_audio.temp");
File.WriteAllBytes(tempFile, oggFile);
string Arguments = $" --quiet --output - \"{tempFile}\"";
byte[] output = StartProcess(Path.Combine(ToolsPath, "oggdec.exe"), Arguments);
return output;
}
Edit: This is to try and see if it works by escaping the temp file's path (\"{tempFile}\"), as I suspect you may have whitespaces in your path to the tool
reading the code, shouldnt you read the output file instead of getting the results from StartProcess ?
We'll try, but I really hate having to rely on temp files and write/read them when we SHOULD just be able to feed bytes and get bytes in return.
Works !
Spaces then :D ahahah, glad it was an easy fix. I'll make a commit.
huh The final file is 0 bytes ..
Yeah, the oggenc also needs escaping :p:
public static byte[] Encode(byte[] wavFile, int SampleRate, int BitRate = 18){
string tempFile = Path.Combine(ToolsPath, "oggtool_audio.temp");
File.WriteAllBytes(tempFile, wavFile);
string Arguments = $" --quiet --bitrate {BitRate} --resample {SampleRate} --downmix --min-bitrate {BitRate} --max-bitrate {BitRate} -o - \"{tempFile}\"";
byte[] output = StartProcess(Path.Combine(ToolsPath, "oggenc.exe"), Arguments);
return output;
}
there might be other places where escaping is required, glad it was only this
We should be fine. The rest of the paths is handled by Path.Combine and other safer methods. This here was an issue because we're relying on an external tool (oggenc/oggdec) that take path as arguments and I forgot to escape those. But again, hopefully we can have a fully managed C# solution, if Evan can pull it off!
Now the presence of Guitar_guitar.ogg causes the issue
(at least that one i can go around easily)
this happens when putting mono audio files (same thing with wav and ogg)