The Xaudio's SDK package was studied, found that VB6 can call it, so write this routine, only part of XAudio.dll, can be used in the same way. Call the DSOUND control voices.
The following code, the original C code section retains to control.
BTW, this thing should be written in 2003, so it is almost almost forgotten, and friends who want to study can go to Xaudio's primary station to download Xaudio C's development package.
frmmain.frm
VERSION 5.00Begin VB.Form frmMain Caption = "Form1" ClientHeight = 3675 ClientLeft = 60 ClientTop = 345 ClientWidth = 4680 LinkTopic = "Form1" ScaleHeight = 3675 ScaleWidth = 4680 StartUpPosition = 2 'CenterScreen Begin VB.CommandButton cmdGetInfo Caption = "GetInfo" Height = 495 Left = 360 TabIndex = 5 Top = 3060 Width = 1215 End Begin VB.CommandButton cmdGetTag Caption = "GetTag" Height = 495 Left = 1740 TabIndex = 4 Top = 3060 Width = 1215 End Begin VB.CommandButton cmdEnum Caption = " ENUM "Height = 495 left = 3120 TabINDEX = 3 TOP = 2400 width = 1215 end begin vb.commandbutton cmdplay CAPTI on = "Play" Height = 495 Left = 1740 TabIndex = 2 Top = 2400 Width = 1215 End Begin VB.TextBox txtLog Height = 1995 Left = 240 MultiLine = -1 'True ScrollBars = 2' Vertical TabIndex = 1 Top = 180 Width = 4215 End begin vb.commandbutton cmdok caption = "ok" height =
495 Left = 360 TabIndex = 0 Top = 2400 Width = 1215 EndEndAttribute VB_Name = "frmMain" Attribute VB_GlobalNameSpace = FalseAttribute VB_Creatable = FalseAttribute VB_PredeclaredId = TrueAttribute VB_Exposed = FalseOption ExplicitDim dx As New DirectX7Dim ds As DirectSoundDim dsb As DirectSoundBufferDim dsbd As DSBUFFERDESCDim wf As WAVEFORMATEX
Dim bplaying as booleandim bcontinue as boolean
DIM EndEvent As LongImplements DirectXevent
'Enum System All Sound Card Private Sub Cmdenum_Click () DIM DE AS DIRECTSOUNDENUM DIM I AS INTEGER
Set de = dx.getdsenum for i = 1 to de.getcount txtlog.text = txtLog.text & de.getGuid (i) & "& de.getname (i) &" & de.getdescription (i) & vbcrlf Next set de = nothingend sub
Private Sub CMDGETINFO_CLICK () DIM S AS STRING DIM L AS XA_INPUTMODULE DIM D AS XA_DECODERINFO DIM DP AS Long Dim OPBI AS XA_OUTPUTBUFFERINFO DIM I as Long
'Note the pointer DP = varptr (d)' decoder_new function request to pass the pointer of the above pointer, which transmits Xa_Decoderinfo back to DP refers to Status = decoder_new (Varptr (DP)) if status <> xa_success kilbox " can not create decoder! "Exit Sub End If'copy to d CopyMemory VarPtr (d), dp, 60 status = file_input_module_register (t) status = decoder_input_module_register (d, t) If status <> XA_SUCCESS Then MsgBox xaudio_error_string (status) status = decoder_input_new (d, App.Path & "/3.mp3", XA_DECODER_INPUT_AUTOSELECT) If status <> XA_SUCCESS Then MsgBox "can not create input!" & status & vbCrLf & xaudio_error_string (status) Exit Sub End If status = decoder_input_open (d) If status <> XA_SUCCESS Then MsgBox "can not open input!" & vbCrLf & xaudio_error_string (status) Exit Sub End If Dim mp3info As MP3InfoType Dim l1 As Long, l2 As Long Dim l3 As Single Do DoEvents status = decoder_decode (d, 0 ) 'Need to point the OPBI's pointer to the addr06 of the D structure CopyMemory VarPtr (opbi), d.Addr06, Len (opbi) With mp3info.WaveFormat .BitsPerSample = opbi.bytes_per_sample * 8 .Channels = 2 ^ opbi.stereo .SamplesPerSec = opbi.sample_rate End With l1 = l1 1 l2 = l2 opbi.size l3 = l3 opbi.size / (opbi.sample_rate * ((2 ^ opbi.stereo) * opbi.bytes_per_sample)) Loop While status = XA_SUCCESS Or status = XA_ERROR_TIMEOUT Or status = XA_ERROR_INVALID_FRAME With mp3info .Frames = l1 .Betelength =
l2 .SecondLength = l3 End With MsgBox "Frames:" & mp3info.Frames & vbCrLf & "Bytes:" & mp3info.ByteLength & vbCrLf & "Seconds:" & mp3info.SecondLength l = xaudio_get_api_version (XA_API_ID_SYNC) MsgBox "XAudio DLL Version: & "l / (2 ^ 16)) and &". "& ((l / (2 ^ 8)) and & h255) &". "& (l and & h255) End subprivate subductag_click () DIM FP AS INTEGER DIM MP3TYPE () AS STRING SONGTYPE = SPLIT (LoadRESSTRING (1001), ";") fp = freefile open app.path & "/4.mp3" for binary as #fp seek # fp, filelen (App.path & "/4.mp3") - 127 Get #fp, MP3TAG Close #fp msgbox RTRIM (MP3TAG.TITLE) & VBCRLF & RTRIM (MP3TAG.Artist) & Vbcrlf & RTRIM (MP3TAG.ALBUM) & _ VBCRLF & RTRIM (MP3TAG.YEAR) & VBCRLF & RTRIM (MP3TAG.COMMENT) End Sub
'The entire mp3 read into the buffer, and then displays the Private Sub cmdOK_Click () Dim s As String Dim l As Long Dim status As Integer Dim t As XA_InputModule Dim d As XA_DecoderInfo Dim dp As Long Dim opbi As XA_OutputBufferInfo Dim i As Long dp = VarPtr (d) status = decoder_new (VarPtr (dp)) If status <> XA_SUCCESS Then MsgBox "can not create decoder!" Exit Sub End If CopyMemory VarPtr (d), dp, 60 status = file_input_module_register (t) status = decoder_input_module_register ( d, t) If status <> XA_SUCCESS Then MsgBox xaudio_error_string (status) status = decoder_input_new (d, App.Path & "/3.mp3", XA_DECODER_INPUT_AUTOSELECT) If status <> XA_SUCCESS Then MsgBox "can not create input!" & status & vbCrLf & xaudio_error_string (status) Exit Sub End If status = decoder_input_open (d) If status <> XA_SUCCESS Then MsgBox "can not open input!" & vbCrLf & xaudio_error_string (status) Exit Sub End If 'build dsound Set d S = DX.directSoundCreate (vbnullstring) DS.SETCOOPERATIVELEVEL ME.HWND, DSSCL_PRIORITY
'Buffer DIM SB (100000000) AS BYTE DIM PSA (0) as dsbpositionNotify Do Mevents Status = Decoder_Decode (D, 0) CopyMemory Varptr (OPBI), D.Addr06, Len (OPBI)' OPBI PCM_SAMPLES represents the code The MP3 audio fragment is located in the memory pointer, we need to let the buffer point to its CopyMemory Varptr (SB (i)), OPBI.PCM_SAMPLES, OPBI.SIZE 'This piece of the length i = i opbi.size loop while status = XA_SUCCESS Or status = XA_ERROR_TIMEOUT Or status = XA_ERROR_INVALID_FRAME dsbd.lFlags = DSBCAPS_CTRLVOLUME Or DSBCAPS_STATIC Or DSBCAPS_CTRLPOSITIONNOTIFY dsbd.lBufferBytes = i wf = MakeWaveEX (opbi.sample_rate, 2 ^ opbi.stereo, opbi.bytes_per_sample * 8) Set dsb = ds.CreateSoundBuffer ( DSBD, WF) 'Write the buffer data to DSB.WriteBuffer 0, i, sb (0), dsblock_default dsb.setvolume 0 Dx.sevent endevent psa (0). HEVENTNTIVENT PSA (0) .heventNotify = endevent psa (0) .loffset = I - 1 dsb.setNotificationPositionPositions 1, PSA () 'Play DSB.Play DSB Play_Default bcontinue = true 'l = xaudio_get_api_version (xa_api_id_sync)' MSGBox "Xaudio DLL VERSION:" & ((L / (2 ^ 16)) and & H255) & "." & (((L / (2 ^ 8)) And & H255 ) & "." & (l and & h255) end sub
'Segment read mp3, continuous playback Private Sub cmdPlay_Click () Dim s As String Dim l As Long Dim status As Integer Dim t As XA_InputModule Dim d As XA_DecoderInfo Dim dp As Long Dim opbi As XA_OutputBufferInfo Dim i As Long dp = VarPtr (d ) status = decoder_new (VarPtr (dp)) If status <> XA_SUCCESS Then MsgBox "can not create decoder!" Exit Sub End If CopyMemory VarPtr (d), dp, 60 status = file_input_module_register (t) status = decoder_input_module_register (d, t ) If status <> XA_SUCCESS Then MsgBox xaudio_error_string (status) status = decoder_input_new (d, App.Path & "/4.mp3", XA_DECODER_INPUT_AUTOSELECT) If status <> XA_SUCCESS Then MsgBox "can not create input!" & status & vbCrLf & xaudio_error_string (status) Exit Sub End If status = decoder_input_open (d) If status <> XA_SUCCESS Then MsgBox "can not open input!" & vbCrLf & xaudio_error_string (status) Exit Sub End If Set ds = dx.Direc tSoundCreate (vbNullString) ds.SetCooperativeLevel Me.hWnd, DSSCL_PRIORITY Dim sb (5000000) As Byte Dim psa (0) As DSBPOSITIONNOTIFY bPlaying = False Do DoEvents status = decoder_decode (d, 0) CopyMemory VarPtr (opbi), d.Addr06, Len (opbi) If i opbi.size> 5000000 Then Do While bPlaying DoEvents Loop dsbd.lFlags = DSBCAPS_CTRLVOLUME Or DSBCAPS_STATIC Or DSBCAPS_CTRLPOSITIONNOTIFY Or DSBCAPS_GLOBALFOCUS dsbd.lBufferBytes = i wf =
MakeWaveEX (opbi.sample_rate, 2 ^ opbi.stereo, opbi.bytes_per_sample * 8) Set dsb = ds.CreateSoundBuffer (dsbd, wf) dsb.WriteBuffer 0, i, sb (0), DSBLOCK_DEFAULT dsb.SetVolume 0 dx.SetEvent endEvent PSA (0) .heventNotify = EndEvent PSA (0) .loffset = i - 1 dsb.setNotificationPositionPositions 1, PSA () dsb.play dsbplay_default bcontinue = true bplaying = true i = 0 End if copyMemory Varptr (SB (i)), opbi.pcm_samples, opbi.size i = i opbi.size Loop While status = XA_SUCCESS Or status = XA_ERROR_TIMEOUT Or status = XA_ERROR_INVALID_FRAME dsbd.lFlags = DSBCAPS_CTRLVOLUME Or DSBCAPS_STATIC Or DSBCAPS_CTRLPOSITIONNOTIFY Or DSBCAPS_GLOBALFOCUS dsbd.lBufferBytes = i wf = MakeWaveEX (opbi.sample_rate , 2 ^ opbi.stereo, opbi.bytes_per_sample * 8) SET DSB = DS.CREATESOUNDBUFFER (DSBD, WF) DSB.WriteBuffer 0, I, SB (0), DSBLOCK_DEFAULT DSB.SETVOLUME 0 DX.SETEVENT EndEvent PSA (0) .heventNotify = Endevent PSA (0) .loffset = i - 1 DSB.SetNotificationPositionPositions 1, PSA () dsb.play dsbplay_default bcontinue = true bplaying = truend subsprivate sub form_load () endevent = dx.createevent (me) end sub
Private Sub Form_QueryUnload (Cancel As Integer, UnloadMode As Integer) If endEvent Then dx.DestroyEvent endEvent If Not dsb Is Nothing Then dsb.Stop bPlaying = False Set dsb = Nothing Set ds = Nothing Set dx = Nothing EndEnd SubPrivate Function MakeWaveEX (Hz As Long, Channels As Integer, Bits As Integer) As WAVEFORMATEX MakeWaveEX.lSamplesPerSec = Hz MakeWaveEX.lExtra = 0 MakeWaveEX.nSize = 0 MakeWaveEX.nBitsPerSample = Bits MakeWaveEX.nChannels = Channels MakeWaveEX.nFormatTag = WAVE_FORMAT_PCM MakeWaveEX.nBlockAlign = Channels * Bits / 8 makewaveex.lavgbytespersec = HZ * (CHANNELS * BITS / 8) End function
Private sub DirectxEvent_dxcallback (Byval Eventid As Long) if bcontinue the bcontinue = false: exit sub bplaying = false
Modxaudio.bas
Attribute vb_name = "modxaudio" option expedition
'/ ********************************************************** **************** '|' | xaudio general definitions '| | (c) 1996-1998 MPEGTV, LLC' | Author: Gilles Boccon-Gibod (Gilles @ MPEGTV. COM) '|' ********************************************************************************************************************************************************************************************************************************************************************************************** ****************** /
'/ * ----------------------------------------------- ----------------------- '| Types' ---------------------- ----------------------------------------------- * / ' Typedef void (VOID * Client, 'Int Source,' Int Code, 'Long Value,' Const Char * Message);
'Typedef void (* XA_DebugNotificationFunction) (void * client,' int source, 'int level,' const char * message, 'const char * reason);' typedef void (* XA_ErrorNotificationFunction) (void * client, 'int source,' INT CODE, 'Const Char * Message,' Const Char * REASON;
Public Type XA_NotificationClient 'void * client;' XA_ProgressNotificationFunction notify_progress; 'XA_DebugNotificationFunction notify_debug;' XA_ErrorNotificationFunction notify_error; 'actually four pointers in vb course corresponding to the four long Addr01 As Long Addr02 As Long Addr03 As Long Addr04 As LongEnd Type
'#define xa_notify_progress (_Value, _Message) /' IF ((_client) -> notify_progress) / '(* (_client) -> notify_progress) ((_ Client) ((_ Client) -> Client, / '_Source, _code, _value, _message)
'#define Xa_notify_debug (_MESSAGE, _REASON) /' IF ((_Client) -> notify_debug / '(* (_ client) -> notify_debug) ((_ Client) -> Client, / '_Source, _level, _message, _reason)
'#define XA_notify_error (_Client, _reason) /' IF ((_Client) && (_client) -> notify_error) / '(* (_client) -> notify_error) ((_client) -> Client, / '_Source, _code, _Message, _reason)' / * -------------------------------------------------------------------------------------------------------------------------------------------- -------------------------------- '| Apis' ------------- -------------------------------------------------- ------ * / public const XA_API_ID_SYNC = 1PUBLIC ConST XA_API_ID_ASYNC = 2
'/ * ----------------------------------------------- ----------------------- '| ERROR CODES' --------------------- ----------------------------------------------- * / Public const xa_success = (0) public const xa_failure = (-1)
'/ * General error codes * / Public Const XA_ERROR_BASE_GENERAL = (-100) Public Const XA_ERROR_OUT_OF_MEMORY = (XA_ERROR_BASE_GENERAL - 0) Public Const XA_ERROR_INVALID_PARAMETERS = (XA_ERROR_BASE_GENERAL - 1) Public Const XA_ERROR_INTERNAL = (XA_ERROR_BASE_GENERAL - 2) Public Const XA_ERROR_TIMEOUT = (XA_ERROR_BASE_GENERAL - 3) PUBLIC const XA_ERROR_VERSION_EXPIRED = (XA_ERROR_BASE_GENERAL - 4)
'/ * Network error codes * / Public Const XA_ERROR_BASE_NETWORK = (-200) Public Const XA_ERROR_CONNECT_TIMEOUT = (XA_ERROR_BASE_NETWORK - 0) Public Const XA_ERROR_CONNECT_FAILED = (XA_ERROR_BASE_NETWORK - 1) Public Const XA_ERROR_CONNECTION_REFUSED = (XA_ERROR_BASE_NETWORK - 2) Public Const XA_ERROR_ACCEPT_FAILED = (XA_ERROR_BASE_NETWORK - 3) Public Const XA_ERROR_LISTEN_FAILED = (XA_ERROR_BASE_NETWORK - 4) Public Const XA_ERROR_SOCKET_FAILED = (XA_ERROR_BASE_NETWORK - 5) Public Const XA_ERROR_SOCKET_CLOSED = (XA_ERROR_BASE_NETWORK - 6) Public Const XA_ERROR_BIND_FAILED = (XA_ERROR_BASE_NETWORK - 7) Public Const XA_ERROR_HOST_UNKNOWN = (XA_ERROR_BASE_NETWORK - 8) Public Const XA_ERROR_HTTP_INVALID_REPLY = (XA_ERROR_BASE_NETWORK - 9) Public Const XA_ERROR_HTTP_ERROR_REPLY = (XA_ERROR_BASE_NETWORK - 10) Public Const XA_ERROR_HTTP_FAILURE = (XA_ERROR_BASE_NETWORK - 11) Public Const XA_ERROR_FTP_INVALID_REPLY = (XA_ERROR_BASE_NETWORK - 12) Public Const XA_ERROR_FTP_ERROR_REPLY = (XA_ERROR_BASE_NETWORK - 13 PUBLIC const XA_ERROR_FTP_FAILURE = (XA_ERROR_BASE_NETWORK - 14)
'/ * Control error codes * / Public Const XA_ERROR_BASE_CONTROL = (-300) Public Const XA_ERROR_PIPE_FAILED = (XA_ERROR_BASE_CONTROL - 0) Public Const XA_ERROR_FORK_FAILED = (XA_ERROR_BASE_CONTROL - 1) Public Const XA_ERROR_SELECT_FAILED = (XA_ERROR_BASE_CONTROL - 2) Public Const XA_ERROR_PIPE_CLOSED = (XA_ERROR_BASE_CONTROL - 3) Public Const XA_ERROR_PIPE_READ_FAILED = (XA_ERROR_BASE_CONTROL - 4) Public Const XA_ERROR_PIPE_WRITE_FAILED = (XA_ERROR_BASE_CONTROL - 5) Public Const XA_ERROR_INVALID_MESSAGE = (XA_ERROR_BASE_CONTROL - 6) Public Const XA_ERROR_CIRQ_FULL = (XA_ERROR_BASE_CONTROL - 7) Public Const XA_ERROR_POST_FAILED = (XA_ERROR_BASE_CONTROL - 8) '/ * url error codes * / Public Const XA_ERROR_BASE_URL = (-400) Public Const XA_ERROR_URL_UNSUPPORTED_SCHEME = (XA_ERROR_BASE_URL - 0) Public Const XA_ERROR_URL_INVALID_SYNTAX = (XA_ERROR_BASE_URL - 1)
'/ * I / o error codes * / Public Const XA_ERROR_BASE_IO = (-500) Public Const XA_ERROR_OPEN_FAILED = (XA_ERROR_BASE_IO - 0) Public Const XA_ERROR_CLOSE_FAILED = (XA_ERROR_BASE_IO - 1) Public Const XA_ERROR_READ_FAILED = (XA_ERROR_BASE_IO - 2) Public Const XA_ERROR_WRITE_FAILED = ( XA_ERROR_BASE_IO - 3) Public Const XA_ERROR_PERMISSION_DENIED = (XA_ERROR_BASE_IO - 4) Public Const XA_ERROR_NO_DEVICE = (XA_ERROR_BASE_IO - 5) Public Const XA_ERROR_IOCTL_FAILED = (XA_ERROR_BASE_IO - 6) Public Const XA_ERROR_MODULE_NOT_FOUND = (XA_ERROR_BASE_IO - 7) Public Const XA_ERROR_UNSUPPORTED_INPUT = (XA_ERROR_BASE_IO - 8) Public const XA_ERROR_UNSUPPORTED_OUTPUT = (XA_ERROR_BASE_IO - 9) Public const XA_ERROR_UNSUPPORTED_FORMAT = (XA_ERROR_BASE_IO - 10) Public const XA_ERROR_DEVICE_BUSY = (XA_ERROR_BASE_IO - 11) Public const XA_ERROR_NO_SUCH_DEVICE = (XA_ERROR_BASE_IO - 12) Public const XA_ERROR_NO_SUCH_FILE = (XA_ERROR_BASE_IO - 13) Public const XA_ERROR_INPUT_EOF = (XA_ERROR_BASE_IO - 14) '/ * BitStream Error Codes * / PUB Lic const XA_ERROR_BASE_BITSTREAM = (-600) public const XA_ERROR_INVALID_FRAME = (Xa_error_Base_bitstream - 0)
'/ * Dynamic linking error codes * / Public Const XA_ERROR_BASE_DYNLINK = (-700) Public Const XA_ERROR_DLL_NOT_FOUND = (XA_ERROR_BASE_DYNLINK - 0) Public Const XA_ERROR_SYMBOL_NOT_FOUND = (XA_ERROR_BASE_DYNLINK - 1)
'/ * Environment variables error codes * / Public Const XA_ERROR_BASE_ENVIRONMENT = (-800) Public Const XA_ERROR_NO_SUCH_ENVIRONMENT = (XA_ERROR_BASE_ENVIRONMENT - 0) Public Const XA_ERROR_ENVIRONMENT_TYPE_MISMATCH = (XA_ERROR_BASE_ENVIRONMENT - 1)
Moddecoder.bas
Attribute vb_name = "moddecoder" option expenented explicitpublic const_seekable = & h1
Public Const XA_DECODER_DEVICE_HAS_MASTER_LEVEL_CONTROL = & H1Public Const XA_DECODER_DEVICE_HAS_PCM_LEVEL_CONTROL = & H2Public Const XA_DECODER_DEVICE_HAS_BALANCE_CONTROL = & H4Public Const XA_DECODER_DEVICE_HAS_LINE_OUT = & H8Public Const XA_DECODER_DEVICE_HAS_SPEAKER_OUT = & H10Public Const XA_DECODER_DEVICE_HAS_HEADPHONE_OUT = & H20Public Const XA_DECODER_DEVICE_HAS_08_000_KHZ = & H40Public Const XA_DECODER_DEVICE_HAS_11_025_KHZ = & H80Public Const XA_DECODER_DEVICE_HAS_12_000_KHZ = & H100Public Const XA_DECODER_DEVICE_HAS_16_000_KHZ = & H200Public Const XA_DECODER_DEVICE_HAS_22_050_KHZ = & H400Public Const XA_DECODER_DEVICE_HAS_24_000_KHZ = & H800Public Const XA_DECODER_DEVICE_HAS_32_000_KHZ = & H1000Public Const XA_DECODER_DEVICE_HAS_44_100_KHZ = & H2000Public Const XA_DECODER_DEVICE_HAS_48_000_KHZ = & H4000Public Const XA_DECODER_DEVICE_HAS_8_BITS = & H8000Public Const XA_DECODER_DEVICE_HAS_MU_LAW = & H10000Public Const XA_DECODER_DEVICE_HAS_16_BITS = & H20000Public Const XA_DECODER_DEVICE_HAS_MU TE = & H40000Public Const XA_DECODER_DEVICE_HAS_RESET = & H80000Public Const XA_DECODER_DEVICE_HAS_PAUSE = & H100000Public Const XA_DECODER_DEVICE_HAS_DRAIN = & H200000Public Const XA_DECODER_DEVICE_HAS_BUFFER_STATUS = & H400000
Public const x_decoder_device_frequencies_offset = 6public const XA_Decoder_device_frequencies_mask = & h1ff
Public Const XA_DECODER_CONTROL_BPS = & H1Public Const XA_DECODER_CONTROL_STEREO = & H2Public Const XA_DECODER_CONTROL_SAMPLE_RATE = & H4Public Const XA_DECODER_CONTROL_MASTER_LEVEL = & H8Public Const XA_DECODER_CONTROL_PCM_LEVEL = & H10Public Const XA_DECODER_CONTROL_BALANCE = & H20Public Const XA_DECODER_CONTROL_PORTS = & H40Public Const XA_DECODER_CONTROL_ALL_INFO = & H7FPublic Const XA_DECODER_CONTROL_MUTE = & H80Public Const XA_DECODER_CONTROL_UNMUTE = & H100Public Const XA_DECODER_CONTROL_RESET = & H200Public Const XA_DECODER_CONTROL_PAUSE = & H400Public Const XA_DECODER_CONTROL_RESTART = & H800Public Const XA_DECODER_CONTROL_DRAIN = & H1000Public Const XA_DECODER_CONTROL_OUTPUT_LINE = & H1Public Const XA_DECODER_CONTROL_OUTPUT_SPEAKER = & H2Public Const XA_DECODER_CONTROL_OUTPUT_HEADPHONE = & H4
PUBLIC const XA_DECODER_ENVIRONMENT_MAX_NAME_LENGTH = 256PUBLIC const XA_DECODER_ENVIRONMENT_MAX_STRING_LENGTH = 1024
Public const xa_decoder_input_query_module_name = & h1public const xa_decoder_input_query_nb_devices = & h2public const xa_decoder_input_query_device_name = & h4
Public const xa_decoder_input_query_name_is_gener = & h1public const xa_decoder_input_query_device_is_default = & h2
Public const_decoder_output_query_module_name = & h1public const xa_decoder_output_query_nb_devices = & H2PUBLIC ConST XA_DECODER_OUTPUT_QUERY_DEVICE_NAME = & H4
Public Const XA_DECODER_OUTPUT_QUERY_NAME_IS_GENERIC = & H1Public Const XA_DECODER_OUTPUT_QUERY_DEVICE_IS_DEFAULT = & H2Public Const XA_DECODER_OUTPUT_QUERY_DEVICE_IS_SHAREABLE = & H4Public Const XA_DECODER_MAX_NAME_LENGTH = 255Public Const XA_DECODER_MAX_DESCRIPTION_LENGTH = 255
Public const XA_Decoder_input_autteelect = -1public const XA_Decoder_output_auttelect = -1
Public const xa_decoder_input_filter_first = -1public const xa_decoder_input_filter_last = 0public const x_decoder_input_filter_by_name = -2
Public const_decoder_output_filter_first = -1public const xa_decoder_output_filter_last = 0PUBLIC const XA_DECODER_OUTPUT_FILTER_BY_NAME = -2
Public const XA_TIMECODE_FRACTIONS_PER_SECOND = 100PUBLIC const XA_TIMECODE_FRACTIONS_PER_MINUTE = (100 * 60) public const XA_TIMECODE_FRACTIONS_PER_HOUR = 360000
Public const XA_Decoder_codec_quality_high = 0public const XA_Decoder_codec_quality_medium = 1public const XA_Decoder_codec_quality_low = 2
Public const XA_Decoder_equalizer_nb_bands = 32public const XA_Decoder_feedback_nb_bands = 32
'/ * ----------------------------------------------- ----------------------- '| Types' ---------------------- ----------------------------------------------- * / ' TypeDef void (Void * listener, 'const char * name,' void * value);
Public Type Xa_timecode H AS Integer M AS Integer S AS Integer f AS integrend Type
Public Type Xa_Absolutetime Seconds As Long Microseconds As LONGEND TYPE
Public Enum XA_IOState XA_IO_STATE_CLOSED = 0 XA_IO_STATE_OPENEnd EnumPublic Type XA_InputStreamInfo changed As Integer level As Integer layer As Integer bitrate As Integer frequency As Integer mode As IntegerEnd Type
PUBLIC TYPE XA_INPUTMODULEQUERY INDEX AS INTEGER FLAGS AS Long Name AS STRING * XA_DECODER_MAX_NAME_LENGTH Description AS STRING * XA_DECODER_MAX_DESCRIPTION_LENGTHEND TYPE
Public Type Xa_InputModuleClassInfo ID As INTEGER 'VOID * GLOBAL; AddR01 AS LONGEND TYPE
'struct xa_decoderinfo;
Public Type XA_InputModule 'int (* input_module_probe) (const char * name);' int (* input_module_query) (XA_InputModuleQuery * query, 'unsigned long query_mask);' int (* input_new) (void ** input, const char * name, 'XA_InputModuleClassInfo * class_info,' struct XA_DecoderInfo * decoder); 'int (* input_delete) (void * input);' int (* input_open) (void * input); 'int (* input_close) (void * input);' int (* INPUT_READ) (Void * INPUT, VOID * Buffer, unsigned long n); 'int (* input_seek) (VOID * INPUT, UNSIGNED Long Offset);' long (* input_get_caps) (VOID * INPUT); 'long (* INPUT_GET_SIZE) (Void * Input); 'Int (* Input_send_Message) (Void * Input, INT TYPE,' Const Void * Data, Unsigned Int Size)
'全 是 指 AddR01 AS Long AddR02 As Long Addr05 As Long AddR06 AS Long AddR09 As Long AddR10 As Long Addr11 As LONGEND TYPE
'struct XA_INPUTFILTERNODE;
Public Type XA_InputFilter 'const char * (* filter_get_name) (void);' int (* filter_new) (void ** filter, int id, 'struct XA_DecoderInfo * decoder);' int (* filter_delete) (void * filter); ' int (* input_open) (struct XA_InputFilterNode * node); 'int (* input_close) (struct XA_InputFilterNode * node);' int (* input_read) (struct XA_InputFilterNode * node, 'void * buffer, unsigned long n);' int ( * input_seek) (struct XA_InputFilterNode * node, 'unsigned long offset);' long (* input_get_caps) (struct XA_InputFilterNode * node); 'long (* input_get_size) (struct XA_InputFilterNode * node);' int (* input_send_message) (struct XA_InputFilterNode * node, 'int type, const void * data, unsigned int size); Addr01 As Long Addr02 As Long Addr03 As Long Addr04 As Long Addr05 As Long Addr06 As Long Addr07 As Long Addr08 As Long Addr09 As Long Addr10 As LongEnd TypePubl ic Type XA_InputFilterNode id As Integer 'void * instance; Addr01 As Long vtable As XA_InputFilter' struct XA_InputFilterNode * next; Addr02 As Long 'struct XA_InputFilterNode * prev; Addr03 As LongEnd Type
Public Type XA_InputInfo state As XA_IOState caps As Long position As Long size As Long duration As Long 'void * device; Addr01 As Long' const XA_InputModule * module; Addr02 As Long 'const char * name; Addr03 As LongEnd Type
PUBLIC ENUM XA_OUTPUTCHANNELSMODE XA_OUTPUT_STEREO XA_OUTPUT_MONO_LEFT XA_OUTPUT_MONO_RIGHT XA_OUTPUT_MONO_MIXEND ENUM
Public Type XA_OutputFeedbackBands' short left [XA_DECODER_FEEDBACK_NB_BANDS]; leftleft (XA_DECODER_FEEDBACK_NB_BANDS) As Integer 'short right [XA_DECODER_FEEDBACK_NB_BANDS]; rightright (XA_DECODER_FEEDBACK_NB_BANDS) As IntegerEnd TypePublic Type XA_OutputBufferInfo changed As Long' short * pcm_samples; pcm_samples As Long size As Long bytes_per_sample As Long stereo As long sample_rate as long delay as long '/ * xa_outputfeedbackBands * feedback; * / end type
Public Type Xa_OutputStatus Delay As Longend Type
Public Type XA_OUTPUTCONTROL BYTES_PER_SAMPLE AS INTEGER SAMPLE_RATE AS INTEGER STEGER PCM_LEVEL AS INTEGER Balance AS INTEGER PORTS AS INTEGEREND TYPE
Public Type XA_OUTPUTMODULEQUERY INDEX AS STEGER FLAGS AS Long Name AS STRING * XA_DECODER_MAX_NAME_LENGTH DESCRIPTION AS STRING * XA_DECODER_MAX_DESCRIPTION_LENGTHEND TYPE
Public Type Xa_OutputModuleClassInfo ID As Integer 'Void * Global; AddR01 As Longend Type
Public Type XA_OutputModule 'int (* output_module_probe) (const char * name);' int (* output_module_query) (XA_OutputModuleQuery * query, 'unsigned long query_mask);' int (* output_new) (void ** output, const char * name, 'XA_OutputModuleClassInfo * class_info,' struct XA_DecoderInfo * decoder); 'int (* output_delete) (void * output);' int (* output_open) (void * output); 'int (* output_close) (void * output);' int (* output_write) (void * output, void * buffer, 'unsigned long size, int bytes_per_sample,' int stereo, int sample_rate); 'void * (* output_get_buffer) (void * output, unsigned long size);' int (* Output_set_control (vid * output, 'xa_outputcontrol * control,' unsigned long flags); 'int (* Output_Get_control) (void * output,' xa_outputcontrol * control, 'unsigned long control_mask);' int (* output_get_status) (void * output, 'XA_OutputStatus * status);' long (* output_get_caps) (void * output); 'int (* output_send_message) (void * output, int type , 'const void * data, unsigned int size); Addr01 As Long Addr02 As Long Addr03 As Long Addr04 As Long Addr05 As Long Addr06 As Long Addr07 As Long Addr08 As Long Addr09 As Long Addr10 As Long addr11 As Long Addr12 As Long Addr13 As Longend Type'Struct XA_outputfilterNode;
Public Type XA_OutputFilter 'const char * (* filter_get_name) (void);' int (* filter_new) (void ** filter, int id, 'struct XA_DecoderInfo * decoder);' int (* filter_delete) (void * filter); ' int (* output_open) (struct XA_OutputFilterNode * node); 'int (* output_close) (struct XA_OutputFilterNode * node);' int (* output_write) (struct XA_OutputFilterNode * node, 'void * buffer,' unsigned long size, int bytes_per_sample, 'int stereo, int sample_rate);' void * (* output_get_buffer) (struct XA_OutputFilterNode * node, 'unsigned long size);' int (* output_set_control) (struct XA_OutputFilterNode * node, 'XA_OutputControl * control,' unsigned long flags); 'int (* OUTPUT_GET_CONTROL) (Struct Xa_outputfilterNode * Node,' Xa_outputControl * Control, 'U nsigned long control_mask); 'int (* output_get_status) (struct XA_OutputFilterNode * node,' XA_OutputStatus * status); 'long (* output_get_caps) (struct XA_OutputFilterNode * node);' int (* output_send_message) (struct XA_OutputFilterNode * node, 'int type, const void * data, unsigned int size); Addr01 As Long Addr02 As Long Addr03 As Long Addr04 As Long Addr05 As Long Addr06 As Long Addr07 As Long Addr08 As Long Addr09 As Long Addr10 As Long addr11 As Long Addr12 As LongEnd type
Public Type XA_OutputFilterNode id As Integer 'void * instance; Addr01 As Long vtable As XA_OutputFilter' struct XA_OutputFilterNode * next; Addr02 As Long 'struct XA_OutputFilterNode * prev; Addr03 As LongEnd TypePublic Type XA_OutputInfo state As XA_IOState caps As Long' void * device; ' Const Xa_OutputModule * Module; 'const char * name; addr01 as long addr02 as long addr03 as longend Type
Public Type XA_EqualizerInfo 'signed char left [XA_DECODER_EQUALIZER_NB_BANDS];' signed char right [XA_DECODER_EQUALIZER_NB_BANDS]; leftleft (XA_DECODER_EQUALIZER_NB_BANDS) As Integer rightright (XA_DECODER_EQUALIZER_NB_BANDS) As IntegerEnd Type
PUBLIC TYPULESINFO NB_INPUT_MODULES AS INTEGER NB_OUTPUT_MODULES AS INTEGEREND TYPE
PUBLIC TYPE XA_STATUSINFO FRAME AS Long Position As Single Info AS XA_INPUTSTREAMIMINFO TIMECODE AS XA_TIMECODEEND TYPE
'struct xa_decoderprivateInfo;' struct xa_decoderinfo;
Public Type XA_DecoderCallbackTable 'int (XA_EXPORT * get_environment_integer) (struct XA_DecoderInfo * decoder,' const char * name, 'long * value);' int (XA_EXPORT * get_environment_string) (struct XA_DecoderInfo * decoder, 'const char * name,' char * value); 'int (XA_EXPORT * add_environment_listener) (struct XA_DecoderInfo * decoder,' const char * name, 'void * client,' XA_EnvironmentCallback callback, 'void ** handle);' int (XA_EXPORT * remove_environment_listener) (struct XA_DecoderInfo * decoder , 'Void * handle); addr01 as long addr02 as long addr03 as long address4 As longend typepu blic Type XA_DecoderInfo 'const char * name;' XA_InputInfo * input; 'XA_OutputInfo * output;' XA_ModulesInfo * modules; 'XA_StatusInfo * status;' XA_OutputBufferInfo * output_buffer; Addr01 As Long Addr02 As Long Addr03 As Long Addr04 As Long Addr05 As Long Addr06 As long notification_client as xa_notificationclient callbacktable 'struct xa_decoderprivateInfo * hidden; addr07 as longend type
ModdeClare.bas
Attribute VB_Name = "ModdeClare" option expedition
'Xaudio.hPublic Declare Function xaudio_error_string Lib "xaudio.dll" (ByVal code As Integer) As StringPublic Declare Function xaudio_get_api_version Lib "xaudio.dll" (ByVal api_id As Long) As Long'audio_output.h'Public Declare Function audio_output_module_register Lib "xaudio .dll "(Module As Xa_OutputModule) AS Integer'Public Declare Function DSOUND_OUTPUT_MODULE_REGISTER LIB" Xaudio.dll "AS INTEGER
'file_input.hpublic declare function file_input_module_register lib "xaudio.dll" (Module As Xa_INPUTMODULE) AS INTEGER
'file_output.h'public declare function file_output_module_register lib "xaudio.dll" (Module As Xa_OutputModule) AS Integer
'Memory_input.h'Public Declare Function memory_input_feed Lib "xaudio.dll" (ByVal devicepointer As Long, ByVal datapointer As Long, ByVal nb_bytes As Long) As Integer'Public Declare Function memory_input_flush Lib "xaudio.dll" (ByVal devicepointer As Long) AS INTEGER'PUBLIC DECLARE FUNCTION MEMORY_INPUT_MODULE_REGISTER LIB "Xaudio.dll" AS Integer
'stream_input.h'public declare function stream_input_module_register lib "xaudio.dll" (Module As Xa_INPUTMODULE) AS INTEGER
'decoder.h'char * xa_export decoder_version (char ** major, char ** minor, char ** state);
Public declare function decoder_new lib "xaudio.dll" (Byval Decoderpp As long) AS Integer
Public Declare Function decoder_delete Lib "xaudio.dll" (decoder As XA_DecoderInfo) As IntegerPublic Declare Function decoder_input_module_register Lib "xaudio.dll" (decoder As XA_DecoderInfo, module As XA_InputModule) As Integer'int XA_EXPORT decoder_input_module_query (XA_DecoderInfo * decoder, 'int module, 'XA_InputModuleQuery * query,' unsigned long query_flags); 'int XA_EXPORT decoder_input_add_filter (XA_DecoderInfo * decoder,' const XA_InputFilter * filter, 'int where);' int XA_EXPORT decoder_input_remove_filter (XA_DecoderInfo * decoder, 'const char * name, int id); 'INT XA_EXPORT DECODER_INPUT_FILTERS_LIST (Xa_Decoderinfo * Decoder,' Void * Client, 'Void (* Callback)' (Void * client, 'XA_InputFilterNode * node)); Public Declare Function decoder_input_new Lib "xaudio.dll" (decoder As XA_DecoderInfo, ByVal name As String, ByVal module As Integer) As Integer'int XA_EXPORT decoder_input_delete (XA_DecoderInfo * decoder); Public Declare Function decoder_input_open Lib "xaudio.dll" (decoder As XA_DecoderInfo) As Integer'int XA_EXPORT decoder_input_close (XA_DecoderInfo * decoder); 'int XA_EXPORT decoder_input_read (XA_DecoderInfo * decoder,' void * buffer, int size); '
int XA_EXPORT decoder_input_seek_to_offset (XA_DecoderInfo * decoder, 'unsigned long offset);' int XA_EXPORT decoder_input_seek_to_position (XA_DecoderInfo * decoder, 'float position);' int XA_EXPORT decoder_input_seek_to_time (XA_DecoderInfo * decoder, 'float seconds);' int XA_EXPORT decoder_input_seek_to_timecode (XA_DecoderInfo * decoder , 'const XA_TimeCode * timecode);' int XA_EXPORT decoder_input_send_message (XA_DecoderInfo * decoder, 'int type,' const void * data, 'unsigned int size);' int XA_EXPORT decoder_output_module_register (XA_DecoderInfo * decoder, 'const XA_OutputModule * module);' INT XA_EXPORT DECODER_OUTPUT_MODULE_QUERY (Xa_Decoderinfo * Decoder, ' int module, 'XA_OutputModuleQuery * query,' unsigned long query_flags); 'int XA_EXPORT decoder_output_add_filter (XA_DecoderInfo * decoder,' const XA_OutputFilter * filter, 'int where);' int XA_EXPORT decoder_output_remove_filter (XA_DecoderInfo * decoder, 'const char * name, int ID); 'INT XA_EXPORT DECODER_OUTPUT_FILTERS_LIST (Xa_Decoderinfo * Decoder,' Void * Client, '
void (* callback) '(void * client,' XA_OutputFilterNode * node)); 'int XA_EXPORT decoder_output_new (XA_DecoderInfo * decoder,' const char * name, int module); 'int XA_EXPORT decoder_output_delete (XA_DecoderInfo * decoder);' int XA_EXPORT decoder_output_open (XA_DecoderInfo * decoder); 'int XA_EXPORT decoder_output_close (XA_DecoderInfo * decoder);' int XA_EXPORT decoder_output_write (XA_DecoderInfo * decoder, void * buffer, 'unsigned long size,' int bytes_per_sample, 'int stereo, int sample_rate);' int XA_EXPORT decoder_output_set_control (XA_DecoderInfo * decoder, 'XA_OutputControl * control,' unsigned long control_flags); 'int XA_EXPORT decoder_output_get_control (XA_DecoderInfo * decoder,' XA_OutputControl * control, 'unsigned long control_flags);' int XA_EXPORT decoder_output_send_message (XA_DecoderInfo * decoder, 'int type,' const void * data, 'unsigned int size);' int XA_EXPORT decoder_codec_set_channels (XA_DecoderInfo * decoder, 'XA_OutputChannelsMode channels);' INT XA_EXPORT DECODER_CODEC_GET_CHANNELS (Xa_Decoderinfo * Decoder); '
int XA_EXPORT decoder_codec_set_quality (XA_DecoderInfo * decoder, 'unsigned int quality);' int XA_EXPORT decoder_codec_get_quality (XA_DecoderInfo * decoder); 'int XA_EXPORT decoder_codec_set_equalizer (XA_DecoderInfo * decoder,' XA_EqualizerInfo * equalizer); 'int XA_EXPORT decoder_codec_get_equalizer (XA_DecoderInfo * decoder,' XA_EqualizerInfo * equalizer); 'int XA_EXPORT decoder_codec_enable_feedback (XA_DecoderInfo * decoder);' int XA_EXPORT decoder_codec_disable_feedback (XA_DecoderInfo * decoder); 'int XA_EXPORT decoder_set_environment_integer (XA_DecoderInfo * decoder,' const char * name, 'long value);' int XA_EXPORT decoder_get_environment_integer (XA_DecoderInfo * Decoder, 'const char * name,' long * value) ; 'Int XA_EXPORT decoder_set_environment_string (XA_DecoderInfo * decoder,' const char * name, 'const char * value);' int XA_EXPORT decoder_get_environment_string (XA_DecoderInfo * decoder, 'const char * name,' char * value); 'int XA_EXPORT decoder_unset_environment (XA_DecoderInfo * decoder, 'const char * name);' INT XA_EXPORT DECODER_ADD_ENVIRONMENT_LISTENER (Xa_Decoderinfo * Decoder, '
const char * name, 'void * client,' XA_EnvironmentCallback callback, 'void ** handle);' int XA_EXPORT decoder_remove_environment_listener (XA_DecoderInfo * decoder, 'void * handle); Public Declare Function decoder_decode Lib "xaudio.dll" (decoder As XA_DecoderInfo , BYVAL OUTPUT_BUFFER_POINTER AS longpublic declare function decoder_play lib "xaudio.dll" (Decoder As Xa_Decoderinfo) AS Integer
Public Declare Sub CopyMemory Lib "kernel32" Alias "RTLmoveMemory" (Byval HPVDest As Long, Byval CBCopy As Long)
Public Declare Function GlobalAlloc Lib "kernel32" (ByVal wFlags As Long, ByVal dwBytes As Long) As LongPublic Declare Function GlobalFree Lib "kernel32" (ByVal hMem As Long) As LongPublic Declare Sub FillMemory Lib "kernel32.dll" Alias "RtlFillMemory" ( BYVAL DESTINATION As Long, Byval Fill AS Byte
Public const GMEM_FIXED = & H0
Public Type ID3v1 Header AS String * 3 '/ * Label Head must be "tag" otherwise not tag * / title as string * 30' / * title * / artist as string * 30 '/ * author * / album as string * 30 '/ * collected * / year as string * 4' / * birth year * / comment as string * 30 '/ * Note * / genre as byteend TYPE
Public Type Waveformattype Samplespersec As Long Bitsample As Long Channels As LONGEND TYPE