diff --git a/DiscoHawk/AudioExtractor.cs b/DiscoHawk/AudioExtractor.cs
new file mode 100644
index 0000000000..86a81d9a5c
--- /dev/null
+++ b/DiscoHawk/AudioExtractor.cs
@@ -0,0 +1,67 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using BizHawk.DiscSystem;
+using WaveLibrary;
+using System.IO;
+using System.Diagnostics;
+
+namespace BizHawk
+{
+ class AudioExtractor
+ {
+ public static string FFmpegPath;
+
+ public static void Extract(Disc disc, string path, string filebase)
+ {
+ var tracks = disc.TOC.Sessions[0].Tracks;
+ foreach (var track in tracks)
+ {
+ if (track.TrackType != ETrackType.Audio)
+ continue;
+
+ var wave = new WaveFile(2, 16, 44100);
+ var waveData = new byte[track.length_aba * 2352];
+ int startLba = track.Indexes[1].LBA;
+ for (int sector = 0; sector < track.length_aba; sector++)
+ disc.ReadLBA_2352(startLba + sector, waveData, sector * 2352);
+
+ wave.SetData(waveData, waveData.Length / 4);
+ string waveFilePath = Path.Combine(path, "__temp.wav");
+ wave.WriteFile(waveFilePath);
+
+ Encode(waveFilePath, string.Format("{0} - Track {1:D2}.mp3", Path.Combine(path, filebase), track.num));
+
+ File.Delete(waveFilePath);
+ }
+ }
+
+ static void Encode(string wavePath, string mp3Path)
+ {
+ var args = Escape("-i", wavePath, "-ab", "192k", mp3Path);
+
+ StringBuilder sbCmdline = new StringBuilder();
+ for (int i = 0; i < args.Length; i++)
+ {
+ sbCmdline.Append(args[i]);
+ if (i != args.Length - 1) sbCmdline.Append(' ');
+ }
+
+ ProcessStartInfo oInfo = new ProcessStartInfo(FFmpegPath, sbCmdline.ToString());
+ oInfo.UseShellExecute = false;
+ oInfo.CreateNoWindow = true;
+ oInfo.RedirectStandardOutput = true;
+ oInfo.RedirectStandardError = true;
+
+ Process proc = System.Diagnostics.Process.Start(oInfo);
+ proc.WaitForExit();
+ string result = proc.StandardError.ReadToEnd();
+ }
+
+ static string[] Escape(params string[] args)
+ {
+ return args.Select(s => s.Contains(" ") ? string.Format("\"{0}\"", s) : s).ToArray();
+ }
+ }
+}
diff --git a/DiscoHawk/DiscoHawk.cs b/DiscoHawk/DiscoHawk.cs
index 11c2efaf78..90061459ac 100644
--- a/DiscoHawk/DiscoHawk.cs
+++ b/DiscoHawk/DiscoHawk.cs
@@ -27,7 +27,9 @@ namespace BizHawk
[STAThread]
static void Main(string[] args)
{
- DiscSystem.FFMpeg.FFMpegPath = Path.Combine(GetExeDirectoryAbsolute(), "ffmpeg.exe");
+ var ffmpegPath = Path.Combine(GetExeDirectoryAbsolute(), "ffmpeg.exe");
+ DiscSystem.FFMpeg.FFMpegPath = ffmpegPath;
+ AudioExtractor.FFmpegPath = ffmpegPath;
new DiscoHawk().Run(args);
}
diff --git a/DiscoHawk/DiscoHawk.csproj b/DiscoHawk/DiscoHawk.csproj
index 0a5fa0f81f..1954e157ff 100644
--- a/DiscoHawk/DiscoHawk.csproj
+++ b/DiscoHawk/DiscoHawk.csproj
@@ -73,6 +73,7 @@
-->
+
Form
@@ -92,6 +93,10 @@
ProgressDialog.cs
+
+
+
+
@@ -136,14 +141,6 @@
{197D4314-8A9F-49BA-977D-54ACEFAEB6BA}
BizHawk.Emulation
-
- {DD448B37-BA3F-4544-9754-5406E8094723}
- BizHawk.MultiClient
-
-
- {EE135301-08B3-4EFC-A61C-1C53E1C65CB9}
- BizHawk.Util
-
diff --git a/DiscoHawk/DiscoHawkDialog.cs b/DiscoHawk/DiscoHawkDialog.cs
index bc12805ae8..bf01b6916d 100644
--- a/DiscoHawk/DiscoHawkDialog.cs
+++ b/DiscoHawk/DiscoHawkDialog.cs
@@ -36,7 +36,7 @@ namespace BizHawk
if (ofd.ShowDialog() != DialogResult.OK)
return;
- Disc disc = DiscSystem.Disc.FromCuePath(ofd.FileName);
+ Disc disc = Disc.FromCuePath(ofd.FileName);
string baseName = Path.GetFileName(ofd.FileName);
ListViewItem lvi = new ListViewItem(baseName);
@@ -99,7 +99,7 @@ namespace BizHawk
CueBinPrefs GetCuePrefs()
{
- var prefs = new DiscSystem.CueBinPrefs();
+ var prefs = new CueBinPrefs();
prefs.AnnotateCue = checkCueProp_Annotations.Checked;
prefs.OneBlobPerTrack = checkCueProp_OneBlobPerTrack.Checked;
prefs.ReallyDumpBin = false;
diff --git a/DiscoHawk/MainDiscoForm.Designer.cs b/DiscoHawk/MainDiscoForm.Designer.cs
index b7b14e3a57..38d30629d9 100644
--- a/DiscoHawk/MainDiscoForm.Designer.cs
+++ b/DiscoHawk/MainDiscoForm.Designer.cs
@@ -28,59 +28,86 @@
///
private void InitializeComponent()
{
- System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainDiscoForm));
- this.ExitButton = new System.Windows.Forms.Button();
- this.lblMagicDragArea = new System.Windows.Forms.Panel();
- this.label1 = new System.Windows.Forms.Label();
- this.lblMagicDragArea.SuspendLayout();
- this.SuspendLayout();
- //
- // ExitButton
- //
- this.ExitButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
- this.ExitButton.Location = new System.Drawing.Point(281, 316);
- this.ExitButton.Name = "ExitButton";
- this.ExitButton.Size = new System.Drawing.Size(75, 23);
- this.ExitButton.TabIndex = 0;
- this.ExitButton.Text = "E&xit";
- this.ExitButton.UseVisualStyleBackColor = true;
- this.ExitButton.Click += new System.EventHandler(this.ExitButton_Click);
- //
- // lblMagicDragArea
- //
- this.lblMagicDragArea.AllowDrop = true;
- this.lblMagicDragArea.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
- this.lblMagicDragArea.Controls.Add(this.label1);
- this.lblMagicDragArea.Location = new System.Drawing.Point(84, 12);
- this.lblMagicDragArea.Name = "lblMagicDragArea";
- this.lblMagicDragArea.Size = new System.Drawing.Size(200, 100);
- this.lblMagicDragArea.TabIndex = 1;
- this.lblMagicDragArea.DragDrop += new System.Windows.Forms.DragEventHandler(this.lblMagicDragArea_DragDrop);
- this.lblMagicDragArea.DragEnter += new System.Windows.Forms.DragEventHandler(this.lblMagicDragArea_DragEnter);
- //
- // label1
- //
- this.label1.AutoSize = true;
- this.label1.Location = new System.Drawing.Point(47, 10);
- this.label1.Name = "label1";
- this.label1.Size = new System.Drawing.Size(106, 13);
- this.label1.TabIndex = 0;
- this.label1.Text = "Drag here for MAGIC";
- //
- // MainDiscoForm
- //
- this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(368, 351);
- this.Controls.Add(this.lblMagicDragArea);
- this.Controls.Add(this.ExitButton);
- this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
- this.Name = "MainDiscoForm";
- this.Text = "DiscoHawk";
- this.Load += new System.EventHandler(this.MainDiscoForm_Load);
- this.lblMagicDragArea.ResumeLayout(false);
- this.lblMagicDragArea.PerformLayout();
- this.ResumeLayout(false);
+ System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainDiscoForm));
+ this.ExitButton = new System.Windows.Forms.Button();
+ this.lblMagicDragArea = new System.Windows.Forms.Panel();
+ this.label1 = new System.Windows.Forms.Label();
+ this.lblMp3ExtractMagicArea = new System.Windows.Forms.Panel();
+ this.label2 = new System.Windows.Forms.Label();
+ this.lblMagicDragArea.SuspendLayout();
+ this.lblMp3ExtractMagicArea.SuspendLayout();
+ this.SuspendLayout();
+ //
+ // ExitButton
+ //
+ this.ExitButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
+ this.ExitButton.Location = new System.Drawing.Point(281, 316);
+ this.ExitButton.Name = "ExitButton";
+ this.ExitButton.Size = new System.Drawing.Size(75, 23);
+ this.ExitButton.TabIndex = 0;
+ this.ExitButton.Text = "E&xit";
+ this.ExitButton.UseVisualStyleBackColor = true;
+ this.ExitButton.Click += new System.EventHandler(this.ExitButton_Click);
+ //
+ // lblMagicDragArea
+ //
+ this.lblMagicDragArea.AllowDrop = true;
+ this.lblMagicDragArea.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
+ this.lblMagicDragArea.Controls.Add(this.label1);
+ this.lblMagicDragArea.Location = new System.Drawing.Point(84, 12);
+ this.lblMagicDragArea.Name = "lblMagicDragArea";
+ this.lblMagicDragArea.Size = new System.Drawing.Size(200, 100);
+ this.lblMagicDragArea.TabIndex = 1;
+ this.lblMagicDragArea.DragDrop += new System.Windows.Forms.DragEventHandler(this.lblMagicDragArea_DragDrop);
+ this.lblMagicDragArea.DragEnter += new System.Windows.Forms.DragEventHandler(this.lblMagicDragArea_DragEnter);
+ //
+ // label1
+ //
+ this.label1.AutoSize = true;
+ this.label1.Location = new System.Drawing.Point(47, 10);
+ this.label1.Name = "label1";
+ this.label1.Size = new System.Drawing.Size(106, 13);
+ this.label1.TabIndex = 0;
+ this.label1.Text = "Drag here for MAGIC";
+ //
+ // lblMp3ExtractMagicArea
+ //
+ this.lblMp3ExtractMagicArea.AllowDrop = true;
+ this.lblMp3ExtractMagicArea.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
+ this.lblMp3ExtractMagicArea.Controls.Add(this.label2);
+ this.lblMp3ExtractMagicArea.Location = new System.Drawing.Point(84, 167);
+ this.lblMp3ExtractMagicArea.Name = "lblMp3ExtractMagicArea";
+ this.lblMp3ExtractMagicArea.Size = new System.Drawing.Size(200, 100);
+ this.lblMp3ExtractMagicArea.TabIndex = 2;
+ this.lblMp3ExtractMagicArea.DragDrop += new System.Windows.Forms.DragEventHandler(this.lblMp3ExtractMagicArea_DragDrop);
+ this.lblMp3ExtractMagicArea.DragEnter += new System.Windows.Forms.DragEventHandler(this.lblMagicDragArea_DragEnter);
+ //
+ // label2
+ //
+ this.label2.AutoSize = true;
+ this.label2.Location = new System.Drawing.Point(17, 25);
+ this.label2.Name = "label2";
+ this.label2.Size = new System.Drawing.Size(151, 39);
+ this.label2.TabIndex = 0;
+ this.label2.Text = "Drag cue here to extract audio\ntracks to MP3 for listening\npleasure!";
+ //
+ // MainDiscoForm
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(368, 351);
+ this.Controls.Add(this.lblMp3ExtractMagicArea);
+ this.Controls.Add(this.lblMagicDragArea);
+ this.Controls.Add(this.ExitButton);
+ this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
+ this.Name = "MainDiscoForm";
+ this.Text = "DiscoHawk";
+ this.Load += new System.EventHandler(this.MainDiscoForm_Load);
+ this.lblMagicDragArea.ResumeLayout(false);
+ this.lblMagicDragArea.PerformLayout();
+ this.lblMp3ExtractMagicArea.ResumeLayout(false);
+ this.lblMp3ExtractMagicArea.PerformLayout();
+ this.ResumeLayout(false);
}
@@ -89,5 +116,7 @@
private System.Windows.Forms.Button ExitButton;
private System.Windows.Forms.Panel lblMagicDragArea;
private System.Windows.Forms.Label label1;
+ private System.Windows.Forms.Panel lblMp3ExtractMagicArea;
+ private System.Windows.Forms.Label label2;
}
}
\ No newline at end of file
diff --git a/DiscoHawk/MainDiscoForm.cs b/DiscoHawk/MainDiscoForm.cs
index 8512983ef7..084ffd356e 100644
--- a/DiscoHawk/MainDiscoForm.cs
+++ b/DiscoHawk/MainDiscoForm.cs
@@ -124,5 +124,18 @@ namespace BizHawk
}
return ret;
}
+
+ private void lblMp3ExtractMagicArea_DragDrop(object sender, DragEventArgs e)
+ {
+ var files = validateDrop(e.Data);
+ if (files.Count == 0) return;
+ foreach (var file in files)
+ {
+ var disc = Disc.FromCuePath(file);
+ var path = Path.GetDirectoryName(file);
+ var filename = Path.GetFileNameWithoutExtension(file);
+ AudioExtractor.Extract(disc, path, filename);
+ }
+ }
}
}