public void LoadFile(string FileName) { byte[] OpenedWAVFile = File.ReadAllBytes(FileName); VGAudio.Containers.Wave.WaveReader Reader = new VGAudio.Containers.Wave.WaveReader(); Audio = Reader.ReadWithConfig(OpenedWAVFile); }
private void TreeView1_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e) { if (e.Button == MouseButtons.Left) { if (e.Node.Nodes.Count == 0) { var Size = (decimal)Rom.FileDict[$"/{e.Node.FullPath}"].DataLength; if (Size == 0) { label1.Text = $"Size: 0 bytes (empty file)"; } else if (Size > 1 << 10 && Size < 1 << 20) { label1.Text = $"Size: {Size / (1 << 10):f}KB"; } else if (Size > 1 << 20 && Size < 1 << 30) { label1.Text = $"Size: {Size / (1 << 20):f}MB"; } else if (Size > 1 << 30) { label1.Text = $"Size: {Size / (1 << 30):f}GB"; } else { label1.Text = $"Size: {Size} bytes"; } var Name = Rom.FileDict[$"/{e.Node.FullPath}"].Name; label4.Text = Name; var Ext = Name.Split('.')[Name.Count(c => c == '.')].ToUpper(); if (CheckExtension(Ext, "bfstm")) { label6.Visible = true; label7.Visible = true; button2.Visible = true; button3.Visible = true; button4.Visible = true; SoundFile = new VGAudio.Containers.NintendoWare.BCFstmReader().Read (Rom.OpenFile(Rom.FileDict[$"/{e.Node.FullPath}"]).AsStream()) .GetAllFormats().ToArray()[0]; SoundName = Rom.FileDict[$"/{e.Node.FullPath}"].Name; label6.Text = $"Length: {new TimeSpan((SoundFile.SampleCount / SoundFile.SampleRate) * 10000000).ToString("mm':'ss")}"; label7.Text = $"Sample rate: {(decimal)(SoundFile.SampleRate / 1000)}KHz"; } else if (CheckExtension(Ext, "wav")) { label6.Visible = true; label7.Visible = true; button2.Visible = true; button3.Visible = true; button4.Visible = true; SoundFile = new VGAudio.Containers.Wave.WaveReader().Read (Rom.OpenFile(Rom.FileDict[$"/{e.Node.FullPath}"]).AsStream()) .GetAllFormats().ToArray()[0]; SoundName = Rom.FileDict[$"/{e.Node.FullPath}"].Name; label6.Text = $"Length: {new TimeSpan(SoundFile.SampleCount / SoundFile.SampleRate * 10000000).ToString("mm':'ss")}"; label7.Text = $"Sample rate: {(decimal)(SoundFile.SampleRate / 1000)}KHz"; } else { label6.Visible = false; label7.Visible = false; button2.Visible = false; button3.Visible = false; button4.Visible = false; } label5.Text = $"{Ext} file"; } else { label5.Text = $"{e.Node.Nodes.Count} {(e.Node.Nodes.Count == 1 ? "file" : "files")}"; label4.Text = e.Node.Name; label1.Text = "Folder"; } } else if (e.Button == MouseButtons.Right) { if (treeView1.SelectedNode.Nodes.Count == 0) { extractFileToolStripMenuItem.Text = "Extract file..."; contextMenuStrip1.Show(Cursor.Position); } else { extractFileToolStripMenuItem.Text = "Extract folder..."; contextMenuStrip1.Show(Cursor.Position); } } }