summaryrefslogtreecommitdiffstats
path: root/WhisperNet/API/iAudioBuffer.cs
diff options
context:
space:
mode:
authorKonstantin <const@const.me>2023-01-16 14:52:43 +0100
committerKonstantin <const@const.me>2023-01-16 14:52:43 +0100
commit8c4603c73675958efc960fbd4bb599a2909d106a (patch)
tree714dc6fc9a1672d5fd7f89676b97e10959662abc /WhisperNet/API/iAudioBuffer.cs
parent990a8d0dbaefc996244097397259e92758b15cce (diff)
Source codes
Diffstat (limited to 'WhisperNet/API/iAudioBuffer.cs')
-rw-r--r--WhisperNet/API/iAudioBuffer.cs27
1 files changed, 27 insertions, 0 deletions
diff --git a/WhisperNet/API/iAudioBuffer.cs b/WhisperNet/API/iAudioBuffer.cs
new file mode 100644
index 0000000..1b35621
--- /dev/null
+++ b/WhisperNet/API/iAudioBuffer.cs
@@ -0,0 +1,27 @@
+using ComLight;
+using System.Runtime.InteropServices;
+
+namespace Whisper
+{
+ /// <summary>A buffer with a chunk of audio.</summary>
+ /// <remarks>Note the interface supports both marshaling directions.<br/>
+ /// I have not tested, but you should be able to implement this interface in C#, to supply PCM audio data to the native code</remarks>
+ [ComInterface( "013583aa-c9eb-42bc-83db-633c2c317051", eMarshalDirection.BothWays )]
+ public interface iAudioBuffer: IDisposable
+ {
+ /// <summary>Count of samples in the buffer</summary>
+ int countSamples();
+
+ /// <summary>Unmanaged pointer to the internal buffer containing single-channel FP32 samples.</summary>
+ /// <remarks>If you implementing this interface in C# and your audio data is on the managed heap, use <see cref="GCHandle" /> to make sure it doesn't move.<br/>
+ /// Or better yet, move the data to unmanaged buffer allocated with <see cref="Marshal.AllocHGlobal(int)" /> or <see cref="Marshal.AllocCoTaskMem(int)" /> method.</remarks>
+ IntPtr getPcmMono();
+
+ /// <summary>Unmanaged pointer to the internal buffer containing stereo FP32 samples.</summary>
+ /// <remarks>When the buffer doesn’t have stereo data, the method gonna return <see cref="IntPtr.Zero" />.</remarks>
+ IntPtr getPcmStereo();
+
+ /// <summary>Start time of the buffer, relative to the start of the media</summary>
+ void getTime( out TimeSpan time );
+ }
+} \ No newline at end of file