-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
39cf50d
commit fc16613
Showing
56 changed files
with
4,905 additions
and
340 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Shamisen.Codecs.Composing | ||
{ | ||
/// <summary> | ||
/// Defines a base infrastructure of a composable object. | ||
/// </summary> | ||
public interface IComposable | ||
{ | ||
/// <summary> | ||
/// Writes this <see cref="IComposable"/> instance to <see cref="IDataSink{TSample}"/>. | ||
/// </summary> | ||
/// <param name="sink">The sink.</param> | ||
void WriteTo(IDataSink<byte> sink); | ||
} | ||
|
||
/// <summary> | ||
/// Defines a base infrastructure of an asynchronously composable object. | ||
/// </summary> | ||
public interface IAsyncComposable | ||
{ | ||
/// <summary> | ||
/// Writes this <see cref="IComparable"/> instance to <see cref="IDataSink{TSample}"/>. | ||
/// </summary> | ||
/// <param name="sink">The sink.</param> | ||
ValueTask WriteTo(IDataSink<byte> sink); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Numerics; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Shamisen.Codecs | ||
{ | ||
/// <summary> | ||
/// Defines a base infrastructure of an instance of encoder. | ||
/// </summary> | ||
public interface IComposer<TSample, TFormat> : IDisposable | ||
where TSample : unmanaged | ||
where TFormat : IAudioFormat<TSample> | ||
{ | ||
/// <summary> | ||
/// Gets the frames written to the <see cref="IDataSink{TSample}"/>. | ||
/// </summary> | ||
/// <value> | ||
/// The frames written. | ||
/// </value> | ||
ulong FramesWritten { get; } | ||
|
||
/// <summary> | ||
/// Gets the theoretical maximum capacity of the codec.<br/> | ||
/// The <see langword="null"/> means the codec doesn't have any limitation of size. | ||
/// </summary> | ||
/// <value> | ||
/// The theoretical maximum capacity of the file format. | ||
/// </value> | ||
BigInteger? TheoreticalMaxCapacity { get; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,52 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Shamisen.Codecs | ||
{ | ||
/// <summary> | ||
/// Defines a base infrastructure of an audio encoder. | ||
/// Defines a base infrastructure of an audio encoder that handles <see cref="IReadableAudioSource{TSample, TFormat}"/> and <see cref="ISampleSource"/>. | ||
/// </summary> | ||
public interface IEncoder | ||
public interface IEncoder<TSample, TFormat, TEncodingOptions> : ISampleEncoder<TEncodingOptions> | ||
where TEncodingOptions : struct | ||
where TSample : unmanaged | ||
where TFormat : IAudioFormat<TSample> | ||
{ | ||
/// <summary> | ||
/// Determines whether the <paramref name="format"/> can be encoded by this codec. | ||
/// Determines whether the <paramref name="source"/> can be encoded to <paramref name="sink"/> by this codec. | ||
/// </summary> | ||
/// <param name="format">The input data's format.</param> | ||
/// <returns><c>true</c> if the <paramref name="format"/> can be supported by this encoder, otherwise, <c>false</c>.</returns> | ||
bool IsEncodable(WaveFormat format); | ||
/// <param name="source">The <see cref="IReadableAudioSource{TSample, TFormat}"/> to read the data to encode from.</param> | ||
/// <param name="sink">The destination.</param> | ||
/// <param name="options">The encoding options.</param> | ||
/// <returns><c>true</c> if the <paramref name="source"/> is supported by this encoder and <paramref name="sink"/> meets the requirement of encoding, otherwise, <c>false</c>.</returns> | ||
bool IsEncodable(IReadableAudioSource<TSample, TFormat> source, IDataSink<byte> sink, TEncodingOptions options = default); | ||
|
||
/// <summary> | ||
/// Encodes <paramref name="source"/> with the given <paramref name="writeAction"/>. | ||
/// Determines whether the <paramref name="source"/> can be encoded to <paramref name="sink"/> by this codec. | ||
/// </summary> | ||
/// <param name="source">The <see cref="IWaveSource"/> to read the data to encode from.</param> | ||
/// <param name="writeAction">The destination.</param> | ||
void Encode(IWaveSource source, WriteAction<byte> writeAction); | ||
/// <param name="source">The <see cref="IAsyncReadableAudioSource{TSample, TFormat}"/> to read the data to encode from.</param> | ||
/// <param name="sink">The destination.</param> | ||
/// <param name="options">The encoding options.</param> | ||
/// <returns><c>true</c> if the <paramref name="source"/> is supported by this encoder and <paramref name="sink"/> meets the requirement of encoding, otherwise, <c>false</c>.</returns> | ||
ValueTask<bool> IsEncodableAsync(IAsyncReadableAudioSource<TSample, TFormat> source, IDataSink<byte> sink, TEncodingOptions options = default); | ||
|
||
/// <summary> | ||
/// Encodes <paramref name="source"/> with the given <paramref name="writeAction"/>. | ||
/// Encodes <paramref name="source"/> to the specified <paramref name="sink"/>. | ||
/// </summary> | ||
/// <param name="source">The <see cref="IWaveSource"/> to read the data to encode from.</param> | ||
/// <param name="parameter">The <typeparamref name="TParam"/> value to call the <paramref name="writeAction"/> with.</param> | ||
/// <param name="writeAction">The destination.</param> | ||
void Encode<TParam>(IWaveSource source, TParam parameter, WriteWithParameterAction<byte, TParam> writeAction); | ||
/// <param name="source">The <see cref="IReadableAudioSource{TSample, TFormat}"/> to read the data to encode from.</param> | ||
/// <param name="sink">The destination.</param> | ||
/// <param name="options">The encoding options.</param> | ||
void Encode(IReadableAudioSource<TSample, TFormat> source, IDataSink<byte> sink, TEncodingOptions options = default); | ||
|
||
/// <summary> | ||
/// Encodes <paramref name="source"/> with the given <paramref name="writeAsyncFunc"/> asynchronously. | ||
/// Encodes <paramref name="source"/> to the specified <paramref name="sink"/> asynchronously. | ||
/// </summary> | ||
/// <param name="source">The <see cref="IAsyncWaveSource"/> to read the data to encode from.</param> | ||
/// <param name="writeAsyncFunc">The destination.</param> | ||
/// <param name="source">The <see cref="IAsyncReadableAudioSource{TSample, TFormat}"/> to read the data to encode from.</param> | ||
/// <param name="sink">The destination.</param> | ||
/// <param name="options">The encoding options.</param> | ||
/// <returns>The whole encoding task.</returns> | ||
Task EncodeAsync(IAsyncWaveSource source, WriteAsyncFunc<byte> writeAsyncFunc); | ||
|
||
/// <summary> | ||
/// Encodes <paramref name="source"/> with the given <paramref name="writeAsyncFunc"/> asynchronously. | ||
/// </summary> | ||
/// <param name="source">The <see cref="IAsyncWaveSource"/> to read the data to encode from.</param> | ||
/// <param name="parameter">The <typeparamref name="TParam"/> value to call the <paramref name="writeAsyncFunc"/> with.</param> | ||
/// <param name="writeAsyncFunc">The destination.</param> | ||
/// <returns>The whole encoding task.</returns> | ||
Task EncodeAsync<TParam>(IAsyncWaveSource source, TParam parameter, WriteAsyncFunc<byte> writeAsyncFunc); | ||
ValueTask EncodeAsync(IAsyncReadableAudioSource<TSample, TFormat> source, IDataSink<byte> sink, TEncodingOptions options = default); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Shamisen.Codecs | ||
{ | ||
/// <summary> | ||
/// Defines a base infrastructure of an audio encoder that handles <see cref="ISampleSource"/>. | ||
/// </summary> | ||
public interface ISampleEncoder<TEncodingOptions> where TEncodingOptions : struct | ||
{ | ||
/// <summary> | ||
/// Determines whether the <paramref name="source"/> can be encoded to <paramref name="sink"/> by this codec. | ||
/// </summary> | ||
/// <param name="source">The <see cref="ISampleSource"/> to read the data to encode from.</param> | ||
/// <param name="sink">The destination.</param> | ||
/// <param name="options">The encoding options.</param> | ||
/// <returns><c>true</c> if the <paramref name="source"/> is supported by this encoder and <paramref name="sink"/> meets the requirement of encoding, otherwise, <c>false</c>.</returns> | ||
bool IsEncodable(ISampleSource source, IDataSink<byte> sink, TEncodingOptions options = default); | ||
|
||
/// <summary> | ||
/// Determines whether the <paramref name="source"/> can be encoded to <paramref name="sink"/> by this codec. | ||
/// </summary> | ||
/// <param name="source">The <see cref="IAsyncSampleSource"/> to read the data to encode from.</param> | ||
/// <param name="sink">The destination.</param> | ||
/// <param name="options">The encoding options.</param> | ||
/// <returns><c>true</c> if the <paramref name="source"/> is supported by this encoder and <paramref name="sink"/> meets the requirement of encoding, otherwise, <c>false</c>.</returns> | ||
ValueTask<bool> IsEncodableAsync(IAsyncSampleSource source, IDataSink<byte> sink, TEncodingOptions options = default); | ||
|
||
/// <summary> | ||
/// Encodes <paramref name="source"/> to the specified <paramref name="sink"/>. | ||
/// </summary> | ||
/// <param name="source">The <see cref="ISampleSource"/> to read the data to encode from.</param> | ||
/// <param name="sink">The destination.</param> | ||
/// <param name="options">The encoding options.</param> | ||
void Encode(ISampleSource source, IDataSink<byte> sink, TEncodingOptions options = default); | ||
|
||
/// <summary> | ||
/// Encodes <paramref name="source"/> to the specified <paramref name="sink"/> asynchronously. | ||
/// </summary> | ||
/// <param name="source">The <see cref="IAsyncSampleSource"/> to read the data to encode from.</param> | ||
/// <param name="sink">The destination.</param> | ||
/// <param name="options">The encoding options.</param> | ||
/// <returns>The whole encoding task.</returns> | ||
ValueTask EncodeAsync(IAsyncSampleSource source, IDataSink<byte> sink, TEncodingOptions options = default); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Shamisen.Codecs | ||
{ | ||
/// <summary> | ||
/// Defines a base infrastructure of an <see cref="IWaveSource"/> encoder. | ||
/// </summary> | ||
public interface IWaveEncoder<TEncodingOptions> : IEncoder<byte, IWaveFormat, TEncodingOptions> | ||
where TEncodingOptions : struct | ||
{ | ||
/// <summary> | ||
/// Determines whether the <paramref name="source"/> can be encoded to <paramref name="sink"/> by this codec. | ||
/// </summary> | ||
/// <param name="source">The <see cref="IWaveSource"/> to read the data to encode from.</param> | ||
/// <param name="sink">The destination.</param> | ||
/// <param name="options">The encoding options.</param> | ||
/// <returns><c>true</c> if the <paramref name="source"/> is supported by this encoder and <paramref name="sink"/> meets the requirement of encoding, otherwise, <c>false</c>.</returns> | ||
bool IsEncodable(IWaveSource source, IDataSink<byte> sink, TEncodingOptions options = default); | ||
|
||
/// <summary> | ||
/// Determines whether the <paramref name="source"/> can be encoded to <paramref name="sink"/> by this codec. | ||
/// </summary> | ||
/// <param name="source">The <see cref="IAsyncWaveSource"/> to read the data to encode from.</param> | ||
/// <param name="sink">The destination.</param> | ||
/// <param name="options">The encoding options.</param> | ||
/// <returns><c>true</c> if the <paramref name="source"/> is supported by this encoder and <paramref name="sink"/> meets the requirement of encoding, otherwise, <c>false</c>.</returns> | ||
ValueTask<bool> IsEncodableAsync(IAsyncWaveSource source, IDataSink<byte> sink, TEncodingOptions options = default); | ||
|
||
/// <summary> | ||
/// Encodes <paramref name="source"/> to the specified <paramref name="sink"/>. | ||
/// </summary> | ||
/// <param name="source">The <see cref="IWaveSource"/> to read the data to encode from.</param> | ||
/// <param name="sink">The destination.</param> | ||
/// <param name="options">The encoding options.</param> | ||
void Encode(IWaveSource source, IDataSink<byte> sink, TEncodingOptions options = default); | ||
|
||
/// <summary> | ||
/// Encodes <paramref name="source"/> to the specified <paramref name="sink"/> asynchronously. | ||
/// </summary> | ||
/// <param name="source">The <see cref="IAsyncWaveSource"/> to read the data to encode from.</param> | ||
/// <param name="sink">The destination.</param> | ||
/// <param name="options">The encoding options.</param> | ||
/// <returns>The whole encoding task.</returns> | ||
ValueTask EncodeAsync(IAsyncWaveSource source, IDataSink<byte> sink, TEncodingOptions options = default); | ||
} | ||
} |
Oops, something went wrong.