• Vui lòng đọc nội qui diễn đàn để tránh bị xóa bài viết
  • Tìm kiếm trước khi đặt câu hỏi

HƯớng dẫn sử dụng engine âm thanh : FmodSoundSystem

Các bài viết hướng dẫn, giúp các bạn hiểu và tiếp cận với Visual Basic nhanh hơn
giongto35
Thành viên danh dự
Thành viên danh dự
Bài viết: 194
Ngày tham gia: T.Năm 19/04/2007 10:17 am
Đến từ: Đà Nẵng City
Been thanked: 1 time
Liên hệ:

HƯớng dẫn sử dụng engine âm thanh : FmodSoundSystem

Gửi bàigửi bởi giongto35 » T.Hai 31/03/2008 10:54 pm

Tên bài viết: Chương trình nghe nhạc bằng engine FModSound
Tác giả: GiongTo35
Cấp độ bài viết: Khó... Hiểu
Tóm tắt: Cả Bài viết này sẽ hướng dẫn sử dụng Fmod Sound System , engine âm thanh mạnh nhất thế giới ,b bằng quá trình hướng dẫn viết chương trình trình nghe nhạc . bài viết chia làm 5 phần



http://www.fmod.org/
Hình ảnh
thấy anh em toàn dùng wmp khổ quá . Giới thiệu cái này
Một sound Engine cực mạnh (mạnh nhất thì phải :-D ): nhưng dành cho game programing , ko phải để play nhạc mô :oops:
Fmod 375 là phiên bản non commercial còn Fmod Ex 408 là mua bằng tiền . Đắt lém , nhưng cho sử dụng Demo được. Dùng VB dễ sử dụng Fmod 375 , ko rắc rối như Fmod Ex cho VB nó xét phiên bản người dùng , chệch một phiên bản là ko chạy được nữa :-x . Dùng C++ , VB.net , C# có đôi phân dễ dàng hơn

Tính năng có thể đo sóng âm (spectrum), tạo bộ nhớ nhạc , play avi , Play sound , Play stream ,(3 cái này là 3 thứ khác nhau ),3d sound
Effect FX:
*Chorus
*Compressor
*Distortion
*Echo
*Flanger
*Gargle
*I3DL2Reverb
*ParamEQ
*WavesReverb
Hình như còn có Surround,Mixer
và playback ...
3d sound ...

Download : http://www.fmod.org/index.php/download

Linkdown Fmod375 For Win: http://www.fmod.org/index.php/release/v ... 375win.zip
Linkdown FmodEx For Win: http://www.fmod.org/index.php/release/v ... taller.exe
đọc trong doccument là chính:
Mình xin chỉ nói về Fmod 375 :

Demo trong bài hướng dẫn :


FmodTUT.rar
(368.95 KiB) Đã tải 1513 lần

Viết thế này cho nổi :-D
_______________________________________________________________________________________________________________________
Khái niệm :

Sample với bytes với miliseconds
với Fmod bạn có thể gặp những cái này :

16 bit stereo sample data 44khz
Samples : 0 1 2 3 4 44100 samples
Bytes : 0 4 8 12 16 176400 bytes
miliseconds : 0 .02 .04 .09 .018 1000 ms
....
Trong biểu đồ này bạn sẽ thấy âm thanh trái phải xen kẽ nhau .
*Một cặp trái phải được gọi là một Sample
vì vậy được tạo ra từ 16 bit 1 Sample = 4 bytes
*Nếu chu kì Sample hoặc playback là 44.1khz hoặc 44100 samples một giây thì một Sample là 1/44100th của giây hoặc 1/44th của một milli giây.
*Bởi vậy 44100 Sample= 1 giây hay 1000 milli giây của dữ liệu.
để chuyển đổi giw
ms = samples * 1000 / samplerate.
samples = ms * samplerate / 1000.
samplerate = samples * 1000 / ms.
bytes = samples * bits * channels / 8.
samples = bytes * 8 / bits / channels.

Để chuyển đổi giữa những thuật ngữ học khác, những công thức sau đây có thể được sử dụng.

ms = samples * 1000 / samplerate.
samples = ms * samplerate / 1000.
samplerate = samples * 1000 / ms.
bytes = samples * bits * channels / 8.
samples = bytes * 8 / bits / channels.

Một số Function cần biết điều này như "Getlength" để lấy milli giây ,sample,byte thì cần phải tính toán

Các định dạng
Sound là một âm thanh , dạng lạ hoắc , đọc Document rồi bít
Music cũng rứa
Stream :cái này thì bít :-D là bản nhạc .

Vì vậy chia ra gồm ba loại FSOUND , FMUSIC.
Trong Fsound có Stream sample ...
Khái niệm kênh (channel):
Ví dụ như kênh TV vậy , hình như có 512 kênh , mỗi lần "playSound" nó sẽ gửi handle của channel về để làm một số thứ khác .
Khi mà hệ thống playSound thì phải nhớ FMOD_CHANNEL_FREE giải phóng kênh , nó sẽ chọn kênh rỗng để bạn play nhạc
Kênh giúp ta có thể play nhiều bài nhạc cùng lúc . Âm thanh hoảng loạng :roll:
2d và 3d :
thường thường bạn nghe nhạc thì chỉ là phát ra âm thanh từ hai cái loa . nhưng khi 3d sound khác :
lập trình 3d cái gì cũng khó , kể cả làm game :grin:
Khi 3d sound bạn sẽ đứng ở một vị trí nào đó , đặt tai nghe tại đâu đó , rồi âm thanh sẽ được play từ vị trí (x,y,z) tới tai ta (listen) sẽ bị nhiều yếu tố ảnh hưỡng (xa , gần ,loãng ...) .
_____________________________________________________________________________________________________________________
Nên nhớ hầu hết tất cả các tut đều là của C++ , mình đã cố gắng đọc và translate 8-) .
Getting Started:
Cài đặt môi trường

Cần có : Fmod.dll ( 375 hay EX hổng biết nữa , thấy tự nhiên nó có thôi)
Fmod.Bas ( nếu là C++ thì chỉ cần include vào là dùng được , cả VB.net và C# cũng nhận được ) Còn VB thì hơi khổ :
Giống hệt win API

Mã: Chọn hết

  1.  
  2.  
  3. Option Explicit
  4.  
  5. '
  6. 'FMOD VB6 Module
  7. '
  8.  
  9. Public Const FMOD_VERSION = 3.75
  10.  
  11. '************
  12. '* Enums
  13. '************
  14.  
  15.  
  16. ' FMOD_ERRORS
  17. ' On failure of commands in FMOD, use FSOUND_GetError to attain what happened.
  18. '
  19. Public Enum FMOD_ERRORS
  20.     FMOD_ERR_NONE             ' No errors
  21.     FMOD_ERR_BUSY             ' Cannot call this command after FSOUND_Init.  Call FSOUND_Close first.
  22.     FMOD_ERR_UNINITIALIZED    ' This command failed because FSOUND_Init was not called
  23.     FMOD_ERR_INIT             ' Error initializing output device.
  24.     FMOD_ERR_ALLOCATED        ' Error initializing output device, but more specifically, the output device is already in use and cannot be reused.
  25.     FMOD_ERR_PLAY             ' Playing the sound failed.
  26.     FMOD_ERR_OUTPUT_FORMAT    ' Soundcard does not support the features needed for this soundsystem (16bit stereo output)
  27.     FMOD_ERR_COOPERATIVELEVEL ' Error setting cooperative level for hardware.
  28.     FMOD_ERR_CREATEBUFFER     ' Error creating hardware sound buffer.
  29.     FMOD_ERR_FILE_NOTFOUND    ' File not found
  30.     FMOD_ERR_FILE_FORMAT      ' Unknown file format
  31.     FMOD_ERR_FILE_BAD         ' Error loading file
  32.     FMOD_ERR_MEMORY           ' Not enough memory
  33.     FMOD_ERR_VERSION          ' The version number of this file format is not supported
  34.     FMOD_ERR_INVALID_PARAM    ' An invalid parameter was passed to this function
  35.     FMOD_ERR_NO_EAX           ' Tried to use an EAX command on a non EAX enabled channel or output.
  36.     FMOD_ERR_CHANNEL_ALLOC    ' Failed to allocate a new channel
  37.     FMOD_ERR_RECORD           ' Recording is not supported on this machine
  38.     FMOD_ERR_MEDIAPLAYER      ' Windows Media Player not installed so cannot play wma or use internet streaming.
  39.     FMOD_ERR_CDDEVICE         ' An error occured trying to open the specified CD device
  40. End Enum
  41.  
  42.  
  43. ' FSOUND_OUTPUTTYPES
  44. ' These output types are used with FSOUND_SetOutput, to choose which output driver to use.
  45. ' FSOUND_OUTPUT_DSOUND will not support hardware 3d acceleration if the sound card driver
  46. ' does not support DirectX 6 Voice Manager Extensions.
  47. ' FSOUND_OUTPUT_WINMM is recommended for NT and CE.
  48. '
  49. Public Enum FSOUND_OUTPUTTYPES
  50.     FSOUND_OUTPUT_NOSOUND   ' NoSound driver, all calls to this succeed but do nothing.
  51.     FSOUND_OUTPUT_WINMM     ' Windows Multimedia driver.
  52.     FSOUND_OUTPUT_DSOUND    ' DirectSound driver.  You need this to get EAX2 or EAX3 support, or FX api support.
  53.     FSOUND_OUTPUT_A3D       ' A3D driver.
  54.  
  55.     FSOUND_OUTPUT_OSS       ' Linux/Unix OSS (Open Sound System) driver, i.e. the kernel sound drivers.
  56.     FSOUND_OUTPUT_ESD       ' Linux/Unix ESD (Enlightment Sound Daemon) driver.
  57.     FSOUND_OUTPUT_ALSA      ' Linux Alsa driver.
  58.  
  59.     FSOUND_OUTPUT_ASIO      ' Low latency ASIO driver
  60.     FSOUND_OUTPUT_XBOX      ' Xbox driver
  61.     FSOUND_OUTPUT_PS2       ' PlayStation 2 driver
  62.     FSOUND_OUTPUT_MAC       ' Mac SoundMager driver
  63.     FSOUND_OUTPUT_GC        ' Gamecube driver
  64.     FSOUND_OUTPUT_PSP           ' PlayStation Portable driver
  65.  
  66.     FSOUND_OUTPUT_NOSOUND_NONREALTIME  ' This is the same as nosound, but the sound generation is driven by FSOUND_Update
  67. End Enum
  68.  
  69.  
  70. ' FSOUND_MIXERTYPES
  71. ' These mixer types are used with FSOUND_SetMixer, to choose which mixer to use, or to act
  72. ' upon for other reasons using FSOUND_GetMixer.
  73. ' It is not nescessary to set the mixer.  FMOD will autodetect the best mixer for you.
  74. '
  75. Public Enum FSOUND_MIXERTYPES
  76.     FSOUND_MIXER_AUTODETECT         ' CE/PS2 Only - Non interpolating/low quality mixer
  77.     FSOUND_MIXER_BLENDMODE          ' removed / obsolete.
  78.     FSOUND_MIXER_MMXP5              ' removed / obsolete.
  79.     FSOUND_MIXER_MMXP6              ' removed / obsolete.
  80.  
  81.     FSOUND_MIXER_QUALITY_AUTODETECT ' All platforms - Autodetect the fastest quality mixer based on your cpu.
  82.     FSOUND_MIXER_QUALITY_FPU        ' Win32/Linux only - Interpolating/volume ramping FPU mixer.
  83.     FSOUND_MIXER_QUALITY_MMXP5      ' Win32/Linux only - Interpolating/volume ramping FPU mixer.
  84.     FSOUND_MIXER_QUALITY_MMXP6      ' Win32/Linux only - Interpolating/volume ramping ppro+ MMX mixer.
  85.    
  86.     FSOUND_MIXER_MONO               ' CE/PS2 only - MONO non interpolating/low quality mixer. For speed
  87.     FSOUND_MIXER_QUALITY_MONO       ' CE/PS2 only - MONO Interpolating mixer.  For speed
  88. End Enum
  89.  
  90.  
  91. ' FMUSIC_TYPES
  92. ' These definitions describe the type of song being played.
  93. ' See FMUSIC_GetType
  94. '
  95. Public Enum FMUSIC_TYPES
  96.     FMUSIC_TYPE_NONE
  97.     FMUSIC_TYPE_MOD         'Protracker / Fasttracker
  98.     FMUSIC_TYPE_S3M         'ScreamTracker 3
  99.     FMUSIC_TYPE_XM          'FastTracker 2
  100.     FMUSIC_TYPE_IT          'Impulse Tracker.
  101.     FMUSIC_TYPE_MIDI        'MIDI file
  102.     FMUSIC_TYPE_FSB         'FMOD Sample Bank file
  103. End Enum
  104.  
  105.  
  106. ' FSOUND_DSP_PRIORITIES
  107. ' These default priorities are used by FMOD internal system DSP units.  They describe the
  108. ' position of the DSP chain, and the order of how audio processing is executed.
  109. ' You can actually through the use of FSOUND_DSP_GetxxxUnit (where xxx is the name of the DSP
  110. ' unit), disable or even change the priority of a DSP unit.
  111. '
  112. Public Enum FSOUND_DSP_PRIORITIES
  113.     FSOUND_DSP_DEFAULTPRIORITY_CLEARUNIT = 0           'DSP CLEAR unit - done first
  114.     FSOUND_DSP_DEFAULTPRIORITY_SFXUNIT = 100           'DSP SFX unit - done second
  115.     FSOUND_DSP_DEFAULTPRIORITY_MUSICUNIT = 200         'DSP MUSIC unit - done third
  116.     FSOUND_DSP_DEFAULTPRIORITY_USER = 300              'User priority, use this as reference for your own dsp units
  117.     FSOUND_DSP_DEFAULTPRIORITY_FFTUNIT = 900           'This reads data for FSOUND_DSP_GetSpectrum, so it comes after user units
  118.     FSOUND_DSP_DEFAULTPRIORITY_CLIPANDCOPYUNIT = 1000  'DSP CLIP AND COPY unit - last
  119. End Enum
  120.  
  121.  
  122. ' FSOUND_CAPS
  123. ' Driver description bitfields.  Use FSOUND_Driver_GetCaps to determine if a driver enumerated
  124. ' has the settings you are after.  The enumerated driver depends on the output mode, see
  125. ' FSOUND_OUTPUTTYPES
  126. '
  127. Public Enum FSOUND_CAPS
  128.     FSOUND_CAPS_HARDWARE = &H1       ' This driver supports hardware accelerated 3d sound.
  129.     FSOUND_CAPS_EAX2 = &H2           ' This driver supports EAX 2 reverb
  130.     FSOUND_CAPS_EAX3 = &H10          ' This driver supports EAX 3 reverb
  131. End Enum
  132.  
  133.  
  134. ' FSOUND_MODES
  135. ' Sample description bitfields, OR them together for loading and describing samples.
  136. ' NOTE.  If the file format being loaded already has a defined format, such as WAV or MP3, then
  137. ' trying to override the pre-defined format with a new set of format flags will not work.  For
  138. ' example, an 8 bit WAV file will not load as 16bit if you specify FSOUND_16BITS.  It will just
  139. ' ignore the flag and go ahead loading it as 8bits.  For these type of formats the only flags
  140. ' you can specify that will really alter the behaviour of how it is loaded, are the following.
  141. '
  142. ' Looping behaviour - FSOUND_LOOP_OFF, FSOUND_LOOP_NORMAL, FSOUND_LOOP_BIDI
  143. ' Load destination - FSOUND_HW3D, FSOUND_HW2D, FSOUND_2D
  144. ' Loading behaviour - FSOUND_NONBLOCKING, FSOUND_LOADMEMORY, FSOUND_LOADRAW, FSOUND_MPEGACCURATE, FSOUND_MPEGHALFRATE, FSOUND_FORCEMONO
  145. ' Playback behaviour - FSOUND_STREAMABLE, FSOUND_ENABLEFX
  146. ' PlayStation 2 only - FSOUND_USECORE0, FSOUND_USECORE1, FSOUND_LOADMEMORYIOP
  147. '
  148. ' See flag descriptions for what these do.
  149. '
  150. Public Enum FSOUND_MODES
  151.     FSOUND_LOOP_OFF = &H1             ' For non looping samples.
  152.     fsound_loop_normal = &H2          ' For forward looping samples.
  153.     FSOUND_LOOP_BIDI = &H4            ' For bidirectional looping samples.  (no effect if in hardware).
  154.     FSOUND_8BITS = &H8                ' For 8 bit samples.
  155.     FSOUND_16BITS = &H10              ' For 16 bit samples.
  156.     FSOUND_MONO = &H20                ' For mono samples.
  157.     FSOUND_STEREO = &H40              ' For stereo samples.
  158.     FSOUND_UNSIGNED = &H80            ' For source data containing unsigned samples.
  159.     FSOUND_SIGNED = &H100             ' For source data containing signed data.
  160.     FSOUND_DELTA = &H200              ' For source data stored as delta values.
  161.     FSOUND_IT214 = &H400              ' For source data stored using IT214 compression.
  162.     FSOUND_IT215 = &H800              ' For source data stored using IT215 compression.
  163.     FSOUND_HW3D = &H1000              ' Attempts to make samples use 3d hardware acceleration. (if the card supports it)
  164.     FSOUND_2D = &H2000                ' Ignores any 3d processing.  overrides FSOUND_HW3D.  Located in software.
  165.     FSOUND_STREAMABLE = &H4000        ' For realtime streamable samples.  If you dont supply this sound may come out corrupted.
  166.     FSOUND_LOADMEMORY = &H8000        ' For FSOUND_Sample_Load - name will be interpreted as a pointer to data
  167.     FSOUND_LOADRAW = &H10000          ' For FSOUND_Sample_Load/FSOUND_Stream_Open - will ignore file format and treat as raw pcm.
  168.     FSOUND_MPEGACCURATE = &H20000     ' For FSOUND_Stream_Open - scans MP2/MP3 (VBR also) for accurate FSOUND_Stream_GetLengthMs/FSOUND_Stream_SetTime.
  169.     FSOUND_FORCEMONO = &H40000        ' For forcing stereo streams and samples to be mono - needed with FSOUND_HW3D - incurs speed hit
  170.     FSOUND_HW2D = &H80000             ' 2d hardware sounds.  allows hardware specific effects
  171.     FSOUND_ENABLEFX = &H100000        ' Allows DX8 FX to be played back on a sound.  Requires DirectX 8 - Note these sounds cant be played more than once, or have a changing frequency
  172.     FSOUND_MPEGHALFRATE = &H200000    ' For FMODCE only - decodes mpeg streams using a lower quality decode, but faster execution
  173.     FSOUND_XADPCM = &H400000          ' For XBOX only - Describes a user sample that its contents are compressed as XADPCM
  174.     FSOUND_VAG = &H800000             ' For PS2 only - Describes a user sample that its contents are compressed as Sony VAG format.
  175.     FSOUND_NONBLOCKING = &H1000000    ' For FSOUND_Stream_Open - Causes stream to open in the background and not block the foreground app - stream plays only when ready.
  176.     FSOUND_GCADPCM = &H2000000        ' For Gamecube only - Contents are compressed as Gamecube DSP-ADPCM format
  177.     FSOUND_MULTICHANNEL = &H4000000   ' For PS2 only - Contents are interleaved into a multi-channel (more than stereo) format
  178.     FSOUND_USECORE0 = &H8000000       ' For PS2 only - Sample/Stream is forced to use hardware voices 00-23
  179.     FSOUND_USECORE1 = &H10000000      ' For PS2 only - Sample/Stream is forced to use hardware voices 24-47
  180.     FSOUND_LOADMEMORYIOP = &H20000000 ' For PS2 only - "name" will be interpreted as a pointer to data for streaming and samples.  The address provided will be an IOP address
  181.         FSOUND_IGNORETAGS = &H40000000    ' Skips id3v2 etc tag checks when opening a stream, to reduce seek/read overhead when opening files (helps with CD performance)
  182.     FSOUND_STREAM_NET = &H80000000    ' Specifies an internet stream
  183.    
  184.     FSOUND_NORMAL = FSOUND_16BITS Or FSOUND_SIGNED Or FSOUND_MONO
  185. End Enum
  186.  
  187.  
  188. ' FSOUND_CDPLAYMODES
  189. ' Playback method for a CD Audio track, with FSOUND_CD_SetPlayMode
  190. '
  191. Public Enum FSOUND_CDPLAYMODES
  192.     FSOUND_CD_PLAYCONTINUOUS         'Starts from the current track and plays to end of CD.
  193.     FSOUND_CD_PLAYONCE               'Plays the specified track then stops.
  194.     FSOUND_CD_PLAYLOOPED             'Plays the specified track looped, forever until stopped manually.
  195.     FSOUND_CD_PLAYRANDOM             'Plays tracks in random order
  196. End Enum
  197.  
  198.  
  199. ' FSOUND_CHANNELSAMPLEMODE
  200. ' Miscellaneous values for FMOD functions.
  201. ' FSOUND_PlaySound, FSOUND_PlaySoundEx, FSOUND_Sample_Alloc, FSOUND_Sample_Load, FSOUND_SetPan
  202. '
  203. Public Enum FSOUND_CHANNELSAMPLEMODE
  204.     FSOUND_FREE = -1                 ' definition for dynamically allocated channel or sample
  205.     FSOUND_UNMANAGED = -2            ' definition for allocating a sample that is NOT managed by fsound
  206.     FSOUND_ALL = -3                  ' for a channel index or sample index, this flag affects ALL channels or samples available!  Not supported by all functions.
  207.     FSOUND_STEREOPAN = -1            ' definition for full middle stereo volume on both channels
  208.     FSOUND_SYSTEMCHANNEL = -1000     ' special channel ID for channel based functions that want to alter the global FSOUND software mixing output channel
  209.     FSOUND_SYSTEMSAMPLE = -1000      ' special sample ID for all sample based functions that want to alter the global FSOUND software mixing output sample
  210. End Enum
  211.  
  212.  
  213. ' FSOUND_REVERB_PROPERTIES
  214. ' FSOUND_Reverb_SetProperties, FSOUND_Reverb_GetProperties, FSOUND_REVERB_PROPERTYFLAGS
  215. '
  216. Public Type FSOUND_REVERB_PROPERTIES
  217.                                     ' MIN     MAX    DEFAULT DESCRIPTION
  218.     Environment         As Long     ' 0       25     0       sets all listener properties
  219.     EnvSize             As Single   ' 1.0     100.0  7.5     environment size in meters
  220.     EnvDiffusion        As Single   ' 0.0     1.0    1.0     environment diffusion
  221.     Room                As Long     ' -10000  0      -1000   room effect level (at mid frequencies)
  222.     RoomHF              As Long     ' -10000  0      -100    relative room effect level at high frequencies
  223.     RoomLF              As Long     ' -10000  0      0       relative room effect level at low frequencies
  224.     DecayTime           As Single   ' 0.1     20.0   1.49    reverberation decay time at mid frequencies
  225.     DecayHFRatio        As Single   ' 0.1     2.0    0.83    high-frequency to mid-frequency decay time ratio
  226.     DecayLFRatio        As Single   ' 0.1     2.0    1.0     low-frequency to mid-frequency decay time ratio
  227.     Reflections         As Long     ' -10000  1000   -2602   early reflections level relative to room effect
  228.     ReflectionsDelay    As Single   ' 0.0     0.3    0.007   initial reflection delay time
  229.     ReflectionsPan(3)   As Single   '                0,0,0   early reflections panning vector
  230.     Reverb              As Long     ' -1000   2000   200     late reverberation level relative to room effect
  231.     ReverbDelay         As Single   ' 0.0     0.1    0.011   late reverberation delay time relative to initial reflection
  232.     ReverbPan(3)        As Single   '                0,0,0   late reverberation panning vector
  233.     EchoTime            As Single   ' .075    0.25   0.25    echo time
  234.     EchoDepth           As Single   ' 0.0     1.0    0.0     echo depth
  235.     ModulationTime      As Single   ' 0.04    4.0    0.25    modulation time
  236.     ModulationDepth     As Single   ' 0.0     1.0    0.0     modulation depth
  237.     AirAbsorptionHF     As Single   ' -100    0.0    -5.0    change in level per meter at high frequencies
  238.     HFReference         As Single   ' 1000.0  20000  5000.0  reference high frequency (hz)
  239.     LFReference         As Single   ' 20.0    1000.0 250.0   reference low frequency (hz)
  240.     RoomRolloffFactor   As Single   ' 0.0     10.0   0.0     like FSOUND_3D_SetRolloffFactor but for room effect
  241.     Diffusion           As Single   ' 0.0     100.0  100.0   Value that controls the echo density in the late reverberation decay. (xbox only)
  242.     Density             As Single   ' 0.0     100.0  100.0   Value that controls the modal density in the late reverberation decay (xbox only)
  243.     flags               As Long     '                        modifies the behavior of above properties
  244. End Type
  245.  
  246.  
  247. ' FSOUND_REVERB_FLAGS
  248. ' Values for the Flags member of the FSOUND_REVERB_PROPERTIES structure.
  249. '
  250. Public Enum FSOUND_REVERB_PROPERTYFLAGS
  251.     FSOUND_REVERBFLAGS_DECAYTIMESCALE = &H1          ' EnvironmentSize affects reverberation decay time
  252.     FSOUND_REVERBFLAGS_REFLECTIONSSCALE = &H2        ' EnvironmentSize affects reflection level
  253.     FSOUND_REVERBFLAGS_REFLECTIONSDELAYSCALE = &H4   ' EnvironmentSize affects initial reflection delay time
  254.     FSOUND_REVERBFLAGS_REVERBSCALE = &H8             ' EnvironmentSize affects reflections level
  255.     FSOUND_REVERBFLAGS_REVERBDELAYSCALE = &H10       ' EnvironmentSize affects late reverberation delay time
  256.     FSOUND_REVERBFLAGS_DECAYHFLIMIT = &H20           ' AirAbsorptionHF affects DecayHFRatio
  257.     FSOUND_REVERBFLAGS_ECHOTIMESCALE = &H40          ' EnvironmentSize affects echo time
  258.     FSOUND_REVERBFLAGS_MODULATIONTIMESCALE = &H80    ' EnvironmentSize affects modulation time
  259.     FSOUND_REVERB_FLAGS_CORE0 = &H100                ' PS2 Only - Reverb is applied to CORE0 (hw voices 0-23)
  260.     FSOUND_REVERB_FLAGS_CORE1 = &H200                ' PS2 Only - Reverb is applied to CORE1 (hw voices 24-47)
  261.     FSOUND_REVERBFLAGS_DEFAULT = FSOUND_REVERBFLAGS_DECAYTIMESCALE Or FSOUND_REVERBFLAGS_REFLECTIONSSCALE Or FSOUND_REVERBFLAGS_REFLECTIONSDELAYSCALE Or FSOUND_REVERBFLAGS_REVERBSCALE Or FSOUND_REVERBFLAGS_REVERBDELAYSCALE Or FSOUND_REVERBFLAGS_DECAYHFLIMIT Or FSOUND_REVERB_FLAGS_CORE0 Or FSOUND_REVERB_FLAGS_CORE1
  262. End Enum
  263.  
  264.  
  265. ' FSOUND_REVERB_CHANNELPROPERTIES
  266. ' Structure defining the properties for a reverb source, related to a FSOUND channel.
  267. ' FSOUND_Reverb_SetEnvironment, FSOUND_Reverb_SetEnvironmentAdvanced
  268. '
  269. Public Type FSOUND_REVERB_CHANNELPROPERTIES
  270.     Direct               As Long     ' direct path level (at low and mid frequencies)
  271.     DirectHF             As Long     ' relative direct path level at high frequencies
  272.     Room                 As Long     ' room effect level (at low and mid frequencies)
  273.     RoomHF               As Long     ' relative room effect level at high frequencies
  274.     Obstruction          As Long     ' main obstruction control (attenuation at high frequencies)
  275.     ObstructionLFRatio   As Single   ' obstruction low-frequency level re. main control
  276.     Occlusion            As Long     ' main occlusion control (attenuation at high frequencies)
  277.     OcclustionLFRatio    As Single   ' occlusion low-frequency level re. main control
  278.     OcclusionRoomRatio   As Single   ' relative occlusion control for room effect
  279.     OcclusionDirectRatio As Single   ' relative occlusion control for direct path
  280.     Exclusion            As Long     ' main exlusion control (attenuation at high frequencies)
  281.     ExclusionLFRatio     As Single   ' exclusion low-frequency level re. main control
  282.     OutsideVolumeHF      As Long     ' outside sound cone level at high frequencies
  283.     DopplerFactor        As Single   ' like DS3D flDopplerFactor but per source
  284.     RolloffFactor        As Single   ' like DS3D flRolloffFactor but per source
  285.     RoomRolloffFactor    As Single   ' like DS3D flRolloffFactor but for room effect
  286.     AirAbsorptionFactor  As Single   ' multiplies AirAbsorptionHF member of FSOUND_REVERB_PROPERTIES
  287.     flags                As Long     ' modifies the behavior of properties
  288. End Type
  289.  
  290.  
  291. ' FSOUND_REVERB_CHANNELFLAGS
  292. ' Values for the Flags member of the FSOUND_REVERB_CHANNELPROPERTIES structure.
  293. '
  294. Public Enum FSOUND_REVERB_CHANNELFLAGS
  295.     FSOUND_REVERB_CHANNELFLAGS_DIRECTHFAUTO = &H1   ' Automatic setting of Direct due to distance from listener
  296.     FSOUND_REVERB_CHANNELFLAGS_ROOMAUTO = &H2       ' Automatic setting of Room due to distance from listener
  297.     FSOUND_REVERB_CHANNELFLAGS_ROOMHFAUTO = &H4     ' Automatic setting of RoomHF due to distance from listener
  298.     FSOUND_REVERB_CHANNELFLAGS_DEFAULT = FSOUND_REVERB_CHANNELFLAGS_DIRECTHFAUTO Or FSOUND_REVERB_CHANNELFLAGS_ROOMAUTO Or FSOUND_REVERB_CHANNELFLAGS_ROOMHFAUTO
  299. End Enum
  300.  
  301.  
  302. ' FSOUND_FX_MODES
  303. ' These values are used with FSOUND_FX_Enable to enable DirectX 8 FX for a channel.
  304. '
  305. Public Enum FSOUND_FX_MODES
  306.     FSOUND_FX_CHORUS
  307.     FSOUND_FX_COMPRESSOR
  308.     FSOUND_FX_DISTORTION
  309.     FSOUND_FX_ECHO
  310.     FSOUND_FX_FLANGER
  311.     FSOUND_FX_GARGLE
  312.     FSOUND_FX_I3DL2REVERB
  313.     FSOUND_FX_PARAMEQ
  314.     FSOUND_FX_WAVES_REVERB
  315. End Enum
  316.  
  317.  
  318. 'FSOUND_SPEAKERMODES
  319. 'These are speaker types defined for use with the FSOUND_SetSpeakerMode command.
  320. 'Note - Only reliably works with FSOUND_OUTPUT_DSOUND or FSOUND_OUTPUT_XBOX output modes.  Other output modes will only
  321. 'interpret FSOUND_SPEAKERMODE_MONO and set everything else to be stereo.
  322. 'Using either DolbyDigital or DTS will use whatever 5.1 digital mode is available if destination hardware is unsure.
  323. '
  324. Public Enum FSOUND_SPEAKERMODES
  325.     FSOUND_SPEAKERMODE_DOLBYDIGITAL  ' The audio is played through a speaker arrangement of surround speakers with a subwoofer.
  326.     FSOUND_SPEAKERMODE_HEADPHONE     ' The speakers are headphones.
  327.     FSOUND_SPEAKERMODE_MONO          ' The speakers are monaural.
  328.     FSOUND_SPEAKERMODE_QUAD          ' The speakers are quadraphonic.
  329.     FSOUND_SPEAKERMODE_STEREO        ' The speakers are stereo (default value).
  330.     FSOUND_SPEAKERMODE_SURROUND      ' The speakers are surround sound.
  331.     FSOUND_SPEAKERMODE_DTS           ' The audio is played through a speaker arrangement of surround speakers with a subwoofer.
  332.     FSOUND_SPEAKERMODE_PROLOGIC2     ' Dolby Prologic 2.  Playstation 2 and Gamecube only
  333. End Enum
  334.  
  335.  
  336. ' FSOUND_INIT_FLAGS
  337. ' Initialization flags.  Use them with FSOUND_Init in the flags parameter to change various behaviour.
  338. ' FSOUND_INIT_ENABLESYSTEMCHANNELFX Is an init mode which enables the FSOUND mixer buffer to be affected by DirectX 8 effects.
  339. ' Note that due to limitations of DirectSound, FSOUND_Init may fail if this is enabled because the buffersize is too small.
  340. ' This can be fixed with FSOUND_SetBufferSize.  Increase the BufferSize until it works.
  341. ' When it is enabled you can use the FSOUND_FX api, and use FSOUND_SYSTEMCHANNEL as the channel id when setting parameters.
  342. '
  343. Public Enum FSOUND_INITMODES
  344.     FSOUND_INIT_USEDEFAULTMIDISYNTH = &H1       'Causes MIDI playback to force software decoding.
  345.     FSOUND_INIT_GLOBALFOCUS = &H2               'For DirectSound output - sound is not muted when window is out of focus.
  346.     FSOUND_INIT_ENABLESYSTEMCHANNELFX = &H4     'For DirectSound output - Allows FSOUND_FX api to be used on global software mixer output!
  347.     FSOUND_INIT_ACCURATEVULEVELS = &H8          'This latency adjusts FSOUND_GetCurrentLevels, but incurs a small cpu and memory hit
  348.     FSOUND_INIT_PS2_DISABLECORE0REVERB = &H10   'PS2 only - Disable reverb on CORE 0 to regain SRAM
  349.     FSOUND_INIT_PS2_DISABLECORE1REVERB = &H20   'PS2 only - Disable reverb on CORE 1 to regain SRAM
  350.     FSOUND_INIT_PS2_SWAPDMACORES = &H40         'PS2 only - By default FMOD uses DMA CH0 for mixing, CH1 for uploads, this flag swaps them around
  351.     FSOUND_INIT_DONTLATENCYADJUST = &H80        'Callbacks are not latency adjusted, and are called at mix time.  Also information functions are immediate
  352.     FSOUND_INIT_GC_INITLIBS = &H100             'Gamecube only - Initializes GC audio libraries
  353.     FSOUND_INIT_STREAM_FROM_MAIN_THREAD = &H200 'Turns off fmod streamer thread, and makes streaming update from FSOUND_Update called by the user
  354.     FSOUND_INIT_PS2_USEVOLUMERAMPING = &H400    'PS2 only   - Turns on volume ramping system to remove hardware clicks.
  355.     FSOUND_INIT_DSOUND_DEFERRED = &H800         'Win32 only - For DirectSound output.  3D commands are batched together and executed at FSOUND_Update.
  356.     FSOUND_INIT_DSOUND_HRTF_LIGHT = &H1000      'Win32 only - For DirectSound output.  FSOUND_HW3D buffers use a slightly higher quality algorithm when 3d hardware acceleration is not present.
  357.     FSOUND_INIT_DSOUND_HRTF_FULL = &H2000       'Win32 only - For DirectSound output.  FSOUND_HW3D buffers use full quality 3d playback when 3d hardware acceleration is not present.
  358.     FSOUND_INIT_XBOX_REMOVEHEADROOM = &H4000    'XBox only - By default directsound attenuates all sound by 6db to avoid clipping/distortion.  CAUTION.  If you use this flag you are responsible for the final mix to make sure clipping / distortion doesn't happen.
  359.     FSOUND_INIT_PSP_SILENCEONUNDERRUN = &H8000  'PSP only - If streams skip / stutter when device is powered on, either increase stream buffersize, or use this flag instead to play silence while the UMD is recovering.
  360. End Enum
  361.  
  362.  
  363. ' FSOUND_STREAM_NET_STATUS
  364. ' Status values for internet streams. Use FSOUND_Stream_Net_GetStatus to get the current status of an internet stream.
  365. '
  366. Public Enum FSOUND_STREAM_NET_STATUS
  367.     FSOUND_STREAM_NET_NOTCONNECTED         ' Stream hasn't connected yet
  368.     FSOUND_STREAM_NET_CONNECTING           ' Stream is connecting to remote host
  369.     FSOUND_STREAM_NET_BUFFERING            ' Stream is buffering data
  370.     FSOUND_STREAM_NET_READY                ' Stream is ready to play
  371.     FSOUND_STREAM_NET_ERROR                ' Stream has suffered a fatal error
  372. End Enum
  373.  
  374.  
  375. ' FSOUND_TAGFIELD_TYPE
  376. ' Describes the type of a particular tag field.
  377. ' See FSOUND_Stream_GetNumTagFields, FSOUND_Stream_GetTagField, FSOUND_Stream_FindTagField
  378. '
  379. Public Enum FSOUND_TAGFIELD_TYPE
  380.     FSOUND_TAGFIELD_VORBISCOMMENT = 0     ' A vorbis comment
  381.     FSOUND_TAGFIELD_ID3V1                 ' Part of an ID3v1 tag
  382.     FSOUND_TAGFIELD_ID3V2                 ' An ID3v2 frame
  383.     FSOUND_TAGFIELD_SHOUTCAST             ' A SHOUTcast header line
  384.     FSOUND_TAGFIELD_ICECAST               ' An Icecast header line
  385.     FSOUND_TAGFIELD_ASF                   ' An Advanced Streaming Format header line
  386. End Enum
  387.  
  388.  
  389. ' FSOUND_STATUS_FLAGS
  390. ' These values describe the protocol and format of an internet stream. Use FSOUND_Stream_Net_GetStatus to retrieve this information for an open internet stream.
  391. '
  392. Public Enum FSOUND_STATUS_FLAGS
  393.     FSOUND_PROTOCOL_SHOUTCAST = &H1
  394.     FSOUND_PROTOCOL_ICECAST = &H2
  395.     FSOUND_PROTOCOL_HTTP = &H4
  396.     FSOUND_FORMAT_MPEG = &H10000
  397.     FSOUND_FORMAT_OGGVORBIS = &H20000
  398. End Enum
  399.  
  400. ' FSOUND_TOC_TAG
  401. ' FSOUND_Stream_Open, FSOUND_Stream_FindTagField
  402. '
  403. Public Type FSOUND_TOC_TAG
  404.     TagName(3)      As Byte         ' The string "TOC" (4th character is 0), just in case this structure is accidentally treated as a string.
  405.     NumTracks       As Long         ' The number of tracks on the CD.
  406.     min(99)         As Long         ' The start offset of each track in minutes.
  407.     Sec(99)         As Long         ' The start offset of each track in seconds.
  408.     Frame(99)       As Long         ' The start offset of each track in frames.
  409. End Type
  410.  
  411.  
  412. '/* ================================== */
  413. '/* Initialization / Global functions. */
  414. '/* ================================== */
  415.  
  416.  
  417. ' PRE - FSOUND_Init functions. These cant be called after FSOUND_Init is
  418. ' called (they will fail). They set up FMOD system functionality.
  419.  
  420.  
  421. Public Declare Function FSOUND_SetOutput Lib "fmod.dll" Alias "_FSOUND_SetOutput@4" (ByVal outputtype As FSOUND_OUTPUTTYPES) As Byte
  422. Public Declare Function FSOUND_SetDriver Lib "fmod.dll" Alias "_FSOUND_SetDriver@4" (ByVal driver As Long) As Byte
  423. Public Declare Function FSOUND_SetMixer Lib "fmod.dll" Alias "_FSOUND_SetMixer@4" (ByVal mixer As FSOUND_MIXERTYPES) As Byte
  424. Public Declare Function FSOUND_SetBufferSize Lib "fmod.dll" Alias "_FSOUND_SetBufferSize@4" (ByVal lenms As Long) As Byte
  425. Public Declare Function FSOUND_SetHWND Lib "fmod.dll" Alias "_FSOUND_SetHWND@4" (ByVal hwnd As Long) As Byte
  426. Public Declare Function FSOUND_SetMinHardwareChannels Lib "fmod.dll" Alias "_FSOUND_SetMinHardwareChannels@4" (ByVal min As Integer) As Byte
  427. Public Declare Function FSOUND_SetMaxHardwareChannels Lib "fmod.dll" Alias "_FSOUND_SetMaxHardwareChannels@4" (ByVal min As Integer) As Byte
  428. Public Declare Function FSOUND_SetMemorySystem Lib "fmod.dll" Alias "_FSOUND_SetMemorySystem@20" (ByVal pool As Long, ByVal poollen As Long, ByVal useralloc As Long, ByVal userrealloc As Long, ByVal userfree As Long) As Byte
  429.  
  430. '
  431. '   Main initialization / closedown functions.
  432. '   Note : Use FSOUND_INIT_USEDEFAULTMIDISYNTH with FSOUND_Init for software override
  433. '          with MIDI playback.
  434. '        : Use FSOUND_INIT_GLOBALFOCUS with FSOUND_Init to make sound audible no matter
  435. '          which window is in focus. (FSOUND_OUTPUT_DSOUND only)
  436. '
  437.  
  438. Public Declare Function FSOUND_Init Lib "fmod.dll" Alias "_FSOUND_Init@12" (ByVal mixrate As Long, ByVal maxchannels As Long, ByVal flags As FSOUND_INITMODES) As Byte
  439. Public Declare Function FSOUND_Close Lib "fmod.dll" Alias "_FSOUND_Close@0" () As Long
  440.  
  441. '
  442. '   Runtime system level functions
  443. '
  444.  
  445. Public Declare Function FSOUND_Update Lib "fmod.dll" Alias "_FSOUND_Update@0" () As Long
  446.  
  447. Public Declare Function FSOUND_SetSpeakerMode Lib "fmod.dll" Alias "_FSOUND_SetSpeakerMode@4" (ByVal speakermode As FSOUND_SPEAKERMODES) As Long
  448. Public Declare Function FSOUND_SetSFXMasterVolume Lib "fmod.dll" Alias "_FSOUND_SetSFXMasterVolume@4" (ByVal volume As Long) As Long
  449. Public Declare Function FSOUND_SetPanSeperation Lib "fmod.dll" Alias "_FSOUND_SetPanSeperation@4" (ByVal pansep As Single) As Long
  450. Public Declare Function FSOUND_File_SetCallbacks Lib "fmod.dll" Alias "_FSOUND_File_SetCallbacks@20" (ByVal OpenCallback As Long, ByVal CloseCallback As Long, ByVal ReadCallback As Long, ByVal SeekCallback As Long, ByVal TellCallback As Long) As Long
  451. '
  452.  

Tiếp
[code=VB6]
  1.  
  2. ' System information functions.
  3. '
  4.  
  5. Public Declare Function FSOUND_GetError Lib "fmod.dll" Alias "_FSOUND_GetError@0" () As FMOD_ERRORS
  6. Public Declare Function FSOUND_GetVersion Lib "fmod.dll" Alias "_FSOUND_GetVersion@0" () As Single
  7. Public Declare Function FSOUND_GetOutput Lib "fmod.dll" Alias "_FSOUND_GetOutput@0" () As FSOUND_OUTPUTTYPES
  8. Public Declare Function FSOUND_GetOutputHandle Lib "fmod.dll" Alias "_FSOUND_GetOutputHandle@0" () As Long
  9. Public Declare Function FSOUND_GetDriver Lib "fmod.dll" Alias "_FSOUND_GetDriver@0" () As Long
  10. Public Declare Function FSOUND_GetMixer Lib "fmod.dll" Alias "_FSOUND_GetMixer@0" () As FSOUND_MIXERTYPES
  11. Public Declare Function FSOUND_GetNumDrivers Lib "fmod.dll" Alias "_FSOUND_GetNumDrivers@0" () As Long
  12. Public Declare Function FSOUND_GetDriverName Lib "fmod.dll" Alias "_FSOUND_GetDriverName@4" (ByVal id As Long) As Long
  13. Public Declare Function FSOUND_GetDriverCaps Lib "fmod.dll" Alias "_FSOUND_GetDriverCaps@8" (ByVal id As Long, ByRef caps As Long) As Byte
  14. Public Declare Function FSOUND_GetOutputRate Lib "fmod.dll" Alias "_FSOUND_GetOutputRate@0" () As Long
  15. Public Declare Function FSOUND_GetMaxChannels Lib "fmod.dll" Alias "_FSOUND_GetMaxChannels@0" () As Long
  16. Public Declare Function FSOUND_GetMaxSamples Lib "fmod.dll" Alias "_FSOUND_GetMaxSamples@0" () As Long
  17. Public Declare Function FSOUND_GetSpeakerMode Lib "fmod.dll" Alias "_FSOUND_GetSpeakerMode@0" () As Long
  18. Public Declare Function FSOUND_GetSFXMasterVolume Lib "fmod.dll" Alias "_FSOUND_GetSFXMasterVolume@0" () As Long
  19. Public Declare Function FSOUND_GetNumHWChannels Lib "fmod.dll" Alias "_FSOUND_GetNumHWChannels@12" (ByRef num2d As Long, ByRef num3d As Long, ByRef total As Long)
  20. Public Declare Function FSOUND_GetChannelsPlaying Lib "fmod.dll" Alias "_FSOUND_GetChannelsPlaying@0" () As Long
  21. Public Declare Function FSOUND_GetCPUUsage Lib "fmod.dll" Alias "_FSOUND_GetCPUUsage@0" () As Single
  22. Public Declare Sub FSOUND_GetMemoryStats Lib "fmod.dll" Alias "_FSOUND_GetMemoryStats@8" (ByRef currentalloced As Long, ByRef maxalloced As Long)
  23.  
  24. '/* =================================== */
  25. '/* Sample management / load functions. */
  26. '/* =================================== */
  27.  
  28.  
  29. '   Sample creation and management functions
  30. '   Note : Use FSOUND_LOADMEMORY   flag with FSOUND_Sample_Load to load from memory.
  31. '          Use FSOUND_LOADRAW      flag with FSOUND_Sample_Load to treat as as raw pcm data.
  32.  
  33.  
  34. Public Declare Function FSOUND_Sample_Load Lib "fmod.dll" Alias "_FSOUND_Sample_Load@20" (ByVal index As Long, ByVal name As String, ByVal mode As FSOUND_MODES, ByVal offset As Long, ByVal length As Long) As Long
  35. Public Declare Function FSOUND_Sample_Alloc Lib "fmod.dll" Alias "_FSOUND_Sample_Alloc@28" (ByVal index As Long, ByVal length As Long, ByVal mode As Long, ByVal deffreq As Long, ByVal defvol As Long, ByVal defpan As Long, ByVal defpri As Long) As Long
  36. Public Declare Function FSOUND_Sample_Free Lib "fmod.dll" Alias "_FSOUND_Sample_Free@4" (ByVal sptr As Long) As Long
  37. Public Declare Function FSOUND_Sample_Upload Lib "fmod.dll" Alias "_FSOUND_Sample_Upload@12" (ByVal sptr As Long, ByRef srcdata As Long, ByVal mode As Long) As Byte
  38. Public Declare Function FSOUND_Sample_Lock Lib "fmod.dll" Alias "_FSOUND_Sample_Lock@28" (ByVal sptr As Long, ByVal offset As Long, ByVal length As Long, ByRef ptr1 As Long, ByRef ptr2 As Long, ByRef len1 As Long, ByRef len2 As Long) As Byte
  39. Public Declare Function FSOUND_Sample_Unlock Lib "fmod.dll" Alias "_FSOUND_Sample_Unlock@20" (ByVal sptr As Long, ByVal sptr1 As Long, ByVal sptr2 As Long, ByVal len1 As Long, ByVal len2 As Long) As Byte
  40.  
  41.  
  42. '   Sample control functions
  43.  
  44.  
  45. Public Declare Function FSOUND_Sample_SetMode Lib "fmod.dll" Alias "_FSOUND_Sample_SetMode@8" (ByVal sptr As Long, ByVal mode As FSOUND_MODES) As Byte
  46. Public Declare Function FSOUND_Sample_SetLoopPoints Lib "fmod.dll" Alias "_FSOUND_Sample_SetLoopPoints@12" (ByVal sptr As Long, ByVal loopstart As Long, ByVal loopend As Long) As Byte
  47. Public Declare Function FSOUND_Sample_SetDefaults Lib "fmod.dll" Alias "_FSOUND_Sample_SetDefaults@20" (ByVal sptr As Long, ByVal deffreq As Long, ByVal defvol As Long, ByVal defpan As Long, ByVal defpri As Long) As Byte
  48. Public Declare Function FSOUND_Sample_SetDefaultsEx Lib "fmod.dll" Alias "_FSOUND_Sample_SetDefaultsEx@32" (ByVal sptr As Long, ByVal deffreq As Long, ByVal defvol As Long, ByVal defpan As Long, ByVal defpri As Long, ByVal varfreq As Long, ByVal varvol As Long, ByVal varpan As Long) As Byte
  49. Public Declare Function FSOUND_Sample_SetMinMaxDistance Lib "fmod.dll" Alias "_FSOUND_Sample_SetMinMaxDistance@12" (ByVal sptr As Long, ByVal min As Single, ByVal max As Single) As Byte
  50. Public Declare Function FSOUND_Sample_SetMaxPlaybacks Lib "fmod.dll" Alias "_FSOUND_Sample_SetMaxPlaybacks@8" (ByVal sptr As Long, ByVal max As Long) As Byte
  51.  
  52.  
  53. '   Sample information functions
  54.  
  55.  
  56. Public Declare Function FSOUND_Sample_Get Lib "fmod.dll" Alias "_FSOUND_Sample_Get@4" (ByVal sampno As Long) As Long
  57. Public Declare Function FSOUND_Sample_GetName Lib "fmod.dll" Alias "_FSOUND_Sample_GetName@4" (ByVal sptr As Long) As Long
  58. Public Declare Function FSOUND_Sample_GetLength Lib "fmod.dll" Alias "_FSOUND_Sample_GetLength@4" (ByVal sptr As Long) As Long
  59. Public Declare Function FSOUND_Sample_GetLoopPoints Lib "fmod.dll" Alias "_FSOUND_Sample_GetLoopPoints@12" (ByVal sptr As Long, ByRef loopstart As Long, ByRef loopend As Long) As Byte
  60. Public Declare Function FSOUND_Sample_GetDefaults Lib "fmod.dll" Alias "_FSOUND_Sample_GetDefaults@20" (ByVal sptr As Long, ByRef deffreq As Long, ByRef defvol As Long, ByRef defpan As Long, ByRef defpri As Long) As Byte
  61. Public Declare Function FSOUND_Sample_GetDefaultsEx Lib "fmod.dll" Alias "_FSOUND_Sample_GetDefaultsEx@32" (ByVal sptr As Long, ByRef deffreq As Long, ByRef defvol As Long, ByRef defpan As Long, ByRef defpri As Long, ByRef varfreq As Long, ByRef varvol As Long, ByRef varpan As Long) As Byte
  62. Public Declare Function FSOUND_Sample_GetMode Lib "fmod.dll" Alias "_FSOUND_Sample_GetMode@4" (ByVal sptr As Long) As Long
  63. Public Declare Function FSOUND_Sample_GetMinMaxDistance Lib "fmod.dll" Alias "_FSOUND_Sample_GetMinMaxDistance@12" (ByVal sptr As Long, ByRef min As Single, ByRef max As Single) As Byte
  64.  
  65. '/* ============================ */
  66. '/* Channel control functions.   */
  67. '/* ============================ */
  68.  
  69.  
  70. '   Playing and stopping sounds.
  71. '   Note : Use FSOUND_FREE as the channel variable, to let FMOD pick a free channel for you.
  72. '          Use FSOUND_ALL as the channel variable to control ALL channels with one function call!
  73.  
  74.  
  75. Public Declare Function FSOUND_PlaySound Lib "fmod.dll" Alias "_FSOUND_PlaySound@8" (ByVal channel As Long, ByVal sptr As Long) As Long
  76. Public Declare Function FSOUND_PlaySoundEx Lib "fmod.dll" Alias "_FSOUND_PlaySoundEx@16" (ByVal channel As Long, ByVal sptr As Long, ByVal dsp As Long, ByVal startpaused As Byte) As Long
  77. Public Declare Function FSOUND_StopSound Lib "fmod.dll" Alias "_FSOUND_StopSound@4" (ByVal channel As Long) As Byte
  78.  
  79.  
  80. '   Functions to control playback of a channel.
  81. '   Note : FSOUND_ALL can be used on most of these functions as a channel value.
  82.  
  83.  
  84. Public Declare Function FSOUND_SetFrequency Lib "fmod.dll" Alias "_FSOUND_SetFrequency@8" (ByVal channel As Long, ByVal freq As Long) As Byte
  85. Public Declare Function FSOUND_SetVolume Lib "fmod.dll" Alias "_FSOUND_SetVolume@8" (ByVal channel As Long, ByVal Vol As Long) As Byte
  86. Public Declare Function FSOUND_SetVolumeAbsolute Lib "fmod.dll" Alias "_FSOUND_SetVolumeAbsolute@8" (ByVal channel As Long, ByVal Vol As Long) As Byte
  87. Public Declare Function FSOUND_SetPan Lib "fmod.dll" Alias "_FSOUND_SetPan@8" (ByVal channel As Long, ByVal pan As Long) As Byte
  88. Public Declare Function FSOUND_SetSurround Lib "fmod.dll" Alias "_FSOUND_SetSurround@8" (ByVal channel As Long, ByVal surround As Long) As Byte
  89. Public Declare Function FSOUND_SetMute Lib "fmod.dll" Alias "_FSOUND_SetMute@8" (ByVal channel As Long, ByVal mute As Byte) As Byte
  90. Public Declare Function FSOUND_SetPriority Lib "fmod.dll" Alias "_FSOUND_SetPriority@8" (ByVal channel As Long, ByVal Priority As Long) As Byte
  91. Public Declare Function FSOUND_SetReserved Lib "fmod.dll" Alias "_FSOUND_SetReserved@8" (ByVal channel As Long, ByVal reserved As Long) As Byte
  92. Public Declare Function FSOUND_SetPaused Lib "fmod.dll" Alias "_FSOUND_SetPaused@8" (ByVal channel As Long, ByVal Paused As Byte) As Byte
  93. Public Declare Function FSOUND_SetLoopMode Lib "fmod.dll" Alias "_FSOUND_SetLoopMode@8" (ByVal channel As Long, ByVal loopmode As Long) As Byte
  94. Public Declare Function FSOUND_SetCurrentPosition Lib "fmod.dll" Alias "_FSOUND_SetCurrentPosition@8" (ByVal channel As Long, ByVal offset As Long) As Byte
  95. Public Declare Function FSOUND_3D_SetAttributes Lib "fmod.dll" Alias "_FSOUND_3D_SetAttributes@12" (ByVal channel As Long, ByRef Pos As Single, ByRef vel As Single) As Byte
  96. Public Declare Function FSOUND_3D_SetMinMaxDistance Lib "fmod.dll" Alias "_FSOUND_3D_SetMinMaxDistance@12" (ByVal channel As Long, ByVal min As Single, ByVal max As Single) As Byte
  97.  
  98. '
  99. '   Channel information functions.
  100. '
  101.  
  102. Public Declare Function FSOUND_IsPlaying Lib "fmod.dll" Alias "_FSOUND_IsPlaying@4" (ByVal channel As Long) As Byte
  103. Public Declare Function FSOUND_GetFrequency Lib "fmod.dll" Alias "_FSOUND_GetFrequency@4" (ByVal channel As Long) As Long
  104. Public Declare Function FSOUND_GetVolume Lib "fmod.dll" Alias "_FSOUND_GetVolume@4" (ByVal channel As Long) As Long
  105. Public Declare Function FSOUND_GetAmplitude Lib "fmod.dll" Alias "_FSOUND_GetAmplitude@4" (ByVal channel As Long) As Long
  106. Public Declare Function FSOUND_GetPan Lib "fmod.dll" Alias "_FSOUND_GetPan@4" (ByVal channel As Long) As Long
  107. Public Declare Function FSOUND_GetSurround Lib "fmod.dll" Alias "_FSOUND_GetSurround@4" (ByVal channel As Long) As Byte
  108. Public Declare Function FSOUND_GetMute Lib "fmod.dll" Alias "_FSOUND_GetMute@4" (ByVal channel As Long) As Byte
  109. Public Declare Function FSOUND_GetPriority Lib "fmod.dll" Alias "_FSOUND_GetPriority@4" (ByVal channel As Long) As Long
  110. Public Declare Function FSOUND_GetReserved Lib "fmod.dll" Alias "_FSOUND_GetReserved@4" (ByVal channel As Long) As Byte
  111. Public Declare Function FSOUND_GetPaused Lib "fmod.dll" Alias "_FSOUND_GetPaused@4" (ByVal channel As Long) As Byte
  112. Public Declare Function FSOUND_GetLoopMode Lib "fmod.dll" Alias "_FSOUND_GetLoopMode@4" (ByVal channel As Long) As Long
  113. Public Declare Function FSOUND_GetCurrentPosition Lib "fmod.dll" Alias "_FSOUND_GetCurrentPosition@4" (ByVal channel As Long) As Long
  114. Public Declare Function FSOUND_GetCurrentSample Lib "fmod.dll" Alias "_FSOUND_GetCurrentSample@4" (ByVal channel As Long) As Long
  115. Public Declare Function FSOUND_GetCurrentLevels Lib "fmod.dll" Alias "_FSOUND_GetCurrentLevels@12" (ByVal channel As Long, ByRef l As Single, ByRef r As Single) As Byte
  116. Public Declare Function FSOUND_GetNumSubChannels Lib "fmod.dll" Alias "_FSOUND_GetNumSubChannels@4" (ByVal channel As Long) As Long
  117. Public Declare Function FSOUND_GetSubChannel Lib "fmod.dll" Alias "_FSOUND_GetSubChannel@8" (ByVal channel As Long, ByVal subchannel As Long) As Long
  118. Public Declare Function FSOUND_3D_GetAttributes Lib "fmod.dll" Alias "_FSOUND_3D_GetAttributes@12" (ByVal channel As Long, ByRef Pos As Single, ByRef vel As Single) As Byte
  119. Public Declare Function FSOUND_3D_GetMinMaxDistance Lib "fmod.dll" Alias "_FSOUND_3D_GetMinMaxDistance@12" (ByVal channel As Long, ByRef min As Single, ByRef max As Single) As Byte
  120.  
  121. '/* ========================== */
  122. '/* Global 3D sound functions. */
  123. '/* ========================== */
  124.  
  125. '
  126. '    See also 3d sample and channel based functions above.
  127. '    Call FSOUND_Update once a frame to process 3d information.
  128. '
  129.  
  130. Public Declare Function FSOUND_3D_Listener_SetCurrent Lib "fmod.dll" Alias "_FSOUND_3D_Listener_SetCurrent@8" (ByVal current As Long) As Long
  131. Public Declare Function FSOUND_3D_Listener_SetAttributes Lib "fmod.dll" Alias "_FSOUND_3D_Listener_SetAttributes@32" (ByVal Pos As Single, ByVal vel As Single, ByVal fx As Single, ByVal fy As Single, ByVal fz As Single, ByVal tx As Single, ByVal ty As Single, ByVal tz As Single) As Long
  132. Public Declare Function FSOUND_3D_Listener_GetAttributes Lib "fmod.dll" Alias "_FSOUND_3D_Listener_GetAttributes@32" (ByRef Pos As Single, ByRef vel As Single, ByRef fx As Single, ByRef fy As Single, ByRef fz As Single, ByRef tx As Single, ByRef ty As Single, ByRef tz As Single) As Long
  133. Public Declare Function FSOUND_3D_SetDopplerFactor Lib "fmod.dll" Alias "_FSOUND_3D_SetDopplerFactor@4" (ByVal fscale As Single) As Long
  134. Public Declare Function FSOUND_3D_SetDistanceFactor Lib "fmod.dll" Alias "_FSOUND_3D_SetDistanceFactor@4" (ByVal fscale As Single) As Long
  135. Public Declare Function FSOUND_3D_SetRolloffFactor Lib "fmod.dll" Alias "_FSOUND_3D_SetRolloffFactor@4" (ByVal fscale As Single) As Long
  136.  
  137. '/* =================== */
  138. '/* FX functions.       */
  139. '/* =================== */
  140.  
  141.  
  142. '   Functions to control DX8 only effects processing.
  143. '
  144. '   - FX enabled samples can only be played once at a time, not multiple times at once.
  145. '   - Sounds have to be created with FSOUND_HW2D or FSOUND_HW3D for this to work.
  146. '   - FSOUND_INIT_ENABLESYSTEMCHANNELFX can be used to apply hardware effect processing to the
  147. '     global mixed output of FMOD's software channels.
  148. '   - FSOUND_FX_Enable returns an FX handle that you can use to alter fx parameters.
  149. '   - FSOUND_FX_Enable can be called multiple times in a row, even on the same FX type,
  150. '     it will return a unique handle for each FX.
  151. '   - FSOUND_FX_Enable cannot be called if the sound is playing or locked.
  152. '   - FSOUND_FX_Disable must be called to reset/clear the FX from a channel.
  153.  
  154.  
  155. Public Declare Function FSOUND_FX_Enable Lib "fmod.dll" Alias "_FSOUND_FX_Enable@8" (ByVal channel As Long, ByVal fx As FSOUND_FX_MODES) As Long
  156. Public Declare Function FSOUND_FX_Disable Lib "fmod.dll" Alias "_FSOUND_FX_Disable@4" (ByVal channel As Long) As Byte
  157.  
  158. Public Declare Function FSOUND_FX_SetChorus Lib "fmod.dll" Alias "_FSOUND_FX_SetChorus@32" (ByVal fxid As Long, ByVal WetDryMix As Single, ByVal Depth As Single, ByVal Feedback As Single, ByVal Frequency As Single, ByVal Waveform As Long, ByVal Delay As Single, ByVal Phase As Long) As Byte
  159. Public Declare Function FSOUND_FX_SetCompressor Lib "fmod.dll" Alias "_FSOUND_FX_SetCompressor@28" (ByVal fxid As Long, ByVal Gain As Single, ByVal Attack As Single, ByVal Release As Single, ByVal Threshold As Single, ByVal Ratio As Single, ByVal Predelay As Single) As Byte
  160. Public Declare Function FSOUND_FX_SetDistortion Lib "fmod.dll" Alias "_FSOUND_FX_SetDistortion@24" (ByVal fxid As Long, ByVal Gain As Single, ByVal Edge As Single, ByVal PostEQCenterFrequency As Single, ByVal PostEQBandwidth As Single, ByVal PreLowpassCutoff As Single) As Byte
  161. Public Declare Function FSOUND_FX_SetEcho Lib "fmod.dll" Alias "_FSOUND_FX_SetEcho@24" (ByVal fxid As Long, ByVal WetDryMix As Single, ByVal Feedback As Single, ByVal LeftDelay As Single, ByVal RightDelay As Single, ByVal PanDelay As Long) As Byte
  162. Public Declare Function FSOUND_FX_SetFlanger Lib "fmod.dll" Alias "_FSOUND_FX_SetFlanger@32" (ByVal fxid As Long, ByVal WetDryMix As Single, ByVal Depth As Single, ByVal Feedback As Single, ByVal Frequency As Single, ByVal Waveform As Long, ByVal Delay As Single, ByVal Phase As Long) As Byte
  163. Public Declare Function FSOUND_FX_SetGargle Lib "fmod.dll" Alias "_FSOUND_FX_SetGargle@12" (ByVal fxid As Long, ByVal RateHz As Long, ByVal WaveShape As Long) As Byte
  164. Public Declare Function FSOUND_FX_SetI3DL2Reverb Lib "fmod.dll" Alias "_FSOUND_FX_SetI3DL2Reverb@52" (ByVal fxid As Long, ByVal Room As Long, ByVal RoomHF As Long, ByVal RoomRolloffFactor As Single, ByVal DecayTime As Single, ByVal DecayHFRatio As Single, ByVal Reflections As Long, ByVal ReflectionsDelay As Single, ByVal Reverb As Long, ByVal ReverbDelay As Single, ByVal Diffusion As Single, ByVal Density As Single, ByVal HFReference As Single) As Byte
  165. Public Declare Function FSOUND_FX_SetParamEQ Lib "fmod.dll" Alias "_FSOUND_FX_SetParamEQ@16" (ByVal fxid As Long, ByVal Center As Single, ByVal Bandwidth As Single, ByVal Gain As Single) As Byte
  166. Public Declare Function FSOUND_FX_SetWavesReverb Lib "fmod.dll" Alias "_FSOUND_FX_SetWavesReverb@20" (ByVal fxid As Long, ByVal InGain As Single, ByVal ReverbMix As Single, ByVal ReverbTime As Single, ByVal HighFreqRTRatio As Single) As Byte
  167.  
  168. ' ========================= */
  169. ' File Streaming functions. */
  170. ' ========================= */
  171.  
  172. '
  173. '    Note : Use FSOUND_LOADMEMORY   flag with FSOUND_Stream_Open to stream from memory.
  174. '           Use FSOUND_LOADRAW      flag with FSOUND_Stream_Open to treat stream as raw pcm data.
  175. '           Use FSOUND_MPEGACCURATE flag with FSOUND_Stream_Open to open mpegs in 'accurate mode' for settime/gettime/getlengthms.
  176. '           Use FSOUND_FREE as the 'channel' variable, to let FMOD pick a free channel for you.
  177. '
  178.  
  179. Public Declare Function FSOUND_Stream_SetBufferSize Lib "fmod.dll" Alias "_FSOUND_Stream_SetBufferSize@4" (ByVal ms As Long) As Byte
  180.  
  181. Public Declare Function FSOUND_Stream_Open Lib "fmod.dll" Alias "_FSOUND_Stream_Open@16" (ByVal filename As String, ByVal mode As FSOUND_MODES, ByVal offset As Long, ByVal length As Long) As Long
  182. Public Declare Function FSOUND_Stream_Open2 Lib "fmod.dll" Alias "_FSOUND_Stream_Open@16" (ByRef data As Byte, ByVal mode As FSOUND_MODES, ByVal offset As Long, ByVal length As Long) As Long
  183. Public Declare Function FSOUND_Stream_Create Lib "fmod.dll" Alias "_FSOUND_Stream_Create@20" (ByVal callback As Long, ByVal length As Long, ByVal mode As Long, ByVal samplerate As Long, ByVal userdata As Long) As Long
  184. Public Declare Function FSOUND_Stream_Close Lib "fmod.dll" Alias "_FSOUND_Stream_Close@4" (ByVal stream As Long) As Byte
  185.  
  186. Public Declare Function FSOUND_Stream_Play Lib "fmod.dll" Alias "_FSOUND_Stream_Play@8" (ByVal channel As Long, ByVal stream As Long) As Long
  187. Public Declare Function FSOUND_Stream_PlayEx Lib "fmod.dll" Alias "_FSOUND_Stream_PlayEx@16" (ByVal channel As Long, ByVal stream As Long, ByVal dsp As Long, ByVal startpaused As Byte) As Long
  188. Public Declare Function FSOUND_Stream_Stop Lib "fmod.dll" Alias "_FSOUND_Stream_Stop@4" (ByVal stream As Long) As Byte
  189.  
  190. Public Declare Function FSOUND_Stream_SetPosition Lib "fmod.dll" Alias "_FSOUND_Stream_SetPosition@8" (ByVal stream As Long, ByVal positition As Long) As Byte
  191. Public Declare Function FSOUND_Stream_GetPosition Lib "fmod.dll" Alias "_FSOUND_Stream_GetPosition@4" (ByVal stream As Long) As Long
  192. Public Declare Function FSOUND_Stream_SetTime Lib "fmod.dll" Alias "_FSOUND_Stream_SetTime@8" (ByVal stream As Long, ByVal ms As Long) As Byte
  193. Public Declare Function FSOUND_Stream_GetTime Lib "fmod.dll" Alias "_FSOUND_Stream_GetTime@4" (ByVal stream As Long) As Long
  194. Public Declare Function FSOUND_Stream_GetLength Lib "fmod.dll" Alias "_FSOUND_Stream_GetLength@4" (ByVal stream As Long) As Long
  195. Public Declare Function FSOUND_Stream_GetLengthMs Lib "fmod.dll" Alias "_FSOUND_Stream_GetLengthMs@4" (ByVal stream As Long) As Long
  196.  
  197. Public Declare Function FSOUND_Stream_SetMode Lib "fmod.dll" Alias "_FSOUND_Stream_SetMode@8" (ByVal stream As Long, ByVal mode As Long) As Byte
  198. Public Declare Function FSOUND_Stream_GetMode Lib "fmod.dll" Alias "_FSOUND_Stream_GetMode@4" (ByVal stream As Long) As Long
  199. Public Declare Function FSOUND_Stream_SetLoopPoints Lib "fmod.dll" Alias "_FSOUND_Stream_SetLoopPoints@12" (ByVal stream As Long, ByVal loopstartpcm As Long, ByVal loopendpcm As Long) As Byte
  200. Public Declare Function FSOUND_Stream_SetLoopCount Lib "fmod.dll" Alias "_FSOUND_Stream_SetLoopCount@8" (ByVal stream As Long, ByVal count As Long) As Byte
  201. Public Declare Function FSOUND_Stream_GetOpenState Lib "fmod.dll" Alias "_FSOUND_Stream_GetOpenState@4" (ByVal stream As Long) As Long
  202. Public Declare Function FSOUND_Stream_GetSample Lib "fmod.dll" Alias "_FSOUND_Stream_GetSample@4" (ByVal stream As Long) As Long
  203. Public Declare Function FSOUND_Stream_CreateDSP Lib "fmod.dll" Alias "_FSOUND_Stream_CreateDSP@16" (ByVal stream As Long, ByVal callback As Long, ByVal Priority As Long, ByVal userdata As Long) As Long
  204.  
  205. Public Declare Function FSOUND_Stream_SetEndCallback Lib "fmod.dll" Alias "_FSOUND_Stream_SetEndCallback@12" (ByVal stream As Long, ByVal callback As Long, ByVal userdata As Long) As Byte
  206. Public Declare Function FSOUND_Stream_SetSyncCallback Lib "fmod.dll" Alias "_FSOUND_Stream_SetSyncCallback@12" (ByVal stream As Long, ByVal callback As Long, ByVal userdata As Long) As Byte
  207.  
  208. Public Declare Function FSOUND_Stream_AddSyncPoint Lib "fmod.dll" Alias "_FSOUND_Stream_AddSyncPoint@12" (ByVal stream As Long, ByVal pcmoffset As Long, ByVal name As String) As Long
  209. Public Declare Function FSOUND_Stream_DeleteSyncPoint Lib "fmod.dll" Alias "_FSOUND_Stream_DeleteSyncPoint@4" (ByVal point As Long) As Byte
  210. Public Declare Function FSOUND_Stream_GetNumSyncPoints Lib "fmod.dll" Alias "_FSOUND_Stream_GetNumSyncPoints@4" (ByVal stream As Long) As Long
  211. Public Declare Function FSOUND_Stream_GetSyncPoint Lib "fmod.dll" Alias "_FSOUND_Stream_GetSyncPoint@8" (ByVal stream As Long, ByVal index As Long) As Long
  212. Public Declare Function FSOUND_Stream_GetSyncPointInfo Lib "fmod.dll" Alias "_FSOUND_Stream_GetSyncPointInfo@8" (ByVal point As Long, ByRef pcmoffset As Long) As Long
  213.  
  214. Public Declare Function FSOUND_Stream_SetSubStream Lib "fmod.dll" Alias "_FSOUND_Stream_SetSubStream@8" (ByVal stream As Long, ByVal index As Long) As Byte
  215. Public Declare Function FSOUND_Stream_GetNumSubStreams Lib "fmod.dll" Alias "_FSOUND_Stream_GetNumSubStreams@4" (ByVal stream As Long) As Long
  216. Public Declare Function FSOUND_Stream_SetSubStreamSentence Lib "fmod.dll" Alias "_FSOUND_Stream_SetSubStreamSentence@12" (ByVal stream As Long, ByRef sentencelist As Long, ByVal numitems As Long) As Byte
  217.  
  218. Public Declare Function FSOUND_Stream_GetNumTagFields Lib "fmod.dll" Alias "_FSOUND_Stream_GetNumTagFields@8" (ByVal stream As Long, ByRef num As Long) As Byte
  219. Public Declare Function FSOUND_Stream_GetTagField Lib "fmod.dll" Alias "_FSOUND_Stream_GetTagField@24" (ByVal stream As Long, ByVal num As Long, ByRef tagtype As Long, ByRef name As Long, ByRef value As Long, ByRef length As Long) As Byte
  220. Public Declare Function FSOUND_Stream_FindTagField Lib "fmod.dll" Alias "_FSOUND_Stream_FindTagField@20" (ByVal stream As Long, ByVal tagtype As Long, ByVal name As String, ByRef value As Long, ByRef length As Long) As Byte
  221.  
  222. '
  223. '   Internet streaming functions
  224. '
  225.  
  226. Public Declare Function FSOUND_Stream_Net_SetProxy Lib "fmod.dll" Alias "_FSOUND_Stream_Net_SetProxy@4" (ByVal proxy As String) As Byte
  227. Public Declare Function FSOUND_Stream_Net_GetLastServerStatus Lib "fmod.dll" Alias "_FSOUND_Stream_Net_GetLastServerStatus@0" () As Long
  228. Public Declare Function FSOUND_Stream_Net_SetBufferProperties Lib "fmod.dll" Alias "_FSOUND_Stream_Net_SetBufferProperties@12" (ByVal buffersize As Long, ByVal prebuffer_percent As Long, ByVal rebuffer_percent As Long) As Byte
  229. Public Declare Function FSOUND_Stream_Net_GetBufferProperties Lib "fmod.dll" Alias "_FSOUND_Stream_Net_GetBufferProperties@12" (ByRef buffersize As Long, ByRef prebuffer_percent As Long, ByRef rebuffer_percent As Long) As Byte
  230. Public Declare Function FSOUND_Stream_Net_SetMetadataCallback Lib "fmod.dll" Alias "_FSOUND_Stream_Net_SetMetadataCallback@12" (ByVal stream As Long, ByVal callback As Long, ByVal userdata As Long) As Byte
  231. Public Declare Function FSOUND_Stream_Net_GetStatus Lib "fmod.dll" Alias "_FSOUND_Stream_Net_GetStatus@20" (ByVal stream As Long, ByRef status As Long, ByRef bufferpercentused As Long, ByRef bitrate As Long, ByRef flags As Long) As Byte
  232.  
  233. '/* =================== */
  234. '/* CD audio functions. */
  235. '/* =================== */
  236.  
  237.  
  238. '   Note : 0 = default cdrom.  Otherwise specify the drive letter, for example. 'D'.
  239.  
  240.  
  241. Public Declare Function FSOUND_CD_Play Lib "fmod.dll" Alias "_FSOUND_CD_Play@8" (ByVal drive As Byte, ByVal Track As Long) As Byte
  242. Public Declare Function FSOUND_CD_SetPlayMode Lib "fmod.dll" Alias "_FSOUND_CD_SetPlayMode@8" (ByVal drive As Byte, ByVal mode As FSOUND_CDPLAYMODES) As Long
  243. Public Declare Function FSOUND_CD_Stop Lib "fmod.dll" Alias "_FSOUND_CD_Stop@4" (ByVal drive As Byte) As Byte
  244. Public Declare Function FSOUND_CD_SetPaused Lib "fmod.dll" Alias "_FSOUND_CD_SetPaused@8" (ByVal drive As Byte, ByVal Paused As Byte) As Byte
  245. Public Declare Function FSOUND_CD_SetVolume Lib "fmod.dll" Alias "_FSOUND_CD_SetVolume@8" (ByVal drive As Byte, ByVal volume As Long) As Byte
  246. Public Declare Function FSOUND_CD_SetTrackTime Lib "fmod.dll" Alias "_FSOUND_CD_SetTrackTime@8" (ByVal drive As Byte, ByVal ms As Long) As Byte
  247. Public Declare Function FSOUND_CD_OpenTray Lib "fmod.dll" Alias "_FSOUND_CD_OpenTray@8" (ByVal drive As Byte, ByVal openState As Byte) As Byte
  248.  
  249. Public Declare Function FSOUND_CD_GetPaused Lib "fmod.dll" Alias "_FSOUND_CD_GetPaused@4" (ByVal drive As Byte) As Byte
  250. Public Declare Function FSOUND_CD_GetTrack Lib "fmod.dll" Alias "_FSOUND_CD_GetTrack@4" (ByVal drive As Byte) As Long
  251. Public Declare Function FSOUND_CD_GetNumTracks Lib "fmod.dll" Alias "_FSOUND_CD_GetNumTracks@4" (ByVal drive As Byte) As Long
  252. Public Declare Function FSOUND_CD_GetVolume Lib "fmod.dll" Alias "_FSOUND_CD_GetVolume@4" (ByVal drive As Byte) As Long
  253. Public Declare Function FSOUND_CD_GetTrackLength Lib "fmod.dll" Alias "_FSOUND_CD_GetTrackLength@8" (ByVal drive As Byte, ByVal Track As Long) As Long
  254. Public Declare Function FSOUND_CD_GetTrackTime Lib "fmod.dll" Alias "_FSOUND_CD_GetTrackTime@4" (ByVal drive As Byte) As Long
  255.  
  256. '/* ============== */
  257. '/* DSP functions. */
  258. '/* ============== */
  259.  
  260.  
  261. '   DSP Unit control and information functions.
  262. '   These functions allow you access to the mixed stream that FMOD uses to play back sound on.
  263.  
  264.  
  265. Public Declare Function FSOUND_DSP_Create Lib "fmod.dll" Alias "_FSOUND_DSP_Create@12" (ByVal callback As Long, ByVal Priority As Long, ByVal param As Long) As Long
  266. Public Declare Function FSOUND_DSP_Free Lib "fmod.dll" Alias "_FSOUND_DSP_Free@4" (ByVal unit As Long) As Long
  267. Public Declare Function FSOUND_DSP_SetPriority Lib "fmod.dll" Alias "_FSOUND_DSP_SetPriority@8" (ByVal unit As Long, ByVal Priority As Long) As Long
  268. Public Declare Function FSOUND_DSP_GetPriority Lib "fmod.dll" Alias "_FSOUND_DSP_GetPriority@4" (ByVal unit As Long) As Long
  269. Public Declare Function FSOUND_DSP_SetActive Lib "fmod.dll" Alias "_FSOUND_DSP_SetActive@8" (ByVal unit As Long, ByVal active As Integer) As Long
  270. Public Declare Function FSOUND_DSP_GetActive Lib "fmod.dll" Alias "_FSOUND_DSP_GetActive@4" (ByVal unit As Long) As Byte
  271.  
  272.  
  273. '   Functions to get hold of FSOUND 'system DSP unit' handles
  274.  
  275.  
  276. Public Declare Function FSOUND_DSP_GetClearUnit Lib "fmod.dll" Alias "_FSOUND_DSP_GetClearUnit@0" () As Long
  277. Public Declare Function FSOUND_DSP_GetSFXUnit Lib "fmod.dll" Alias "_FSOUND_DSP_GetSFXUnit@0" () As Long
  278. Public Declare Function FSOUND_DSP_GetMusicUnit Lib "fmod.dll" Alias "_FSOUND_DSP_GetMusicUnit@0" () As Long
  279. Public Declare Function FSOUND_DSP_GetFFTUnit Lib "fmod.dll" Alias "_FSOUND_DSP_GetFFTUnit@0" () As Long
  280. Public Declare Function FSOUND_DSP_GetClipAndCopyUnit Lib "fmod.dll" Alias "_FSOUND_DSP_GetClipAndCopyUnit@0" () As Long
  281.  
  282.  
  283. '   Miscellaneous DSP functions
  284. '   Note for the spectrum analysis function to work, you have to enable the FFT DSP unit with
  285. '   the following code FSOUND_DSP_SetActive(FSOUND_DSP_GetFFTUnit(), TRUE);
  286. '   It is off by default to save cpu usage.
  287.  
  288.  
  289. Public Declare Function FSOUND_DSP_MixBuffers Lib "fmod.dll" Alias "_FSOUND_DSP_MixBuffers@28" (ByVal destbuffer As Long, ByVal srcbuffer As Long, ByVal length As Long, ByVal freq As Long, ByVal Vol As Long, ByVal pan As Long, ByVal mode As Long) As Byte
  290. Public Declare Function FSOUND_DSP_ClearMixBuffer Lib "fmod.dll" Alias "_FSOUND_DSP_ClearMixBuffer@0" () As Long
  291. Public Declare Function FSOUND_DSP_GetBufferLength Lib "fmod.dll" Alias "_FSOUND_DSP_GetBufferLength@0" () As Long
  292. Public Declare Function FSOUND_DSP_GetBufferLengthTotal Lib "fmod.dll" Alias "_FSOUND_DSP_GetBufferLengthTotal@0" () As Long
  293. Public Declare Function FSOUND_DSP_GetSpectrum Lib "fmod.dll" Alias "_FSOUND_DSP_GetSpectrum@0" () As Long
  294.  
  295. '/* =================================================================================== */
  296. '/* Reverb functions. (eax2/eax3 reverb)  (ONLY SUPPORTED ON WIN32 W/ FSOUND_HW3D FLAG) */
  297. '/* =================================================================================== */
  298.  
  299.  
  300. '   See top of file for definitions and information on the reverb parameters.
  301.  
  302. 'The FSOUND_REVERB_PRESETS have not been included in VB yet so they cannot yet be used here...
  303. Public Declare Function FSOUND_Reverb_SetProperties Lib "fmod.dll" Alias "_FSOUND_Reverb_SetProperties@4" (ByRef prop As FSOUND_REVERB_PROPERTIES) As Byte
  304. Public Declare Function FSOUND_Reverb_GetProperties Lib "fmod.dll" Alias "_FSOUND_Reverb_GetProperties@4" (ByRef prop As FSOUND_REVERB_PROPERTIES) As Byte
  305. Public Declare Function FSOUND_Reverb_SetChannelProperties Lib "fmod.dll" Alias "_FSOUND_Reverb_SetChannelProperties@8" (ByVal channel As Long, ByRef prop As FSOUND_REVERB_CHANNELPROPERTIES) As Byte
  306. Public Declare Function FSOUND_Reverb_GetChannelProperties Lib "fmod.dll" Alias "_FSOUND_Reverb_GetChannelProperties@8" (ByVal channel As Long, ByRef prop As FSOUND_REVERB_CHANNELPROPERTIES) As Byte
  307.  
  308. '/* ===================================================== */
  309. '/* Recording functions  (ONLY SUPPORTED IN WIN32, WINCE) */
  310. '/* ===================================================== */
  311.  
  312.  
  313. '    Recording initialization functions
  314.  
  315.  
  316. Public Declare Function FSOUND_Record_SetDriver Lib "fmod.dll" Alias "_FSOUND_Record_SetDriver@4" (ByVal outputtype As Long) As Byte
  317. Public Declare Function FSOUND_Record_GetNumDrivers Lib "fmod.dll" Alias "_FSOUND_Record_GetNumDrivers@0" () As Long
  318. Public Declare Function FSOUND_Record_GetDriverName Lib "fmod.dll" Alias "_FSOUND_Record_GetDriverName@4" (ByVal id As Long) As Long
  319. Public Declare Function FSOUND_Record_GetDriver Lib "fmod.dll" Alias "_FSOUND_Record_GetDriver@0" () As Long
  320.  
  321.  
  322. '    Recording functionality.  Only one recording session will work at a time.
  323.  
  324.  
  325. Public Declare Function FSOUND_Record_StartSample Lib "fmod.dll" Alias "_FSOUND_Record_StartSample@8" (ByVal sample As Long, ByVal loopit As Boolean) As Byte
  326. Public Declare Function FSOUND_Record_Stop Lib "fmod.dll" Alias "_FSOUND_Record_Stop@0" () As Byte
  327. Public Declare Function FSOUND_Record_GetPosition Lib "fmod.dll" Alias "_FSOUND_Record_GetPosition@0" () As Long
  328.  
  329. '/* ========================================================================================== */
  330. '/* FMUSIC API (MOD,S3M,XM,IT,MIDI PLAYBACK)                                                   */
  331. '/* ========================================================================================== */
  332.  
  333.  
  334. '   Song management / playback functions.
  335.  
  336.  
  337. Public Declare Function FMUSIC_LoadSong Lib "fmod.dll" Alias "_FMUSIC_LoadSong@4" (ByVal name As String) As Long
  338. Public Declare Function FMUSIC_LoadSongEx Lib "fmod.dll" Alias "_FMUSIC_LoadSongEx@24" (ByVal name As String, ByVal offset As Long, ByVal length As Long, ByVal mode As FSOUND_MODES, ByRef sentencelist As Long, ByVal numitems As Long) As Long
  339. Public Declare Function FMUSIC_LoadSongEx2 Lib "fmod.dll" Alias "_FMUSIC_LoadSongEx@24" (ByRef data As Byte, ByVal offset As Long, ByVal length As Long, ByVal mode As FSOUND_MODES, ByRef sentencelist As Long, ByVal numitems As Long) As Long
  340. Public Declare Function FMUSIC_GetOpenState Lib "fmod.dll" Alias "_FMUSIC_GetOpenState@4" (ByVal module As Long) As Long
  341. Public Declare Function FMUSIC_FreeSong Lib "fmod.dll" Alias "_FMUSIC_FreeSong@4" (ByVal module As Long) As Byte
  342. Public Declare Function FMUSIC_PlaySong Lib "fmod.dll" Alias "_FMUSIC_PlaySong@4" (ByVal module As Long) As Byte
  343. Public Declare Function FMUSIC_StopSong Lib "fmod.dll" Alias "_FMUSIC_StopSong@4" (ByVal module As Long) As Byte
  344. Public Declare Function FMUSIC_StopAllSongs Lib "fmod.dll" Alias "_FMUSIC_StopAllSongs@0" () As Long
  345.  
  346. Public Declare Function FMUSIC_SetZxxCallback Lib "fmod.dll" Alias "_FMUSIC_SetZxxCallback@8" (ByVal module As Long, ByVal callback As Long) As Byte
  347. Public Declare Function FMUSIC_SetRowCallback Lib "fmod.dll" Alias "_FMUSIC_SetRowCallback@12" (ByVal module As Long, ByVal callback As Long, ByVal rowstep As Long) As Byte
  348. Public Declare Function FMUSIC_SetOrderCallback Lib "fmod.dll" Alias "_FMUSIC_SetOrderCallback@12" (ByVal module As Long, ByVal callback As Long, ByVal rowstep As Long) As Byte
  349. Public Declare Function FMUSIC_SetInstCallback Lib "fmod.dll" Alias "_FMUSIC_SetInstCallback@12" (ByVal module As Long, ByVal callback As Long, ByVal instrument As Long) As Byte
  350.  
  351. Public Declare Function FMUSIC_SetSample Lib "fmod.dll" Alias "_FMUSIC_SetSample@12" (ByVal module As Long, ByVal sampno As Long, ByVal sptr As Long) As Byte
  352. Public Declare Function FMUSIC_SetUserData Lib "fmod.dll" Alias "_FMUSIC_SetUserData@8" (ByVal module As Long, ByVal userdata As Long) As Byte
  353. Public Declare Function FMUSIC_OptimizeChannels Lib "fmod.dll" Alias "_FMUSIC_OptimizeChannels@12" (ByVal module As Long, ByVal maxchannels As Long, ByVal minvolume As Long) As Byte
  354.  
  355.  
  356. '   Runtime song functions
  357.  
  358.  
  359. Public Declare Function FMUSIC_SetReverb Lib "fmod.dll" Alias "_FMUSIC_SetReverb@4" (ByVal Reverb As Byte) As Byte
  360. Public Declare Function FMUSIC_SetLooping Lib "fmod.dll" Alias "_FMUSIC_SetLooping@8" (ByVal module As Long, ByVal looping As Byte) As Byte
  361. Public Declare Function FMUSIC_SetOrder Lib "fmod.dll" Alias "_FMUSIC_SetOrder@8" (ByVal module As Long, ByVal order As Long) As Byte
  362. Public Declare Function FMUSIC_SetPaused Lib "fmod.dll" Alias "_FMUSIC_SetPaused@8" (ByVal module As Long, ByVal Pause As Byte) As Byte
  363. Public Declare Function FMUSIC_SetMasterVolume Lib "fmod.dll" Alias "_FMUSIC_SetMasterVolume@8" (ByVal module As Long, ByVal volume As Long) As Byte
  364. Public Declare Function FMUSIC_SetMasterSpeed Lib "fmod.dll" Alias "_FMUSIC_SetMasterSpeed@8" (ByVal module As Long, ByVal speed As Single) As Byte
  365. Public Declare Function FMUSIC_SetPanSeperation Lib "fmod.dll" Alias "_FMUSIC_SetPanSeperation@8" (ByVal module As Long, ByVal pansep As Single) As Byte
  366.  
  367.  
  368. '   Static song information functions
  369.  
  370.  
  371. Public Declare Function FMUSIC_GetName Lib "fmod.dll" Alias "_FMUSIC_GetName@4" (ByVal module As Long) As Long
  372. Public Declare Function FMUSIC_GetType Lib "fmod.dll" Alias "_FMUSIC_GetType@4" (ByVal module As Long) As FMUSIC_TYPES
  373. Public Declare Function FMUSIC_GetNumOrders Lib "fmod.dll" Alias "_FMUSIC_GetNumOrders@4" (ByVal module As Long) As Long
  374. Public Declare Function FMUSIC_GetNumPatterns Lib "fmod.dll" Alias "_FMUSIC_GetNumPatterns@4" (ByVal module As Long) As Long
  375. Public Declare Function FMUSIC_GetNumInstruments Lib "fmod.dll" Alias "_FMUSIC_GetNumInstruments@4" (ByVal module As Long) As Long
  376. Public Declare Function FMUSIC_GetNumSamples Lib "fmod.dll" Alias "_FMUSIC_GetNumSamples@4" (ByVal module As Long) As Long
  377. Public Declare Function FMUSIC_GetNumChannels Lib "fmod.dll" Alias "_FMUSIC_GetNumChannels@4" (ByVal module As Long) As Long
  378. Public Declare Function FMUSIC_GetSample Lib "fmod.dll" Alias "_FMUSIC_GetSample@8" (ByVal module As Long, ByVal sampno As Long) As Long
  379. Public Declare Function FMUSIC_GetPatternLength Lib "fmod.dll" Alias "_FMUSIC_GetPatternLength@8" (ByVal module As Long, ByVal orderno As Long) As Long
  380.  
  381.  
  382. '   Runtime song information
  383.  
  384.  
  385. Public Declare Function FMUSIC_IsFinished Lib "fmod.dll" Alias "_FMUSIC_IsFinished@4" (ByVal module As Long) As Byte
  386. Public Declare Function FMUSIC_IsPlaying Lib "fmod.dll" Alias "_FMUSIC_IsPlaying@4" (ByVal module As Long) As Byte
  387. Public Declare Function FMUSIC_GetMasterVolume Lib "fmod.dll" Alias "_FMUSIC_GetMasterVolume@4" (ByVal module As Long) As Long
  388. Public Declare Function FMUSIC_GetGlobalVolume Lib "fmod.dll" Alias "_FMUSIC_GetGlobalVolume@4" (ByVal module As Long) As Long
  389. Public Declare Function FMUSIC_GetOrder Lib "fmod.dll" Alias "_FMUSIC_GetOrder@4" (ByVal module As Long) As Long
  390. Public Declare Function FMUSIC_GetPattern Lib "fmod.dll" Alias "_FMUSIC_GetPattern@4" (ByVal module As Long) As Long
  391. Public Declare Function FMUSIC_GetSpeed Lib "fmod.dll" Alias "_FMUSIC_GetSpeed@4" (ByVal module As Long) As Long
  392. Public Declare Function FMUSIC_GetBPM Lib "fmod.dll" Alias "_FMUSIC_GetBPM@4" (ByVal module As Long) As Long
  393. Public Declare Function FMUSIC_GetRow Lib "fmod.dll" Alias "_FMUSIC_GetRow@4" (ByVal module As Long) As Long
  394. Public Declare Function FMUSIC_GetPaused Lib "fmod.dll" Alias "_FMUSIC_GetPaused@4" (ByVal module As Long) As Byte
  395. Public Declare Function FMUSIC_GetTime Lib "fmod.dll" Alias "_FMUSIC_GetTime@4" (ByVal module As Long) As Long
  396. Public Declare Function FMUSIC_GetRealChannel Lib "fmod.dll" Alias "_FMUSIC_GetRealChannel@8" (ByVal module As Long, ByVal modchannel As Long) As Long
  397. Public Declare Function FMUSIC_GetUserData Lib "fmod.dll" Alias "_FMUSIC_GetUserData@4" (ByVal module As Long) As Long
  398.  
  399. '************
  400. '* Windows Declarations (Added by Adion)
  401. '************
  402. 'Required for GetStringFromPointer
  403. Private Declare Function ConvCStringToVBString Lib "kernel32" Alias "lstrcpyA" (ByVal lpsz As String, ByVal pt As Long) As Long ' Notice the As Long return value replacing the As String given by the API Viewer.
  404. 'Required for the FFT/Spectral functions
  405. Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal length As Long)
  406.  
  407. '************
  408. '* FUNCTIONS (Added by Adion)
  409. '************
  410. 'Usage: myerrorstring = FSOUND_GetErrorString(FSOUND_GetError)
  411. Public Function FSOUND_GetErrorString(ByVal errorcode As Long) As String
  412.     Select Case errorcode
  413.         Case FMOD_ERR_NONE:             FSOUND_GetErrorString = "No errors"
  414.         Case FMOD_ERR_BUSY:             FSOUND_GetErrorString = "Cannot call this command after FSOUND_Init.  Call FSOUND_Close first."
  415.         Case FMOD_ERR_UNINITIALIZED:    FSOUND_GetErrorString = "This command failed because FSOUND_Init was not called"
  416.         Case FMOD_ERR_PLAY:             FSOUND_GetErrorString = "Playing the sound failed."
  417.         Case FMOD_ERR_INIT:             FSOUND_GetErrorString = "Error initializing output device."
  418.         Case FMOD_ERR_ALLOCATED:        FSOUND_GetErrorString = "The output device is already in use and cannot be reused."
  419.         Case FMOD_ERR_OUTPUT_FORMAT:    FSOUND_GetErrorString = "Soundcard does not support the features needed for this soundsystem (16bit stereo output)"
  420.         Case FMOD_ERR_COOPERATIVELEVEL: FSOUND_GetErrorString = "Error setting cooperative level for hardware."
  421.         Case FMOD_ERR_CREATEBUFFER:     FSOUND_GetErrorString = "Error creating hardware sound buffer."
  422.         Case FMOD_ERR_FILE_NOTFOUND:    FSOUND_GetErrorString = "File not found"
  423.         Case FMOD_ERR_FILE_FORMAT:      FSOUND_GetErrorString = "Unknown file format"
  424.         Case FMOD_ERR_FILE_BAD:         FSOUND_GetErrorString = "Error loading file"
  425.         Case FMOD_ERR_MEMORY:           FSOUND_GetErrorString = "Not enough memory "
  426.         Case FMOD_ERR_VERSION:          FSOUND_GetErrorString = "The version number of this file format is not supported"
  427.         Case FMOD_ERR_INVALID_PARAM:    FSOUND_GetErrorString = "An invalid parameter was passed to this function"
  428.         Case FMOD_ERR_NO_EAX:           FSOUND_GetErrorString = "Tried to use an EAX command on a non EAX enabled channel or output."
  429.         Case FMOD_ERR_CHANNEL_ALLOC:    FSOUND_GetErrorString = "Failed to allocate a new channel"
  430.         Case FMOD_ERR_RECORD:           FSOUND_GetErrorString = "Recording is not supported on this machine"
  431.         Case FMOD_ERR_MEDIAPLAYER:      FSOUND_GetErrorString = "Required Mediaplayer codec is not installed"
  432.         Case FMOD_ERR_CDDEVICE:         FSOUND_GetErrorString = "An error occured trying to open the specified CD device"
  433.         Case Else:                      FSOUND_GetErrorString = "Unknown error"
  434.     End Select
  435. End Function
  436.  
  437. 'Thanks to KarLKoX for the following function
  438. 'Example: MyDriverName = GetStringFromPointer(FSOUND_GetDriverName(count))
  439. Public Function GetStringFromPointer(ByVal lpString As Long) As String
  440. Dim NullCharPos As Long
  441. Dim szBuffer As String
  442.  
  443.     szBuffer = String(255, 0)
  444.     ConvCStringToVBString szBuffer, lpString
  445.     ' Look for the null char ending the C string
  446.     NullCharPos = InStr(szBuffer, vbNullChar)
  447.     GetStringFromPointer = Left(szBuffer, NullCharPos - 1)
  448. End Function
  449.  
  450. 'These functions are added by Adion
  451. Public Function GetSingleFromPointer(ByVal lpSingle As Long) As Single
  452. 'A Single is 4 bytes, so we copy 4 bytes
  453. CopyMemory GetSingleFromPointer, ByVal lpSingle, 4
  454. End Function
  455. 'Warning: You should set the fft dsp to active before retreiving the spectrum
  456. 'Also make sure the array you pass is dimensioned and ready to use
  457. 'FSOUND_DSP_SetActive FSOUND_DSP_GetFFTUnit, 1
  458. Public Function GetSpectrum(ByRef Spectrum() As Single)
  459. Dim nrOfVals As Long, lpSpectrum As Long
  460. Dim a As Long
  461. If UBound(Spectrum) > 511 Then nrOfVals = 512 Else nrOfVals = UBound(Spectrum) + 1
  462. lpSpectrum = FSOUND_DSP_GetSpectrum
  463. CopyMemory Spectrum(0), ByVal lpSpectrum, nrOfVals * 4
  464. End Function
[/code]

Do C++ có tính OOP nên ko trục trặc gì , còn VB6 thì phải thêm vài hàm phụ tự viết .
Sửa lần cuối bởi giongto35 vào ngày T.Bảy 31/05/2008 12:43 pm với 3 lần sửa.


________________________________________________________________________________________________
. . . . . . . . . . . . .. .

giongto35
Thành viên danh dự
Thành viên danh dự
Bài viết: 194
Ngày tham gia: T.Năm 19/04/2007 10:17 am
Đến từ: Đà Nẵng City
Been thanked: 1 time
Liên hệ:

Re: HƯớng dẫn sử dụng engine âm thanh : FmodSoundSystem

Gửi bàigửi bởi giongto35 » T.Hai 31/03/2008 10:55 pm

Tiếp tục nào .
TUTORIAL2 : Basic Step

Giờ cài đặt xong hai thứ đó rồi là xài được , xài EX mất công hơn .
___
Còn cài đặt ban đầu đặt trong Form_load :

Mã: Chọn hết

  1.  
  2. FSOUND_Init 44100, 32, 0
  3. FSOUND_DSP_SetActive FSOUND_DSP_GetFFTUnit, 1
  4.  

Mã: Chọn hết

  1.  
  2. Public Declare Function FSOUND_Init Lib "fmod.dll" Alias "_FSOUND_Init@12" (ByVal mixrate As Long, ByVal maxchannels As Long, ByVal flags As FSOUND_INITMODES) As Byte
  3.  

mixrate : 44100 = 44100 khz
maxchanne : kênh tối đa :32 = 32 channel
0 = ko quan trọng :-D

Mã: Chọn hết

  1.  
  2. FSOUND_DSP_SetActive FSOUND_DSP_GetFFTUnit, 1

CHo phép getspectrum and effect
___
Cài đặt trong Form_unload

Mã: Chọn hết

  1. Public Declare Function FSOUND_Close Lib "fmod.dll" Alias "_FSOUND_Close@0" () As Long
  2.  

Private Sub Form_Unload(Cancel As Integer)
FSOUND_Stream_Stop streamHandle
FSOUND_Stream_Close streamHandle
FSOUND_Close
End Sub
streamHandle là nhận được từ openstream

Việc ta làm là xét xem Fmod375 làm gì với stream :

Mã: Chọn hết

  1.  
  2. Public Declare Function FSOUND_Stream_SetBufferSize Lib "fmod.dll" Alias "_FSOUND_Stream_SetBufferSize@4" (ByVal ms As Long) As Byte
  3.  
  4. Public Declare Function FSOUND_Stream_Open Lib "fmod.dll" Alias "_FSOUND_Stream_Open@16" (ByVal filename As String, ByVal mode As FSOUND_MODES, ByVal offset As Long, ByVal length As Long) As Long
  5. Public Declare Function FSOUND_Stream_Open2 Lib "fmod.dll" Alias "_FSOUND_Stream_Open@16" (ByRef data As Byte, ByVal mode As FSOUND_MODES, ByVal offset As Long, ByVal length As Long) As Long
  6. Public Declare Function FSOUND_Stream_Create Lib "fmod.dll" Alias "_FSOUND_Stream_Create@20" (ByVal callback As Long, ByVal length As Long, ByVal mode As Long, ByVal samplerate As Long, ByVal userdata As Long) As Long
  7. Public Declare Function FSOUND_Stream_Close Lib "fmod.dll" Alias "_FSOUND_Stream_Close@4" (ByVal stream As Long) As Byte
  8.  
  9. Public Declare Function FSOUND_Stream_Play Lib "fmod.dll" Alias "_FSOUND_Stream_Play@8" (ByVal channel As Long, ByVal stream As Long) As Long
  10. Public Declare Function FSOUND_Stream_PlayEx Lib "fmod.dll" Alias "_FSOUND_Stream_PlayEx@16" (ByVal channel As Long, ByVal stream As Long, ByVal dsp As Long, ByVal startpaused As Byte) As Long
  11. Public Declare Function FSOUND_Stream_Stop Lib "fmod.dll" Alias "_FSOUND_Stream_Stop@4" (ByVal stream As Long) As Byte
  12.  
  13. Public Declare Function FSOUND_Stream_SetPosition Lib "fmod.dll" Alias "_FSOUND_Stream_SetPosition@8" (ByVal stream As Long, ByVal positition As Long) As Byte
  14. Public Declare Function FSOUND_Stream_GetPosition Lib "fmod.dll" Alias "_FSOUND_Stream_GetPosition@4" (ByVal stream As Long) As Long
  15. Public Declare Function FSOUND_Stream_SetTime Lib "fmod.dll" Alias "_FSOUND_Stream_SetTime@8" (ByVal stream As Long, ByVal ms As Long) As Byte
  16. Public Declare Function FSOUND_Stream_GetTime Lib "fmod.dll" Alias "_FSOUND_Stream_GetTime@4" (ByVal stream As Long) As Long
  17. Public Declare Function FSOUND_Stream_GetLength Lib "fmod.dll" Alias "_FSOUND_Stream_GetLength@4" (ByVal stream As Long) As Long
  18. Public Declare Function FSOUND_Stream_GetLengthMs Lib "fmod.dll" Alias "_FSOUND_Stream_GetLengthMs@4" (ByVal stream As Long) As Long
  19.  
  20. Public Declare Function FSOUND_Stream_SetMode Lib "fmod.dll" Alias "_FSOUND_Stream_SetMode@8" (ByVal stream As Long, ByVal mode As Long) As Byte
  21. Public Declare Function FSOUND_Stream_GetMode Lib "fmod.dll" Alias "_FSOUND_Stream_GetMode@4" (ByVal stream As Long) As Long
  22. Public Declare Function FSOUND_Stream_SetLoopPoints Lib "fmod.dll" Alias "_FSOUND_Stream_SetLoopPoints@12" (ByVal stream As Long, ByVal loopstartpcm As Long, ByVal loopendpcm As Long) As Byte
  23. Public Declare Function FSOUND_Stream_SetLoopCount Lib "fmod.dll" Alias "_FSOUND_Stream_SetLoopCount@8" (ByVal stream As Long, ByVal count As Long) As Byte
  24. Public Declare Function FSOUND_Stream_GetOpenState Lib "fmod.dll" Alias "_FSOUND_Stream_GetOpenState@4" (ByVal stream As Long) As Long
  25. Public Declare Function FSOUND_Stream_GetSample Lib "fmod.dll" Alias "_FSOUND_Stream_GetSample@4" (ByVal stream As Long) As Long
  26. Public Declare Function FSOUND_Stream_CreateDSP Lib "fmod.dll" Alias "_FSOUND_Stream_CreateDSP@16" (ByVal stream As Long, ByVal callback As Long, ByVal Priority As Long, ByVal userdata As Long) As Long
  27.  
  28. Public Declare Function FSOUND_Stream_SetEndCallback Lib "fmod.dll" Alias "_FSOUND_Stream_SetEndCallback@12" (ByVal stream As Long, ByVal callback As Long, ByVal userdata As Long) As Byte
  29. Public Declare Function FSOUND_Stream_SetSyncCallback Lib "fmod.dll" Alias "_FSOUND_Stream_SetSyncCallback@12" (ByVal stream As Long, ByVal callback As Long, ByVal userdata As Long) As Byte
  30.  
  31. Public Declare Function FSOUND_Stream_AddSyncPoint Lib "fmod.dll" Alias "_FSOUND_Stream_AddSyncPoint@12" (ByVal stream As Long, ByVal pcmoffset As Long, ByVal name As String) As Long
  32. Public Declare Function FSOUND_Stream_DeleteSyncPoint Lib "fmod.dll" Alias "_FSOUND_Stream_DeleteSyncPoint@4" (ByVal point As Long) As Byte
  33. Public Declare Function FSOUND_Stream_GetNumSyncPoints Lib "fmod.dll" Alias "_FSOUND_Stream_GetNumSyncPoints@4" (ByVal stream As Long) As Long
  34. Public Declare Function FSOUND_Stream_GetSyncPoint Lib "fmod.dll" Alias "_FSOUND_Stream_GetSyncPoint@8" (ByVal stream As Long, ByVal index As Long) As Long
  35. Public Declare Function FSOUND_Stream_GetSyncPointInfo Lib "fmod.dll" Alias "_FSOUND_Stream_GetSyncPointInfo@8" (ByVal point As Long, ByRef pcmoffset As Long) As Long
  36.  
  37. Public Declare Function FSOUND_Stream_SetSubStream Lib "fmod.dll" Alias "_FSOUND_Stream_SetSubStream@8" (ByVal stream As Long, ByVal index As Long) As Byte
  38. Public Declare Function FSOUND_Stream_GetNumSubStreams Lib "fmod.dll" Alias "_FSOUND_Stream_GetNumSubStreams@4" (ByVal stream As Long) As Long
  39. Public Declare Function FSOUND_Stream_SetSubStreamSentence Lib "fmod.dll" Alias "_FSOUND_Stream_SetSubStreamSentence@12" (ByVal stream As Long, ByRef sentencelist As Long, ByVal numitems As Long) As Byte
  40.  
  41. Public Declare Function FSOUND_Stream_GetNumTagFields Lib "fmod.dll" Alias "_FSOUND_Stream_GetNumTagFields@8" (ByVal stream As Long, ByRef num As Long) As Byte
  42. Public Declare Function FSOUND_Stream_GetTagField Lib "fmod.dll" Alias "_FSOUND_Stream_GetTagField@24" (ByVal stream As Long, ByVal num As Long, ByRef tagtype As Long, ByRef name As Long, ByRef value As Long, ByRef length As Long) As Byte
  43. Public Declare Function FSOUND_Stream_FindTagField Lib "fmod.dll" Alias "_FSOUND_Stream_FindTagField@20" (ByVal stream As Long, ByVal tagtype As Long, ByVal name As String, ByRef value As Long, ByRef length As Long) As Byte
  44.  
  45. '
  46. '   Internet streaming functions
  47. '
  48.  
  49. Public Declare Function FSOUND_Stream_Net_SetProxy Lib "fmod.dll" Alias "_FSOUND_Stream_Net_SetProxy@4" (ByVal proxy As String) As Byte
  50. Public Declare Function FSOUND_Stream_Net_GetLastServerStatus Lib "fmod.dll" Alias "_FSOUND_Stream_Net_GetLastServerStatus@0" () As Long
  51. Public Declare Function FSOUND_Stream_Net_SetBufferProperties Lib "fmod.dll" Alias "_FSOUND_Stream_Net_SetBufferProperties@12" (ByVal buffersize As Long, ByVal prebuffer_percent As Long, ByVal rebuffer_percent As Long) As Byte
  52. Public Declare Function FSOUND_Stream_Net_GetBufferProperties Lib "fmod.dll" Alias "_FSOUND_Stream_Net_GetBufferProperties@12" (ByRef buffersize As Long, ByRef prebuffer_percent As Long, ByRef rebuffer_percent As Long) As Byte
  53. Public Declare Function FSOUND_Stream_Net_SetMetadataCallback Lib "fmod.dll" Alias "_FSOUND_Stream_Net_SetMetadataCallback@12" (ByVal stream As Long, ByVal callback As Long, ByVal userdata As Long) As Byte
  54. Public Declare Function FSOUND_Stream_Net_GetStatus Lib "fmod.dll" Alias "_FSOUND_Stream_Net_GetStatus@20" (ByVal stream As Long, ByRef status As Long, ByRef bufferpercentused As Long, ByRef bitrate As Long, ByRef flags As Long) As Byte
  55.  

Cỡ 30 hàm .
Ta chỉ bàn đếm stream vì vậy :
____________________________
Mở nhạc Có:
Hàm

Mã: Chọn hết

  1.  
  2. Public Declare Function FSOUND_Stream_Open Lib "fmod.dll" Alias "_FSOUND_Stream_Open@16" (ByVal filename As String, ByVal mode As FSOUND_MODES, ByVal offset As Long, ByVal length As Long) As Long


File name : đường dẫn
mode : FSound_modes ,cài đặt bản nhạc
Offset : bộ nhớ cần lưu trữ ( ta muốn hết , chọn 0)
length : độ dài ( quái cần cái này làm gì nhỉ , mình mở nhạc làm sao biết length , vì vậy cho 0 là tốt nhất)

Vì vậy ta có đa số là :

Mã: Chọn hết

  1.  
  2. streamHandle = FSOUND_Stream_Open(dlg.filename, FSOUND_2D, 0, 0)
  3.  

dlg.filename : đường dẫn của dialog đến bài nhạc .
FSound_2d : sound 2d thôi , chương trình play nhạc mà .

Chú ý :Trả về là handle của stream ko phải là channel .
____________________________
Play Sound:
Có hai hàm là

Mã: Chọn hết

  1.  
  2. Public Declare Function FSOUND_Stream_Play Lib "fmod.dll" Alias "_FSOUND_Stream_Play@8" (ByVal channel As Long, ByVal stream As Long) As Long
  3. Public Declare Function FSOUND_Stream_PlayEx Lib "fmod.dll" Alias "_FSOUND_Stream_PlayEx@16" (ByVal channel As Long, ByVal stream As Long, ByVal dsp As Long, ByVal startpaused As Byte) As Long


Nhưng tốt nhất nên dùng PlayEx vì có thể làm thêm Fx hay một cái gì khác ... :-o ,

Mã: Chọn hết

  1.  
  2. Public Declare Function FSOUND_Stream_PlayEx Lib "fmod.dll" Alias "_FSOUND_Stream_PlayEx@16" (ByVal channel As Long, ByVal stream As Long, ByVal dsp As Long, ByVal startpaused As Byte) As Long


channel: kênh nào , Kênh được giải phóng chứ kênh nào nữa FSOUND_CHANNELSAMPLEMODE.FSOUND_FREE ( CHù cái FSOUND_FREE nó là con đối tượng gì kì quá , tìm mãi ko ra , trong C++ chỉ có Fsound_FREE thôi à)
Stream : streamHandle nhận được từ play sound
Dsp : Là cái gì nhỉ ? một kiểu Effect Mix mà mình ko bít làm ? trình độ non nớt
start hay pause : gì cũng được False là nó play .

Dzay ta có code nguyên si là

Mã: Chọn hết

  1.  
  2. streamChannel = FSOUND_Stream_PlayEx(FSOUND_CHANNELSAMPLEMODE.FSOUND_FREE, streamHandle, drySFXunit, False)

Đối tượng trả về là kênh streamChannel

Chú Ý : play Ex có chức năng là play thêm một bài mới ở một kênh free, đồng nghĩa là nhiều bài hát cùng một lúc nếu chưa stop thì việc đó còn tiếp diễn
play rồi phải stop (pause ở đâu nhỉ ? ac quên nghiên cứu , ko bít nữa :-D ):

Mã: Chọn hết

  1.  
  2. Public Declare Function FSOUND_Stream_Stop Lib "fmod.dll" Alias "_FSOUND_Stream_Stop@4" (ByVal stream As Long) As Byte
  3.  

Stream : COn trỏ đến streamHandle
Vì vậy ta có code sau :

Mã: Chọn hết

  1. FSOUND_Stream_Stop streamHandle
  2.  

Quá đơn giản .
CHÚ Ý : nếu mà thoát ra ngoài mà quên chưa stop nhạc là bị dont send liền đó tắt khỏi VB6 APP luôn , nguy hiểm lắm !
________________________________________________________________________________________________
. . . . . . . . . . . . .. .

giongto35
Thành viên danh dự
Thành viên danh dự
Bài viết: 194
Ngày tham gia: T.Năm 19/04/2007 10:17 am
Đến từ: Đà Nẵng City
Been thanked: 1 time
Liên hệ:

Re: HƯớng dẫn sử dụng engine âm thanh : FmodSoundSystem

Gửi bàigửi bởi giongto35 » T.Hai 31/03/2008 10:56 pm


Tutorial 3: Property of Song And Stream

Giờ mình sẽ nói đến các thuộc tính liên quan Của Bài nhạc :

Các thuộc tính này chứa trong FMUSIC , Và hễ có chữ GET là lấy thông tin về thứ đó
*Lấy nhạc cụ:

Mã: Chọn hết

  1.  
  2. Public Declare Function FMUSIC_GetNumInstruments Lib "fmod.dll" Alias "_FMUSIC_GetNumInstruments@4" (ByVal module As Long) As Long
  3.  

module : streamhandle (handle nhận được từ openstream)

*Lấy loại của sound , ko dành cho stream

Mã: Chọn hết

  1. Public Declare Function FMUSIC_GetType Lib "fmod.dll" Alias "_FMUSIC_GetType@4" (ByVal module As Long) As FMUSIC_TYPES

Mã: Chọn hết

  1. ' FMUSIC_TYPES
  2. ' These definitions describe the type of song being played.
  3. ' See FMUSIC_GetType
  4. '
  5. Public Enum FMUSIC_TYPES
  6.     FMUSIC_TYPE_NONE
  7.     FMUSIC_TYPE_MOD         'Protracker / Fasttracker
  8.     FMUSIC_TYPE_S3M         'ScreamTracker 3
  9.     FMUSIC_TYPE_XM          'FastTracker 2
  10.     FMUSIC_TYPE_IT          'Impulse Tracker.
  11.     FMUSIC_TYPE_MIDI        'MIDI file
  12.     FMUSIC_TYPE_FSB         'FMOD Sample Bank file
  13. End Enum

*lấy Pattern

Mã: Chọn hết

  1. Public Declare Function FMUSIC_GetNumPatterns Lib "fmod.dll" Alias "_FMUSIC_GetNumPatterns@4" (ByVal module As Long) As Long

*Lấy tên

Mã: Chọn hết

  1.  
  2. Public Declare Function FMUSIC_GetName Lib "fmod.dll" Alias "_FMUSIC_GetName@4" (ByVal module As Long) As Long

*Lấy số kênh

Mã: Chọn hết

  1. Public Declare Function FMUSIC_GetNumChannels Lib "fmod.dll" Alias "_FMUSIC_GetNumChannels@4" (ByVal module As Long) As Long
  2.  

*lấy số sample

Mã: Chọn hết

  1. Public Declare Function FMUSIC_GetNumSamples Lib "fmod.dll" Alias "_FMUSIC_GetNumSamples@4" (ByVal module As Long) As Long
  2.  

*lấy sample

Mã: Chọn hết

  1. Public Declare Function FMUSIC_GetSample Lib "fmod.dll" Alias "_FMUSIC_GetSample@8" (ByVal module As Long, ByVal sampno As Long) As Long

*Lấy độ dài thời gian stream

Mã: Chọn hết

  1. Public Declare Function FSOUND_Stream_GetLength Lib "fmod.dll" Alias "_FSOUND_Stream_GetLength@4" (ByVal stream As Long) As Long
  2.  

Lấy theo đơn vị Milli giây : ms

Mã: Chọn hết

  1. Public Declare Function FSOUND_Stream_GetLengthMs Lib "fmod.dll" Alias "_FSOUND_Stream_GetLengthMs@4" (ByVal stream As Long) As Long


Tổng hợp các cái này lại ta có được phần chương trình nhỏ như sau
trong phần open Song

Mã: Chọn hết

  1.  
  2. Dim h, p, s, ms As Long 'biến chứa các đơn vị giờ , phút ,giây , milli giây
  3. Dim ThoiGian As Long 'Biến tổng thời gian
  4. dlg.ShowOpen 'Hộp dialog bật lên để chọn bài hát
  5. 'Ko để ý đến việc bắt lỗi cancel error ở đây
  6. streamHandle = FSOUND_Stream_Open(dlg.filename, FSOUND_2D, 0, 0) ' Mở bài nhạc theo dlg.filename , xem lại TUTORIAL 2
  7. lblName.Caption = dlg.FileTitle 'Tên bài hát là tên file Title
  8. lblType.Caption = FMUSIC_GetType(songHandle) 'Lấy loại
  9. lblInst.Caption = FMUSIC_GetNumInstruments(songHandle) 'Lấy nhạc cụ
  10. lblChan.Caption = FMUSIC_GetNumChannels(songHandle) 'Lấy số kênh
  11. lblTime.Caption = FSOUND_Stream_GetLengthMs(songHandle)'Lấy độ dài gán cho time
  12. ThoiGian = FSOUND_Stream_GetLengthMs(songHandle) ' Thoi gian là getlengthMs
  13. 'Phép chuyển
  14. h = ThoiGian \ 360000
  15. p = ThoiGian Mod 360000 \ 6000
  16. s = ThoiGian Mod 360000 Mod 6000 \ 100
  17. ms = ThoiGian Mod 360000 Mod 6000 Mod 100
  18. Label6.Caption = h & ":" & p & ":" & s & ":" & ms ' Gán vào thời gian
  19.  

À , quên nói : mấy cái Fmusic đó toàn dành cho song ko à , ko dành cho stream, Nên mấy cái

Mã: Chọn hết

  1. lblType.Caption = FMUSIC_GetType(songHandle) 'Lấy loại
  2. lblInst.Caption = FMUSIC_GetNumInstruments(songHandle) 'Lấy nhạc cụ
  3. lblChan.Caption = FMUSIC_GetNumChannels(songHandle) 'Lấy số kênh
  4.  

ko ra kết quả :shock:
Hết tutorial 3 , đến tut sau sẽ đề cập đến phần rất thú vị : SPECTRUM
________________________________________________________________________________________________
. . . . . . . . . . . . .. .

giongto35
Thành viên danh dự
Thành viên danh dự
Bài viết: 194
Ngày tham gia: T.Năm 19/04/2007 10:17 am
Đến từ: Đà Nẵng City
Been thanked: 1 time
Liên hệ:

Re: HƯớng dẫn sử dụng engine âm thanh : FmodSoundSystem

Gửi bàigửi bởi giongto35 » T.Hai 31/03/2008 10:57 pm

Tutorial 4:Get Spectrum(Sóng âm)

Mã: Chọn hết

  1. [code][/code]

đơn giản thế này thôi

Mã: Chọn hết

  1. Public Declare Function FSOUND_DSP_GetSpectrum Lib "fmod.dll" Alias "_FSOUND_DSP_GetSpectrum@0" () As Long


Tưởng là hết chứ , C++ xài thì được còn VB xài hổng được :-D .
Một Member đã add thêm một function trong Fmod để làm việc này

Mã: Chọn hết

  1.  
  2. 'Warning: You should set the fft dsp to active before retreiving the spectrum
  3. 'Also make sure the array you pass is dimensioned and ready to use
  4. 'FSOUND_DSP_SetActive FSOUND_DSP_GetFFTUnit, 1
  5. Public Function GetSpectrum(ByRef Spectrum() As Single)
  6. Dim nrOfVals As Long, lpSpectrum As Long
  7. Dim a As Long
  8. If UBound(Spectrum) > 511 Then nrOfVals = 512 Else nrOfVals = UBound(Spectrum) + 1
  9. lpSpectrum = FSOUND_DSP_GetSpectrum
  10. CopyMemory Spectrum(0), ByVal lpSpectrum, nrOfVals * 4
  11. End Function
  12.  

Trong đó nói rằng , bạn phải SetActive FSOUND_DSP_GetFFTUnit,1 trước để làm các việc đó !

đọc code bạn cũng có thể hiểu rằng , VB ko làm công việc trả lại một mảng âm thanh , nên phải đưa qua procedure . Họ đã thêm một số thủ tục chỉnh sửa như độ dài tối đa của spectrum là 512.

Công việc phân tích code ta hãy bỏ qua , giờ thì ta sẽ CODE !!!
_____________________________
Khi "stream is playing" :-D thì tầng số cũng được đo theo mỗi khoảng khắc thời gian , Vì vậy việc đo cường độ sóng là đặt trong một timer (interval = 1 cho nó xịn :-P )

Chương trình sẽ lấy biểu đồ về sóng đưa vào text

CHÚ Ý : GetSpectrum ko cần đối số đưa vào là một streamHandle hay streamChannel nữa

Mã: Chọn hết

  1.  
  2. Dim SpeNode(512) As Single
  3. Private Sub SpectrumTime_Timer()
  4. Dim i As Integer
  5. GetSpectrum SpeNode 'Lấy âm thanh lúc bấy giờ
  6. Text1.Text = "" 'Gán text bằng rỗng , ko cần cũng được
  7. For i = 1 To 512 ' Chạy từ 1 đến vị trí 512
  8. Text1.Text = Text1.Text & SpeNode(i) & " " 'Hiển thị vào text
  9. Next
  10. End Sub
  11.  

Việc cường độ sóng chỉ biểu diễn qua text thì thật là nhàm chán và thiếu tính chuyên nghiệp , Ai bít dùng Đồ họa (Như GDI)thì có thể thêm vài cái code vẽ lên cho nó đẹp .

Thêm vào các code , đặt vào Module đặt là bas GDI

Mã: Chọn hết

  1. Public Type POINTAPI
  2.         x As Long
  3.         y As Long
  4. End Type
  5.  
  6. Public Declare Function LineTo Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long) As Long
  7. Public Declare Function MoveToEx Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, lpPoint As POINTAPI) As Long
  8.  
  9.  

_____________
*MovetoEx là dịch chuyển điểm bắt đầu đặt nét vẽ .
các tham số
hdc : là khung vẽ , bề mặt cần vẽ lên ( thường là picturebox.hdc),
x : tọa độ trục hoành tính bằng pixel của điểm,
y : tọa độ trục tung tính bằng pixel của điểm,
PointAPI là điểm được khai báo thuộc TYPE POINTAPI : Công dụng , cứ đặt rỗng đi
*LineTo là vẽ từ điểm gốc đến một điểm nào đó . Điểm gốc là
1: điểm bắt đầu đặt nét vẽ
2: điểm vừa vẽ xong
Các tham số
hdc : là khung vẽ , bề mặt cần vẽ lên ( thường là picturebox.hdc),
x : tọa độ trục hoành tính bằng pixel của điểm,
y : tọa độ trục tung tính bằng pixel của điểm,
Chú ý : Trong VB nó mặc định là twip nên có nhiều sai số nếu quên đặt lại scalemode =Pixel .
_____________
Trở về lại vấn đề Spectrum , sau khi nói lên vài cách vẽ đồ họa thì ta có thể làm một biểu đồ đoạn thẳng rồi

Picspe : là bản vẽ spectrum . là một picturebox có scalemode = pixel

Mã: Chọn hết

  1.  
  2. Dim SpeNode(512) As Single
  3. Private Sub SpectrumTime_Timer()
  4. Dim i As Integer
  5. PicSpe.Refresh
  6. PicSpe.Cls
  7. GetSpectrum SpeNode
  8. Text1.Text = ""
  9. MoveToEx PicSpe.hdc, 0, PicSpe.ScaleHeight, a 'di chuyển đến điểm đầu tiên ở vị trí trục hoành là pícpe.scaleHeight, trục tung là 0 tức là góc trái của pic
  10. For i = 1 To 512
  11. LineTo PicSpe.hdc, Round(i * PicSpe.ScaleWidth / 512), PicSpe.ScaleHeight - (Round(SpeNode(i) * 100 + 1))
  12. 'Bước vẽ , ta có "Round(i * PicSpe.ScaleWidth / 512)" nghĩa là : chia picspe ra thành 512 phần theo độ rộng , từ đó nhân lên với i thì ta có vị trí x thuộc trục tung cần phải vẽ ."PicSpe.ScaleHeight - (Round(SpeNode(i) * 100 + 1)" nghĩa là biểu thị cường độ sóng theo SpeNode(i) . Vì có lẽ quá nhỏ nên mình nhân thêm 100 vô để cho nó lớn , dễ nhìn hơn , +1 là để tránh cho trường hợp số 0 .  còn lấy PicSpe.ScaleHeight trừ cho kết quả vừa rồi để thể hiện ở phần đáy dưới
  13. Text1.Text = Text1.Text & SpeNode(i) & " "
  14. Next
  15. End Sub
  16.  

Xong phần spectrum rồi
Oạp mệt quá ,nói thế này hơi trừu tượng ,để post demo lên rồi sẽ thích ngay thôi mà
phần sau : Tutorial 5: Coding a Stream Player
________________________________________________________________________________________________
. . . . . . . . . . . . .. .

giongto35
Thành viên danh dự
Thành viên danh dự
Bài viết: 194
Ngày tham gia: T.Năm 19/04/2007 10:17 am
Đến từ: Đà Nẵng City
Been thanked: 1 time
Liên hệ:

Re: HƯớng dẫn sử dụng engine âm thanh : FmodSoundSystem

Gửi bàigửi bởi giongto35 » T.Hai 31/03/2008 10:58 pm

Tutorial 5: Coding a Stream Player

Bổ sung thêm 2 phần trước khi nói đến phần DEMO PLAYING

1 ) Volume
Nếu là sound thì có "FMUSIC_SetMasterVolume" nhưng đối với stream thì thử ko được
Có cái code này xài là ok . giảm volume còn giảm cả sóng mới hay :twisted:

Mã: Chọn hết

  1.  
  2. Public Declare Function FSOUND_SetVolume Lib "fmod.dll" Alias "_FSOUND_SetVolume@8" (ByVal channel As Long, ByVal Vol As Long) As Byte
  3.  


trong đó channel : là kênh nhận được từ hàm playsoundEx
Vol : Là volume , chỉ mức độ to hay nhỏ của âm thanh , Min : 0 , Max : 100

Ta sẽ đặt phần này vào một slider

Mã: Chọn hết

  1.  
  2. Private Sub sldSpeed_Change() 'Khi mà cái thanh sldSpeed thay đổi giá trị
  3. FSOUND_SetVolume streamChannel, sldSpeed.value
  4. End Sub
  5. Private Sub sldSpeed_Scroll() 'Khi mà cái thanh sldSpeed thay đổi giá trị
  6. FSOUND_SetVolume streamChannel, sldSpeed.value
  7. End Sub
  8.  

Làm 2 cái luôn cho chắc :wink:
2) SeekBar
Bạn luôn luôn thấy một cái thanh nhỏ nhỏ chạy chạy thể hiện được phần trăm thời gian play nhạc . Ta cũng có thể làm được
SeekBar từ một slider . trong đó có
Min : 0
Max : Time , nhận từ biến thời gian qua hàm GetLengthms,(Xem ở tut 3)
Thời gian seekbar thay đổi , ta sẽ tạo một timer làm việc đó , enable(hoạt động) khi play nhạc . interval = 1
trong sự kiện time chạy ta sẽ cho value = thời gian đã bật được từ hàm

Mã: Chọn hết

  1. Public Declare Function FSOUND_Stream_GetTime Lib "fmod.dll" Alias "_FSOUND_Stream_GetTime@4" (ByVal stream As Long) As Long

Mã: Chọn hết

  1.  
  2. Private Sub SliTimer_Timer()
  3. SliTime.value = FSOUND_Stream_GetTime(songHandle)
  4. End Sub

Khi mà nhấn vào seek bar , thì sẽ chuyển đến vị trí thời gian đó. Ta cũng làm được việc này
bằng

Mã: Chọn hết

  1.  
  2. Public Declare Function FSOUND_Stream_GetTime Lib "fmod.dll" Alias "_FSOUND_Stream_GetTime@4" (ByVal stream As Long) As Long

thụ lí sự kiện chuột ấn và thả ở seek
Khi chuột nhấn thì sliTime sẽ dừng , ko cho dịch chuyển cục seek( giống cục SHIT nhỉ :-D ) nữa

Mã: Chọn hết

  1.  
  2. Private Sub SliTime_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
  3. SliTimer.Enabled = False
  4. End Sub
  5.  

Khi chuột thả ra sẽ thay đổi vị trí của cục seek

Mã: Chọn hết

  1.  
  2. Private Sub SliTime_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
  3. FSOUND_Stream_SetTime songHandle, SliTime.value
  4. SliTime.Enabled = True
  5. End Sub
  6.  


Giờ ta đã hoàn chỉnh một số thứ , đơn giản để làm một streamPlayer . Bạn có thể thêm một số thứ nữa để hoàn chỉnh hơn như pause , hay tua tới , tua lui bằng hàm SetTime .

THam khảo code này download/file.php?id=1379
Advance là làm FX (EFFECT) và (3d Sound) . MIỄN BÀN VÌ TRÌNH ĐỘ MÌNH CHƯA ĐẾN ĐÂU CẢ
Sửa lần cuối bởi giongto35 vào ngày T.Bảy 31/05/2008 12:45 pm với 1 lần sửa.
________________________________________________________________________________________________
. . . . . . . . . . . . .. .

Hình đại diện của người dùng
tungblt
Điều hành viên
Điều hành viên
Bài viết: 548
Ngày tham gia: T.Hai 22/12/2008 5:22 pm
Đến từ: quy nhơn
Has thanked: 6 time
Been thanked: 76 time
Liên hệ:

Re: HƯớng dẫn sử dụng engine âm thanh : FmodSoundSystem

Gửi bàigửi bởi tungblt » CN 07/09/2014 12:11 pm

:(( giờ mới thấy bài này . hôm bữa mò cái fmod muốn nản mà chả ra đâu :((
love


Quay về “[VB] Bài viết hướng dẫn”

Đang trực tuyến

Đang xem chuyên mục này: Không có thành viên nào trực tuyến.1 khách