Class AbstractUtility
Base abstract class for all audio and spectrogram utilities.
Inherited Members
Namespace: Acoustics.Tools.Audio
Assembly: Acoustics.Tools.dll
Syntax
public abstract class AbstractUtility
Constructors
| Improve this Doc View SourceAbstractUtility()
Initializes a new instance of the AbstractUtility class.
Declaration
protected AbstractUtility()
Fields
| Improve this Doc View SourceLog
Provides logging.
Declaration
protected readonly ILog Log
Field Value
| Type | Description |
|---|---|
| log4net.ILog |
MimeTypeExtensionErrorFormatString
Format string for mime type and extension mis-match. Params: Mimetype, extension.
Declaration
protected readonly string MimeTypeExtensionErrorFormatString
Field Value
| Type | Description |
|---|---|
| String |
Properties
| Improve this Doc View SourceProcessRunnerMaxRetries
Gets or sets ProcessRunnerMaxRetries. The maximum number of times a process will attempt a retry after a failure.
Declaration
public int ProcessRunnerMaxRetries { get; set; }
Property Value
| Type | Description |
|---|---|
| Int32 |
ProcessRunnerTimeout
Gets or sets ProcessRunnerTimeout. That is, how long to wait for a running executable to finish.
Declaration
public TimeSpan ProcessRunnerTimeout { get; set; }
Property Value
| Type | Description |
|---|---|
| TimeSpan |
Methods
| Improve this Doc View SourceBuildFileDebuggingOutput(FileInfo)
The build file debugging output.
Declaration
protected string BuildFileDebuggingOutput(FileInfo file)
Parameters
| Type | Name | Description |
|---|---|---|
| FileInfo | file | The file. |
Returns
| Type | Description |
|---|---|
| String | The System.String. |
CanProcess(FileInfo, IEnumerable<String>, IEnumerable<String>)
Check if a file can be processed.
Declaration
protected void CanProcess(FileInfo file, IEnumerable<string> validMediaTypes, IEnumerable<string> invalidMediaTypes)
Parameters
| Type | Name | Description |
|---|---|---|
| FileInfo | file | The file to check. |
| IEnumerable<String> | validMediaTypes | The valid Mime Types. |
| IEnumerable<String> | invalidMediaTypes | The invalid Mime Types. |
Exceptions
| Type | Condition |
|---|---|
| NotSupportedException |
|
| FileNotFoundException |
|
CheckExe(FileInfo, String)
The check exe.
Declaration
protected void CheckExe(FileInfo file, string expectedFileName)
Parameters
| Type | Name | Description |
|---|---|---|
| FileInfo | file | The file. |
| String | expectedFileName | The expected File Name. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException |
|
| FileNotFoundException | Could not find exe. |
| ArgumentException | file. |
CheckFile(FileInfo)
The check file.
Declaration
protected void CheckFile(FileInfo file)
Parameters
| Type | Name | Description |
|---|---|---|
| FileInfo | file | The file. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | file. |
| ArgumentException | file. |
CheckMimeTypeExtension(FileInfo, String)
Check that mime type and extension match.
Declaration
protected bool CheckMimeTypeExtension(FileInfo file, string mimeType)
Parameters
| Type | Name | Description |
|---|---|---|
| FileInfo | file | The audio file. |
| String | mimeType | The mime Type. |
Returns
| Type | Description |
|---|---|
| Boolean | True if mime type and extension match, otherwise false. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentException |
|
CheckMp3BitRate(Int32)
The check mp 3 bit rate.
Declaration
protected void CheckMp3BitRate(int value)
Parameters
| Type | Name | Description |
|---|---|---|
| Int32 | value | The value. |
CheckMp3SampleRate(Int32)
The check mp 3 sample rate.
Declaration
protected void CheckMp3SampleRate(int value)
Parameters
| Type | Name | Description |
|---|---|---|
| Int32 | value | The value. |
CheckRequestValidForMediaType(FileInfo, String, AudioUtilityRequest)
The check request valid for output.
Declaration
protected void CheckRequestValidForMediaType(FileInfo output, string outputMediaType, AudioUtilityRequest request)
Parameters
| Type | Name | Description |
|---|---|---|
| FileInfo | output | The output. |
| String | outputMediaType | The output media type. |
| AudioUtilityRequest | request | The request. |
GetExtension(FileInfo)
Get file extension in uppercase, without dot.
Declaration
protected string GetExtension(FileInfo file)
Parameters
| Type | Name | Description |
|---|---|---|
| FileInfo | file | The file to get extension from. |
Returns
| Type | Description |
|---|---|
| String | Cleaned extension. |
OutputContains(ProcessRunner, String)
The output contains.
Declaration
protected bool OutputContains(ProcessRunner runner, string compareString)
Parameters
| Type | Name | Description |
|---|---|---|
| ProcessRunner | runner | The runner. |
| String | compareString | The compare string. |
Returns
| Type | Description |
|---|---|
| Boolean | The System.Boolean. |
ParseDoubleStringWithException(String, String, IEnumerable<String>)
Declaration
protected double? ParseDoubleStringWithException(string text, string propertyName, IEnumerable<string> expectedNonNumeric = null)
Parameters
| Type | Name | Description |
|---|---|---|
| String | text | |
| String | propertyName | |
| IEnumerable<String> | expectedNonNumeric |
Returns
| Type | Description |
|---|---|
| Nullable<Double> |
ParseIntStringWithException(String, String, IEnumerable<String>)
Declaration
protected int? ParseIntStringWithException(string text, string propertyName, IEnumerable<string> expectedNonNumeric = null)
Parameters
| Type | Name | Description |
|---|---|---|
| String | text | |
| String | propertyName | |
| IEnumerable<String> | expectedNonNumeric |
Returns
| Type | Description |
|---|---|
| Nullable<Int32> |
ParseLongStringWithException(String, String, IEnumerable<String>)
Declaration
protected long? ParseLongStringWithException(string text, string propertyName, IEnumerable<string> expectedNonNumeric = null)
Parameters
| Type | Name | Description |
|---|---|---|
| String | text | |
| String | propertyName | |
| IEnumerable<String> | expectedNonNumeric |
Returns
| Type | Description |
|---|---|
| Nullable<Int64> |
RunExe(ProcessRunner, String, String)
Run an executable. Will wait for up to ProcessTimeout time,
then kill the process. Will retry up to 3 times if the timeout is reached.
Declaration
protected void RunExe(ProcessRunner processRunner, string arguments, string workingDirectory)
Parameters
| Type | Name | Description |
|---|---|---|
| ProcessRunner | processRunner | The process runner. |
| String | arguments | The arguments. |
| String | workingDirectory | The working Directory. |
ValidateMimeTypeExtension(FileInfo, String)
Validate to ensure that mime type and file extension match.
Declaration
protected void ValidateMimeTypeExtension(FileInfo source, string sourceMimeType)
Parameters
| Type | Name | Description |
|---|---|---|
| FileInfo | source | The source. |
| String | sourceMimeType | The source mime type. |
ValidateMimeTypeExtension(FileInfo, String, FileInfo, String)
Validate to ensure that mime type and file extension match for source and output.
Declaration
protected void ValidateMimeTypeExtension(FileInfo source, string sourceMimeType, FileInfo output, string outputMimeType)
Parameters
| Type | Name | Description |
|---|---|---|
| FileInfo | source | The source audio file. |
| String | sourceMimeType | The source Mime Type. |
| FileInfo | output | The output audio file. |
| String | outputMimeType | The output Mime Type. |