public void FixChannels(string BRSTMPath, int amount) { BinaryReader br = new BinaryReader(File.Open(BRSTMPath, FileMode.Open), Encoding.ASCII); const string Magic = "DATA"; int position = 0; for (int i = 0; i < br.BaseStream.Length; i += 4) { if (new String(br.ReadChars(4)) == Magic) //if we find the magic we can stop and we have our position { position = i + 4; br.Dispose(); br.Close(); break; } } BigEndianReader ber = new BigEndianReader(File.Open(BRSTMPath, FileMode.Open)); ber.BaseStream.Seek(position, SeekOrigin.Begin); uint value = ber.ReadUInt32() + 0x20; ber.Dispose(); ber.Close(); BigEndianWriter bw = new BigEndianWriter(File.Open(BRSTMPath, FileMode.Open)); bw.Seek(position, SeekOrigin.Begin); bw.Write(value); bw.Flush(); bw.Close(); BRSTMPath = '"' + BRSTMPath + '"'; //fix path DecodeBRSTM brstm = new DecodeBRSTM(); brstm.DecodeBRSTMDSP(BRSTMPath, amount); //pass value }
private void button2_Click(object sender, EventArgs e) { BatchFileBuilder builder = new BatchFileBuilder(); SaveFileDialog save = new SaveFileDialog(); save.Filter = "Multi-Channel BRSTM|*.brstm"; DecodeBRSTM brstm = new DecodeBRSTM(); BuildBRSTM buildBRSTM = new BuildBRSTM(); if (comboBox1.SelectedIndex == 0) { brstm.FixChannels(BRSTMPath, 5); builder.BatchBuilder(Convert.ToInt32(loop_start_text.Text), Convert.ToInt32(loop_end_text.Text), 5); buildBRSTM.BuildMultiChannel("BUILD 4CH BRSTM.bat"); MessageBox.Show("Finished! Please select where you want to save your Multi-Channel BRSTM!"); if (save.ShowDialog() != DialogResult.OK) return; File.Move(@"Tools\mcbuild\out.brstm", save.FileName); } else if (comboBox1.SelectedIndex == 1) { brstm.FixChannels(BRSTMPath, 7); builder.BatchBuilder(Convert.ToInt32(loop_start_text.Text), Convert.ToInt32(loop_end_text.Text), 7); buildBRSTM.BuildMultiChannel("BUILD 6CH BRSTM.bat"); MessageBox.Show("Finished! Please select where you want to save your Multi-Channel BRSTM!"); if (save.ShowDialog() != DialogResult.OK) return; File.Move(@"Tools\mcbuild\out.brstm", save.FileName); } else if (comboBox1.SelectedIndex == 2) { brstm.FixChannels(BRSTMPath, 9); builder.BatchBuilder(Convert.ToInt32(loop_start_text.Text), Convert.ToInt32(loop_end_text.Text), 9); buildBRSTM.BuildMultiChannel("BUILD 8CH BRSTM.bat"); MessageBox.Show("Finished! Please select where you want to save your Multi-Channel BRSTM!"); if (save.ShowDialog() != DialogResult.OK) return; File.Move(@"Tools\mcbuild\out.brstm", save.FileName); } else { MessageBox.Show("Error! No amount selected!", "Single to Multi-Channel BRSTM Converter"); return; } }