New mp3 options and improved encoding performance

This commit is contained in:
Michael Bucari-Tovo 2023-02-24 12:12:41 -07:00
parent 49982043e0
commit 1b0a7f5062
25 changed files with 299 additions and 63 deletions

View file

@ -1,6 +1,7 @@
using System;
using LibationFileManager;
using System.Linq;
using LibationUiBase;
namespace LibationWinForms.Dialogs
{
@ -26,6 +27,25 @@ namespace LibationWinForms.Dialogs
Configuration.ClipBookmarkFormat.Json
});
maxSampleRateCb.Items.AddRange(
new object[]
{
new SampleRateSelection(AAXClean.SampleRate.Hz_44100),
new SampleRateSelection(AAXClean.SampleRate.Hz_32000),
new SampleRateSelection(AAXClean.SampleRate.Hz_24000),
new SampleRateSelection(AAXClean.SampleRate.Hz_22050),
new SampleRateSelection(AAXClean.SampleRate.Hz_16000),
new SampleRateSelection(AAXClean.SampleRate.Hz_12000)
});
encoderQualityCb.Items.AddRange(
new object[]
{
NAudio.Lame.EncoderQuality.High,
NAudio.Lame.EncoderQuality.Standard,
NAudio.Lame.EncoderQuality.Fast,
});
allowLibationFixupCbox.Checked = config.AllowLibationFixup;
createCueSheetCbox.Checked = config.CreateCueSheet;
downloadCoverArtCbox.Checked = config.DownloadCoverArt;
@ -42,6 +62,8 @@ namespace LibationWinForms.Dialogs
lameTargetBitrateRb.Checked = config.LameTargetBitrate;
lameTargetQualityRb.Checked = !config.LameTargetBitrate;
maxSampleRateCb.SelectedItem = maxSampleRateCb.Items.Cast<SampleRateSelection>().Single(s => s.SampleRate == config.MaxSampleRate);
encoderQualityCb.SelectedItem = config.LameEncoderQuality;
lameDownsampleMonoCbox.Checked = config.LameDownsampleMono;
lameBitrateTb.Value = config.LameBitrate;
lameConstantBitrateCbox.Checked = config.LameConstantBitrate;
@ -75,6 +97,9 @@ namespace LibationWinForms.Dialogs
config.MoveMoovToBeginning = moveMoovAtomCbox.Checked;
config.LameTargetBitrate = lameTargetBitrateRb.Checked;
config.MaxSampleRate = ((SampleRateSelection)maxSampleRateCb.SelectedItem).SampleRate;
config.LameEncoderQuality = (NAudio.Lame.EncoderQuality)encoderQualityCb.SelectedItem;
encoderQualityCb.SelectedItem = config.LameEncoderQuality;
config.LameDownsampleMono = lameDownsampleMonoCbox.Checked;
config.LameBitrate = lameBitrateTb.Value;
config.LameConstantBitrate = lameConstantBitrateCbox.Checked;

View file

@ -115,6 +115,10 @@
this.retainAaxFileCbox = new System.Windows.Forms.CheckBox();
this.downloadCoverArtCbox = new System.Windows.Forms.CheckBox();
this.createCueSheetCbox = new System.Windows.Forms.CheckBox();
this.maxSampleRateCb = new System.Windows.Forms.ComboBox();
this.encoderQualityCb = new System.Windows.Forms.ComboBox();
this.label20 = new System.Windows.Forms.Label();
this.label21 = new System.Windows.Forms.Label();
this.badBookGb.SuspendLayout();
this.tabControl.SuspendLayout();
this.tab1ImportantSettings.SuspendLayout();
@ -743,6 +747,10 @@
//
// lameOptionsGb
//
this.lameOptionsGb.Controls.Add(this.label20);
this.lameOptionsGb.Controls.Add(this.label21);
this.lameOptionsGb.Controls.Add(this.encoderQualityCb);
this.lameOptionsGb.Controls.Add(this.maxSampleRateCb);
this.lameOptionsGb.Controls.Add(this.lameDownsampleMonoCbox);
this.lameOptionsGb.Controls.Add(this.lameBitrateGb);
this.lameOptionsGb.Controls.Add(this.label1);
@ -757,8 +765,7 @@
//
// lameDownsampleMonoCbox
//
this.lameDownsampleMonoCbox.AutoSize = true;
this.lameDownsampleMonoCbox.Location = new System.Drawing.Point(234, 35);
this.lameDownsampleMonoCbox.Location = new System.Drawing.Point(237, 30);
this.lameDownsampleMonoCbox.Name = "lameDownsampleMonoCbox";
this.lameDownsampleMonoCbox.Size = new System.Drawing.Size(184, 34);
this.lameDownsampleMonoCbox.TabIndex = 1;
@ -776,9 +783,9 @@
this.lameBitrateGb.Controls.Add(this.label11);
this.lameBitrateGb.Controls.Add(this.label3);
this.lameBitrateGb.Controls.Add(this.lameBitrateTb);
this.lameBitrateGb.Location = new System.Drawing.Point(6, 84);
this.lameBitrateGb.Location = new System.Drawing.Point(6, 104);
this.lameBitrateGb.Name = "lameBitrateGb";
this.lameBitrateGb.Size = new System.Drawing.Size(421, 101);
this.lameBitrateGb.Size = new System.Drawing.Size(421, 102);
this.lameBitrateGb.TabIndex = 0;
this.lameBitrateGb.TabStop = false;
this.lameBitrateGb.Text = "Bitrate";
@ -786,7 +793,7 @@
// LameMatchSourceBRCbox
//
this.LameMatchSourceBRCbox.AutoSize = true;
this.LameMatchSourceBRCbox.Location = new System.Drawing.Point(260, 77);
this.LameMatchSourceBRCbox.Location = new System.Drawing.Point(275, 76);
this.LameMatchSourceBRCbox.Name = "LameMatchSourceBRCbox";
this.LameMatchSourceBRCbox.Size = new System.Drawing.Size(140, 19);
this.LameMatchSourceBRCbox.TabIndex = 3;
@ -883,7 +890,7 @@
this.label1.AutoSize = true;
this.label1.Enabled = false;
this.label1.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Point);
this.label1.Location = new System.Drawing.Point(6, 298);
this.label1.Location = new System.Drawing.Point(6, 325);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(172, 15);
this.label1.TabIndex = 1;
@ -904,9 +911,9 @@
this.lameQualityGb.Controls.Add(this.label14);
this.lameQualityGb.Controls.Add(this.label2);
this.lameQualityGb.Controls.Add(this.lameVBRQualityTb);
this.lameQualityGb.Location = new System.Drawing.Point(6, 186);
this.lameQualityGb.Location = new System.Drawing.Point(6, 212);
this.lameQualityGb.Name = "lameQualityGb";
this.lameQualityGb.Size = new System.Drawing.Size(421, 109);
this.lameQualityGb.Size = new System.Drawing.Size(421, 103);
this.lameQualityGb.TabIndex = 0;
this.lameQualityGb.TabStop = false;
this.lameQualityGb.Text = "Quality";
@ -986,7 +993,7 @@
// label13
//
this.label13.AutoSize = true;
this.label13.Location = new System.Drawing.Point(376, 81);
this.label13.Location = new System.Drawing.Point(376, 80);
this.label13.Name = "label13";
this.label13.Size = new System.Drawing.Size(39, 15);
this.label13.TabIndex = 1;
@ -995,7 +1002,7 @@
// label10
//
this.label10.AutoSize = true;
this.label10.Location = new System.Drawing.Point(6, 81);
this.label10.Location = new System.Drawing.Point(6, 80);
this.label10.Name = "label10";
this.label10.Size = new System.Drawing.Size(43, 15);
this.label10.TabIndex = 1;
@ -1036,7 +1043,7 @@
this.groupBox2.Controls.Add(this.lameTargetBitrateRb);
this.groupBox2.Location = new System.Drawing.Point(6, 22);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(222, 56);
this.groupBox2.Size = new System.Drawing.Size(214, 47);
this.groupBox2.TabIndex = 0;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "Target";
@ -1044,7 +1051,7 @@
// lameTargetQualityRb
//
this.lameTargetQualityRb.AutoSize = true;
this.lameTargetQualityRb.Location = new System.Drawing.Point(138, 23);
this.lameTargetQualityRb.Location = new System.Drawing.Point(139, 22);
this.lameTargetQualityRb.Name = "lameTargetQualityRb";
this.lameTargetQualityRb.Size = new System.Drawing.Size(63, 19);
this.lameTargetQualityRb.TabIndex = 0;
@ -1056,7 +1063,7 @@
// lameTargetBitrateRb
//
this.lameTargetBitrateRb.AutoSize = true;
this.lameTargetBitrateRb.Location = new System.Drawing.Point(6, 23);
this.lameTargetBitrateRb.Location = new System.Drawing.Point(6, 22);
this.lameTargetBitrateRb.Name = "lameTargetBitrateRb";
this.lameTargetBitrateRb.Size = new System.Drawing.Size(59, 19);
this.lameTargetBitrateRb.TabIndex = 0;
@ -1112,6 +1119,42 @@
this.createCueSheetCbox.UseVisualStyleBackColor = true;
this.createCueSheetCbox.CheckedChanged += new System.EventHandler(this.allowLibationFixupCbox_CheckedChanged);
//
// maxSampleRateCb
//
this.maxSampleRateCb.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.maxSampleRateCb.FormattingEnabled = true;
this.maxSampleRateCb.Location = new System.Drawing.Point(119, 75);
this.maxSampleRateCb.Name = "maxSampleRateCb";
this.maxSampleRateCb.Size = new System.Drawing.Size(101, 23);
this.maxSampleRateCb.TabIndex = 2;
//
// encoderQualityCb
//
this.encoderQualityCb.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.encoderQualityCb.FormattingEnabled = true;
this.encoderQualityCb.Location = new System.Drawing.Point(337, 75);
this.encoderQualityCb.Name = "encoderQualityCb";
this.encoderQualityCb.Size = new System.Drawing.Size(90, 23);
this.encoderQualityCb.TabIndex = 2;
//
// label20
//
this.label20.AutoSize = true;
this.label20.Location = new System.Drawing.Point(12, 78);
this.label20.Name = "label20";
this.label20.Size = new System.Drawing.Size(101, 15);
this.label20.TabIndex = 3;
this.label20.Text = "Max Sample Rate:";
//
// label21
//
this.label21.AutoSize = true;
this.label21.Location = new System.Drawing.Point(239, 78);
this.label21.Name = "label21";
this.label21.Size = new System.Drawing.Size(94, 15);
this.label21.TabIndex = 3;
this.label21.Text = "Encoder Quality:";
//
// SettingsDialog
//
this.AcceptButton = this.saveBtn;
@ -1253,5 +1296,9 @@
private System.Windows.Forms.ComboBox clipsBookmarksFormatCb;
private System.Windows.Forms.CheckBox downloadClipsBookmarksCbox;
private System.Windows.Forms.CheckBox moveMoovAtomCbox;
private System.Windows.Forms.ComboBox encoderQualityCb;
private System.Windows.Forms.ComboBox maxSampleRateCb;
private System.Windows.Forms.Label label21;
private System.Windows.Forms.Label label20;
}
}

View file

@ -520,6 +520,7 @@
this.productsDisplay.VisibleCountChanged += new System.EventHandler<int>(this.productsDisplay_VisibleCountChanged);
this.productsDisplay.RemovableCountChanged += new System.EventHandler<int>(this.productsDisplay_RemovableCountChanged);
this.productsDisplay.LiberateClicked += new System.EventHandler<DataLayer.LibraryBook>(this.ProductsDisplay_LiberateClicked);
this.productsDisplay.ConvertToMp3Clicked += new System.EventHandler<DataLayer.LibraryBook>(this.ProductsDisplay_ConvertToMp3Clicked);
this.productsDisplay.InitialLoaded += new System.EventHandler(this.productsDisplay_InitialLoaded);
//
// toggleQueueHideBtn

View file

@ -56,6 +56,23 @@ namespace LibationWinForms
}
}
private void ProductsDisplay_ConvertToMp3Clicked(object sender, LibraryBook libraryBook)
{
try
{
if (libraryBook.Book.UserDefinedItem.BookStatus is LiberatedStatus.Liberated)
{
Serilog.Log.Logger.Information("Begin single pdf backup of {libraryBook}", libraryBook);
SetQueueCollapseState(false);
processBookQueue1.AddConvertMp3(libraryBook);
}
}
catch (Exception ex)
{
Serilog.Log.Logger.Error(ex, "An error occurred while handling the stop light button click for {libraryBook}", libraryBook);
}
}
private void SetQueueCollapseState(bool collapsed)
{
if (collapsed && !splitContainer1.Panel2Collapsed)

View file

@ -41,6 +41,7 @@
this.productsGrid.TabIndex = 0;
this.productsGrid.VisibleCountChanged += new System.EventHandler<int>(this.productsGrid_VisibleCountChanged);
this.productsGrid.LiberateClicked += new LibationWinForms.GridView.LibraryBookEntryClickedEventHandler(this.productsGrid_LiberateClicked);
this.productsGrid.ConvertToMp3Clicked += new LibationWinForms.GridView.LibraryBookEntryClickedEventHandler(this.productsGrid_ConvertToMp3Clicked);
this.productsGrid.CoverClicked += new LibationWinForms.GridView.GridEntryClickedEventHandler(this.productsGrid_CoverClicked);
this.productsGrid.DetailsClicked += new LibationWinForms.GridView.LibraryBookEntryClickedEventHandler(this.productsGrid_DetailsClicked);
this.productsGrid.DescriptionClicked += new LibationWinForms.GridView.GridEntryRectangleClickedEventHandler(this.productsGrid_DescriptionClicked);

View file

@ -19,6 +19,7 @@ namespace LibationWinForms.GridView
public event EventHandler<int> VisibleCountChanged;
public event EventHandler<int> RemovableCountChanged;
public event EventHandler<LibraryBook> LiberateClicked;
public event EventHandler<LibraryBook> ConvertToMp3Clicked;
public event EventHandler InitialLoaded;
private bool hasBeenDisplayed;
@ -204,6 +205,12 @@ namespace LibationWinForms.GridView
LiberateClicked?.Invoke(this, liveGridEntry.LibraryBook);
}
private void productsGrid_ConvertToMp3Clicked(LibraryBookEntry liveGridEntry)
{
if (liveGridEntry.LibraryBook.Book.UserDefinedItem.BookStatus is not LiberatedStatus.Error)
ConvertToMp3Clicked?.Invoke(this, liveGridEntry.LibraryBook);
}
private void productsGrid_RemovableCountChanged(object sender, EventArgs e)
{
RemovableCountChanged?.Invoke(sender, productsGrid.GetAllBookEntries().Count(lbe => lbe.Remove is RemoveStatus.Removed));

View file

@ -22,6 +22,7 @@ namespace LibationWinForms.GridView
/// <summary>Number of visible rows has changed</summary>
public event EventHandler<int> VisibleCountChanged;
public event LibraryBookEntryClickedEventHandler LiberateClicked;
public event LibraryBookEntryClickedEventHandler ConvertToMp3Clicked;
public event GridEntryClickedEventHandler CoverClicked;
public event LibraryBookEntryClickedEventHandler DetailsClicked;
public event GridEntryRectangleClickedEventHandler DescriptionClicked;
@ -176,6 +177,13 @@ namespace LibationWinForms.GridView
}
};
var convertToMp3MenuItem = new ToolStripMenuItem
{
Text = "&Convert to Mp3",
Enabled = entry.Book.UserDefinedItem.BookStatus != LiberatedStatus.NotLiberated
};
convertToMp3MenuItem.Click += (_, e) => ConvertToMp3Clicked?.Invoke(entry as LibraryBookEntry);
var bookRecordMenuItem = new ToolStripMenuItem { Text = "View &Bookmarks/Clips" };
bookRecordMenuItem.Click += (_, _) => new BookRecordsDialog(entry.LibraryBook).ShowDialog(this);
@ -184,6 +192,7 @@ namespace LibationWinForms.GridView
stopLightContextMenu.Items.Add(setNotDownloadMenuItem);
stopLightContextMenu.Items.Add(removeMenuItem);
stopLightContextMenu.Items.Add(locateFileMenuItem);
stopLightContextMenu.Items.Add(convertToMp3MenuItem);
stopLightContextMenu.Items.Add(new ToolStripSeparator());
stopLightContextMenu.Items.Add(bookRecordMenuItem);