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
#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)
Try using a double instead of a float. C compilers always promote floats to doubles on return.
Paul.
It is very interesting.
I have looked at this function under the debugger, the volume is returned in st0:
call 11001178 // xor eax,eax
fld dword [1102518C]
ret
This piece of code is working:#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.
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.
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:
call 11001178 // xor eax,eax
fld dword [1102518C]
ret
is it a problem with the dll? I doesnt understand what this mean ;)
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:
float g_myvolume;
sub myfunc()
{
[...]
BASS_GetVolume();
#emit fstp dword[g_myvolume]
// use g_myvolume here
}
or instead BASS_GetVolume, call this function:sub BASSGetVolume(),float
{
float vol;
BASS_GetVolume();
#emit fstp dword[ebp-4]
return vol;
}
Thanks it does the trick in a sub ;D