Develop DirectSound programs with VB

xiaoxiao2021-03-06  37

Everyone knows DirectSound is part of DirectX. Its main function is used to play sound. In fact, there are many ways to develop play sounds with VB. But these methods are lacking flexibility than DirectSound. It is precisely due to these flexibility, making DirectSound programming has certain difficulties. Although Microsoft gave many program code instances, I found that these programs were not suitable for beginners. Because in these programs, there are many error handles and debug code. This gives a big learning difficulty to beginners. It is because of the best, I have written a simple foundation entry code to help beginners will start quickly and make a higher level study by this basis. Program Description We add two commands in this program to open a file dialog box. The first button is used to play the sound, the second command button is used to open the file dialog, select the sound file you want to play. For DirectSound initialization, complete in Formloy. To use DirectSound, you first have to install DirectX's SDK's SDK package (there is a large number of examples and help, I only find SDK package in the prequestation number Q99JQ-HvJYX-68GM3-WXT68 WIN98 installation disk) or with DX7 library games (refer to some games with 'Install DIRHCT7.0' options). Select 'DirectX7 for VisualBase Type LidRary' in the VB menu [Engine] - "(Reference ...) pop-up. Code into the next: dim m_dx as new directx7 'statement dlrect x7 objects dim dufferdesc as dsbufferdesc' statement buffer structure dim waveformat as waveformatex 'declaration file format dim m_dsduffer (100) as directsoundbuffer' declared buffer object dim k as string dim m_ds as directsound ' Declaring DirectSound Object Private SUD Commandl Click () SET M_DSDUFFER (100) = m DS CreatesoundBufferFromFile (k, dufferDesc, Waveformat) 'Load files into buffer. m DSDuffer (100) represents the size of the buffer.

转载请注明原文地址:https://www.9cbs.com/read-66956.html

New Post(0)