using System;
using System.Reflection;

using MathWorks.MATLAB.NET.Arrays;
using MathWorks.MATLAB.NET.Utility;


[assembly: System.Reflection.AssemblyVersion("0.0.*")]
#if SHARED
[assembly: System.Reflection.AssemblyKeyFile(@"")]
#endif

namespace dotnet
{
  /// <summary>
  /// The dotnetclass class provides a CLS compliant interface to the M-functions
  /// contained in the files:
  /// <newpara></newpara>
  /// C:\Users\User\Documents\MATLAB\waveCS\wavread.m
  /// <newpara></newpara>
  /// deployprint.m
  /// <newpara></newpara>
  /// printdlg.m
  /// </summary>
  /// <remarks>
  /// @Version 0.0
  /// </remarks>
  public class dotnetclass : IDisposable
    {
      #region Constructors

      /// <summary internal= "true">
      /// The static constructor instantiates and initializes the MATLAB Component
      /// Runtime instance.
      /// </summary>
      static dotnetclass()
        {
          if (MWArray.MCRAppInitialized)
            {
              Assembly assembly= Assembly.GetExecutingAssembly();

              string ctfFilePath= assembly.Location;

              int lastDelimeter= ctfFilePath.LastIndexOf(@"\");

              ctfFilePath= ctfFilePath.Remove(lastDelimeter, (ctfFilePath.Length - lastDelimeter));

              mcr= new MWMCR(MCRComponentState.MCC_dotnet_name_data,
                             MCRComponentState.MCC_dotnet_root_data,
                             MCRComponentState.MCC_dotnet_public_data,
                             MCRComponentState.MCC_dotnet_session_data,
                             MCRComponentState.MCC_dotnet_matlabpath_data,
                             MCRComponentState.MCC_dotnet_classpath_data,
                             MCRComponentState.MCC_dotnet_libpath_data,
                             MCRComponentState.MCC_dotnet_mcr_application_options,
                             MCRComponentState.MCC_dotnet_mcr_runtime_options,
                             MCRComponentState.MCC_dotnet_mcr_pref_dir,
                             MCRComponentState.MCC_dotnet_set_warning_state,
                             ctfFilePath, true);
            }
          else
            {
              throw new ApplicationException("MWArray assembly could not be initialized");
            }
        }


      /// <summary>
      /// Constructs a new instance of the dotnetclass class.
      /// </summary>
      public dotnetclass()
        {
        }


      #endregion Constructors

      #region Finalize

      /// <summary internal= "true">
      /// Class destructor called by the CLR garbage collector.
      /// </summary>
      ~dotnetclass()
        {
          Dispose(false);
        }


      /// <summary>
      /// Frees the native resources associated with this object
      /// </summary>
      public void Dispose()
        {
          Dispose(true);

          GC.SuppressFinalize(this);
        }


      /// <summary internal= "true">
      /// Internal dispose function
      /// </summary>
      protected virtual void Dispose(bool disposing)
        {
          if (!disposed)
            {
              disposed= true;

              if (disposing)
                {
                  // Free managed resources;
                }

              // Free native resources
            }
        }


      #endregion Finalize

      #region Methods

      /// <summary>
      /// Provides a single output, 0-input interface to the wavread M-function.
      /// </summary>
      /// <remarks>
      /// M-Documentation:
      /// WAVREAD Read Microsoft WAVE (".wav") sound file.
      /// Y=WAVREAD(FILE) reads a WAVE file specified by the string FILE,
      /// returning the sampled data in Y. The ".wav" extension is appended
      /// if no extension is given.
      /// [Y,FS,NBITS]=WAVREAD(FILE) returns the sample rate (FS) in Hertz
      /// and the number of bits per sample (NBITS) used to encode the
      /// data in the file.
      /// [...]=WAVREAD(FILE,N) returns only the first N samples from each
      /// channel in the file.
      /// [...]=WAVREAD(FILE,[N1 N2]) returns only samples N1 through N2 from
      /// each channel in the file.
      /// [Y,...]=WAVREAD(...,FMT) specifies the data type format of Y used
      /// to represent samples read from the file.
      /// If FMT='double', Y contains double-precision normalized samples.
      /// If FMT='native', Y contains samples in the native data type
      /// found in the file.  Interpretation of FMT is case-insensitive,
      /// and partial matching is supported.  If omitted, FMT='double'.
      /// SIZ=WAVREAD(FILE,'size') returns the size of the audio data contained
      /// in the file in place of the actual audio data, returning the
      /// 2-element vector SIZ=[samples channels].
      /// [Y,FS,NBITS,OPTS]=WAVREAD(...) returns a structure OPTS of additional
      /// information contained in the WAV file.  The content of this
      /// structure differs from file to file.  Typical structure fields
      /// include '.fmt' (audio format information) and '.info' (text
      /// which may describe title, author, etc.)
      /// Output Scaling
      /// The range of values in Y depends on the data format FMT specified.
      /// Some examples of output scaling based on typical bit-widths found
      /// in a WAV file are given below for both 'double' and 'native' formats.
      /// FMT='native'
      /// #Bits   MATLAB data type          Data range
      /// -----   ------------------------- -------------------
      /// 8     uint8  (unsigned integer)      0 &lt;= Y &lt;= 255
      /// 16     int16  (signed integer)   -32768 &lt;= Y &lt;= +32767
      /// 24     int32  (signed integer)    -2^23 &lt;= Y &lt;= 2^23-1
      /// 32     single (floating point)     -1.0 &lt;= Y &lt;= +1.0
      /// FMT='double'
      /// #Bits   MATLAB data type          Data range
      /// -----   ------------------------- -------------------
      /// N&lt;32   double                     -1.0 &lt;= Y &lt;  +1.0
      /// N=32   double                     -1.0 &lt;= Y &lt;= +1.0
      /// Note: Values in y might exceed -1.0 or +1.0 for the case of
      /// N=32 bit data samples stored in the WAV file.
      /// Supports multi-channel data, with up to 32 bits per sample.
      /// Supports Microsoft PCM data format only.
      /// See also WAVWRITE, AUREAD, AUWRITE.
      /// </remarks>
      /// <returns>An MWArray containing the first output argument.</returns>
      ///
      public MWArray wavread()
        {
          return mcr.EvaluateFunction("wavread");
        }


      
      public MWArray wavread(params MWArray[] varargin)
        {
          return mcr.EvaluateFunction("wavread", varargin);
        }


      
      public MWArray[] wavread(int numArgsOut)
        {
          return mcr.EvaluateFunction(numArgsOut, "wavread");
        }


      
      public MWArray[] wavread(int numArgsOut, params MWArray[] varargin)
        {
          return mcr.EvaluateFunction(numArgsOut, "wavread", varargin);
        }


      
      public void wavread(int numArgsOut, ref MWArray[] argsOut, MWArray[] argsIn)
        {
          mcr.EvaluateFunction("wavread", numArgsOut, ref argsOut, argsIn);
        }


      /// <summary>
      /// This method will cause a MATLAB figure window to behave as a modal dialog box.
      /// The method will not return until all the figure windows associated with this
      /// component have been closed.
      /// </summary>
      /// <remarks>
      /// An application should only call this method when required to keep the
      /// MATLAB figure window from disappearing.  Other techniques, such as calling
      /// Console.ReadLine() from the application should be considered where
      /// possible.</remarks>
      ///
      public void WaitForFiguresToDie()
        {
          mcr.WaitForFiguresToDie();
        }


      
      #endregion Methods

      #region Class Members

      private static MWMCR mcr= null;

      private bool disposed= false;

      #endregion Class Members
    }
}

This was dotnetclass.cs that I created using a Matlab-.Net builder of Matlab R2007b.
I wish to use a function to read .wav files (Microsoft PCM format) using wavread() function.

For any queries regarding the wavread() function, I have some comments on that in the given code ....

Theses name spaces have to be included in the program :

using System;
using System.Collections.Generic;
using System.Text;

// MathWorks assemblies that ship with Builder for .NET
// and should be registered in Global Assembly Cache
using MathWorks.MATLAB.NET.Utility;
using MathWorks.MATLAB.NET.Arrays;

// Assembly built by Builder for .NET containing 
// wavread.m
using dotnet;

What is the question ? do you want to use wavread in c# form and are failing to use?? if yes then check this link might be helpful

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.