Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
IRecorder.cs
Go to the documentation of this file.
1 // Copyright (c) 2014 Silicon Studio Corp. (http://siliconstudio.co.jp)
2 // This file is distributed under GPL v3. See LICENSE.md for details.
3 using System;
4 
5 namespace SiliconStudio.Paradox.Audio
6 {
7  /// <summary>
8  /// <para>Interface for an audio input recorder</para>
9  /// <para></para>
10  /// </summary>
11  //TODO improve documentation explaining how the interface works, especially what happens when the buffer is full (ring buffer/stops ??) when it will be implemented
12  internal interface IRecorder
13  {
14  /// <summary>
15  /// Gets or sets audio capture buffer duration.
16  /// </summary>
17  // TODO documentation for Exception thrown when duration is not enough or correct
18  TimeSpan BufferDuration { get; set; }
19 
20  /// <summary>
21  /// Gets or sets audio capture buffer size in bytes.
22  /// </summary>
23  // TODO documentation for Exception thrown when duration is not enough or correct
24  TimeSpan BufferSize { get; set; }
25 
26  /// <summary>
27  /// Returns the sample rate in Hertz (Hz) at which the microphone is capturing audio data.
28  /// </summary>
29  int SampleRate { get; }
30 
31  /// <summary>
32  /// Returns the recording state of the recorder object.
33  /// </summary>
34  RecorderState State { get; }
35 
36  /// <summary>
37  /// Returns the duration of audio playback based on the hypotetical given size of the buffer.
38  /// </summary>
39  /// <param name="sizeInBytes">Size, in bytes, of the audio data of which we want to know the duration.</param>
40  /// <returns><see cref="TimeSpan"/> object that represents the duration of the audio playback.</returns>
41  TimeSpan GetSampleDuration(int sizeInBytes);
42 
43  /// <summary>
44  /// Returns the size of the byte array required to hold the specified duration of audio for this microphone object.
45  /// </summary>
46  /// <param name="duration"><see cref="TimeSpan"/> object that contains the duration of the audio sample of which we want to know the size. </param>
47  /// <returns>Size in bytes, of the audio buffer.</returns>
48  int GetSampleSizeInBytes(TimeSpan duration);
49 
50  /// <summary>
51  /// Starts microphone audio capture.
52  /// </summary>
53  /// <exception cref="NoMicrophoneConnectedException">The microphone has been unplugged since the creation of the recorder instance</exception>
54  void Start();
55 
56  /// <summary>
57  /// Stops microphone audio capture.
58  /// </summary>
59  void Stop();
60 
61  /// <summary>
62  /// Gets the latest recorded data from the microphone based on the audio capture buffer size.
63  /// </summary>
64  /// <param name="buffer">Buffer, in bytes, that will contain the captured audio data. The audio format is PCM wave data.</param>
65  /// <returns>The buffer size, in bytes, of the audio data.</returns>
66  /// <exception cref="ArgumentException">buffer is null, has zero length, or does not satisfy alignment requirements.</exception>
67  int GetData(byte[] buffer);
68 
69  /// <summary>
70  /// Gets the latest captured audio data from the microphone based on the specified offset and byte count.
71  /// </summary>
72  /// <param name="buffer">Buffer, in bytes, that will contain the captured audio data. The audio format is PCM wave data.</param>
73  /// <param name="offset">Offset, in bytes, to the desired starting position of the data.</param>
74  /// <param name="count">Amount, in bytes, of desired audio data.</param>
75  /// <returns>The buffer size, in bytes, of the audio data.</returns>
76  /// <exception cref="ArgumentException">
77  /// The exception thrown when the following arguments are invalid:
78  /// <list type="bullet">
79  /// <item>buffer is null, has zero length, or does not satisfy alignment requirements.</item>
80  /// <item>offset is less than zero, is greater than or equal to the size of the buffer, or does not satisfy alignment requirements. </item>
81  /// <item>The sum of count and offset is greater than the size of the buffer, count is less than or equal to zero, or does not satisfy alignment requirements. </item>
82  /// </list>
83  /// </exception>
84  int GetData(byte[] buffer, int offset, int count);
85 
86  /// <summary>
87  /// Event that occurs when the audio capture buffer is ready to processed.
88  /// </summary>
89  event EventHandler<EventArgs> BufferReady;
90  }
91 }
_In_ size_t count
Definition: DirectXTexP.h:174