我最终只使用了一些功能,但如果有人不想做这项工作,这是我写的:
[DllImportAttribute("libspeexdsp.dll")]
public static extern IntPtr speex_echo_state_init(int frameSize,int filterLength);
[DllImportAttribute("libspeexdsp.dll")]
public static extern void speex_echo_state_destroy(IntPtr st);
[DllImportAttribute("libspeexdsp.dll")]
public static extern void speex_echo_cancellation(IntPtr st, IntPtr recorded, IntPtr played, IntPtr echoRemoved);
[DllImportAttribute("libspeexdsp.dll")]
public static extern void speex_echo_playback(IntPtr st, IntPtr played);
[DllImportAttribute("libspeexdsp.dll")]
public static extern void speex_echo_capture(IntPtr st, IntPtr recorded, IntPtr echoRemoved);
[DllImportAttribute("libspeexdsp.dll")]
public unsafe static extern int speex_echo_ctl(IntPtr st, int id, ref IntPtr val);
[DllImportAttribute("libspeexdsp.dll")]
public static extern IntPtr speex_preprocess_state_init(int frameSize, int sampleRate);
[DllImportAttribute("libspeexdsp.dll")]
public static extern int speex_preprocess_ctl(IntPtr st, int id, IntPtr val);
[DllImportAttribute("libspeexdsp.dll")]
public static extern int speex_preprocess_run(IntPtr st, IntPtr recorded);
[DllImportAttribute("libspeexdsp.dll")]
public static extern void speex_preprocess_state_destroy(IntPtr st);
我想我很幸运,因为没有很多结构需要 delcare,大部分都是 IntPtr 或 int,所以很容易。
至于找到二进制文件,我没有发现它们在任何地方预编译,但源代码确实包含了 VS 解决方案文件,这些文件只经过了一些小改动,所以我想这部分对于任何使用 C# 的人来说都很容易,因为他们'无论如何都会使用VS。出于某种原因,我认为它需要其他一些编译器,比如 GCC,或者大多数开源项目似乎使用的其他编译器(我都不熟悉)。再次,幸运的是,它没有!