diff --git a/BRSTM Encoder/Form1.cs b/BRSTM Encoder/Form1.cs index 38a2470..da260d3 100644 --- a/BRSTM Encoder/Form1.cs +++ b/BRSTM Encoder/Form1.cs @@ -65,12 +65,12 @@ public void LoadFile(string FileName) public void Convert(int LoopSt, int LoopEn, bool Loop, string Out) { - VGAudio.Containers.NintendoWare.BrstmWriter Writer = new VGAudio.Containers.NintendoWare.BrstmWriter(); - if (File.Exists(Out)) File.Delete(Out); FileStream Stream = new FileStream(Out, FileMode.CreateNew); + VGAudio.Containers.NintendoWare.BrstmWriter Writer = new VGAudio.Containers.NintendoWare.BrstmWriter(); + Writer.WriteToStream(Audio.AudioFormat.WithLoop(Loop, LoopSt, LoopEn == 0 ? Audio.AudioFormat.SampleCount : LoopEn), Stream, Audio.Configuration); Stream.Close(); } @@ -95,6 +95,12 @@ private void Button_Save_Click(object sender, EventArgs e) Label_Status.Text = "Saving BRSTM..."; Label_Status.Update(); + if (CheckBox_IsLooped.Checked && (int)NumUpDown_LoopStart.Value > (int)NumUpDown_LoopEnd.Value) + { + MessageBox.Show("Loop start cannot be smaller than the loop end"); + return; + } + Convert((int)NumUpDown_LoopStart.Value, (int)NumUpDown_LoopEnd.Value, CheckBox_IsLooped.Checked, Dialog.FileName); Label_Status.Text = "Done!"; diff --git a/BRSTM Encoder/Program.cs b/BRSTM Encoder/Program.cs index 0635e64..287e960 100644 --- a/BRSTM Encoder/Program.cs +++ b/BRSTM Encoder/Program.cs @@ -49,6 +49,13 @@ static int Main(string[] args) Console.WriteLine(""); Console.WriteLine($"Convert {args[0]} to {args[0].Replace(".wav", "")}_out.brstm"); + + if (Loop && LoopEn != 0 && LoopSt > LoopEn) + { + Console.WriteLine("Loop start cannot be smaller than the loop end"); + return -1; + } + f.Convert(LoopSt, LoopEn, Loop, $"{args[0].Replace(".wav", "")}_out.brstm"); Console.WriteLine("Done!"); } diff --git a/BRSTM Encoder/bin/Debug/BRSTM Encoder.exe b/BRSTM Encoder/bin/Debug/BRSTM Encoder.exe index 92b2a50..5b954ba 100644 Binary files a/BRSTM Encoder/bin/Debug/BRSTM Encoder.exe and b/BRSTM Encoder/bin/Debug/BRSTM Encoder.exe differ diff --git a/BRSTM Encoder/bin/Debug/BRSTM Encoder.pdb b/BRSTM Encoder/bin/Debug/BRSTM Encoder.pdb index 2f47b46..c6b318a 100644 Binary files a/BRSTM Encoder/bin/Debug/BRSTM Encoder.pdb and b/BRSTM Encoder/bin/Debug/BRSTM Encoder.pdb differ diff --git a/BRSTM Encoder/obj/Debug/BRSTM Encoder.csproj.FileListAbsolute.txt b/BRSTM Encoder/obj/Debug/BRSTM Encoder.csproj.FileListAbsolute.txt index 00b7ca2..1d82fab 100644 --- a/BRSTM Encoder/obj/Debug/BRSTM Encoder.csproj.FileListAbsolute.txt +++ b/BRSTM Encoder/obj/Debug/BRSTM Encoder.csproj.FileListAbsolute.txt @@ -19,6 +19,6 @@ D:\GIT\brstm-encoder\BRSTM Encoder\obj\Debug\BRSTM Encoder.csproj.CoreCompileInp D:\GIT\brstm-encoder\BRSTM Encoder\obj\Debug\BRSTM Encoder.exe D:\GIT\brstm-encoder\BRSTM Encoder\obj\Debug\BRSTM Encoder.pdb D:\GIT\brstm-encoder\BRSTM Encoder\obj\Debug\BRSTM Encoder.csproj.SuggestedBindingRedirects.cache -D:\GIT\brstm-encoder\BRSTM Encoder\obj\Debug\BRSTM Encoder.csproj.AssemblyReference.cache D:\GIT\brstm-encoder\BRSTM Encoder\bin\Debug\VGAudio.dll D:\GIT\brstm-encoder\BRSTM Encoder\bin\Debug\VGAudio.xml +D:\GIT\brstm-encoder\BRSTM Encoder\obj\Debug\BRSTM Encoder.csproj.CopyComplete diff --git a/BRSTM Encoder/obj/Debug/BRSTM Encoder.exe b/BRSTM Encoder/obj/Debug/BRSTM Encoder.exe index 92b2a50..5b954ba 100644 Binary files a/BRSTM Encoder/obj/Debug/BRSTM Encoder.exe and b/BRSTM Encoder/obj/Debug/BRSTM Encoder.exe differ diff --git a/BRSTM Encoder/obj/Debug/BRSTM Encoder.pdb b/BRSTM Encoder/obj/Debug/BRSTM Encoder.pdb index 2f47b46..c6b318a 100644 Binary files a/BRSTM Encoder/obj/Debug/BRSTM Encoder.pdb and b/BRSTM Encoder/obj/Debug/BRSTM Encoder.pdb differ