It is currently Thu Nov 23, 2017 12:10 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 36 posts ]  Go to page 1, 2, 3  Next
Author Message
 Post subject: BASS audio library v2.4 PureBasic 4.20 includes.
PostPosted: Fri Apr 04, 2008 2:13 am 
Offline
Addict
Addict
User avatar

Joined: Sat Feb 19, 2005 5:05 pm
Posts: 1769
Location: Norway
BASS 2.4 has just recently been released.

http://un4seen.com/

Quote:
BASS is an audio library for use in Windows and Mac OSX software. Its purpose is to provide developers with powerful and efficient sample, stream (MP3, MP2, MP1, OGG, WAV, AIFF, custom generated, and more via add-ons), MOD music (XM, IT, S3M, MOD, MTM, UMX), MO3 music (MP3/OGG compressed MODs), and recording functions. All in a tiny DLL, under 100KB* in size.

On Windows, BASS requires DirectX 3 or above for output, and takes advantage of DirectSound and DirectSound3D hardware accelerated drivers, when available. On OSX, BASS uses CoreAudio for output, and OSX 10.3 or above is recommended. Both PowerPC and Intel Macs are supported.

C/C++, Delphi, Visual Basic, and MASM APIs are provided, with several examples to get you started. .Net and other APIs are also available.
Ian Luck wrote:
Version 2.4 of BASS and the add-ons is now available for download. There are quite a lot of additions and changes in this release, in both BASS and the add-ons. Probably the most notable new BASS feature is "push" streaming, allowing data to be pushed to BASS instead of BASS pulling it. Also new is sinc interpolated MOD mixing, 64-bit file support, floating-point volume & pan control, detection of new & removed devices, multiple update threads, and a bunch of other stuff.

The PureBasic API includes support for BASS and the BASSenc/BASSmix add-ons. I will update these and any other future includes I create on a need to basis, so if anyone else wish to submit includes for other BASS plugins. Or even port some of the examples to PureBasic, by all means go ahead and Ian will add those to the current PureBasic API download.

Only the includes are included (pun intended), they make use of ImportC and thus need the .lib files from the C folders in the main distribution archives. (which you should have already if you've downloaded BASS and the respective addons). The includes contains some commented C code stuff that was not directly "portable", mostly callback definitions and similar messy stuff.

Also note that BASS uses a special unicode flag on certain functions, the rest of BASS is ansi, so pay attention when passing strings to/from BASS functions.

Personally I have found that BASS plays nicely (pun intended) with PureBasic. There is also a MacOS version available but as I do not have MAC I could not check if the includes work on Mac, but they should contain no platform specific limitations so they should work just fine.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Fri Apr 04, 2008 10:05 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Mon Jan 12, 2004 11:40 pm
Posts: 746
Location: Okazaki, JAPAN
Good News. I can develop Netradio orya II.
Thank you.

_________________
My general site & Bug head technology - Ultimate high quality sound player by BASS
My facebook page.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Fri May 16, 2008 6:42 am 
Offline
Enthusiast
Enthusiast

Joined: Mon Oct 24, 2005 1:05 pm
Posts: 660
Does the PureBasic version of BASS support audio capture/recording or just playback?


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon May 19, 2008 7:11 pm 
Offline
Addict
Addict
User avatar

Joined: Tue Jul 22, 2003 5:02 pm
Posts: 1530
Location: In a long distant galaxy
Yes, recording is well supported.

_________________
No programming language is perfect. There is not even a single best language.
There are only languages well suited or perhaps poorly suited for particular purposes. Herbert Mayer


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Wed May 21, 2008 8:03 am 
Offline
Enthusiast
Enthusiast

Joined: Mon Oct 24, 2005 1:05 pm
Posts: 660
Flype wrote:
Yes, recording is well supported.

Not that well. It doesn't do 24 bits or sample rates over 48 kHz.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Wed May 21, 2008 1:52 pm 
Offline
Addict
Addict
User avatar

Joined: Tue Jul 22, 2003 5:02 pm
Posts: 1530
Location: In a long distant galaxy
in my use cases, it was enough (recording internet radio / audio streams for instance).

_________________
No programming language is perfect. There is not even a single best language.
There are only languages well suited or perhaps poorly suited for particular purposes. Herbert Mayer


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sat May 24, 2008 10:34 pm 
Offline
Addict
Addict
User avatar

Joined: Sat Feb 19, 2005 5:05 pm
Posts: 1769
Location: Norway
chris319 wrote:
Flype wrote:
Yes, recording is well supported.

Not that well. It doesn't do 24 bits or sample rates over 48 kHz.


Sure about that? It may not allow you to choose 24bit integer for recording. (haven't checked) but you can use float (32bit floating point ieee normalized) and it's a prefered way to work with the sound really. Turning that into 24bit integer is very easy.

The benefit is that you can set it to request float, and you'll get 32bit float regardless of what it actually is. On Vista all audio is sent through the audio system as 32bit float anyway.

So choose 32bit float for playback and recording as well as 32bit float DSP,
and you'll get it. Whether the actual recording was originally 16bit or 24bit or 32bit float (no conversion) no longer matters.

The limitation would instead be in the driver. (it is possible that some drivers support 24bit+ with ASIO only?)

As to 48khz. Hmm, again it depends on the driver. BASS should support anything that the system let it use. So if the OS and drivers are able to record up to 192KHz then you should be able to do that. But again some drivers only support this for ASIO, if at all.

Also, on Vista the recording frequency is ignored and BASS uses what you have set for your recording input in the Vista speaker/audio setup, it is possible that max is only 48khz there. Which means a driver/Vista limitation in that case.

On Vista right click on the speaker icon in the tray, choose Recording Devices, choose the input, double click.
Choose advanced tab. In the drop down list you should be able to schoose 16bit and 24bit as well as 44khz and 48, 96 and 192khz.

At least on my system, again it depends on your card and drivers. My Audigy2ZS does. But the Realtek on the motherboard only provides 16bit and 44khz and 48khz and 96khz recordings on line in. Mic on the Realtek has no choices at all.

If you only have 16bit and 48khz set here then that is what BASS will use,
set it to 24bit and 96khz and BASS should use that. (make sure you set the float flag in bass as well to prevent 24bit being reduces to 16bit)

XP and older Windows does not behave this way, here you can request the frequency with the recording init calls and you will get that (or an error if not supported by the OS or driver)

It is only on Vista that frequency is ignored. (why the user setting dominates like this I got no idea, the audio system in Vista is good in principle but kinda silly in implementation).

PS! Be aware that if in the actual recording input stream/callback you create and ask for 48khz but the user has set 96khz in recording devices input, then the system will downsample from 96khz to 48khz. So keep alert when doing audio coding on XP + Vista as the input stuff is very confusing due to the large differences.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sun May 25, 2008 2:09 pm 
Offline
Addict
Addict
User avatar

Joined: Fri Apr 25, 2003 7:06 pm
Posts: 2212
Location: Argentina
Hi

I was using succesfully the BASS_FX in BASS 2.3, did you use it?

The thing in never get to wrok fine (and its very interesting) is the BASS_FX_BPM_DecodeGet, that let you find the beat to sync to songs (after giving them the same tempo).

The tempo i was able to manage it well, fully working. But not the BMP.

I will post an example later.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sun May 25, 2008 3:27 pm 
Offline
Addict
Addict
User avatar

Joined: Fri Apr 25, 2003 7:06 pm
Posts: 2212
Location: Argentina
Here a wroking example (works everything BUT the BPM).

-Equalizer works fine
-DSP own callback to manipulate sound works fine
-Pitch works fine
-Tempo works fine

Im only lost in the BPM stuff.

Code:
;PB4 example of a mp3 player with pitch, tempo, equalizer and karaoke
;using bass.dll 2.3 and bass_fx dll 2.3, all downloable from http://www.un4seen.com/
;Ricardo (updated and corrected May 2008)

;Tempo, Pitch, Equalizer and DSP is working 100%
;Im trying to implement BPM without success, you can just comment this part, the rest is working


IncludeFile "bass.pb"
IncludeFile "bass_fx.pb"
uBasDll = BASS_OpenDLL()
uBas_FX_Dll = BASS_FX_OpenDLL()

Global Handle, Karaoke, MyDSPHandle


Enumeration
  ;PLAY GADGETS
  #MP3Play
  #MP3Pause
  #MP3Stop
  #MP3Load
 
  ;EFFECTS GADGETS
  #FX_KARAOKE
 
  #FX_Tempo
  #FX_Tempo_TrackBar
  #FX_Tempo_Label
 
  #FX_Pitch
  #FX_Pitch_TrackBar
  #FX_Pitch_Label
 
  #FX_PEAKEQ
  #FX_EQ_1
  #FX_EQ_2
  #FX_EQ_3
  #FX_EQ_4
  #FX_EQ_5
  #FX_EQ_6
  #FX_EQ_7
  #FX_EQ_8
  #FX_EQ_9
  #FX_EQ_10
 
  #FX_BMP_Get
  #FX_BMP_Label
EndEnumeration


Procedure MyDSP(Handle,Channel,Buffer,Lenght,User)
  ;Just an example of DSP
 
  ;This karaoke is the method used by some hardware
  ;Just find the sound in the middle of the channels pan
  ;and take it out
  ;Makes poor the sound, yes and only works in tracks with not much effects on the main voice
  ;and also takes out bass and some other sounds (snaredrum usually) that was setted on the middle
  ;As i said, its only an example of some DSP, not a very accurate karaoke.
 
  ;Please close the windos and door of your house if you plan to sing... don't be rude to your neighbors peace of mind :)
 
  ;Delay(0);:WindowEvent()
  If Karaoke = 1
    For i = 0 To Lenght-1 Step 4
      Channel1.w = PeekW(Buffer+i)
      Channel2.w = PeekW(Buffer+i+2)
      nChannel1.w = Channel1 * -1
      nChannel2.w = Channel2 * -1
      Channel1 + nChannel2
      Channel2 + nChannel1
      PokeW(Buffer+i,Channel1)
      PokeW(Buffer+i+2,Channel2)
    Next
  EndIf
EndProcedure



If OpenWindow(0,100,50,450,400,"Test",#PB_Window_SystemMenu)
  CreateGadgetList(WindowID(0))
 
  ButtonGadget(#MP3Load,150,50,50,25,"Load")
  ButtonGadget(#MP3Stop,200,50,50,25,"Stop")
  ButtonGadget(#MP3Play,250,50,75,25,"Play")
  ButtonGadget(#MP3Pause,325,50,50,25,"Pause")
 
  ;Karaoke
  CheckBoxGadget(#FX_KARAOKE,10,100,120,25,"Karaoke")
  SetGadgetState(#FX_KARAOKE,0);Karaoke not set by default
 
  ;Tempo
  TextGadget(#FX_Tempo_Label,290,90,120,25,"Tempo: 0% ")
  TrackBarGadget(#FX_Tempo_TrackBar,290,115,100,25,0,200)
  SetGadgetState(#FX_Tempo_TrackBar,100)
 
  ;Pitch
  TextGadget(#FX_Pitch_Label,190,90,70,25,"Pitch: 0% ")
  TrackBarGadget(#FX_Pitch_TrackBar,190,115,100,25,0,40)
  SetGadgetState(#FX_Pitch_TrackBar,20)
 
  ;EQ GADGETS
  CheckBoxGadget(#FX_PEAKEQ,10,80,120,25,"EQ")
  SetGadgetState(#FX_PEAKEQ,0)
 
  TrackBarGadget(#FX_EQ_1,60,220,25,100,0,20,#PB_TrackBar_Vertical)
  TrackBarGadget(#FX_EQ_2,90,220,25,100,0,20,#PB_TrackBar_Vertical)
  TrackBarGadget(#FX_EQ_3,120,220,25,100,0,20,#PB_TrackBar_Vertical)
  TrackBarGadget(#FX_EQ_4,150,220,25,100,0,20,#PB_TrackBar_Vertical)
  TrackBarGadget(#FX_EQ_5,180,220,25,100,0,20,#PB_TrackBar_Vertical)
  TrackBarGadget(#FX_EQ_6,210,220,25,100,0,20,#PB_TrackBar_Vertical)
  TrackBarGadget(#FX_EQ_7,240,220,25,100,0,20,#PB_TrackBar_Vertical)
  TrackBarGadget(#FX_EQ_8,270,220,25,100,0,20,#PB_TrackBar_Vertical)
  TrackBarGadget(#FX_EQ_9,300,220,25,100,0,20,#PB_TrackBar_Vertical)
  TrackBarGadget(#FX_EQ_10,330,220,25,100,0,20,#PB_TrackBar_Vertical)
 
  ; SetGadgetState(#FX_PEAKEQ,1)
  SetGadgetState(#FX_EQ_1,10)
  SetGadgetState(#FX_EQ_2,10)
  SetGadgetState(#FX_EQ_3,10)
  SetGadgetState(#FX_EQ_4,10)
  SetGadgetState(#FX_EQ_5,10)
  SetGadgetState(#FX_EQ_6,10)
  SetGadgetState(#FX_EQ_7,10)
  SetGadgetState(#FX_EQ_8,10)
  SetGadgetState(#FX_EQ_9,10)
  SetGadgetState(#FX_EQ_10,10)
 
  CheckBoxGadget(#FX_BMP_Get,20,350,120,25,"GetTempo")
  TextGadget(#FX_BMP_Label,250,345,120,25,"BMP")
 
  ;- INICIA BASS
  BASS_Init(-1,44100,0,WindowID(0),#Null)
  ;Load song
  FileName.s = OpenFileRequester("","","MP3|*.MP3|;",0)
  If FileName
    Handle=BASS_StreamCreateFile(#BASSFALSE, FileName, 0, 0, #BASS_STREAM_DECODE)
    BASS_SetVolume(100)
    Handle = BASS_FX_TempoCreate(Handle,#BASS_SAMPLE_LOOP | #BASS_FX_FREESOURCE)
    BASS_ChannelSetAttributes(Handle,-1,100,-101)
    MyDSPHandle = BASS_ChannelSetDSP(Handle,@MyDSP(),0,0)
    BASS_ChannelPlay(Handle,0)
  EndIf

  Dim FFT.f(512)
  Repeat
    EventID=WindowEvent()
    Delay(10)
    Select EventID
      Case 0
        If Handle And BASS_ChannelIsActive(Handle) = #BASS_ACTIVE_PLAYING
          BASS_ChannelGetData(Handle,@FFT(),#BASS_DATA_FFT1024);Here we get the FFT info to make later a metter
          uPos = BASS_StreamGetFilePosition(Handle,#BASS_FILEPOS_CURRENT)
        EndIf
      Case #PB_Event_Gadget
        Select EventGadget()
            ;- PLAY
          Case #MP3Load
            BASS_StreamFree(Handle)
            FileName.s = OpenFileRequester("","","MP3|*.MP3|;",0)
            If FileName
              Handle=BASS_StreamCreateFile(#BASSFALSE, FileName, 0, 0, #BASS_STREAM_DECODE)
              BASS_SetVolume(100)
              Handle = BASS_FX_TempoCreate(Handle,#BASS_SAMPLE_LOOP | #BASS_FX_FREESOURCE)
              BASS_ChannelSetAttributes(Handle,-1,100,-101)
              MyDSPHandle = BASS_ChannelSetDSP(Handle,@MyDSP(),0,0)
              BASS_ChannelPlay(Handle,0)
              BASS_FX_TempoSet(Handle,uTempo,0,uPitch)
            EndIf
          Case #MP3Play
            BASS_ChannelPlay(Handle,0)
          Case #MP3Pause
            BASS_ChannelPause(Handle)
            BASS_Start()
          Case #MP3Stop
            BASS_ChannelStop(Handle)
            BASS_ChannelSetPosition(Handle,0)
            ;- EFFECTS
          Case #FX_BMP_Get ;//HERE IS THE BMP STUFF THAT IS NOT DRIVING ME NOWHERE
            Debug ""
            fxBMP.f = BASS_FX_BPM_DecodeGet(Handle,0,1,0,#BASS_FX_BPM_BKGRND|#BASS_FX_BPM_MULT2|#BASS_FX_FREESOURCE,0)
            TRadio.f = BASS_FX_TempoGetRateRatio(Handle)
            NewBMP.f = fxBMP * TRadio
            fxBMP1.f = BASS_FX_BPM_Translate(Handle,TRadio*100,#BASS_FX_BPM_PERCENT2 )
            SetGadgetText(#FX_BMP_Label,StrF(fxBMP1))
            Debug fxBMP
            Debug TRadio
            Debug fxBMP1
            Debug NewBMP

          Case #FX_KARAOKE
            If GetGadgetState(#FX_KARAOKE) = 1
              Karaoke = 1
            Else
              Karaoke = 0
            EndIf
          Case #FX_Tempo_TrackBar
            uTempo = GetGadgetState(#FX_Tempo_TrackBar)-100
            BASS_FX_TempoSet(Handle,uTempo,0,uPitch)
            SetGadgetText(#FX_Tempo_Label,"Tempo: " + Str(uTempo) + "%")
          Case #FX_Pitch_TrackBar
            uPitch = GetGadgetState(#FX_Pitch_TrackBar)-20
            BASS_FX_TempoSet(Handle,uTempo,0,uPitch)
            SetGadgetText(#FX_Pitch_Label,"Pitch: " + Str(uPitch) + "%")
          Case #FX_PEAKEQ
            If GetGadgetState(#FX_PEAKEQ) = 1
              FX_Priority+1
              EQ.BASS_FX_DSPPEAKEQ
              BASS_ChannelGetAttributes(Handle,@f,0,0)
              Debug BASS_ErrorGetText()
             
              ;Set the EQ effect + 1st Band
              BASS_FX_DSP_Set(Handle,#BASS_FX_DSPFX_PEAKEQ,0)
              BASS_FX_DSP_Set(Handle,#BASS_FX_DSPFX_PEAKEQ,0)
              BASS_FX_DSP_Set(Handle,#BASS_FX_DSPFX_PEAKEQ,0)
              BASS_FX_DSP_Set(Handle,#BASS_FX_DSPFX_PEAKEQ,0)
              BASS_FX_DSP_Set(Handle,#BASS_FX_DSPFX_PEAKEQ,0)
              BASS_FX_DSP_Set(Handle,#BASS_FX_DSPFX_PEAKEQ,0)
              BASS_FX_DSP_Set(Handle,#BASS_FX_DSPFX_PEAKEQ,0)
              BASS_FX_DSP_Set(Handle,#BASS_FX_DSPFX_PEAKEQ,0)
              BASS_FX_DSP_Set(Handle,#BASS_FX_DSPFX_PEAKEQ,0)
              BASS_FX_DSP_Set(Handle,#BASS_FX_DSPFX_PEAKEQ,0)
             
              EQ\lFreq = f
              EQ\fBandwidth = 2.5
              EQ\fQ = 0
              EQ\fGain = 0
             
              ; set bass
              EQ\lBand = 0
              EQ\fCenter = 60
             
              BASS_FX_DSP_SetParameters (Handle, #BASS_FX_DSPFX_PEAKEQ, @EQ.BASS_FX_DSPPEAKEQ)
              Debug BASS_ErrorGetText()
              ; set MID
              EQ\lBand = 1
              EQ\fCenter = 170
             
              BASS_FX_DSP_SetParameters (Handle, #BASS_FX_DSPFX_PEAKEQ, @EQ.BASS_FX_DSPPEAKEQ)
              Debug BASS_ErrorGetText()
              ; set TEBLE
              EQ\lBand = 2
              EQ\fCenter = 310
             
              BASS_FX_DSP_SetParameters (Handle, #BASS_FX_DSPFX_PEAKEQ, @EQ.BASS_FX_DSPPEAKEQ)
              Debug BASS_ErrorGetText()
              ; set TEBLE
              EQ\lBand = 3
              EQ\fCenter = 600
             
              BASS_FX_DSP_SetParameters (Handle, #BASS_FX_DSPFX_PEAKEQ, @EQ.BASS_FX_DSPPEAKEQ)
              Debug BASS_ErrorGetText()
              ; set TEBLE
              EQ\lBand = 4
              EQ\fCenter = 1000
             
              BASS_FX_DSP_SetParameters (Handle, #BASS_FX_DSPFX_PEAKEQ, @EQ.BASS_FX_DSPPEAKEQ)
              Debug BASS_ErrorGetText()
              ; set TEBLE
              EQ\lBand = 5
              EQ\fCenter = 3000
             
              BASS_FX_DSP_SetParameters (Handle, #BASS_FX_DSPFX_PEAKEQ, @EQ.BASS_FX_DSPPEAKEQ)
              Debug BASS_ErrorGetText()
              ; set TEBLE
              EQ\lBand = 6
              EQ\fCenter = 6000
             
              BASS_FX_DSP_SetParameters (Handle, #BASS_FX_DSPFX_PEAKEQ, @EQ.BASS_FX_DSPPEAKEQ)
              Debug BASS_ErrorGetText()
              ; set TEBLE
              EQ\lBand = 7
              EQ\fCenter = 12000
             
              BASS_FX_DSP_SetParameters (Handle, #BASS_FX_DSPFX_PEAKEQ, @EQ.BASS_FX_DSPPEAKEQ)
              Debug BASS_ErrorGetText()
              ; set TEBLE
              EQ\lBand = 8
              EQ\fCenter = 14000
             
              BASS_FX_DSP_SetParameters (Handle, #BASS_FX_DSPFX_PEAKEQ, @EQ.BASS_FX_DSPPEAKEQ)
              Debug BASS_ErrorGetText()
              ; set TEBLE
              EQ\lBand = 9
              EQ\fCenter = 16000
             
              BASS_FX_DSP_SetParameters (Handle, #BASS_FX_DSPFX_PEAKEQ, @EQ.BASS_FX_DSPPEAKEQ)
              Debug BASS_ErrorGetText()

            Else
              BASS_FX_DSP_Remove(Handle,#BASS_FX_DSPFX_PEAKEQ)
              Debug BASS_ErrorGetText()
            EndIf
          Case #FX_EQ_1
            EQ\lBand = 0
            BASS_FX_DSP_GetParameters (Handle, #BASS_FX_DSPFX_PEAKEQ, @EQ.BASS_FX_DSPPEAKEQ)
            EQ\fGain = GetGadgetState(#FX_EQ_1)-10
            BASS_FX_DSP_SetParameters (Handle, #BASS_FX_DSPFX_PEAKEQ, @EQ.BASS_FX_DSPPEAKEQ)
          Case #FX_EQ_2
            EQ\lBand = 1
            BASS_FX_DSP_GetParameters (Handle, #BASS_FX_DSPFX_PEAKEQ, @EQ.BASS_FX_DSPPEAKEQ)
            EQ\fGain = GetGadgetState(#FX_EQ_2)-10
            BASS_FX_DSP_SetParameters (Handle, #BASS_FX_DSPFX_PEAKEQ, @EQ.BASS_FX_DSPPEAKEQ)
          Case #FX_EQ_3
            EQ\lBand = 2
            BASS_FX_DSP_GetParameters (Handle, #BASS_FX_DSPFX_PEAKEQ, @EQ.BASS_FX_DSPPEAKEQ)
            EQ\fGain = GetGadgetState(#FX_EQ_3)-10
            BASS_FX_DSP_SetParameters (Handle, #BASS_FX_DSPFX_PEAKEQ, @EQ.BASS_FX_DSPPEAKEQ)
          Case #FX_EQ_4
            EQ\lBand = 3
            BASS_FX_DSP_GetParameters (Handle, #BASS_FX_DSPFX_PEAKEQ, @EQ.BASS_FX_DSPPEAKEQ)
            EQ\fGain = GetGadgetState(#FX_EQ_4)-10
            BASS_FX_DSP_SetParameters (Handle, #BASS_FX_DSPFX_PEAKEQ, @EQ.BASS_FX_DSPPEAKEQ)
          Case #FX_EQ_5
            EQ\lBand = 4
            BASS_FX_DSP_GetParameters (Handle, #BASS_FX_DSPFX_PEAKEQ, @EQ.BASS_FX_DSPPEAKEQ)
            EQ\fGain = GetGadgetState(#FX_EQ_5)-10
            BASS_FX_DSP_SetParameters (Handle, #BASS_FX_DSPFX_PEAKEQ, @EQ.BASS_FX_DSPPEAKEQ)
          Case #FX_EQ_6
            EQ\lBand = 5
            BASS_FX_DSP_GetParameters (Handle, #BASS_FX_DSPFX_PEAKEQ, @EQ.BASS_FX_DSPPEAKEQ)
            EQ\fGain = GetGadgetState(#FX_EQ_6)-10
            BASS_FX_DSP_SetParameters (Handle, #BASS_FX_DSPFX_PEAKEQ, @EQ.BASS_FX_DSPPEAKEQ)
          Case #FX_EQ_7
            EQ\lBand = 6
            BASS_FX_DSP_GetParameters (Handle, #BASS_FX_DSPFX_PEAKEQ, @EQ.BASS_FX_DSPPEAKEQ)
            EQ\fGain = GetGadgetState(#FX_EQ_7)-10
            BASS_FX_DSP_SetParameters (Handle, #BASS_FX_DSPFX_PEAKEQ, @EQ.BASS_FX_DSPPEAKEQ)
          Case #FX_EQ_8
            EQ\lBand = 7
            BASS_FX_DSP_GetParameters (Handle, #BASS_FX_DSPFX_PEAKEQ, @EQ.BASS_FX_DSPPEAKEQ)
            EQ\fGain = GetGadgetState(#FX_EQ_8)-10
            BASS_FX_DSP_SetParameters (Handle, #BASS_FX_DSPFX_PEAKEQ, @EQ.BASS_FX_DSPPEAKEQ)
          Case #FX_EQ_9
            EQ\lBand = 8
            BASS_FX_DSP_GetParameters (Handle, #BASS_FX_DSPFX_PEAKEQ, @EQ.BASS_FX_DSPPEAKEQ)
            EQ\fGain = GetGadgetState(#FX_EQ_9)-10
            BASS_FX_DSP_SetParameters (Handle, #BASS_FX_DSPFX_PEAKEQ, @EQ.BASS_FX_DSPPEAKEQ)
          Case #FX_EQ_10
            EQ\lBand = 9
            BASS_FX_DSP_GetParameters (Handle, #BASS_FX_DSPFX_PEAKEQ, @EQ.BASS_FX_DSPPEAKEQ)
            EQ\fGain = GetGadgetState(#FX_EQ_10)-10
            BASS_FX_DSP_SetParameters (Handle, #BASS_FX_DSPFX_PEAKEQ, @EQ.BASS_FX_DSPPEAKEQ)
           
        EndSelect
    EndSelect
  Until EventID=#PB_Event_CloseWindow
EndIf
BASS_ChannelRemoveDSP(Handle,MyDSPHandle)
BASS_CloseDLL()
BASS_FX_CloseDLL()
End


Includes:

BASSFX

Code:
;=============================================================================
; BASS_FX 2.3 - Copyright (c) 2002-2006 (: JOBnik! :) [Arthur Aminov, ISRAEL]
;                                                     [http://www.jobnik.org]
;
;     bugs/suggestions/questions -> e-mail: bass_fx@jobnik.org
;    ----------------------------------------------------------
;
; NOTE: This module will only work with BASS_FX version 2.3
;       Check http://www.un4seen.com for any later versions of BASS_FX.BAS
;
; * Requires BASS & BASS.BAS 2.3 - available @ www.un4seen.com
;=============================================================================
Global bass_fx_dll
; Error codes returned by BASS_ErrorGetCode
#BASS_FX_ERROR_NODECODE = 100    ; Not a decoding channel
#BASS_FX_ERROR_STEREO = 101      ; Only for stereo
#BASS_FX_ERROR_BPMINUSE = 102    ; BPM detection is in use

; Tempo / Reverse / BPM flag
#BASS_FX_FREESOURCE = $10000   ; Free the source handle as well? 0x10000

;=============================================================================================
;   D S P (Digital Signal Processing)
;=============================================================================================

;  Multi-channel order of each channel is as follows:
;   3 channels       left-front, right-front, center.
;   4 channels       left-front, right-front, left-rear/side, right-rear/side.
;   6 channels (5.1) left-front, right-front, center, LFE, left-rear/side, right-rear/side.
;   8 channels (7.1) left-front, right-front, center, LFE, left-rear/side, right-rear/side, left-rear center, right-rear center.

;DSP channels flags
#BASS_FX_DSP_CHANALL = -1        ; all channels at once (as by default)
#BASS_FX_DSP_CHANNONE = 0        ; disable an effect for all channels
#BASS_FX_DSP_CHAN1 = 1           ; left-front channel
#BASS_FX_DSP_CHAN2 = 2           ; right-front channel
#BASS_FX_DSP_CHAN3 = 4           ; see above info
#BASS_FX_DSP_CHAN4 = 8           ; see above info
#BASS_FX_DSP_CHAN5 = 16          ; see above info
#BASS_FX_DSP_CHAN6 = 32          ; see above info
#BASS_FX_DSP_CHAN7 = 64          ; see above info
#BASS_FX_DSP_CHAN8 = 128         ; see above info

;DSP effects
Enumeration ;DSPFX
  #BASS_FX_DSPFX_SWAP                       ; Swap or Remap channels       / MC
  #BASS_FX_DSPFX_ROTATE                     ; A channels volume ping-pong  / STEREO Only!
  #BASS_FX_DSPFX_ECHO                       ; Echo                         / 2C max
  #BASS_FX_DSPFX_FLANGER                    ; Flanger                      / MC
  #BASS_FX_DSPFX_VOLUME                     ; Volume                       / MC
  #BASS_FX_DSPFX_PEAKEQ                     ; Peaking Equalizer            / MC
  #BASS_FX_DSPFX_REVERB                     ; Reverb                       / 2C max
  #BASS_FX_DSPFX_LPF                        ; Low Pass Filter              / MC
  #BASS_FX_DSPFX_S2M                        ; Stereo 2 Mono                / STEREO Only!
  #BASS_FX_DSPFX_DAMP                       ; Dynamic Amplification        / MC
  #BASS_FX_DSPFX_AUTOWAH                    ; Auto WAH                     / MC
  #BASS_FX_DSPFX_ECHO2                      ; Echo 2                       / MC
  #BASS_FX_DSPFX_PHASER                     ; Phaser                       / MC
  #BASS_FX_DSPFX_ECHO3                      ; Echo 3                       / MC
  #BASS_FX_DSPFX_CHORUS                     ; Chorus                       / MC
  #BASS_FX_DSPFX_APF                        ; All Pass Filter              / MC
  #BASS_FX_DSPFX_COMPRESSOR                 ; Compressor                   / MC
  #BASS_FX_DSPFX_DISTORTION                 ; Distortion                   / MC
EndEnumeration

Structure BASS_FX_DSPSWAP
  lChansOrder.l                       ; A pointer to an array of channels order (BASS_FX_DSP_CHANxxx not in use, 1st channel index=0)
EndStructure

; Echo
Structure BASS_FX_DSPECHO
  fLevel.l                           ; [0....1....n] linear
  lDelay.l                             ; [1200..30000]
EndStructure

; Flanger
Structure BASS_FX_DSPFLANGER
  fWetDry.l                          ; [0....1....n] linear
  fSpeed.l                           ; [0......0.09]
  lChannel.l                           ; BASS_FX_DSP_CHANxxx flag/s
EndStructure

; Volume
; Global volume is set to 1.0. Channels volume can;t be greater than global volume.
; To set a new global volume, set lChannel = 0
Structure BASS_FX_DSPVOLUME
  lChannel.l                           ; BASS_FX_DSP_CHANxxx flag/s or 0 for global volume control
  fVolume.l                          ; [0....1....n] linear
EndStructure

; Peaking Equalizer
Structure BASS_FX_DSPPEAKEQ
  lBand.l                              ; [0..n] more bands => more memory & cpu usage
  lFreq.l                              ; current samplerate [1Hz..nHz]
  fBandwidth.f                       ; in octaves [0.1..4..n] - Q is not in use
  fQ.f                               ; the EE kinda definition [0..1..n] - Bandwidth is not in use
  fCenter.f                          ; in Hz [1Hz.........nHz]
  fGain.f                            ; in dB [-15dB..0..+15dB]
  lChannel.l                           ; BASS_FX_DSP_CHANxxx flag/s
EndStructure

; Reverb
Structure BASS_FX_DSPREVERB
  fLevel.l                           ; [0....1....n] linear
  lDelay.l                             ; [1200..10000]
EndStructure

; Low Pass Filter
Structure BASS_FX_DSPLPF
  lFreq.l                              ; current samplerate [400Hz<=..n]
  fResonance.l                       ; [0.1...........10]
  fCutOffFreq.l                      ; [1Hz..info.freq/2]
  lChannel.l                           ; BASS_FX_DSP_CHANxxx flag/s
EndStructure

; Dynamic Amplification
Structure BASS_FX_DSPDAMP
  fTarget.l                          ; target volume level                      [0<......1] linear
  fQuiet.l                           ; quiet  volume level                      [0.......1] linear
  fRate.l                            ; amp adjustment rate                      [0.......1] linear
  fGain.l                            ; amplification level                      [0...1...n] linear
  fDelay.l                           ; delay in seconds before increasing level [0.......n] linear
  lChannel.l                           ; BASS_FX_DSP_CHANxxx flag/s
EndStructure

; Auto WAH
Structure BASS_FX_DSPAUTOWAH
  fDryMix.l                          ; dry (unaffected) signal mix              [-2......2]
  fWetMix.l                          ; wet (affected) signal mix                [-2......2]
  fFeedback.l                        ; feedback                                 [-1......1]
  fRate.l                            ; rate of sweep in cycles per second       [0<....<10]
  fRange.l                           ; sweep range in octaves                   [0<....<10]
  fFreq.l                            ; base frequency of sweep Hz               [0<...1000]
  lChannel.l                           ; BASS_FX_DSP_CHANxxx flag/s
EndStructure

; Echo 2
Structure BASS_FX_DSPECHO2
  fDryMix.l                          ; dry (unaffected) signal mix              [-2......2]
  fWetMix.l                          ; wet (affected) signal mix                [-2......2]
  fFeedback.l                        ; feedback                                 [-1......1]
  fDelay.l                           ; delay sec                                [0<......6]
  lChannel.l                           ; BASS_FX_DSP_CHANxxx flag/s
EndStructure

; Phaser
Structure BASS_FX_DSPPHASER
  fDryMix.l                          ; dry (unaffected) signal mix              [-2......2]
  fWetMix.l                          ; wet (affected) signal mix                [-2......2]
  fFeedback.l                        ; feedback                                 [-1......1]
  fRate.l                            ; rate of sweep in cycles per second       [0<....<10]
  fRange.l                           ; sweep range in octaves                   [0<....<10]
  fFreq.l                            ; base frequency of sweep                  [0<...1000]
  lChannel.l                           ; BASS_FX_DSP_CHANxxx flag/s
EndStructure

; Echo 3
Structure BASS_FX_DSPECHO3
  fDryMix.l                          ; dry (unaffected) signal mix              [-2......2]
  fWetMix.l                          ; wet (affected) signal mix                [-2......2]
  fDelay.l                           ; delay sec                                [0<......6]
  lChannel.l                           ; BASS_FX_DSP_CHANxxx flag/s
EndStructure

; Chorus
Structure BASS_FX_DSPCHORUS
  fDryMix.l                          ; dry (unaffected) signal mix              [-2......2]
  fWetMix.l                          ; wet (affected) signal mix                [-2......2]
  fFeedback.l                        ; feedback                                 [-1......1]
  fMinSweep.l                        ; minimal delay ms                         [0<..<6000]
  fMaxSweep.l                        ; maximum delay ms                         [0<..<6000]
  fRate.l                            ; rate ms/s                                [0<...1000]
  lChannel.l                           ; BASS_FX_DSP_CHANxxx flag/s
EndStructure

; All Pass Filter
Structure BASS_FX_DSPAPF
  fGain.l                            ; reverberation time                       [-1=<..<=1]
  fDelay.l                           ; delay sec                                [0<....<=6]
  lChannel.l                           ; BASS_FX_DSP_CHANxxx flag/s
EndStructure

; Compressor
Structure BASS_FX_DSPCOMPRESSOR
  fThreshold.l                       ; compressor threshold                     [0<=...<=1]
  fAttacktime.l                      ; attack time ms                           [0<.<=1000]
  fReleasetime.l                     ; release time ms                          [0<.<=5000]
  lChannel.l                           ; BASS_FX_DSP_CHANxxx flag/s
EndStructure

; Distortion
Structure BASS_FX_DSPDISTORTION
  fDrive.l                           ; distortion drive                         [0<=...<=5]
  fDryMix.l                          ; dry (unaffected) signal mix              [-5<=..<=5]
  fWetMix.l                          ; wet (affected) signal mix                [-5<=..<=5]
  fFeedback.l                        ; feedback                                 [-1<=..<=1]
  fVolume.l                          ; distortion volume                        [0=<...<=2]
  lChannel.l                           ; BASS_FX_DSP_CHANxxx flag/s
EndStructure


ProcedureDLL.l BASS_FX_OpenDLL()
  bass_fx_dll=OpenLibrary(#PB_Any,"bass_fx.dll")
  ProcedureReturn bass_fx_dll
EndProcedure

ProcedureDLL.l BASS_FX_CloseDLL()
  If bass_fx_dll
    ;CallFunction(bass_fx_dll,"BASS_Free")
    CloseLibrary(bass_fx_dll)
    bass_fx_dll=0
  EndIf
EndProcedure

ProcedureDLL.l  BASS_FX_DSP_Set (Handle.l, dsp_fx.l, Priority.l)
  ;   Set any chosen DSP effect to any handle.
  ;   handle   ; stream/music/wma/cd/any other supported add-on format
  ;   dsp_fx   ; FX you wish to use
  ;   priority ; The priority of the new DSP, which determines it;s position in the DSP chain
  ;              DSPs with higher priority are called before those with lower.
  ;   RETURN   ; TRUE if created (0=error!)
  ProcedureReturn CallFunction(bass_fx_dll,"BASS_FX_DSP_Set",Handle.l, dsp_fx.l, Priority.l)
EndProcedure

ProcedureDLL.l  BASS_FX_DSP_Remove (Handle.l, dsp_fx.l)
  ;   Remove chosen DSP effect.
  ;   handle ; stream/music/wma/cd/any other supported add-on format
  ;   dsp_fx ; FX you wish to remove
  ;   RETURN ; TRUE if removed (0=error!)
  ProcedureReturn CallFunction(bass_fx_dll,"BASS_FX_DSP_Remove",Handle.l, dsp_fx.l)
EndProcedure

ProcedureDLL.l  BASS_FX_DSP_SetParameters (Handle.l, dsp_fx.l, *EQ)
  ;   Set the parameters of a DSP effect.
  ;   handle ; stream/music/wma/cd/any other supported add-on format
  ;   dsp_fx ; FX you wish to set parameters to
  ;   par    ; Pointer to the parameter structure
  ;   RETURN ; TRUE if ok (0=error!)
  ProcedureReturn CallFunction(bass_fx_dll,"BASS_FX_DSP_SetParameters",Handle.l, dsp_fx.l, *EQ)
EndProcedure

ProcedureDLL.l  BASS_FX_DSP_SetEQParameters (Handle.l, dsp_fx.l, *EQ)
  ProcedureReturn CallFunction(bass_fx_dll,"BASS_FX_DSP_SetParameters",Handle.l, dsp_fx.l, *EQ)
EndProcedure

ProcedureDLL.l  BASS_FX_DSP_GetParameters (Handle.l, dsp_fx.l, *EQ)
  ;   Retrieve the parameters of a DSP effect.
  ;   handle ; stream/music/wma/cd/any other supported add-on format
  ;   dsp_fx ; FX you wish to get parameters from
  ;   par    ; Pointer to the parameter structure
  ;   RETURN ; TRUE if ok (0=error!)
  ProcedureReturn CallFunction(bass_fx_dll,"BASS_FX_DSP_GetParameters",Handle.l, dsp_fx.l, *EQ)
EndProcedure

ProcedureDLL.l  BASS_FX_DSP_Reset (Handle.l, dsp_fx.l)
  ;   Call this function before changing position to avoid *clicks*
  ;   handle ; stream/music/wma/cd/any other supported add-on format
  ;   dsp_fx ; FX you wish to reset parameters of
  ;   RETURN ; TRUE if ok (0=error!)
  ProcedureReturn CallFunction(bass_fx_dll,"BASS_FX_DSP_Reset",Handle.l, dsp_fx.l)
EndProcedure

;=============================================================================================
;   TEMPO / PITCH SCALING / SAMPLERATE
;=============================================================================================


; NOTE: 1. Supported ONLY - mono / stereo - channels
;       2. Enable Tempo supported flags in BASS_FX_TempoCreate and the others to source handle.

ProcedureDLL.l BASS_FX_TempoCreate (chan.l, flags.l)
  ;   Creates a resampling stream from a decoding channel.
  ;   chan     : a handle returned by:
  ;                   BASS_StreamCreateFile     : flags = BASS_STREAM_DECODE ...
  ;                   BASS_MusicLoad            : flags = BASS_MUSIC_DECODE ...
  ;                   BASS_WMA_StreamCreateFile : flags = BASS_STREAM_DECODE ...
  ;                   BASS_CD_StreamCreate      : flags = BASS_STREAM_DECODE ...
  ;                   * Any other add-on handle using a decoding channel.
  ;   flags    : BASS_SAMPLE_SOFTWARE/LOOP/3D/FX or BASS_STREAM_DECODE/AUTOFREE or
  ;              BASS_SPEAKER_xxx or BASS_FX_FREESOURCE
  ;   RETURN   : the tempo stream handle (0=error!)
  ProcedureReturn CallFunction(bass_fx_dll,"BASS_FX_TempoCreate",chan.l, flags.l)
EndProcedure

ProcedureDLL.l BASS_FX_TempoGetSource (chan.l)
  ;   Get the source channel handle.
  ;   chan   : tempo stream handle
  ;   RETURN : the source channel handle (0=error!)
  ProcedureReturn CallFunction(bass_fx_dll,"BASS_FX_TempoGetSource",chan.l)
EndProcedure

ProcedureDLL.l BASS_FX_TempoSet (chan.l, tempo.f, samplerate.f, pitch.f)
  ;   Set new values to tempo/rate/pitch to change its speed.
  ;   chan       : tempo stream (or source channel) handle
  ;   tempo      : in Percents  [-95%..0..+5000%]                 (-100 = leave current)
  ;   samplerate : in Hz, but calculates by the same % as tempo   (   0 = leave current)
  ;   pitch      : in Semitones [-60....0....+60]                 (-100 = leave current)
  ;   RETURN     : TRUE if ok (0=error!)
  ProcedureReturn CallFunction(bass_fx_dll,"BASS_FX_TempoSet",chan.l, tempo.f, samplerate.f, pitch.f)
EndProcedure

ProcedureDLL.l BASS_FX_TempoGet (chan.l, tempo.f, samplerate.f, pitch.f)
  ;   Get tempo/rate/pitch values.
  ;   chan       : tempo stream (or source channel) handle
  ;   tempo      : current tempo          (0 if not in use)
  ;   samplerate : current samplerate     (0 if not in use)
  ;   pitch      : current pitch          (0 if not in use)
  ;   RETURN     : TRUE if ok (0=error!)
  ProcedureReturn CallFunction(bass_fx_dll,"BASS_FX_TempoGet",chan.l, tempo.f, samplerate.f, pitch.f)
EndProcedure

ProcedureDLL.f BASS_FX_TempoGetRateRatio (chan.l)
  ;   Get the ratio of the resulting rate and source rate (the resampling ratio).
  ;   chan   : tempo stream (or source channel) handle
  ;   RETURN : the ratio(0 = Error!)
  ProcedureReturn CallFunction(bass_fx_dll,"BASS_FX_TempoGetRateRatio",chan.l)
EndProcedure

; Tempo settings. You can change all of them in real-time.
; setting_option                                           setting_value
; --------------                                           -------------

#BASS_FX_TEMPO_SETTING_USE_AA_FILTER = 0      ; TRUE / FALSE
#BASS_FX_TEMPO_SETTING_AA_FILTER_LENGTH = 1   ; 32 default (8 .. 128 taps)
#BASS_FX_TEMPO_SETTING_USE_QUICKALGO = 2      ; TRUE / FALSE
#BASS_FX_TEMPO_SETTING_SEQUENCE_MS = 3        ; 82 default
#BASS_FX_TEMPO_SETTING_SEEKWINDOW_MS = 4      ; 14 default
#BASS_FX_TEMPO_SETTING_OVERLAP_MS = 5         ; 12 default

ProcedureDLL.l BASS_FX_TempoSettingSet (chan.l, setting_option.l, setting_value.l)
  ;   Set tempo settings, one setting each call.
  ;   chan           : tempo stream handle
  ;   setting_option : BASS_FX_TEMPO_SETTING_xxx
  ;   setting_value  : as written above.
  ;   RETURN         : TRUE if ok (0=error!)
  ProcedureReturn CallFunction(bass_fx_dll,"BASS_FX_TempoSettingSet",chan.l, setting_option.l, setting_value.l)
EndProcedure

ProcedureDLL.l BASS_FX_TempoSettingGet (chan.l, setting_option.l)
  ;   Get tempo settings, one setting each call.
  ;   chan           : tempo stream handle
  ;   setting_option : BASS_FX_TEMPO_SETTING_xxx
  ;   Return         : setting Value(-1 = Error!)
  ProcedureReturn CallFunction(bass_fx_dll,"BASS_FX_TempoSettingGet",chan.l, setting_option.l)
EndProcedure

;=============================================================================================
;   R E V E R S E
;=============================================================================================

; NOTE: 1. MODs won;t load without BASS_MUSIC_PRESCAN flag.
;       2. Enable Reverse supported flags in BASS_FX_ReverseCreate and the others to source handle.

ProcedureDLL.l BASS_FX_ReverseCreate (chan.l, dec_block.l, flags.l)
  ;   Creates a Reversed stream from a decoding channel.
  ;   chan      : a handle returned by:
  ;                   BASS_StreamCreateFile     : flags = BASS_STREAM_DECODE ...
  ;                   BASS_MusicLoad            : flags = BASS_MUSIC_DECODE Or BASS_MUSIC_PRESCAN ...
  ;                   BASS_WMA_StreamCreateFile : flags = BASS_STREAM_DECODE ...
  ;                   BASS_CD_StreamCreate      : flags = BASS_STREAM_DECODE ...
  ;                   * Other stream add-on formats if created as decoded channel.
  ;               * For better MP3/2/1 Reverse playback use: BASS_STREAM_PRESCAN flag.
  ;   dec_block : decode in # of seconds blocks...
  ;               larger blocks = less seeking overhead but larger spikes.
  ;   flags     : BASS_SAMPLE_SOFTWARE/LOOP/3D/FX or BASS_STREAM_DECODE/AUTOFREE or
  ;               BASS_SPEAKER_xxx or BASS_FX_FREESOURCE
  ;   RETURN    : the reverse stream handle (0=error!)
  ProcedureReturn CallFunction(bass_fx_dll,"BASS_FX_ReverseCreate",chan.l, dec_block.l, flags.l)
EndProcedure

ProcedureDLL.l BASS_FX_ReverseGetSource (chan.l)
  ;   Get the source channel handle.
  ;   chan   : reverse stream handle
  ;   RETURN : the source channel handle (0=error!)
  ProcedureReturn CallFunction(bass_fx_dll,"BASS_FX_ReverseGetSource",chan.l)
EndProcedure

;=============================================================================================
;   B P M (Beats Per Minute)
;=============================================================================================

; NOTE: Supported only mono or stereo channels.

; bpm flags
#BASS_FX_BPM_BKGRND = 1   ;If in use, then you can do other stuff while detection;s in process
#BASS_FX_BPM_MULT2 = 2    ;If in use, then will auto multiply bpm by 2 (if BPM < MinBPM*2)

;-----------
; Option - 1 - Get BPM from a decoded channel
;--------------------------------------------
ProcedureDLL.l BASS_FX_BPM_DecodeGet (chan.l, startSec.l, endSec.l, minMaxBPM.l, flags.l, proc.l)
  ;   Get the original BPM of a decoding channel.
  ;   chan      : a handle returned by:
  ;                   BASS_StreamCreateFile     : flags = BASS_STREAM_DECODE ...
  ;                   BASS_MusicLoad            : flags = BASS_MUSIC_DECODE Or BASS_MUSIC_PRESCAN ...
  ;                   BASS_WMA_StreamCreateFile : flags = BASS_STREAM_DECODE ...
  ;                   BASS_CD_StreamCreate      : flags = BASS_STREAM_DECODE ...
  ;                   * Any other add-on handle using a decoding channel.
  ;   startSec  : start detecting position in seconds
  ;   endSec    : end detecting position in seconds
  ;   minMaxBPM : set min & max bpm, e.g: MAKELONG(LOWORD.HIWORD), LO=Min, HI=Max. 0 = defaults 45/230
  ;   flags     : BASS_FX_BPM_xxx or BASS_FX_FREESOURCE
  ;   proc      : user defined function to receive the process in percents, use 0 if not in use
  ;   RETURN    : the original BPM value (-1=error!)
  ProcedureReturn CallFunction(bass_fx_dll,"BASS_FX_BPM_DecodeGet",chan.l, startSec.l, endSec.l, minMaxBPM.l, flags.l, proc.l)
EndProcedure

;-----------
; Option - 2 - Auto get BPM by period of time in seconds
;-------------------------------------------------------
ProcedureDLL.l BASS_FX_BPM_CallbackSet (Handle.l, proc.l, period.l, minMaxBPM.l, flags.l, User.l)
  ;   Enable getting BPM value by period of time in seconds.
  ;   handle    : stream/music/wma/cd/any other supported add-on format
  ;   proc      : user defined function to receive the bpm value
  ;   period    : detection period in seconds
  ;   minMaxBPM : set min & max bpm, e.g: MAKELONG(LOWORD.HIWORD), LO=Min, HI=Max. 0 = defaults 45/230
  ;   flags     : only BASS_FX_BPM_MULT2 flag is used
  ;   user      : user instance data to pass to the callback function.
  ;   RETURN    : TRUE if ok (0=error!)
  ProcedureReturn CallFunction(bass_fx_dll,"BASS_FX_BPM_CallbackSet",Handle.l, proc.l, period.l, minMaxBPM.l, flags.l, User.l)
EndProcedure

ProcedureDLL.l BASS_FX_BPM_CallbackReset (Handle.l)
  ;   Reset the buffers. Call this function after changing position.
  ;   handle : stream/music/wma/cd/any other supported add-on format
  ;   RETURN : TRUE if ok (0=error!)
  ProcedureReturn CallFunction(bass_fx_dll,"BASS_FX_BPM_CallbackReset",Handle.l)
EndProcedure

;---------------------------------------
;  Functions to use with Both options.
;---------------------------------------

; translation options
#BASS_FX_BPM_X2 = 0         ; Multiply the original BPM value by 2 (may be called only once & will change the original BPM as well!)
#BASS_FX_BPM_2FREQ = 1      ; BPM value to Frequency
#BASS_FX_BPM_FREQ2 = 2      ; Frequency to BPM value
#BASS_FX_BPM_2PERCENT = 3   ; BPM value to Percents
#BASS_FX_BPM_PERCENT2 = 4   ; Percents to BPM value

ProcedureDLL.l BASS_FX_BPM_Translate (Handle.l, val2tran.l, trans.l)
  ;   Translate the given BPM to FREQ/PERCENT and vice versa or multiply BPM by 2.
  ;   handle   : stream/music/wma/cd/any other supported add-on format
  ;   val2tran : specify a value to translate to a given option (no matter if used X2).
  ;   trans    : any of the above translation option
  ;   RETURN   : new calculated value. (-1=error!)
  ;
  ;   NOTE     : This function will not detect the BPM, it will just translate the detected
  ;              original BPM value of a given handle.
  ProcedureReturn CallFunction(bass_fx_dll,"BASS_FX_BPM_Translate",Handle.l, val2tran.l, trans.l)
EndProcedure

ProcedureDLL.l BASS_FX_BPM_Free (Handle.l)
  ;   Free all resources used by a given handle.
  ;
  ;   NOTE: If BASS_FX_FREESOURCE is used, then will free the decoding channel as well.
  ;         You can;t set/get this flag with BASS_ChannelSetFlags/BASS_ChannelGetInfo.
  ;
  ;   handle : stream/music/wma/cd/any other supported add-on format
  ProcedureReturn CallFunction(bass_fx_dll,"BASS_FX_BPM_Free",Handle.l)
EndProcedure

;-------------------------------------------
; Real-time Beat position trigger functions
;-------------------------------------------

ProcedureDLL.l BASS_FX_BPM_BeatCallbackSet (Handle.l, proc.l, User.l)
  ;   Enable getting Beat position in seconds.
  ;   handle   : stream/music/wma/cd/any other supported add-on format
  ;   proc     : user defined function to receive the beat position in seconds
  ;   user     : user instance data to pass to the callback function.
  ;   RETURN   : TRUE if ok (0=error!)
  ProcedureReturn CallFunction(bass_fx_dll,"BASS_FX_BPM_BeatCallbackSet",Handle.l, proc.l, User.l)
EndProcedure

ProcedureDLL.l BASS_FX_BPM_BeatFree (Handle.l)
  ;   Free all resources used by a given handle.
  ;   handle : stream/music/wma/cd/any other supported add-on format
  ProcedureReturn CallFunction(bass_fx_dll,"BASS_FX_BPM_BeatFree",Handle.l)
EndProcedure

ProcedureDLL.l BPMBEATPROC(Handle.l, beatpos.l, User.l)
  ;   CALLBACK FUNCTION! - Uses with Beat Callback
  ;
  ;   Get the Beat position in seconds.
  ;   handle  : handle that the BASS_FX_BPM_BeatCallbackSet has applied to
  ;   beatpos : the exact beat position in seconds
  ;   user    : the user instance data given when BASS_FX_BPM_BeatCallbackSet was called
EndProcedure

ProcedureDLL.l BPMPROCESSPROC(chan.l, percent.l)
  ;   CALLBACK FUNCTION! - Uses with Option 1 (decode)
  ;
  ;   Get the detection process in percents of a channel.
  ;   chan    : channel that the BASS_FX_BPM_DecodeGet has applied to
  ;   percent : the process in percents [0%..100%]
EndProcedure

ProcedureDLL.l BPMPROC(Handle.l, bpm.l, User.l)
  ;   CALLBACK FUNCTION! - Uses with Option 2 (callback)
  ;
  ;   Get the BPM after period of time in seconds.
  ;   handle : handle that the BASS_FX_BPM_CallbackSet has applied to
  ;   bpm    : the new original bpm value
  ;   user   : the user instance data given when BASS_FX_BPM_CallbackSet was called.
EndProcedure

; If you have more than 8 channels, use this macro
ProcedureDLL.l  BASS_FX_DSP_CHANNEL_N(n.l)
  ;BASS_FX_DSP_CHANNEL_N = 2 ^ (n - 1)
  ;ProcedureReturn 2 ^ (n - 1)
EndProcedure


BASS
Code:
;- Error codes returned by BASS_GetErrorCode
#BASS_OK   =         0   ; all is OK
#BASS_ERROR_MEM   =   1   ; memory error
#BASS_ERROR_FILEOPEN   =2   ; can't open the file
#BASS_ERROR_DRIVER   =3   ; can't find a free/valid driver
#BASS_ERROR_BUFLOST   =4   ; the sample buffer was lost
#BASS_ERROR_HANDLE   =5   ; invalid handle
#BASS_ERROR_FORMAT   =6   ; unsupported sample format
#BASS_ERROR_POSITION   =7   ; invalid playback position
#BASS_ERROR_INIT      =8   ; BASS_Init has not been successfully called
#BASS_ERROR_START   =9   ; BASS_Start has not been successfully called
#BASS_ERROR_ALREADY   =14   ; already initialized
#BASS_ERROR_NOPAUSE   =16   ; not paused
#BASS_ERROR_NOCHAN   =18   ; can't get a free channel
#BASS_ERROR_ILLTYPE   =19   ;an illegal type was specified
#BASS_ERROR_ILLPARAM   =20   ; an illegal parameter was specified
#BASS_ERROR_NO3D      =21   ; no 3D support
#BASS_ERROR_NOEAX   =22   ; no EAX support
#BASS_ERROR_DEVICE   =23   ; illegal device number
#BASS_ERROR_NOPLAY   =24   ; not playing
#BASS_ERROR_FREQ      =25   ; illegal sample rate
#BASS_ERROR_NOTFILE   =27   ; the stream is not a file stream
#BASS_ERROR_NOHW      =29   ; no hardware voices available
#BASS_ERROR_EMPTY   =31   ; the MOD music has no sequence Data
#BASS_ERROR_NONET   =32   ; no internet connection could be opened
#BASS_ERROR_CREATE   =33   ; couldn't create the file
#BASS_ERROR_NOFX      =34   ;effects are not available
#BASS_ERROR_PLAYING   =35   ; the channel is playing
#BASS_ERROR_NOTAVAIL   =37   ; requested Data is not available
#BASS_ERROR_DECODE   =38   ; the channel is a "decoding channel"
#BASS_ERROR_DX      =39   ; a sufficient DirectX version is not installed
#BASS_ERROR_TIMEOUT   =40   ; connection timedout
#BASS_ERROR_FILEFORM   =41   ; unsupported file format
#BASS_ERROR_SPEAKER   =42   ; unavailable speaker
#BASS_ERROR_UNKNOWN   =-1   ; some other mystery error
#BASS_ERROR_VERSION = 43
#BASS_ERROR_CODEC = 44

;- BASS Constants
#BASS_MP3_SETPOS=$20000 ; enable pin-point seeking on the MP3/MP2/MP1

#BASS_STREAM_AUTOFREE=$40000   ; automatically free the stream when it stop/ends
#BASS_STREAM_RESTRATE=$80000   ; restrict the download rate of internet file streams
#BASS_STREAM_BLOCK=$100000 ; download/play internet file stream in small blocks
#BASS_STREAM_DECODE=$200000 ; don't play the stream, only decode (BASS_ChannelGetData)
#BASS_STREAM_META=$400000 ; request metadata from a Shoutcast stream
#BASS_STREAM_STATUS=$800000 ; give server status info (HTTP/ICY tags) in DOWNLOADPROC

#BASS_SAMPLE_8BITS=1   ; 8 bit
#BASS_SAMPLE_FLOAT=256   ; 32-bit floating-point
#BASS_SAMPLE_MONO=2   ; mono, Else stereo
#BASS_SAMPLE_LOOP=4   ; looped
#BASS_SAMPLE_3D=8   ; 3D functionality enabled
#BASS_SAMPLE_SOFTWARE=16   ; it's NOT using hardware mixing
#BASS_SAMPLE_MUTEMAX=32   ; muted at max distance (3D only)
#BASS_SAMPLE_VAM=64   ; uses the DX7 voice allocation & management
#BASS_SAMPLE_FX=128   ; old implementation of DX8 effects are enabled
#BASS_SAMPLE_OVER_VOL=$10000   ; override lowest volume
#BASS_SAMPLE_OVER_POS=$20000   ; override longest playing
#BASS_SAMPLE_OVER_DIST=$30000 ; override furthest from listener (3D only)

#BASS_SPEAKER_FRONT=$1000000   ; front speakers
#BASS_SPEAKER_REAR=$2000000   ; rear/side speakers
#BASS_SPEAKER_CENLFE=$3000000   ; center & LFE speakers (5.1)
#BASS_SPEAKER_REAR2=$4000000   ; rear center speakers (7.1)
#BASS_SPEAKER_LEFT=$10000000   ; modifier: left
#BASS_SPEAKER_RIGHT=$20000000   ; modifier: right
#BASS_SPEAKER_FRONTLEFT=#BASS_SPEAKER_FRONT|#BASS_SPEAKER_LEFT
#BASS_SPEAKER_FRONTRIGHT=#BASS_SPEAKER_FRONT|#BASS_SPEAKER_RIGHT
#BASS_SPEAKER_REARLEFT=#BASS_SPEAKER_REAR|#BASS_SPEAKER_LEFT
#BASS_SPEAKER_REARRIGHT=#BASS_SPEAKER_REAR|#BASS_SPEAKER_RIGHT
#BASS_SPEAKER_CENTER   =#BASS_SPEAKER_CENLFE|#BASS_SPEAKER_LEFT
#BASS_SPEAKER_LFE=#BASS_SPEAKER_CENLFE|#BASS_SPEAKER_RIGHT
#BASS_SPEAKER_REAR2LEFT=#BASS_SPEAKER_REAR2|#BASS_SPEAKER_LEFT
#BASS_SPEAKER_REAR2RIGHT=#BASS_SPEAKER_REAR2|#BASS_SPEAKER_RIGHT

#BASS_UNICODE=$80000000

#BASS_SYNC_MUSICPOS=0
#BASS_SYNC_POS=0
#BASS_SYNC_MUSICINST=1
#BASS_SYNC_END=2
#BASS_SYNC_MUSICFX=3
#BASS_SYNC_META=4
#BASS_SYNC_SLIDE=5
#BASS_SYNC_STALL=6
#BASS_SYNC_DOWNLOAD=7
#BASS_SYNC_FREE=8
#BASS_SYNC_MESSAGE=$20000000
#BASS_SYNC_MIXTIME=$40000000
#BASS_SYNC_ONETIME=$80000000

#BASS_CONFIG_BUFFER=0
#BASS_CONFIG_UPDATEPERIOD=1
#BASS_CONFIG_MAXVOL=3
#BASS_CONFIG_GVOL_SAMPLE=4
#BASS_CONFIG_GVOL_STREAM=5
#BASS_CONFIG_GVOL_MUSIC=6
#BASS_CONFIG_CURVE_VOL=7
#BASS_CONFIG_CURVE_PAN=8
#BASS_CONFIG_FLOATDSP=9
#BASS_CONFIG_3DALGORITHM=10
#BASS_CONFIG_NET_TIMEOUT=11
#BASS_CONFIG_NET_BUFFER=12
#BASS_CONFIG_PAUSE_NOPLAY=13
#BASS_CONFIG_NET_NOPROXY=14

#BASS_ACTIVE_STOPPED=0
#BASS_ACTIVE_PLAYING=1
#BASS_ACTIVE_STALLED=2
#BASS_ACTIVE_PAUSED=3

#BASS_FILEPOS_DECODE=0
#BASS_FILEPOS_DOWNLOAD=1
#BASS_FILEPOS_END=2
#BASS_FILEPOS_START=3

; DX8 effect types, use with BASS_ChannelSetFX
#BASS_FX_CHORUS = 0         ;  GUID_DSFX_STANDARD_CHORUS
#BASS_FX_COMPRESSOR = 1     ;  GUID_DSFX_STANDARD_COMPRESSOR
#BASS_FX_DISTORTION = 2     ;  GUID_DSFX_STANDARD_DISTORTION
#BASS_FX_ECHO = 3           ;  GUID_DSFX_STANDARD_ECHO
#BASS_FX_FLANGER = 4        ;  GUID_DSFX_STANDARD_FLANGER
#BASS_FX_GARGLE = 5         ;  GUID_DSFX_STANDARD_GARGLE
#BASS_FX_I3DL2REVERB = 6    ;  GUID_DSFX_STANDARD_I3DL2REVERB
#BASS_FX_PARAMEQ = 7        ;  GUID_DSFX_STANDARD_PARAMEQ
#BASS_FX_REVERB = 8         ;  GUID_DSFX_WAVES_REVERB

#ASS_DATA_FLOAT = $40000000    ; flag: return floating-point sample data
#BASS_DATA_FFT512 = $80000000   ; 512 sample FFT
#BASS_DATA_FFT1024 = $80000001  ; 1024 FFT
#BASS_DATA_FFT2048 = $80000002  ; 2048 FFT
#BASS_DATA_FFT4096 = $80000003

; BASS_StreamGetFilePosition modes
#BASS_FILEPOS_CURRENT = 0
#BASS_FILEPOS_DECODE = #BASS_FILEPOS_CURRENT
#BASS_FILEPOS_DOWNLOAD = 1
#BASS_FILEPOS_END = 2
#BASS_FILEPOS_START = 3

#BASS_MUSIC_RAMP = $200

#BASSFALSE = 0
#BASSTRUE = 1
;- Bass Globals
Structure BASS_CHANNELINFO
  freq.l
  chans.l
  flags.l
  ctype.l
  origres.l
EndStructure

Structure BASS_VERSION
  ver.w
  rev.w
EndStructure

Structure BASS_FXPARAMEQ
  fCenter.l
  fBandwidth.l
  fGain.l
EndStructure

Global bassdll.l

;- Procedures

Procedure.l BASS_OpenDLL()
  bassdll=OpenLibrary(#PB_Any,"bass.dll")
  ProcedureReturn bassdll
EndProcedure

Procedure.l BASS_CloseDLL()
  If bassdll
    CallFunction(bassdll,"BASS_Free")
    CloseLibrary(bassdll)
    bassdll=0
  EndIf
EndProcedure

Procedure.l BASS_GetVersion()
  If bassdll
    ProcedureReturn CallFunction(bassdll,"BASS_GetVersion")
  EndIf
EndProcedure

Procedure.l BASS_CheckVersion(ver.l,rev.l)
  Version.BASS_VERSION
  PokeL(@Version,BASS_GetVersion())
  If Version/ver=ver ; if version match
    If Version/rev>=rev ; if revision match or higher
      result.l=#True
    Else ; revision was lower
      result.l=#False
    EndIf
  Else ; version was lower
    result.l=#False
  EndIf
  ProcedureReturn result
EndProcedure

Procedure.l BASS_SetConfig(option.l,Value.l)
  If bassdll
    ProcedureReturn CallFunction(bassdll,"BASS_SetConfig",option,Value)
  EndIf
EndProcedure

Procedure.l BASS_GetConfig(option.l)
  If bassdll
    ProcedureReturn CallFunction(bassdll,"BASS_GetConfig",option)
  EndIf
EndProcedure

ProcedureDLL.l BASS_ChannelSetFX(Handle.l,uType.l,Priority.l)
  ProcedureReturn CallFunction(bassdll,"BASS_ChannelSetFX",Handle.l,uType.l,Priority.l)
EndProcedure

ProcedureDLL.l BASS_FXSetParameters(Handle.l,par.l)
  ProcedureReturn CallFunction(bassdll,"BASS_FXSetParameters",Handle.l,par.l)
EndProcedure

Procedure.l BASS_Init(device.l,freq.l,flags.l,window.l,guid.l)
  If bassdll
    ProcedureReturn CallFunction(bassdll,"BASS_Init",device,freq,flags,window,guid)
  EndIf
EndProcedure

Procedure.l BASS_ChannelGetInfo(Handle.l,*chaninfo)
  If bassdll
    ProcedureReturn CallFunction(bassdll,"BASS_ChannelGetInfo",Handle,*chaninfo)
  EndIf
EndProcedure

Procedure.l BASS_StreamGetFilePosition(Handle.l,Mode.l)
  If bassdll
    ProcedureReturn CallFunction(bassdll,"BASS_StreamGetFilePosition",Handle,Mode)
  EndIf
EndProcedure

Procedure.l BASS_ChannelSetPosition(Handle.l,Position.l)
  If bassdll
    ProcedureReturn CallFunction(bassdll,"BASS_ChannelSetPosition",Handle,Position,0)
  EndIf
EndProcedure

Procedure.l BASS_ChannelIsActive(Handle.l)
  If bassdll
    ProcedureReturn CallFunction(bassdll,"BASS_ChannelIsActive",Handle)
  EndIf
EndProcedure

Procedure.l BASS_ChannelGetData(Handle.l,Buffer.l,length.l)
  If bassdll
    ProcedureReturn CallFunction(bassdll,"BASS_ChannelGetData",Handle,Buffer.l,length.l)
  EndIf
EndProcedure

Procedure.l BASS_StreamCreateFile(mem.b,File$,offset.l,length.l,flags.l)
  If bassdll
    ProcedureReturn CallFunction(bassdll,"BASS_StreamCreateFile",mem,File$,offset,length,flags)
  EndIf
EndProcedure
 
Procedure.l BASS_StreamFree(Handle.l)
  If bassdll
    CallFunction(bassdll,"BASS_StreamFree",Handle)
  EndIf
EndProcedure

ProcedureDLL.l BASS_ChannelPlay(a.l,b.l)
  ProcedureReturn CallFunction(bassdll,"BASS_ChannelPlay",a,b)
EndProcedure

ProcedureDLL.l BASS_ChannelPause(a.l)
  ProcedureReturn CallFunction(bassdll,"BASS_ChannelPause",a)
EndProcedure

ProcedureDLL.l BASS_Start()
  ProcedureReturn CallFunction(bassdll,"BASS_Start")
EndProcedure

ProcedureDLL.l BASS_ChannelStop(a.l)
  ProcedureReturn CallFunction(bassdll,"BASS_ChannelStop",a)
EndProcedure

ProcedureDLL.l BASS_SampleStop(a.l)
  ProcedureReturn CallFunction(bassdll,"BASS_SampleStop",a)
EndProcedure

ProcedureDLL.l BASS_ChannelSetDSP(a.l,b.l,c.l,d.l)
  ProcedureReturn CallFunction(bassdll,"BASS_ChannelSetDSP",a,b,c,d)
EndProcedure

ProcedureDLL.l BASS_ChannelRemoveDSP(a.l,b.l)
  ProcedureReturn CallFunction(bassdll,"BASS_ChannelRemoveDSP",a,b)
EndProcedure

ProcedureDLL.l BASS_SetVolume(a.l)
  ProcedureReturn CallFunction(bassdll,"BASS_SetVolume",a)
EndProcedure

ProcedureDLL.l BASS_PluginLoad(Dll$,b.l)
  ProcedureReturn CallFunction(bassdll,"BASS_PluginLoad",Dll$,b.l)
EndProcedure

ProcedureDLL.l BASS_ChannelGetAttributes(a.l,b.l,c.l,d.l)
  ProcedureReturn CallFunction(bassdll,"BASS_ChannelGetAttributes",a.l,b.l,c.l,d.l)
EndProcedure

ProcedureDLL.l BASS_ChannelSetAttributes(Handle.l,Volume.l,Frequency.l,Pan.l)
  ProcedureReturn CallFunction(bassdll,"BASS_ChannelSetAttributes",Handle.l,Volume.l,Frequency.l,Pan.l)
EndProcedure

Procedure.s BASS_ErrorGetText()
  Protected errortxt.s
  If bassdll
    errorcode.l=CallFunction(bassdll,"BASS_ErrorGetCode")
    Debug "Error code: " + Str(errorcode)
    Select errorcode
      Case #BASS_OK : errortxt="OK"
      Case #BASS_ERROR_MEM :   errortxt="Memory error"
      Case #BASS_ERROR_FILEOPEN    : errortxt="Can't open the file"
      Case #BASS_ERROR_DRIVER    : errortxt="Can't find a free/valid driver"
      Case #BASS_ERROR_BUFLOST : errortxt="The sample buffer was lost"
      Case #BASS_ERROR_HANDLE : errortxt="Invalid handle"
      Case #BASS_ERROR_FORMAT : errortxt="Unsupported sample format"
      Case #BASS_ERROR_POSITION : errortxt="Invalid playback position"
      Case #BASS_ERROR_INIT : errortxt="BASS_Init has not been successfully called"
      Case #BASS_ERROR_START : errortxt="BASS_Start has not been successfully called"
      Case #BASS_ERROR_ALREADY : errortxt="Already initialized"
      Case #BASS_ERROR_NOPAUSE : errortxt="Not paused"
      Case #BASS_ERROR_NOCHAN : errortxt="Can't get a free channel"
      Case #BASS_ERROR_ILLTYPE : errortxt="An illegal type was specified"
      Case #BASS_ERROR_ILLPARAM : errortxt="An illegal parameter was specified"
      Case #BASS_ERROR_NO3D : errortxt="No 3D support"
      Case #BASS_ERROR_NOEAX : errortxt="No EAX support"
      Case #BASS_ERROR_DEVICE : errortxt="Illegal device number"
      Case #BASS_ERROR_NOPLAY : errortxt="Not playing"
      Case #BASS_ERROR_FREQ : errortxt="Illegal sample rate"
      Case #BASS_ERROR_NOTFILE : errortxt="The stream is not a file stream"
      Case #BASS_ERROR_NOHW : errortxt="No hardware voices available"
      Case #BASS_ERROR_EMPTY    : errortxt="The MOD music has no sequence Data"
      Case #BASS_ERROR_NONET : errortxt="No internet connection could be opened"
      Case #BASS_ERROR_CREATE : errortxt="Couldn't create the file"
      Case #BASS_ERROR_NOFX : errortxt="Effects are not available"
      Case #BASS_ERROR_PLAYING : errortxt="The channel is playing"
      Case #BASS_ERROR_NOTAVAIL : errortxt="Requested Data is not available"
      Case #BASS_ERROR_DECODE : errortxt="The channel is a decoding channel"
      Case #BASS_ERROR_DX : errortxt="A sufficient DirectX version is not installed"
      Case #BASS_ERROR_TIMEOUT : errortxt="Connection timedout"
      Case #BASS_ERROR_FILEFORM : errortxt="Unsupported file format"
      Case #BASS_ERROR_SPEAKER : errortxt="Unavailable speaker"
      Case #BASS_ERROR_UNKNOWN : errortxt="Some other mystery error"
      Case #BASS_ERROR_VERSION : errortxt = "Wrong version"
      Case #BASS_ERROR_CODEC :errortxt = "Codec problem"
    EndSelect
  EndIf
  ProcedureReturn errortxt
EndProcedure



Yes, it old version (BASS 2.3) i will reconvert it to 2.4 as soon as i get BPM to work.

Any help finding how to use and get the BPM working?


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sun May 25, 2008 5:26 pm 
Offline
Addict
Addict
User avatar

Joined: Fri Apr 25, 2003 7:06 pm
Posts: 2212
Location: Argentina
First example with this include, only a mp3 player with custom DSP

Code:

;PB4 example of a media player with pitch, tempo, equalizar and karaoke
;Ricardo (from PureBasic forum MAY 2008


IncludeFile "bass.pbi"

Global Handle, Karaoke, MyDSPHandle


Enumeration
  ;PLAY GADGETS
  #MP3Play
  #MP3Pause
  #MP3Stop
  #MP3Load
 
  ;EFFECTS GADGETS
  #FX_KARAOKE
 
EndEnumeration


Procedure MyDSP(Handle,Channel,Buffer,Lenght,User)
  Shared Karaoke
  ;Just an example of DSP
 
  If Karaoke = 1
    Debug "aqui"
    For i = 0 To Lenght-1 Step 4
      Channel1.w = PeekW(Buffer+i)
      Channel2.w = PeekW(Buffer+i+2)
      nChannel1.w = Channel1 * -1
      nChannel2.w = Channel2 * -1
      Channel1 + nChannel2
      Channel2 + nChannel1
      PokeW(Buffer+i,Channel1)
      PokeW(Buffer+i+2,Channel2)
    Next
  EndIf
EndProcedure



If OpenWindow(0,100,50,450,150,"Example",#PB_Window_SystemMenu)
  CreateGadgetList(WindowID(0))
 
  ButtonGadget(#MP3Load,150,50,50,25,"Load")
  ButtonGadget(#MP3Stop,200,50,50,25,"Stop")
  ButtonGadget(#MP3Play,250,50,75,25,"Play")
  ButtonGadget(#MP3Pause,325,50,50,25,"Pause")
 
  ;Karaoke , its just an example of DSP usage
  CheckBoxGadget(#FX_KARAOKE,10,50,120,25,"Karaoke")
  SetGadgetState(#FX_KARAOKE,0);Karaoke not set by default
 
  ;- INICIA BASS
  BASS_Init(-1,44100,0,WindowID(0),#Null)
  ;Load song
  FileName.s = OpenFileRequester("","","MP3|*.MP3|;",0)
  If FileName
    Handle=BASS_StreamCreateFile(0, @FileName, 0, 0, 0)
    BASS_SetVolume(100)
    MyDSPHandle = BASS_ChannelSetDSP(Handle,@MyDSP(),0,0)
    Debug MyDSPHandle
    BASS_ChannelPlay(Handle,0)
  EndIf
 
  Dim FFT.f(512)
  Repeat
    EventID=WindowEvent()
    Delay(10)
    Select EventID
      Case 0
        If Handle And BASS_ChannelIsActive(Handle) = #BASS_ACTIVE_PLAYING
           BASS_ChannelGetData(Handle,@FFT(),#BASS_DATA_FFT1024);Here we get the FFT info to make later a metter
           uPos = BASS_StreamGetFilePosition(Handle,#BASS_FILEPOS_CURRENT)
        EndIf
      Case #PB_Event_Gadget
        Select EventGadget()
            ; ;- PLAY
          Case #MP3Load
            BASS_StreamFree(Handle)
            FileName.s = OpenFileRequester("","","MP3|*.MP3|;",0)
            If FileName
              Handle=BASS_StreamCreateFile(0, @FileName, 0, 0, 0)
              BASS_SetVolume(100)
              MyDSPHandle = BASS_ChannelSetDSP(Handle,@MyDSP(),0,0)
              BASS_ChannelPlay(Handle,0)
            EndIf
          Case #MP3Play
            BASS_ChannelPlay(Handle,0)
          Case #MP3Pause
            BASS_ChannelPause(Handle)
            BASS_Start()
          Case #MP3Stop
            BASS_ChannelStop(Handle)
            BASS_ChannelSetPosition(Handle,0,#BASS_POS_BYTE)
          Case #FX_KARAOKE
            If GetGadgetState(#FX_KARAOKE) = 1
              Karaoke = 1
            Else
              Karaoke = 0
            EndIf
        EndSelect
    EndSelect
  Until EventID=#PB_Event_CloseWindow
EndIf
BASS_ChannelRemoveDSP(Handle,MyDSPHandle)
End


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sun May 25, 2008 5:36 pm 
Offline
Addict
Addict
User avatar

Joined: Fri Apr 25, 2003 7:06 pm
Posts: 2212
Location: Argentina
Now with a TracBar showing the position of the playing song

Code:

;PB4 example of a media player with pitch, tempo, equalizar and karaoke
;Ricardo (from PureBasic forum MAY 2008


IncludeFile "bass.pbi"

Global Handle, Karaoke, MyDSPHandle


Enumeration
  ;PLAY GADGETS
  #MP3Play
  #MP3Pause
  #MP3Stop
  #MP3Load
 
  ;EFFECTS GADGETS
  #FX_KARAOKE
 
  ;POSITION
  #Position_TrackBar
 
EndEnumeration


Procedure MyDSP(Handle,Channel,Buffer,Lenght,User)
  Shared Karaoke
  ;Just an example of DSP
 
  If Karaoke = 1
    Debug "aqui"
    For i = 0 To Lenght-1 Step 4
      Channel1.w = PeekW(Buffer+i)
      Channel2.w = PeekW(Buffer+i+2)
      nChannel1.w = Channel1 * -1
      nChannel2.w = Channel2 * -1
      Channel1 + nChannel2
      Channel2 + nChannel1
      PokeW(Buffer+i,Channel1)
      PokeW(Buffer+i+2,Channel2)
    Next
  EndIf
EndProcedure



If OpenWindow(0,100,50,450,150,"Example",#PB_Window_SystemMenu)
  CreateGadgetList(WindowID(0))
 
  ButtonGadget(#MP3Load,150,50,50,25,"Load")
  ButtonGadget(#MP3Stop,200,50,50,25,"Stop")
  ButtonGadget(#MP3Play,250,50,75,25,"Play")
  ButtonGadget(#MP3Pause,325,50,50,25,"Pause")
 
  ;Karaoke , its just an example of DSP usage
  CheckBoxGadget(#FX_KARAOKE,10,50,120,25,"Karaoke")
  SetGadgetState(#FX_KARAOKE,0);Karaoke not set by default
 
  TrackBarGadget(#Position_TrackBar,10,100,430,25,0,10000)
 
  ;- INICIA BASS
  BASS_Init(-1,44100,0,WindowID(0),#Null)
  ;Load song
  FileName.s = OpenFileRequester("","","MP3|*.MP3|;",0)
  If FileName
    Handle=BASS_StreamCreateFile(0, @FileName, 0, 0, 0)
    BASS_SetVolume(100)
    MyDSPHandle = BASS_ChannelSetDSP(Handle,@MyDSP(),0,0)
    BASS_ChannelPlay(Handle,0)
    uEndPos = BASS_StreamGetFilePosition(Handle,#BASS_FILEPOS_END);The lenght
  EndIf
 
  Dim FFT.f(512)
  Repeat
    EventID=WindowEvent()
    Delay(10)
    Select EventID
      Case 0
        If Handle And BASS_ChannelIsActive(Handle) = #BASS_ACTIVE_PLAYING
           BASS_ChannelGetData(Handle,@FFT(),#BASS_DATA_FFT1024);Here we get the FFT info to make later a metter
           uPos = BASS_StreamGetFilePosition(Handle,#BASS_FILEPOS_CURRENT)
          uActualPosition.f = (uPos/uEndPos) * 10000
          Debug uActualPosition
          SetGadgetState(#Position_TrackBar,Abs(uActualPosition))
        EndIf
      Case #PB_Event_Gadget
        Select EventGadget()
            ; ;- PLAY
          Case #MP3Load
            BASS_StreamFree(Handle)
            FileName.s = OpenFileRequester("","","MP3|*.MP3|;",0)
            If FileName
              Handle=BASS_StreamCreateFile(0, @FileName, 0, 0, 0)
              BASS_SetVolume(100)
              MyDSPHandle = BASS_ChannelSetDSP(Handle,@MyDSP(),0,0)
              BASS_ChannelPlay(Handle,0)
              uEndPos = BASS_StreamGetFilePosition(Handle,#BASS_FILEPOS_END);The lenght
            EndIf
          Case #MP3Play
            BASS_ChannelPlay(Handle,0)
          Case #MP3Pause
            BASS_ChannelPause(Handle)
            BASS_Start()
          Case #MP3Stop
            BASS_ChannelStop(Handle)
            BASS_ChannelSetPosition(Handle,0,#BASS_POS_BYTE)
          Case #FX_KARAOKE
            If GetGadgetState(#FX_KARAOKE) = 1
              Karaoke = 1
            Else
              Karaoke = 0
            EndIf
        EndSelect
    EndSelect
  Until EventID=#PB_Event_CloseWindow
EndIf
BASS_ChannelRemoveDSP(Handle,MyDSPHandle)
End


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sun May 25, 2008 9:59 pm 
Offline
Addict
Addict
User avatar

Joined: Fri Apr 25, 2003 7:06 pm
Posts: 2212
Location: Argentina
Okay, i have the include for BASS_FX 2.4



Code:
; '=============================================================================
; ' BASS_FX 2.4 - Copyright (c) 2002-2008 (: JOBnik! :) [Arthur Aminov, ISRAEL]
; '                                                     [http://www.jobnik.org]
; '
; '         bugs/suggestions/questions:
; '           forum  : http://www.un4seen.com/forum/?board=1
; '                    http://www.jobnik.org/smforum
; '           e-mail : bass_fx@jobnik.org
; '        --------------------------------------------------
; '
; ' NOTE: This module will only work with BASS_FX version 2.4
; '       Check www.un4seen.com or www.jobnik.org for any later versions.
; '
; ' * Requires BASS 2.4 (available @ www.un4seen.com)
; '=============================================================================


Global bass_fx_dll

ProcedureDLL.l BASS_FX_OpenDLL()
  bass_fx_dll=OpenLibrary(#PB_Any,"bass_fx.dll")
  ProcedureReturn bass_fx_dll
EndProcedure

ProcedureDLL.l BASS_FX_CloseDLL()
  If bass_fx_dll
    ;CallFunction(bass_fx_dll,"BASS_Free")
    CloseLibrary(bass_fx_dll)
    bass_fx_dll=0
  EndIf
EndProcedure


; Error codes returned by BASS_ErrorGetCode
#BASS_ERROR_FX_NODECODE = 4000     ; Not a decoding channel
BASS_ERROR_FX_BPMINUSE = 4001      ; BPM/Beat detection is in use


; Tempo / Reverse / BPM flag
#BASS_FX_FREESOURCE = $10000   ; Free the source handle as well? 0x10000

;=============================================================================================
;   D S P (Digital Signal Processing)
;=============================================================================================

;  Multi-channel order of each channel is as follows:
;   3 channels       left-front, right-front, center.
;   4 channels       left-front, right-front, left-rear/side, right-rear/side.
;   6 channels (5.1) left-front, right-front, center, LFE, left-rear/side, right-rear/side.
;   8 channels (7.1) left-front, right-front, center, LFE, left-rear/side, right-rear/side, left-rear center, right-rear center.

;DSP channels flags
#BASS_FX_DSP_CHANALL = -1        ; all channels at once (as by default)
#BASS_FX_DSP_CHANNONE = 0        ; disable an effect for all channels
#BASS_FX_DSP_CHAN1 = 1           ; left-front channel
#BASS_FX_DSP_CHAN2 = 2           ; right-front channel
#BASS_FX_DSP_CHAN3 = 4           ; see above info
#BASS_FX_DSP_CHAN4 = 8           ; see above info
#BASS_FX_DSP_CHAN5 = 16          ; see above info
#BASS_FX_DSP_CHAN6 = 32          ; see above info
#BASS_FX_DSP_CHAN7 = 64          ; see above info
#BASS_FX_DSP_CHAN8 = 128         ; see above info

;DSP effects
Enumeration ;DSPFX 
  #BASS_FX_DSPFX_ROTATE = $10000            ; A channels volume ping-pong  / STEREO Only!
  #BASS_FX_DSPFX_ECHO                       ; Echo                         / 2C max
  #BASS_FX_DSPFX_FLANGER                    ; Flanger                      / MC
  #BASS_FX_DSPFX_VOLUME                     ; Volume                       / MC
  #BASS_FX_DSPFX_PEAKEQ                     ; Peaking Equalizer            / MC
  #BASS_FX_DSPFX_REVERB                     ; Reverb                       / 2C max
  #BASS_FX_DSPFX_LPF                        ; Low Pass Filter              / MC
  #BASS_FX_BFX_MIX                         ; Stereo 2 Mono                / STEREO Only!
  #BASS_FX_DSPFX_DAMP                       ; Dynamic Amplification        / MC
  #BASS_FX_DSPFX_AUTOWAH                    ; Auto WAH                     / MC
  #BASS_FX_DSPFX_ECHO2                      ; Echo 2                       / MC
  #BASS_FX_DSPFX_PHASER                     ; Phaser                       / MC
  #BASS_FX_DSPFX_ECHO3                      ; Echo 3                       / MC
  #BASS_FX_DSPFX_CHORUS                     ; Chorus                       / MC
  #BASS_FX_DSPFX_APF                        ; All Pass Filter              / MC
  #BASS_FX_DSPFX_COMPRESSOR                 ; Compressor                   / MC
  #BASS_FX_DSPFX_DISTORTION                 ; Distortion                   / MC
EndEnumeration

Structure BASS_BFX_ECHO
  fLevel.f
  lDelay.l
EndStructure

; Flanger
Structure BASS_BFX_FLANGER
  fWetDry.f                          ; [0....1....n] linear
  fSpeed.f                           ; [0......0.09]
  lChannel.l                           ; BASS_FX_DSP_CHANxxx flag/s
EndStructure

Structure BASS_BFX_VOLUME
  lChannel.l
  fVolume.f
EndStructure

; Peaking Equalizer
Structure BASS_BFX_PEAKEQ
  lBand.l                              ; [0..n] more bands => more memory & cpu usage
  fBandwidth.f                       ; in octaves [0.1..4..n] - Q is not in use
  fQ.f                               ; the EE kinda definition [0..1..n] - Bandwidth is not in use
  fCenter.f                          ; in Hz [1Hz.........nHz]
  fGain.f                            ; in dB [-15dB..0..+15dB]
  lChannel.l                           ; BASS_FX_DSP_CHANxxx flag/s
EndStructure

; Reverb
Structure BASS_BFX_REVERB
  fLevel.f                           ; [0....1....n] linear
  lDelay.l                             ; [1200..10000]
EndStructure

; Low Pass Filter
Structure BASS_FX_DSPLPF
  fResonance.f                       ; [0.1...........10]
  fCutOffFreq.f                      ; [1Hz..info.freq/2]
  lChannel.l                           ; BASS_FX_DSP_CHANxxx flag/s
EndStructure

Structure BASS_BFX_MIX
  lChannel.l                         ; a pointer to an array of channels to mix using BASS_BFX_CHANxxx flag/s (lChannel[0] is left channel...)
EndStructure

; Dynamic Amplification
Structure BASS_BFX_DAMP
  fTarget.f                          ; target volume level                      [0<......1] linear
  fQuiet.f                           ; quiet  volume level                      [0.......1] linear
  fRate.f                            ; amp adjustment rate                      [0.......1] linear
  fGain.f                            ; amplification level                      [0...1...n] linear
  fDelay.f                           ; delay in seconds before increasing level [0.......n] linear
  lChannel.l                           ; BASS_FX_DSP_CHANxxx flag/s
EndStructure

; Auto WAH
Structure BASS_BFX_AUTOWAH
  fDryMix.f                          ; dry (unaffected) signal mix              [-2......2]
  fWetMix.f                          ; wet (affected) signal mix                [-2......2]
  fFeedback.f                        ; feedback                                 [-1......1]
  fRate.f                            ; rate of sweep in cycles per second       [0<....<10]
  fRange.f                           ; sweep range in octaves                   [0<....<10]
  fFreq.f                            ; base frequency of sweep Hz               [0<...1000]
  lChannel.l                           ; BASS_FX_DSP_CHANxxx flag/s
EndStructure

; Echo 2
Structure BASS_BFX_ECHO2
  fDryMix.f                          ; dry (unaffected) signal mix              [-2......2]
  fWetMix.f                          ; wet (affected) signal mix                [-2......2]
  fFeedback.f                        ; feedback                                 [-1......1]
  fDelay.f                           ; delay sec                                [0<......6]
  lChannel.l                           ; BASS_FX_DSP_CHANxxx flag/s
EndStructure

; Phaser
Structure BASS_BFX_PHASER
  fDryMix.f                          ; dry (unaffected) signal mix              [-2......2]
  fWetMix.f                          ; wet (affected) signal mix                [-2......2]
  fFeedback.f                        ; feedback                                 [-1......1]
  fRate.f                            ; rate of sweep in cycles per second       [0<....<10]
  fRange.f                           ; sweep range in octaves                   [0<....<10]
  fFreq.f                            ; base frequency of sweep                  [0<...1000]
  lChannel.l                           ; BASS_FX_DSP_CHANxxx flag/s
EndStructure

; Echo 3
Structure BASS_BFX_ECHO3
  fDryMix.f                          ; dry (unaffected) signal mix              [-2......2]
  fWetMix.f                          ; wet (affected) signal mix                [-2......2]
  fDelay.f                           ; delay sec                                [0<......6]
  lChannel.f                           ; BASS_FX_DSP_CHANxxx flag/s
EndStructure

; Chorus
Structure BASS_BFX_CHORUS
  fDryMix.f                          ; dry (unaffected) signal mix              [-2......2]
  fWetMix.f                          ; wet (affected) signal mix                [-2......2]
  fFeedback.f                        ; feedback                                 [-1......1]
  fMinSweep.f                        ; minimal delay ms                         [0<..<6000]
  fMaxSweep.f                        ; maximum delay ms                         [0<..<6000]
  fRate.f                            ; rate ms/s                                [0<...1000]
  lChannel.l                           ; BASS_FX_DSP_CHANxxx flag/s
EndStructure

; All Pass Filter
Structure BASS_BFX_APF
  fGain.f                            ; reverberation time                       [-1=<..<=1]
  fDelay.f                           ; delay sec                                [0<....<=6]
  lChannel.l                           ; BASS_FX_DSP_CHANxxx flag/s
EndStructure

; Compressor
Structure BASS_BFX_COMPRESSOR
  fThreshold.f                       ; compressor threshold                     [0<=...<=1]
  fAttacktime.f                      ; attack time ms                           [0<.<=1000]
  fReleasetime.f                     ; release time ms                          [0<.<=5000]
  lChannel.l                           ; BASS_FX_DSP_CHANxxx flag/s
EndStructure

; Distortion
Structure BASS_BFX_DISTORTION
  fDrive.f                           ; distortion drive                         [0<=...<=5]
  fDryMix.f                          ; dry (unaffected) signal mix              [-5<=..<=5]
  fWetMix.f                          ; wet (affected) signal mix                [-5<=..<=5]
  fFeedback.f                        ; feedback                                 [-1<=..<=1]
  fVolume.f                          ; distortion volume                        [0=<...<=2]
  lChannel.l                           ; BASS_FX_DSP_CHANxxx flag/s
EndStructure

; '=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
; '       set dsp fx - BASS_ChannelSetFX
; ' ===========================================================================================
; '       remove dsp fx - BASS_ChannelRemoveFX
; ' ===========================================================================================
; '       set parameters - BASS_FXSetParameters
; ' ===========================================================================================
; '       retrieve parameters - BASS_FXGetParameters
; ' ===========================================================================================
; '       reset the state - BASS_FXReset
; '=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
;
; '=============================================================================================
; '   TEMPO / PITCH SCALING / SAMPLERATE
; '=============================================================================================


Enumeration ;TempoAttribs
  #BASS_ATTRIB_TEMPO = $10000
  #BASS_ATTRIB_TEMPO_PITCH
  #BASS_ATTRIB_TEMPO_FREQ
EndEnumeration

Enumeration ;TempoAttribsOptions
  #BASS_ATTRIB_TEMPO_OPTION_USE_AA_FILTER = $10010     ;' TRUE / FALSE
  #BASS_ATTRIB_TEMPO_OPTION_AA_FILTER_LENGTH           ;' 32 default (8 .. 128 taps)
  #BASS_ATTRIB_TEMPO_OPTION_USE_QUICKALGO              ;' TRUE / FALSE
  #BASS_ATTRIB_TEMPO_OPTION_SEQUENCE_MS                ;' 82 default
  #BASS_ATTRIB_TEMPO_OPTION_SEEKWINDOW_MS              ;' 14 default
  #BASS_ATTRIB_TEMPO_OPTION_OVERLAP_MS                 ;' 12 default
EndEnumeration


; NOTE: 1. Supported ONLY - mono / stereo - channels
;       2. Enable Tempo supported flags in BASS_FX_TempoCreate and the others to source handle.

ProcedureDLL.l BASS_FX_TempoCreate (chan.l, flags.l)
  ;   Creates a resampling stream from a decoding channel.
  ;   chan     : a handle returned by:
  ;                   BASS_StreamCreateFile     : flags = BASS_STREAM_DECODE ...
  ;                   BASS_MusicLoad            : flags = BASS_MUSIC_DECODE ...
  ;                   BASS_WMA_StreamCreateFile : flags = BASS_STREAM_DECODE ...
  ;                   BASS_CD_StreamCreate      : flags = BASS_STREAM_DECODE ...
  ;                   * Any other add-on handle using a decoding channel.
  ;   flags    : BASS_SAMPLE_SOFTWARE/LOOP/3D/FX or BASS_STREAM_DECODE/AUTOFREE or
  ;              BASS_SPEAKER_xxx or BASS_FX_FREESOURCE
  ;   RETURN   : the tempo stream handle (0=error!)
  ProcedureReturn CallFunction(bass_fx_dll,"BASS_FX_TempoCreate",chan.l, flags.l)
EndProcedure

ProcedureDLL.l BASS_FX_TempoGetSource (chan.l)
  ;   Get the source channel handle.
  ;   chan   : tempo stream handle
  ;   RETURN : the source channel handle (0=error!)
  ProcedureReturn CallFunction(bass_fx_dll,"BASS_FX_TempoGetSource",chan.l)
EndProcedure


ProcedureDLL.f BASS_FX_TempoGetRateRatio (chan.l)
  ;   Get the ratio of the resulting rate and source rate (the resampling ratio).
  ;   chan   : tempo stream (or source channel) handle
  ;   RETURN : the ratio(0 = Error!)
  ProcedureReturn CallFunction(bass_fx_dll,"BASS_FX_TempoGetRateRatio",chan.l)
EndProcedure

; '=============================================================================================
; '   B P M (Beats Per Minute)
; '=============================================================================================
;
; ' NOTE: Supported only mono or stereo channels.
;
; ' bpm flags


#BASS_FX_BPM_BKGRND = 1      ; If in use, then you can do other processing While detection's in progress. (bpm/Beat)
#BASS_FX_BPM_MULT2 = 2       ; If in use, then will auto multiply bpm by 2 (If bpm < MinBPM*2)

Enumeration ;bpmTranslation
  #BASS_FX_BPM_TRAN_X2         ; multiply the original BPM value by 2 (may be called only once & will change the original BPM as well!)
  #BASS_FX_BPM_TRAN_2FREQ      ; bpm Value To frequency
  #BASS_FX_BPM_TRAN_FREQ2      ; frequency To bpm Value
  #BASS_FX_BPM_TRAN_2PERCENT   ; bpm Value To Percents
  #BASS_FX_BPM_TRAN_PERCENT2   ; Percents To bpm Value
EndEnumeration


; Option - 1 - Get BPM from a decoded channel

ProcedureDLL.l BASS_FX_BPM_DecodeGet (chan.l, startSec.l, endSec.l, minMaxBPM.l, flags.l, proc.l)
  ;   Get the original BPM of a decoding channel.
  ;   chan      : a handle returned by:
  ;                   BASS_StreamCreateFile     : flags = BASS_STREAM_DECODE ...
  ;                   BASS_MusicLoad            : flags = BASS_MUSIC_DECODE Or BASS_MUSIC_PRESCAN ...
  ;                   BASS_WMA_StreamCreateFile : flags = BASS_STREAM_DECODE ...
  ;                   BASS_CD_StreamCreate      : flags = BASS_STREAM_DECODE ...
  ;                   * Any other add-on handle using a decoding channel.
  ;   startSec  : start detecting position in seconds
  ;   endSec    : end detecting position in seconds
  ;   minMaxBPM : set min & max bpm, e.g: MAKELONG(LOWORD.HIWORD), LO=Min, HI=Max. 0 = defaults 45/230
  ;   flags     : BASS_FX_BPM_xxx or BASS_FX_FREESOURCE
  ;   proc      : user defined function to receive the process in percents, use 0 if not in use
  ;   RETURN    : the original BPM value (-1=error!)
  ProcedureReturn CallFunction(bass_fx_dll,"BASS_FX_BPM_DecodeGet",chan.l, startSec.l, endSec.l, minMaxBPM.l, flags.l, proc.l)
EndProcedure


; Option - 2 - Auto get BPM by period of time in seconds

ProcedureDLL.l BASS_FX_BPM_CallbackSet (Handle.l, proc.l, period.l, minMaxBPM.l, flags.l, User.l)
  ;   Enable getting BPM value by period of time in seconds.
  ;   handle    : stream/music/wma/cd/any other supported add-on format
  ;   proc      : user defined function to receive the bpm value
  ;   period    : detection period in seconds
  ;   minMaxBPM : set min & max bpm, e.g: MAKELONG(LOWORD.HIWORD), LO=Min, HI=Max. 0 = defaults 45/230
  ;   flags     : only BASS_FX_BPM_MULT2 flag is used
  ;   user      : user instance data to pass to the callback function.
  ;   RETURN    : TRUE if ok (0=error!)
  ProcedureReturn CallFunction(bass_fx_dll,"BASS_FX_BPM_CallbackSet",Handle.l, proc.l, period.l, minMaxBPM.l, flags.l, User.l)
EndProcedure

ProcedureDLL.l BASS_FX_BPM_CallbackReset (Handle.l)
  ;   Reset the buffers. Call this function after changing position.
  ;   handle : stream/music/wma/cd/any other supported add-on format
  ;   RETURN : TRUE if ok (0=error!)
  ProcedureReturn CallFunction(bass_fx_dll,"BASS_FX_BPM_CallbackReset",Handle.l)
EndProcedure

ProcedureDLL.l BASS_FX_BPM_Translate (Handle.l, val2tran.f, trans.l)
  ;   Translate the given BPM to FREQ/PERCENT and vice versa or multiply BPM by 2.
  ;   handle   : stream/music/wma/cd/any other supported add-on format
  ;   val2tran : specify a value to translate to a given option (no matter if used X2).
  ;   trans    : any of the above translation option
  ;   RETURN   : new calculated value. (-1=error!)
  ;
  ;   NOTE     : This function will not detect the BPM, it will just translate the detected
  ;              original BPM value of a given handle.
  ProcedureReturn CallFunction(bass_fx_dll,"BASS_FX_BPM_Translate",Handle.l, val2tran.f, trans.l)
EndProcedure

ProcedureDLL.l BASS_FX_BPM_Free (Handle.l)
  ;   Free all resources used by a given handle.
  ;
  ;   NOTE: If BASS_FX_FREESOURCE is used, then will free the decoding channel as well.
  ;         You can;t set/get this flag with BASS_ChannelSetFlags/BASS_ChannelGetInfo.
  ;
  ;   handle : stream/music/wma/cd/any other supported add-on format
  ProcedureReturn CallFunction(bass_fx_dll,"BASS_FX_BPM_Free",Handle.l)
EndProcedure


; '=============================================================================================
; '   B E A T
; '=============================================================================================

ProcedureDLL.l BASS_FX_BPM_BeatCallbackSet (Handle.l, proc.l, User.l)
  ;   Enable getting Beat position in seconds.
  ;   handle   : stream/music/wma/cd/any other supported add-on format
  ;   proc     : user defined function to receive the beat position in seconds
  ;   user     : user instance data to pass to the callback function.
  ;   RETURN   : TRUE if ok (0=error!)
  ProcedureReturn CallFunction(bass_fx_dll,"BASS_FX_BPM_BeatCallbackSet",Handle.l, proc.l, User.l)
EndProcedure

ProcedureDLL.l BASS_FX_BPM_BeatCallbackReset (Handle.l)
  ProcedureReturn CallFunction(bass_fx_dll,"BASS_FX_BPM_BeatCallbackReset",Handle.l)
EndProcedure

ProcedureDLL.l BASS_FX_BPM_BeatDecodeGet (Handle.l,startSec.l,endSec.l,flags.l,Process.l,userdata.l)
  ProcedureReturn CallFunction(bass_fx_dll,"BASS_FX_BPM_BeatDecodeGet",Handle.l,startSec.l,endSec.l,flags.l,Process.l,userdata.l)
EndProcedure

ProcedureDLL BASS_FX_BPM_BeatSetParameters (Handle.l, Bandwith.l,centerfreq.f,beat_rtime.l)
  ProcedureReturn CallFunction(bass_fx_dll,"BASS_FX_BPM_BeatSetParameters",Handle.l, Bandwith.l,centerfreq.f,beat_rtime.l)
EndProcedure

ProcedureDLL BASS_FX_BPM_BeatGetParameters (Handle.l, Bandwith.l,centerfreq.f,beat_rtime.l)
  ProcedureReturn CallFunction(bass_fx_dll,"BASS_FX_BPM_BeatGetParameters",Handle.l, Bandwith.l,centerfreq.f,beat_rtime.l)
EndProcedure

ProcedureDLL.l BASS_FX_BPM_BeatFree (Handle.l)
  ;   Free all resources used by a given handle.
  ;   handle : stream/music/wma/cd/any other supported add-on format
  ProcedureReturn CallFunction(bass_fx_dll,"BASS_FX_BPM_BeatFree",Handle.l)
EndProcedure


; '=============================================================================================
; '   Callback functions
; '=============================================================================================

ProcedureDLL.l BPMBEATPROC(Handle.l, beatpos.l, User.l)
  ;   CALLBACK FUNCTION! - Uses with Beat Callback
  ;
  ;   Get the Beat position in seconds.
  ;   handle  : handle that the BASS_FX_BPM_BeatCallbackSet has applied to
  ;   beatpos : the exact beat position in seconds
  ;   user    : the user instance data given when BASS_FX_BPM_BeatCallbackSet was called
EndProcedure

ProcedureDLL.l BPMPROCESSPROC(chan.l, percent.l)
  ;   CALLBACK FUNCTION! - Uses with Option 1 (decode)
  ;
  ;   Get the detection process in percents of a channel.
  ;   chan    : channel that the BASS_FX_BPM_DecodeGet has applied to
  ;   percent : the process in percents [0%..100%]
EndProcedure

ProcedureDLL.l BPMPROC(Handle.l, bpm.l, User.l)
  ;   CALLBACK FUNCTION! - Uses with Option 2 (callback)
  ;
  ;   Get the BPM after period of time in seconds.
  ;   handle : handle that the BASS_FX_BPM_CallbackSet has applied to
  ;   bpm    : the new original bpm value
  ;   user   : the user instance data given when BASS_FX_BPM_CallbackSet was called.
EndProcedure



So, i will start trying to get the BEAT to see if i can sync 2 song to tplay at same TEMPO.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sun May 25, 2008 10:09 pm 
Offline
Addict
Addict
User avatar

Joined: Sat Feb 19, 2005 5:05 pm
Posts: 1769
Location: Norway
Cool. Hey ricardo you should email jobnik your BASS_FX 2.4 include so he can add it to the BASS_FX 2.4 archive. :)


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sun May 25, 2008 10:24 pm 
Offline
Addict
Addict
User avatar

Joined: Fri Apr 25, 2003 7:06 pm
Posts: 2212
Location: Argentina
Rescator wrote:
Cool. Hey ricardo you should email jobnik your BASS_FX 2.4 include so he can add it to the BASS_FX 2.4 archive. :)


Okay :)


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon May 26, 2008 12:07 am 
Offline
Addict
Addict
User avatar

Joined: Fri Apr 25, 2003 7:06 pm
Posts: 2212
Location: Argentina
Trying to detect BEAT and BPM

Beat is allready working (however something is a little tricky in my code)

Take a look of where i am at this moment (help needed to find problem!)

*I will open a thread for that for not interfering with this one.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 36 posts ]  Go to page 1, 2, 3  Next

All times are UTC + 1 hour


Who is online

Users browsing this forum: Yahoo [Bot] and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye