有没有大神帮下,帮我把这个DLL声明一下,一直在vb.net中调用不成功
sing System;
using System.Text;
using System.Runtime.InteropServices;
namespace LCAudioDll
{
#region 文件结构参数定义
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
public unsafe struct _Fileinfo
{
public int Duration; //play Duration
public int SampleRate; //audio samplerate
public int BitRate; //audio bitrate
}
#endregion
#region 音频结构参数定义
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
public unsafe struct _WaveInInfo
{
public int Index; //The first soundcard is index 0,the second soundcard is index 1, and so on.
public int name; //soundcard's name which is selected.
public int Formats; //(unuse)
public int Channels; //(unuse)
}
#endregion
#region 混音器结构参数定义
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
public unsafe struct _MuxInfo
{
public char name; //Mixer Name
}
#endregion
#region 动态库结构参数定义
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
public unsafe struct _PlayParam
{
/// Windows窗口句柄,如果不为NULL,线程将事件消息发送到此窗口
public UInt32 hWnd;
/// 音频流优先级,1优先级最低,255优先级最高,音频终端优先播放优先级高的音频。
public Int32 Priority;
/// 组播组号,表示线程向那个组发送音频数据,当播放方式是单播或广播是,此参数无意义。
public Int32 MultiGroup;
/// 播放方式,单播,组播和广播
public Int32 CastMode;
/// IP地址,当为播放方式单播是指的是目标IP地址,为组播和广播时,表示使用的本地网络接口
public UInt32 IP;
///播放音量
public Int32 Volume;
///播放音调
public Int32 Tone;
/// 高音频率
public Int32 Treble;
/// 低音频率
public Int32 Bass;
/// 高音放大因子
public Int32 Treble_En;
/// 低音放大因子
public Int32 Bass_En;
/// 音频数据源,0表示数据源为文件,1表示数据源为声卡输入(Line in 或 mic输入)
public short SourceType;
/// 声卡采样开关变量
public short OptionByte;
/// 声卡ID号,仅在SourcType = 1时有效,表示采用哪个声卡的输入。
public Int32 DeviceID;
/// 混音器名字,表示混音器的那个输入通道最终被采样。不同的声卡有不同的混音器名字。
public fixed byte MuxName[64];
/// 通道,采样的通道数
public Int32 nChannels;
/// 音源为声卡输入时的采样频率
public Int32 nSamplesPerSec;
/// 音频文件的长度,仅SourcType=0时有效
public Int32 AudioBufferLength;
/// 音频数据存储地址
public IntPtr AudioBuf;
/// 私有数据数组,用户不能修改里面的数据。
public fixed Int32 PrivateData[128];
}
#endregion
#region 动态裤函数导入
public unsafe class LCAudioThrDll
{
private const string LCAudioThrDllName = "LCAudioThrDll.dll";
//(1) Initialize the _PlayParam structure.
[DllImport(LCAudioThrDllName, EntryPoint = "lc_init")]
public extern static int Lc_Init(string filename, _PlayParam* pParam);
//(2) Start playing audio data
[DllImport(LCAudioThrDllName, EntryPoint = "lc_play")]
public static extern int Lc_Play(_PlayParam* pParam);
//(3) Stop playing audio data
[DllImport(LCAudioThrDllName, EntryPoint = "lc_stop")]
public static extern int Lc_Stop(_PlayParam* pParam);
//(4) Pause playback audio data
[DllImport(LCAudioThrDllName, EntryPoint = "lc_pause")]
public static extern int Lc_Pause(_PlayParam* pParam);
//(5) Continue playing audio data
[DllImport(LCAudioThrDllName, EntryPoint = "lc_continue")]
public static extern int Lc_Continue(_PlayParam* pParam);
//(6) Specify play time point
[DllImport(LCAudioThrDllName, EntryPoint = "lc_seek")]
public static extern int Lc_Seek(_PlayParam* pParam, Int32 time);
//(7) Wait for the play to finish
[DllImport(LCAudioThrDllName, EntryPoint = "lc_wait")]
public extern static int Lc_Wait(_PlayParam* pParam);
//(8) Dynamically adjust the volume
[DllImport(LCAudioThrDllName, EntryPoint = "lc_set_volume")]
public static extern int Lc_Set_Volume(_PlayParam* pParam, Int32 Volue);
//(9) Get the played time
[DllImport(LCAudioThrDllName, EntryPoint = "lc_get_playtime")]
public static extern int Lc_Get_PlayTime(_PlayParam* pParam);
//(10) Get play status
[DllImport(LCAudioThrDllName, EntryPoint = "lc_get_playstatus")]
public extern static int Lc_Get_PlayStatus(_PlayParam* pParam);
//(11) Get the total play time of the current file
[DllImport(LCAudioThrDllName, EntryPoint = "lc_get_duration")]
public static extern int Lc_Get_Duration(_PlayParam* pParam);
//(12) Get the information of the specified file
[DllImport(LCAudioThrDllName, EntryPoint = "lc_get_fileinfo")]
unsafe public static extern int Lc_Get_FileInfo(string filename, ref _Fileinfo myfileinfo);
//(13) Get the information of the sound card
[DllImport(LCAudioThrDllName, EntryPoint = "lc_rec_devinfo")]
public extern static int Lc_Rec_DevInfo(_WaveInInfo* Info, ref int Number);
//(14) Get the information of the sound mixer
[DllImport(LCAudioThrDllName, EntryPoint = "lc_rec_muxinfo")]
public extern static int Lc_Rec_MuxInfo(_MuxInfo* Info, ref int Number);
//(15) Get the version information of dynamic library
[DllImport(LCAudioThrDllName, EntryPoint = "lc_get_version")]
public extern static int Lc_Get_Version();
//(16) Get the last error message
[DllImport(LCAudioThrDllName, EntryPoint = "lc_getlasterror")]
public extern static int Lc_GetLastError(_PlayParam* pParam);
//(17) Start to record audio data
[DllImport(LCAudioThrDllName, EntryPoint = "lc_record_start")]
public static extern int Lc_Record_Start(_PlayParam* pParam, string filename);
//(18) Stop to record audio data
[DllImport(LCAudioThrDllName, EntryPoint = "lc_record_stop")]
public static extern int Lc_Record_Stop(_PlayParam* pParam);
//(19) Query recording status
[DllImport(LCAudioThrDllName, EntryPoint = "lc_record_status")]
public static extern int Lc_Record_Status(_PlayParam* pParam);
//(20) Allocate memory
[DllImport(LCAudioThrDllName, EntryPoint = "lc_play_getmem")]
public static extern _PlayParam* Lc_Play_GetMem();
//(21) Free memory
[DllImport(LCAudioThrDllName, EntryPoint = "lc_play_freemem")]
public static extern int Lc_Play_FreeMem(_PlayParam* Plm);
//(22) Add unicast device
[DllImport(LCAudioThrDllName, EntryPoint = "lc_addip")]
public static extern int Lc_AddIP(_PlayParam* pParam, uint ip);
//(23) Delete unicast device
[DllImport(LCAudioThrDllName, EntryPoint = "lc_delip")]
public static extern int Lc_DelIP(_PlayParam* pParam, uint ip);
//(24) Input audio data of WAV to the dynamic library
[DllImport(LCAudioThrDllName, EntryPoint = "lc_inputdata")]
public static extern int Lc_InputData(_PlayParam* pParam, byte[] buf, int datalen);
//(25) Input audio data of MP3 to the dynamic library
[DllImport(LCAudioThrDllName, EntryPoint = "lc_inputdata_mp3")]
public static extern int Lc_InputData_Mp3(_PlayParam* pParam, byte[] buf, int datalen);
}
#endregion
}
上面是C# 例子,如何改为VB。net
我自个改了,好象调用不成功,
Option Explicit On
Imports System
Imports System.Text
Imports System.Runtime.InteropServices
Module Module1
'定义网络通信方式
Public Const cUnicast = 0 '单播
Public Const cMulticast = 1 '组播
Public Const cBroadcast = 2 '广播
Public Const AUDIO_TYPE_UNKNOWN = 0
Public Const AUDIO_TYPE_MP3 = 1
Public Const AUDIO_TYPE_WAV = 2
Public Const AUDIO_TYPE_WMA = 3
Public Const SCR_TYPE_FILE = 0 '数据来源是文件
Public Const SCR_TYPE_AUDIOCARD = 1 '数据来源是声卡
Public Const SCR_TYPE_BUFFER = 2 '数据来源是内存缓存
Public Const SCR_TYPE_STREAM = 3 '数据来源是数据流'V2.0.3.0
'定义函数返回值
Public Const R_OK = 0 '成功
Public Const ERR_PARAM = -1 '参数错误
Public Const ERR_OPT = -2 '函数执行错误
Public Const ERR_SOCKET = -3 'socket操作失败
Public Const ERR_CODEC = -4 '初始化编解码器失败。
'Windows 消息定义
Public Const WM_USER = &H400
'public const WM_MSG_EXCEPTION (WM_USER+100)
Public Const WM_MSG_COMPLETED = (WM_USER + 101)
Public Const WM_MSG_PAUSE = (WM_USER + 102)
Public Const WM_MSG_CONTINUE = (WM_USER + 103)
Public Const WM_MSG_AUDIOPOWER = (WM_USER + 104)
'Public Const WM_MSG_DATA = (WM_USER + 9901)
#Region "文件结构参数定义"
Public Structure FileInfo
Public Duration As Long '播放时长
Public SampleRate As Long '采样率
Public BitRate As Long '比特率
End Structure
#End Region
#Region "音频结构 声卡信息结构"
Public Structure WaveInInfo
Public Index As Long '输入通道的序号
Public name As Long '名字
Public Formats As Long '支持的格式
Public Channels As Long '通道数 2为立体声输入。
End Structure
#End Region
#Region "混音器名称"
Public Structure MuxInfo
<VBFixedArray(63)> Public name() As Byte '名字
End Structure
#End Region
#Region "线程播放结构"
' <StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)>
Public Structure PlayParam
Public hWnd As Long 'Windows窗口句柄,如果不为NULL,线程将事件消息发送到此窗口主窗口的句柄
Public Priority As Long '音频流优先级 1最低 255最高
Public MultiGroup As Long '组播组号,表示线程向那个组发送音频数据,当播放方式是单播或广播是,此参数无意义。
Public CastMode As Long '播放方式,单播,组播和广播
Public IP As Long 'ip,如果是广播和多播,此参数是源网卡的IP,如果此地址为0,则由系统决定使用哪个网卡,如果是单播,这是个目标设备的ip地址。
Public Volume As Long '播放音量取值0~100
Public Tone As Long '音调
Public Treble As Long