-
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
abfd411
commit 732f381
Showing
11 changed files
with
197 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using MonoAudio.Formats; | ||
|
||
namespace MonoAudio.IO | ||
{ | ||
/// <summary> | ||
/// Represents an event handler that holds recorded audio data. | ||
/// </summary> | ||
/// <param name="sender">The sender.</param> | ||
/// <param name="e">The <see cref="DataAvailableEventArgs"/> instance containing the event data.</param> | ||
public delegate void DataAvailableEventHandler(object sender, DataAvailableEventArgs e); | ||
|
||
/// <summary> | ||
/// Represents an event arguments that holds recorded audio data.<br/> | ||
/// It is a <c>struct</c> which has <c>ref</c> and <c>readonly</c> modifier because the event occurs frequently and has a <see cref="Span{T}"/> to deliver a raw buffer.<br/> | ||
/// <b>CAUTION! REF STRUCT! IT CANNOT BE STORED ON HEAPS!</b> | ||
/// </summary> | ||
public readonly ref struct DataAvailableEventArgs | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="DataAvailableEventArgs" /> struct. | ||
/// </summary> | ||
/// <param name="data">The data.</param> | ||
/// <param name="format">The format.</param> | ||
public DataAvailableEventArgs(Span<byte> data, WaveFormat format) | ||
{ | ||
Data = data; | ||
Format = format; | ||
} | ||
|
||
/// <summary> | ||
/// Gets the data. | ||
/// </summary> | ||
/// <value> | ||
/// The data. | ||
/// </value> | ||
public Span<byte> Data { get; } | ||
|
||
/// <summary> | ||
/// Gets the format of the available <see cref="Data"/>. | ||
/// </summary> | ||
/// <value> | ||
/// The format. | ||
/// </value> | ||
public WaveFormat Format { 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 |
---|---|---|
@@ -0,0 +1,47 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using MonoAudio.Formats; | ||
|
||
namespace MonoAudio.IO | ||
{ | ||
/// <summary> | ||
/// Defines a base infrastructure of a sound input.<br/> | ||
/// CAUTION! IT HAS SOME EVENT HANDLERS! IMPLEMENTERS MUST NOT FORGET TO RELEASE THEM! | ||
/// </summary> | ||
public interface ISoundIn : IDisposable | ||
{ | ||
/// <summary> | ||
/// Occurs when some data are available. | ||
/// </summary> | ||
event DataAvailableEventHandler DataAvailable; | ||
|
||
/// <summary> | ||
/// Occurs when the recording stopped. | ||
/// </summary> | ||
event EventHandler<RecordingStoppedEventArgs> Stopped; | ||
|
||
/// <summary> | ||
/// Starts recording. | ||
/// </summary> | ||
void Start(); | ||
|
||
/// <summary> | ||
/// Stops recording. | ||
/// </summary> | ||
void Stop(); | ||
|
||
/// <summary> | ||
/// Initializes the recorder. | ||
/// </summary> | ||
void Initialize(); | ||
|
||
/// <summary> | ||
/// Gets the state of the recording. | ||
/// </summary> | ||
/// <value> | ||
/// The state of the recording. | ||
/// </value> | ||
RecordingState RecordingState { 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
2 changes: 1 addition & 1 deletion
2
MonoAudio.Core/IO/SoundOut/PlaybackState.cs → MonoAudio.Core/IO/PlaybackState.cs
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,4 +1,4 @@ | ||
namespace MonoAudio.IO.SoundOut | ||
namespace MonoAudio.IO | ||
{ | ||
/// <summary> | ||
/// Represents a state of playback. | ||
|
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,22 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
|
||
namespace MonoAudio.IO | ||
{ | ||
/// <summary> | ||
/// Represents a state of recording. | ||
/// </summary> | ||
public enum RecordingState | ||
{ | ||
/// <summary> | ||
/// The recording is stopped. | ||
/// </summary> | ||
Stopped, | ||
|
||
/// <summary> | ||
/// The recording is in progress. | ||
/// </summary> | ||
Recording | ||
} | ||
} |
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,28 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
|
||
namespace MonoAudio.IO | ||
{ | ||
/// <summary> | ||
/// Represents an event arguments that tells you that the recording has (been) stopped and holds why.<br/> | ||
/// </summary> | ||
/// <seealso cref="StoppedEventArgs" /> | ||
public class RecordingStoppedEventArgs : StoppedEventArgs | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="RecordingStoppedEventArgs"/> class. | ||
/// </summary> | ||
public RecordingStoppedEventArgs() : this(null) | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="RecordingStoppedEventArgs"/> class. | ||
/// </summary> | ||
/// <param name="exception">The exception.</param> | ||
public RecordingStoppedEventArgs(Exception exception) : base(exception) | ||
{ | ||
} | ||
} | ||
} |
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,45 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
|
||
namespace MonoAudio | ||
{ | ||
/// <summary> | ||
/// Represents an event arguments that tells you that something has (been) stopped and holds why.<br/> | ||
/// </summary> | ||
/// <seealso cref="EventArgs" /> | ||
public class StoppedEventArgs : EventArgs | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="StoppedEventArgs"/> class. | ||
/// </summary> | ||
public StoppedEventArgs() : this(null) | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="StoppedEventArgs"/> class. | ||
/// </summary> | ||
/// <param name="exception">The exception.</param> | ||
public StoppedEventArgs(Exception exception) | ||
{ | ||
Exception = exception; | ||
} | ||
|
||
/// <summary> | ||
/// Gets the exception. | ||
/// </summary> | ||
/// <value> | ||
/// The exception. | ||
/// </value> | ||
public Exception Exception { get; } | ||
|
||
/// <summary> | ||
/// Gets a value indicating whether this instance has error. | ||
/// </summary> | ||
/// <value> | ||
/// <c>true</c> if this instance has error; otherwise, <c>false</c>. | ||
/// </value> | ||
public bool HasError => !(Exception is null); | ||
} | ||
} |
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