March 28, 2024, 03:42:57 PM

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

#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:

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.

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:

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:
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;
}

ExMember001

Thanks it does the trick in a sub  ;D