Added dialog for "Seek silence" in waveform (and not only shortcuts) - thx Jaroslav :)

git-svn-id: https://subtitleedit.googlecode.com/svn/trunk@1370 99eadd0c-20b8-1223-b5c4-2a2b2df33de2
This commit is contained in:
niksedk 2012-09-18 14:06:47 +00:00
parent 4096db1671
commit 2492f73f5b
10 changed files with 452 additions and 3 deletions

View File

@ -56,6 +56,7 @@ Subtitle Edit Changelog
* Can now read SCC with ";" in time code - thx Thane
* Crash when splitting an empty line - thx Pimmetje
* Fixed "Timed Text" time codes with comma in seconds - thx Steffan
* Fixed insert line via F9 or waveform in network mode - thx Martin
3.2.8 (3rd June 2012)

View File

@ -394,6 +394,7 @@
this.imageListPlayRate = new System.Windows.Forms.ImageList(this.components);
this.timerTextUndo = new System.Windows.Forms.Timer(this.components);
this.timerAlternateTextUndo = new System.Windows.Forms.Timer(this.components);
this.seekSilenceToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.statusStrip1.SuspendLayout();
this.toolStrip1.SuspendLayout();
this.menuStrip1.SuspendLayout();
@ -3141,9 +3142,10 @@
this.showOnlyWaveformToolStripMenuItem,
this.showOnlySpectrogramToolStripMenuItem,
this.toolStripSeparatorGuessTimeCodes,
this.guessTimeCodesToolStripMenuItem});
this.guessTimeCodesToolStripMenuItem,
this.seekSilenceToolStripMenuItem});
this.contextMenuStripWaveForm.Name = "contextMenuStripWaveForm";
this.contextMenuStripWaveForm.Size = new System.Drawing.Size(275, 264);
this.contextMenuStripWaveForm.Size = new System.Drawing.Size(275, 308);
this.contextMenuStripWaveForm.Opening += new System.ComponentModel.CancelEventHandler(this.ContextMenuStripWaveFormOpening);
//
// addParagraphHereToolStripMenuItem
@ -3888,6 +3890,13 @@
this.timerAlternateTextUndo.Interval = 700;
this.timerAlternateTextUndo.Tick += new System.EventHandler(this.TimerAlternateTextUndoTick);
//
// seekSilenceToolStripMenuItem
//
this.seekSilenceToolStripMenuItem.Name = "seekSilenceToolStripMenuItem";
this.seekSilenceToolStripMenuItem.Size = new System.Drawing.Size(274, 22);
this.seekSilenceToolStripMenuItem.Text = "Seek silence...";
this.seekSilenceToolStripMenuItem.Click += new System.EventHandler(this.seekSilenceToolStripMenuItem_Click);
//
// Main
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@ -4329,6 +4338,7 @@
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemRedo;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemShowOriginalInPreview;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemPlugins;
private System.Windows.Forms.ToolStripMenuItem seekSilenceToolStripMenuItem;
}
}

View File

@ -15199,5 +15199,24 @@ namespace Nikse.SubtitleEdit.Forms
RedoLastAction();
}
private void seekSilenceToolStripMenuItem_Click(object sender, EventArgs e)
{
if (audioVisualizer == null)
return;
var form = new SeekSilence();
if (form.ShowDialog(this) == DialogResult.OK)
{
if (form.SeekForward)
{
audioVisualizer.FindDataBelowThresshold(form.VolumeBelow, form.SecondsDuration);
}
else
{
audioVisualizer.FindDataBelowThressholdBack(form.VolumeBelow, form.SecondsDuration);
}
}
}
}
}

View File

@ -681,7 +681,7 @@
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w
LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAAD2
CAAAAk1TRnQBSQFMAgEBAgEAAYABFwGAARcBEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo
CAAAAk1TRnQBSQFMAgEBAgEAAYgBFwGIARcBEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo
AwABQAMAARADAAEBAQABCAYAAQQYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA
AQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEAA0IBAAM5
AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8BAAHWAucBAAGQAakBrQIAAf8BMwMA

205
src/Forms/SeekSilence.Designer.cs generated Normal file
View File

@ -0,0 +1,205 @@
namespace Nikse.SubtitleEdit.Forms
{
partial class SeekSilence
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.buttonCancel = new System.Windows.Forms.Button();
this.buttonOK = new System.Windows.Forms.Button();
this.groupBoxSearchDirection = new System.Windows.Forms.GroupBox();
this.radioButtonBack = new System.Windows.Forms.RadioButton();
this.radioButtonForward = new System.Windows.Forms.RadioButton();
this.numericUpDownSeconds = new System.Windows.Forms.NumericUpDown();
this.numericUpDownVolume = new System.Windows.Forms.NumericUpDown();
this.labelDuration = new System.Windows.Forms.Label();
this.labelVolumeBelow = new System.Windows.Forms.Label();
this.groupBoxSearchDirection.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownSeconds)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownVolume)).BeginInit();
this.SuspendLayout();
//
// buttonCancel
//
this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl;
this.buttonCancel.Location = new System.Drawing.Point(247, 152);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(75, 21);
this.buttonCancel.TabIndex = 4;
this.buttonCancel.Text = "C&ancel";
this.buttonCancel.UseVisualStyleBackColor = true;
this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
//
// buttonOK
//
this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonOK.ImeMode = System.Windows.Forms.ImeMode.NoControl;
this.buttonOK.Location = new System.Drawing.Point(166, 152);
this.buttonOK.Name = "buttonOK";
this.buttonOK.Size = new System.Drawing.Size(75, 21);
this.buttonOK.TabIndex = 3;
this.buttonOK.Text = "&OK";
this.buttonOK.UseVisualStyleBackColor = true;
this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click);
//
// groupBoxSearchDirection
//
this.groupBoxSearchDirection.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.groupBoxSearchDirection.Controls.Add(this.radioButtonBack);
this.groupBoxSearchDirection.Controls.Add(this.radioButtonForward);
this.groupBoxSearchDirection.Location = new System.Drawing.Point(12, 12);
this.groupBoxSearchDirection.Name = "groupBoxSearchDirection";
this.groupBoxSearchDirection.Size = new System.Drawing.Size(310, 73);
this.groupBoxSearchDirection.TabIndex = 5;
this.groupBoxSearchDirection.TabStop = false;
this.groupBoxSearchDirection.Text = "Search direction";
//
// radioButtonBack
//
this.radioButtonBack.AutoSize = true;
this.radioButtonBack.Location = new System.Drawing.Point(7, 44);
this.radioButtonBack.Name = "radioButtonBack";
this.radioButtonBack.Size = new System.Drawing.Size(50, 17);
this.radioButtonBack.TabIndex = 1;
this.radioButtonBack.Text = "Back";
this.radioButtonBack.UseVisualStyleBackColor = true;
//
// radioButtonForward
//
this.radioButtonForward.AutoSize = true;
this.radioButtonForward.Checked = true;
this.radioButtonForward.Location = new System.Drawing.Point(7, 20);
this.radioButtonForward.Name = "radioButtonForward";
this.radioButtonForward.Size = new System.Drawing.Size(63, 17);
this.radioButtonForward.TabIndex = 0;
this.radioButtonForward.TabStop = true;
this.radioButtonForward.Text = "Forward";
this.radioButtonForward.UseVisualStyleBackColor = true;
//
// numericUpDownSeconds
//
this.numericUpDownSeconds.DecimalPlaces = 1;
this.numericUpDownSeconds.Increment = new decimal(new int[] {
1,
0,
0,
65536});
this.numericUpDownSeconds.Location = new System.Drawing.Point(247, 91);
this.numericUpDownSeconds.Maximum = new decimal(new int[] {
5,
0,
0,
0});
this.numericUpDownSeconds.Minimum = new decimal(new int[] {
1,
0,
0,
65536});
this.numericUpDownSeconds.Name = "numericUpDownSeconds";
this.numericUpDownSeconds.Size = new System.Drawing.Size(75, 20);
this.numericUpDownSeconds.TabIndex = 6;
this.numericUpDownSeconds.Value = new decimal(new int[] {
3,
0,
0,
65536});
//
// numericUpDownVolume
//
this.numericUpDownVolume.Location = new System.Drawing.Point(247, 117);
this.numericUpDownVolume.Name = "numericUpDownVolume";
this.numericUpDownVolume.Size = new System.Drawing.Size(75, 20);
this.numericUpDownVolume.TabIndex = 7;
this.numericUpDownVolume.Value = new decimal(new int[] {
10,
0,
0,
0});
//
// labelDuration
//
this.labelDuration.AutoSize = true;
this.labelDuration.Location = new System.Drawing.Point(12, 93);
this.labelDuration.Name = "labelDuration";
this.labelDuration.Size = new System.Drawing.Size(180, 13);
this.labelDuration.TabIndex = 8;
this.labelDuration.Text = "Silence must be at at least (seconds)";
//
// labelVolumeBelow
//
this.labelVolumeBelow.AutoSize = true;
this.labelVolumeBelow.Location = new System.Drawing.Point(12, 119);
this.labelVolumeBelow.Name = "labelVolumeBelow";
this.labelVolumeBelow.Size = new System.Drawing.Size(113, 13);
this.labelVolumeBelow.TabIndex = 9;
this.labelVolumeBelow.Text = "Volume must be below";
//
// SeekSilence
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(334, 185);
this.Controls.Add(this.labelVolumeBelow);
this.Controls.Add(this.labelDuration);
this.Controls.Add(this.numericUpDownVolume);
this.Controls.Add(this.numericUpDownSeconds);
this.Controls.Add(this.groupBoxSearchDirection);
this.Controls.Add(this.buttonCancel);
this.Controls.Add(this.buttonOK);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.KeyPreview = true;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "SeekSilence";
this.ShowIcon = false;
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Seek silence";
this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.SeekSilence_KeyDown);
this.groupBoxSearchDirection.ResumeLayout(false);
this.groupBoxSearchDirection.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownSeconds)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownVolume)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Button buttonCancel;
private System.Windows.Forms.Button buttonOK;
private System.Windows.Forms.GroupBox groupBoxSearchDirection;
private System.Windows.Forms.RadioButton radioButtonBack;
private System.Windows.Forms.RadioButton radioButtonForward;
private System.Windows.Forms.NumericUpDown numericUpDownSeconds;
private System.Windows.Forms.NumericUpDown numericUpDownVolume;
private System.Windows.Forms.Label labelDuration;
private System.Windows.Forms.Label labelVolumeBelow;
}
}

64
src/Forms/SeekSilence.cs Normal file
View File

@ -0,0 +1,64 @@
using System;
using System.Windows.Forms;
using Nikse.SubtitleEdit.Logic;
using System.Drawing;
namespace Nikse.SubtitleEdit.Forms
{
public partial class SeekSilence : Form
{
public bool SeekForward { get; set; }
public double SecondsDuration { get; set; }
public int VolumeBelow { get; set; }
public SeekSilence()
{
InitializeComponent();
Text = Configuration.Settings.Language.SeekSilence.Title;
groupBoxSearchDirection.Text = Configuration.Settings.Language.SeekSilence.SearchDirection;
radioButtonForward.Text = Configuration.Settings.Language.SeekSilence.Forward;
radioButtonBack.Text = Configuration.Settings.Language.SeekSilence.Back;
labelDuration.Text = Configuration.Settings.Language.SeekSilence.LengthInSeconds;
labelVolumeBelow.Text = Configuration.Settings.Language.SeekSilence.MaxVolume;
numericUpDownSeconds.Value = (decimal)Configuration.Settings.VideoControls.WaveformSeeksSilenceDurationSeconds;
numericUpDownVolume.Value = Configuration.Settings.VideoControls.WaveformSeeksSilenceMaxVolume;
buttonOK.Text = Configuration.Settings.Language.General.OK;
buttonCancel.Text = Configuration.Settings.Language.General.Cancel;
FixLargeFonts();
}
private void FixLargeFonts()
{
Graphics graphics = this.CreateGraphics();
SizeF textSize = graphics.MeasureString(buttonOK.Text, this.Font);
if (textSize.Height > buttonOK.Height - 4)
{
int newButtonHeight = (int)(textSize.Height + 7 + 0.5);
Utilities.SetButtonHeight(this, newButtonHeight, 1);
}
}
private void SeekSilence_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Escape)
DialogResult = DialogResult.Cancel;
}
private void buttonOK_Click(object sender, EventArgs e)
{
SeekForward = radioButtonForward.Checked;
SecondsDuration = (double)numericUpDownSeconds.Value;
VolumeBelow = (int)numericUpDownVolume.Value;
Configuration.Settings.VideoControls.WaveformSeeksSilenceDurationSeconds = SecondsDuration;
numericUpDownVolume.Value = VolumeBelow;
DialogResult = DialogResult.OK;
}
private void buttonCancel_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
}
}
}

120
src/Forms/SeekSilence.resx Normal file
View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -52,6 +52,7 @@ namespace Nikse.SubtitleEdit.Logic
public LanguageStructure.RemoveTextFromHearImpaired RemoveTextFromHearImpaired;
public LanguageStructure.ReplaceDialog ReplaceDialog;
public LanguageStructure.RestoreAutoBackup RestoreAutoBackup;
public LanguageStructure.SeekSilence SeekSilence;
public LanguageStructure.SetMinimumDisplayTimeBetweenParagraphs SetMinimumDisplayTimeBetweenParagraphs;
public LanguageStructure.SetSyncPoint SetSyncPoint;
public LanguageStructure.Settings Settings;
@ -1259,6 +1260,16 @@ can edit in same subtitle file (collaboration)",
NoBackedUpFilesFound = "No backed up files found!",
};
SeekSilence = new LanguageStructure.SeekSilence
{
Title = "Seek silence",
SearchDirection = "Search direction",
Forward = "Forward",
Back = "Back",
LengthInSeconds = "Silence must be at at least (seconds)",
MaxVolume = "Volume must be below",
};
SetMinimumDisplayTimeBetweenParagraphs = new LanguageStructure.SetMinimumDisplayTimeBetweenParagraphs
{
Title = "Set minimum display time between paragraphs",

View File

@ -1179,6 +1179,16 @@
public string NoBackedUpFilesFound { get; set; }
}
public class SeekSilence
{
public string Title { get; set; }
public string SearchDirection { get; set; }
public string Forward { get; set; }
public string Back { get; set; }
public string LengthInSeconds { get; set; }
public string MaxVolume { get; set; }
}
public class SetMinimumDisplayTimeBetweenParagraphs
{
public string Title { get; set; }

View File

@ -344,6 +344,12 @@
<Compile Include="Forms\RestoreAutoBackup.Designer.cs">
<DependentUpon>RestoreAutoBackup.cs</DependentUpon>
</Compile>
<Compile Include="Forms\SeekSilence.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Forms\SeekSilence.Designer.cs">
<DependentUpon>SeekSilence.cs</DependentUpon>
</Compile>
<Compile Include="Forms\SetSyncPoint.cs">
<SubType>Form</SubType>
</Compile>
@ -1005,6 +1011,9 @@
<EmbeddedResource Include="Forms\RestoreAutoBackup.resx">
<DependentUpon>RestoreAutoBackup.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Forms\SeekSilence.resx">
<DependentUpon>SeekSilence.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Forms\SetSyncPoint.resx">
<DependentUpon>SetSyncPoint.cs</DependentUpon>
</EmbeddedResource>