IonicWind Software

Aurora Compiler => Coding Help - Aurora 101 => Topic started by: ExMember001 on April 29, 2008, 03:10:57 PM

Title: Problem using BASS dll 2.4
Post by: ExMember001 on April 29, 2008, 03:10:57 PM
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)

Title: Re: Problem using BASS dll 2.4
Post by: Ionic Wind Support Team on April 29, 2008, 04:03:21 PM
Try using a double instead of a float.  C compilers always promote floats to doubles on return.

Paul.
Title: Re: Problem using BASS dll 2.4
Post by: 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


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.
Title: Re: Problem using BASS dll 2.4
Post by: ExMember001 on April 29, 2008, 05:30:09 PM
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.
Title: Re: Problem using BASS dll 2.4
Post by: ExMember001 on April 29, 2008, 05:41:18 PM
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 ;)
Title: Re: Problem using BASS dll 2.4
Post by: sapero on April 29, 2008, 05:53:05 PM
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;
}
Title: Re: Problem using BASS dll 2.4
Post by: ExMember001 on April 29, 2008, 06:07:17 PM
Thanks it does the trick in a sub  ;D