Question

I am trying to call Windows Core Audio from C#. I understand I can use NAudio and NetCoreAudio.

However I wanted to get or generate a type library for the Windows Core Audio libraries AudioSes.dll and MMDeviceApi.dll and import it into my project

I have tried Tlbexp, TlbImp and RegAsm. The dlls do not seem to contain the type information. If it is not in theses dlls where can I find it.

Any ideas?

Any help will be appreciated.

Was it helpful?

Solution

There is no type library to hold information about MMDevice API interfaces. Native code apps use Windows SDK headers which define these interfaces, and C# apps will have to have their own private code definitions, such as those in NAudio source, IAudioClient.cs:

namespace NAudio.CoreAudioApi.Interfaces
{
    /// <summary>
    /// n.b. WORK IN PROGRESS - this code will probably do nothing but crash at the moment
    /// Defined in AudioClient.h
    /// </summary>
    [Guid("1CB9AD4C-DBFA-4c32-B178-C2F568A703B2"), 
        InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
    internal interface IAudioClient
    {
        [PreserveSig]
        int Initialize(AudioClientShareMode shareMode,
            AudioClientStreamFlags StreamFlags,
            long hnsBufferDuration, // REFERENCE_TIME
            long hnsPeriodicity, // REFERENCE_TIME
            [In] WaveFormat pFormat,
            [In] ref Guid AudioSessionGuid);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top