public void ConvertFile(string filename, string OutputFormat) { FISP file; string outputfilepath; switch (filename.Substring(filename.Length - 4)) { case ".wav": RiffWave w = new RiffWave(); w.Load(File.ReadAllBytes(filename)); file = new FISP(w); outputfilepath = entry_output_file_path.Text; if (checkbutton_output_copy_input_name.Active) { int lastDotLocate = entry_input_file_path.Text.LastIndexOf('.'); if (lastDotLocate > 0) { if (OutputFormat == "BWAV") { outputfilepath = entry_input_file_path.Text.Substring(0, lastDotLocate) + ".bwav"; } if (OutputFormat == "WAV") { outputfilepath = entry_input_file_path.Text.Substring(0, lastDotLocate) + ".wav"; } } else { if (OutputFormat == "BWAV") { outputfilepath = entry_input_file_path.Text + ".bwav"; } if (OutputFormat == "WAV") { outputfilepath = entry_input_file_path.Text + ".wav"; } } } //MsgBox("in?:" + filename +"\nout:"+outputfilepath); file.stream.isLoop = checkbutton_looping.Active; file.stream.loopStart = (uint)spinbutton_loop_start.Value; file.stream.loopEnd = (uint)spinbutton_loop_end.Value; //File.WriteAllBytes(outputfilepath, BinaryWave.FromRiff(w).ToBytes()); if (OutputFormat == "BWAV") { File.WriteAllBytes(outputfilepath, BinaryWave.FromFISP(file).ToBytes()); } if (OutputFormat == "WAV") { File.WriteAllBytes(outputfilepath, RiffWaveFactory.CreateRiffWave(file).ToBytes()); } break; case "bwav": BinaryWave r = new BinaryWave(); r.Load(File.ReadAllBytes(filename)); file = new FISP(r); outputfilepath = entry_output_file_path.Text; if (checkbutton_output_copy_input_name.Active) { int lastDotLocate = entry_input_file_path.Text.LastIndexOf('.'); if (lastDotLocate > 0) { if (OutputFormat == "BWAV") { outputfilepath = entry_input_file_path.Text.Substring(0, lastDotLocate) + ".bwav"; } if (OutputFormat == "WAV") { outputfilepath = entry_input_file_path.Text.Substring(0, lastDotLocate) + ".wav"; } } else { if (OutputFormat == "BWAV") { outputfilepath = entry_input_file_path.Text + ".bwav"; } if (OutputFormat == "WAV") { outputfilepath = entry_input_file_path.Text + ".wav"; } } } //riffWave file.stream.encoding = (byte)1; if (OutputFormat == "BWAV") { File.WriteAllBytes(outputfilepath, file.ToBytes()); } if (OutputFormat == "WAV") { File.WriteAllBytes(outputfilepath, RiffWaveFactory.CreateRiffWave(file).ToBytes()); } break; default: MsgBox("Unknown type - Only WAV and BWAV are supported.\nIf file isn't WAV or BWAV but like Ogg, convert before. (Oddly, some WAVs crash. Exporting with Audacity may work.)\nThis check depends on the file name (mainly the extension), not the actual file contents.\nIf it is WAV or BWAV, please change the file name.\nBut BWAV input support is too bad. In that case, try using VGMStream.", "Error", MessageType.Error, ButtonsType.Ok); return; } //file.stream /*MsgBox("file.stream.isLoop: \"" + (file.stream.isLoop.ToString() ?? "NULL!!!") + "\"\n" + "file.stream.loopStart: \"" + (file.stream.loopStart.ToString() ?? "NULL!!!") + "\"\n" + "file.stream.loopEnd: \"" + (file.stream.loopEnd.ToString() ?? "NULL!!!") + "\"\n" + "file.stream.originalLoopStart: \"" + (file.stream.originalLoopStart.ToString() ?? "NULL!!!") + "\"\n" + "file.stream.originalLoopEnd: \"" + (file.stream.originalLoopEnd.ToString() ?? "NULL!!!") + "\"\n" + "file.stream.encoding: \"" + (file.stream.encoding.ToString() ?? "NULL!!!") + "\"\n" + //+ "file.stream.magic: \"" + (file.stream.magic.ToString() ?? "NULL!!!") + "\"\n" + "file.stream.sampleRate: \"" + (file.stream.sampleRate.ToString() ?? "NULL!!!") + "\"\n" + "file.stream.secretInfo: \"" + (file.stream.secretInfo.ToString() ?? "NULL!!!") + "\"\n");*/ }
protected void OnButtonLoadClicked(object sender, EventArgs e) { var filepath = entry_input_file_path.Text; System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder(filepath); try { stringBuilder.Replace("~", Environment.GetEnvironmentVariable("HOME"), 0, 1); } catch (Exception ex) { } filepath = stringBuilder.ToString(); if (!IsReadable(filepath, true)) { return; } entry_loaded_file_path.Text = filepath; FISP file; switch (filepath.Substring(filepath.Length - 4)) { case ".wav": entry_loaded_file_format.Text = "WAV"; RiffWave w = new RiffWave(); w.Load(File.ReadAllBytes(filepath)); file = new FISP(w); break; case "bwav": entry_loaded_file_format.Text = "BWAV"; BinaryWave r = new BinaryWave(); if (r.Codic == 0) { entry_loaded_file_format.Text = "BWAV(PCM16)"; } if (r.Codic == 1) { entry_loaded_file_format.Text = "BWAV(DSPADPCM)"; } //RiffWave riffWave = new RiffWave(); r.Load(File.ReadAllBytes(filepath)); file = new FISP(r); break; default: entry_loaded_file_format.Text = "Unknown"; MsgBox("Unknown type - Only WAV and BWAV are supported.\nIf file isn't WAV or BWAV but like Ogg, convert before. (Oddly, some WAVs crash. Exporting with Audacity may work.)\nThis check depends on the file name (mainly the extension), not the actual file contents.\nIf it is WAV or BWAV, please change the file name.\nBut BWAV input support is too bad. In that case, try using VGMStream.", "Error", MessageType.Error, ButtonsType.Ok); return; } checkbutton_looping.Sensitive = spinbutton_loop_start.Sensitive = spinbutton_loop_end.Sensitive = hbox_convert_buttons.Sensitive = true; checkbutton_looping.Inconsistent = false; spinbutton_loop_start.Adjustment.Upper = spinbutton_loop_end.Adjustment.Upper = double.MaxValue; checkbutton_looping.Active = file.stream.isLoop; spinbutton_loop_start.Value = file.stream.loopStart; spinbutton_loop_end.Value = file.stream.loopEnd; //MsgBox(spinbutton_loop_start.Adjustment.Upper.ToString()+"\n" +spinbutton_loop_end.Adjustment.Upper.ToString()); MsgBox("file.stream.isLoop: \"" + (file.stream.isLoop.ToString() ?? "NULL!!!") + "\"\n" + "file.stream.loopStart: \"" + (file.stream.loopStart.ToString() ?? "NULL!!!") + "\"\n" + "file.stream.loopEnd: \"" + (file.stream.loopEnd.ToString() ?? "NULL!!!") + "\"\n" + "file.stream.originalLoopStart: \"" + (file.stream.originalLoopStart.ToString() ?? "NULL!!!") + "\"\n" + "file.stream.originalLoopEnd: \"" + (file.stream.originalLoopEnd.ToString() ?? "NULL!!!") + "\"\n" + "file.stream.encoding: \"" + (file.stream.encoding.ToString() ?? "NULL!!!") + "\"\n" //+ "file.stream.magic: \"" + (file.stream.magic.ToString() ?? "NULL!!!") + "\"\n" + "file.stream.sampleRate: \"" + (file.stream.sampleRate.ToString() ?? "NULL!!!") + "\"\n" + "file.stream.secretInfo: \"" + (file.stream.secretInfo.ToString() ?? "NULL!!!") + "\"\n" + "file.stream.vMajor: \"" + (file.stream.vMajor.ToString() ?? "NULL!!!") + "\"\n" + "file.stream.vMinor: \"" + (file.stream.vMinor.ToString() ?? "NULL!!!") + "\"\n" + "file.stream.vRevision: \"" + (file.stream.vRevision.ToString() ?? "NULL!!!") + "\""); }