Author Topic: Is BASS FX "loaded" ?  (Read 104 times)

Couin

  • Posts: 61
Is BASS FX "loaded" ?
« on: 14 Jan '23 - 04:41 »
Hi friends :)

First , I wish you a happy new year :)

I catched a problem on customized version Jingle Palette, i a precise case.
If I have no palette (all jingles buttons are empty, palettes list is empty), I can not fully assign a jingle.

Here i revelant lines of my code :
Code: [Select]
Jing(btNum).StrmFile = BASS_StreamCreateFile(BASSFALSE, StrPtr(Jing(btNum).Path), 0, 0, BASS_STREAM_DECODE)
If Jing(btNum).StrmFile = 0 Then Jing(btNum).StrmFile = BASS_MusicLoad(BASSFALSE, StrPtr(Jing(btNum).Path), 0, 0, BASS_MUSIC_RAMP Or BASS_MUSIC_PRESCAN Or
BASS_ChannelSetAttribute Jing(btNum).StrmFile, BASS_ATTRIB_VOL, 1
Call BASS_ChannelGetInfo(Jing(btNum).StrmFile, info(btNum))
freq(btNum) = info(btNum).freq
MsgBox freq(btNum)
Jing(btNum).Strm = BASS_FX_TempoCreate(Jing(btNum).StrmFile, BASS_FX_FREESOURCE)
MsgBox Jing(btNum).Strm

You can notice 2 MsgBox commands. The first (where I get the samplerate of the audio  file, is displaying, with the good value (ie. 44100) but the second MsgBox does not appears.

If I save the new palette, I get a Missing file Bass_fx.dll error (but the palette is saved), and after, it's ok, the  assigned jingle appears and can be played without problem.
I restart the software, no probleme to assign other jingles.
It's only when all is empty.


Is there a BASS command to check if BASS FX is loaded ?  I would try to use it to search where I did something wrong.

Thank :)
Couin

jpf

  • Posts: 163
Re: Is BASS FX "loaded" ?
« Reply #1 on: 14 Jan '23 - 10:47 »
Is there a BASS command to check if BASS FX is loaded ?

It's BASS_FX_GetVersion.
Call it before any use of other bass_fx.dll calls to load and initialize the dll. Otherwise other functions first call  may fail because the dll isn't already loaded. VB6 doesn't load any dll until they're called for the first time. A Declare statement doesn't automatically load a dll.

Chris

  • Posts: 2114
Re: Is BASS FX "loaded" ?
« Reply #2 on: 14 Jan '23 - 11:41 »
yes the problem is also you don't check if the stream is valid.
Code: [Select]
Jing(btNum).StrmFile = BASS_StreamCreateFile(BASSFALSE, StrPtr(Jing(btNum).Path), 0, 0, BASS_STREAM_DECODE)
If Jing(btNum).StrmFile = 0 Then Jing(btNum).StrmFile = BASS_MusicLoad(BASSFALSE, StrPtr(Jing(btNum).Path), 0, 0, BASS_MUSIC_RAMP Or BASS_MUSIC_PRESCAN ..........
If Jing(btNum).StrmFile  <> 0 then .... Here your Error Handling  (Stream has not loaded)



Couin

  • Posts: 61
Re: Is BASS FX "loaded" ?
« Reply #3 on: 14 Jan '23 - 15:03 »
Hi friends :)

In fact, there is an more detailled code (I though the lines I posted first was the only revelant files), so my code should already contains the If Jing(btNum).StrmFile  <> 0 (as well as I have If Jing(btNum).StrmFile  = 0 and else after). Plus, I just saw I made a mistake when I copied-paste code  :-[

Code: [Select]
Jing(btNum).StrmFile = BASS_StreamCreateFile(BASSFALSE, StrPtr(Jing(btNum).Path), 0, 0, BASS_STREAM_DECODE)
If Jing(btNum).StrmFile = 0 Then Jing(btNum).StrmFile = BASS_MusicLoad(BASSFALSE, StrPtr(Jing(btNum).Path), 0, 0, BASS_MUSIC_RAMP Or BASS_MUSIC_PRESCAN Or BASS_MUSIC_DECODE, 0)
If Jing(btNum).StrmFile = 0 Then
If BASS_ErrorGetCode() <> 0 Then
If BASS_ErrorGetCode() = 2 Then
frmMain.b_Jingle(btNum).Caption = Replace(btCaption(Jing(btNum).Path, frmMain.b_Jingle(btNum)), JLabelSeparator, Chr(13)) & Chr(13) & LangSet.Entry("mMissFile", , Language)
Else
frmMain.b_Jingle(btNum).Caption = Replace(btCaption(Jing(btNum).Path, frmMain.b_Jingle(btNum)), JLabelSeparator, Chr(13)) & Chr(13) & BassErrMessage(BASS_ErrorGetCode())
End If
frmMain.b_Jingle(btNum).BackColor = DefBackColor
frmMain.b_Jingle(btNum).ForeColor = vbRed
...
End If
Else
BASS_ChannelSetAttribute Jing(btNum).StrmFile, BASS_ATTRIB_VOL, 1
Call BASS_ChannelGetInfo(Jing(btNum).StrmFile, info(btNum))
freq(btNum) = info(btNum).freq
MsgBox freq(btNum)
BASS_FX_GetVersion
Jing(btNum).Strm = BASS_FX_TempoCreate(Jing(btNum).StrmFile, BASS_FX_FREESOURCE)
MsgBox Jing(btNum).Strm
...
End If

But as described by jpf, if I add BASS_FX_GetVersion after MsgBox freq(btNum), the problem disappear :)

Thaks for great help and have a nice week-end :)