Skip to content

Commit

Permalink
Added Rwav Converter
Browse files Browse the repository at this point in the history
  • Loading branch information
notBenjaminHalko committed Jan 22, 2022
1 parent dae2d2a commit a217147
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
15 changes: 9 additions & 6 deletions WiiMusicEditorPlus.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from main_window_ui import Ui_MainWindow

import editor
from editor import RetranslateSongNames, TranslationPath, PlayRwav, ReplaceWave, SaveRecording, GetDolphinSave, SavePath, HelperPath, ChangeName, GetBrsarPath, GetDefaultStyle, GetGeckoPath, GetMainDolPath, PatchMainDol, CreateGct, DecodeTxt, EncodeTxt, FixMessageFile, Run, GetMessagePath, GivePermission, BasedOnRegion, SaveSetting, LoadSetting, PrepareFile, LoadMidi, PatchBrsar, GetStyles, AddPatch, ChooseFromOS, currentSystem, Instruments, gctRegionOffsets, Songs, Styles, gameIds, gctRegionOffsetsStyles, savePathIds, extraSounds, languageList, StyleTypeValue, SongTypeValue, LoadType, RecordType
from editor import ConvertWav, RetranslateSongNames, TranslationPath, PlayRwav, ReplaceWave, SaveRecording, GetDolphinSave, SavePath, HelperPath, ChangeName, GetBrsarPath, GetDefaultStyle, GetGeckoPath, GetMainDolPath, PatchMainDol, CreateGct, DecodeTxt, EncodeTxt, FixMessageFile, Run, GetMessagePath, GivePermission, BasedOnRegion, SaveSetting, LoadSetting, PrepareFile, LoadMidi, PatchBrsar, GetStyles, AddPatch, ChooseFromOS, currentSystem, Instruments, gctRegionOffsets, Songs, Styles, gameIds, gctRegionOffsetsStyles, savePathIds, extraSounds, languageList, StyleTypeValue, SongTypeValue, LoadType, RecordType
from update import UpdateWindow, CheckForUpdate
from errorhandler import ShowError
from settings import SettingsWindow, CheckboxSeperateSongPatching
Expand Down Expand Up @@ -1019,15 +1019,18 @@ def Button_SOE_SelectAll(self):
self.SOE_Patchable()

def Button_SOE_Browse(self):
if(self.LoadExtraFile("rwav (*.rwav)")):
if(self.LoadExtraFile("Wav Files (*.wav *.rwav)")):
self.SOE_Patchable()
self.SOE_File_Label.setText(os.path.basename(self.extraFile))

def Button_SOE_Patch(self):
file = open(self.extraFile,"rb")
rwavInfo = file.read()
file.close()
rwavSize = os.stat(self.extraFile).st_size
if(pathlib.Path(self.extraFile).suffix == ".wav"):
rwavInfo, rwavSize = ConvertWav(self.extraFile)
else:
file = open(self.extraFile,"rb")
rwavInfo = file.read()
file.close()
rwavSize = os.stat(self.extraFile).st_size
index = 0x33654
selected = []
offset = 0
Expand Down
Binary file not shown.
10 changes: 10 additions & 0 deletions editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -662,6 +662,16 @@ def ReplaceSong(positionNum,replacementArray,BrseqOrdering,BrseqInfoArray,BrseqL
brsar.write((int.from_bytes(size,"big")+sizeDifference).to_bytes(4, 'big'))
brsar.close()

def ConvertWav(wavPath):
with tempfile.TemporaryDirectory() as directory:
Run([HelperPath()+"/soundconverter/rwavconverter",wavPath,directory+"converted.rwav"])
file = open(directory+"converted.rwav","rb")
rwavInfo = file.read()
file.close()
rwavSize = os.stat(directory+"converted.rwav").st_size

return rwavInfo, rwavSize

def ReplaceWave(startOffset,replaceNumber,rwavInfo,rwavSize):
if(not os.path.exists(GetBrsarPath()+".backup")): copyfile(GetBrsarPath(),GetBrsarPath()+".backup")
sizeDifference = 0
Expand Down

0 comments on commit a217147

Please sign in to comment.