May 23, 2019, 06:56:07 am

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


Problem using BASS dll 2.4

Started by ExMember001, April 29, 2008, 03:10:57 pm

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

ExMember001

April 29, 2008, 03:10:57 pm Last Edit: April 29, 2008, 03:53:22 pm by KrYpT
Hi,
BASS dll as been updated to 2.4 and i have a problem translating one function
In the new version 2.4
the function BASS_GetVolume() now return a float from 0 (no sound) to 1(max sound)
I'm trying to get this function to works but it always return me "0.00" with this code
Code Select

#include "bass.inc"

//Our main routine
global sub main()
{
        BASS_Init( -1,44100,0,0,null);
float myvolume = BASS_GetVolume();
print(USING("%f#.## master volume",myvolume));
do{}until getkey() <> "";
return false;
}



From the docs they said :
Retrieves the current master volume level.
float BASS_GetVolume();
Return value
If successful, the volume level is returned, else -1 is returned.


i have contacted BASS support but they said thats the function works (Using their "C "precompiled BASSTEST.exe)
So now i'm asking here, Does someone know what i'm doing wrong here?

Compilable code is attach to this post in the zip file below (Include BASS 2.4.0.1 headers and dll files)


Ionic Wind Support Team

Try using a double instead of a float.  C compilers always promote floats to doubles on return.

Paul.
Ionic Wind Support Team

sapero

April 29, 2008, 04:28:27 pm #2 Last Edit: April 29, 2008, 04:48:21 pm by sapero
It is very interesting.
I have looked at this function under the debugger, the volume is returned in st0:

Code Select
call    11001178 // xor eax,eax
fld     dword [1102518C]
ret


This piece of code is working:
Code Select
#include "bass.inc"

//Our main routine
global sub main()
{
float myvolume;
int MyCurrentDesktopHandle = 0x000B00D2;

BASS_Init(-1,44100,0,MyCurrentDesktopHandle,NULL);
BASS_GetVolume();
// working
#emit fstp dword[ebp-4]
print(USING("%f#.## master volume",myvolume));
// not working
myvolume = BASS_GetVolume();
print(USING("%f#.## master volume",myvolume));

do{}until getkey() <> "";
return false;
}
But after changing BASS_GetVolume return value to double (and the fstp to qword) does not help.

ExMember001

April 29, 2008, 05:30:09 pm #3 Last Edit: April 29, 2008, 05:37:23 pm by KrYpT
thanks sapero :)
the working part works in the console but when i put it in my program it return random number  :-\
Paul, i had try with double but same result.

ExMember001

Quote from: sapero on April 29, 2008, 04:28:27 pm
It is very interesting.
I have looked at this function under the debugger, the volume is returned in st0:

Code Select
call    11001178 // xor eax,eax
fld     dword [1102518C]
ret



is it a problem with the dll? I doesnt understand what this mean ;)

sapero

April 29, 2008, 05:53:05 pm #5 Last Edit: April 29, 2008, 05:56:59 pm by sapero
It shows how the function returns a value.

To use the 'myvolume' variable as function local variable, ensure it is always the first variable.
Or move it to global variables, and change the FSTP:
Code Select
float g_myvolume;

sub myfunc()
{
[...]
BASS_GetVolume();
#emit fstp dword[g_myvolume]
// use g_myvolume here
}

or instead BASS_GetVolume, call this function:
Code Select
sub BASSGetVolume(),float
{
float vol;
BASS_GetVolume();
#emit fstp dword[ebp-4]
return vol;
}

ExMember001

Thanks it does the trick in a sub  ;D