Jump to content
    1. Welcome to GTAForums!

    1. GTANet.com

    1. GTA Online

      1. The Criminal Enterprises
      2. Updates
      3. Find Lobbies & Players
      4. Guides & Strategies
      5. Vehicles
      6. Content Creator
      7. Help & Support
    2. Red Dead Online

      1. Blood Money
      2. Frontier Pursuits
      3. Find Lobbies & Outlaws
      4. Help & Support
    3. Crews

    1. Grand Theft Auto Series

      1. Bugs*
      2. St. Andrews Cathedral
    2. GTA VI

    3. GTA V

      1. Guides & Strategies
      2. Help & Support
    4. GTA IV

      1. The Lost and Damned
      2. The Ballad of Gay Tony
      3. Guides & Strategies
      4. Help & Support
    5. GTA San Andreas

      1. Classic GTA SA
      2. Guides & Strategies
      3. Help & Support
    6. GTA Vice City

      1. Classic GTA VC
      2. Guides & Strategies
      3. Help & Support
    7. GTA III

      1. Classic GTA III
      2. Guides & Strategies
      3. Help & Support
    8. Portable Games

      1. GTA Chinatown Wars
      2. GTA Vice City Stories
      3. GTA Liberty City Stories
    9. Top-Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    1. Red Dead Redemption 2

      1. PC
      2. Help & Support
    2. Red Dead Redemption

    1. GTA Mods

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Red Dead Mods

      1. Documentation
    3. Mod Showroom

      1. Scripts & Plugins
      2. Maps
      3. Total Conversions
      4. Vehicles
      5. Textures
      6. Characters
      7. Tools
      8. Other
      9. Workshop
    4. Featured Mods

      1. Design Your Own Mission
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Rockstar Games

    2. Rockstar Collectors

    1. Off-Topic

      1. General Chat
      2. Gaming
      3. Technology
      4. Movies & TV
      5. Music
      6. Sports
      7. Vehicles
    2. Expression

      1. Graphics / Visual Arts
      2. GFX Requests & Tutorials
      3. Writers' Discussion
      4. Debates & Discussion
    1. Announcements

    2. Support

    3. Suggestions

*DO NOT* SHARE MEDIA OR LINKS TO LEAKED COPYRIGHTED MATERIAL. Discussion is allowed.

Call bass.dll function from cleo


MKKJ
 Share

Recommended Posts

I'm trying to use functions from bass.dll that returns a value.
However the proc always return -1 and with error code 5, which means the handle is invalid.

So does handle i got from CLEO is different from handle used in bass.dll?
Or is there's anything else i miss?

 

0AAC: [email protected] = load_audiostream "cleo\track.mp3"0AAD: set_mp3 [email protected] perform_action 10AC0: audiostream [email protected] loop 1......:Loopwait 0if 0AA2: [email protected] = load_library "bass.dll" // IF and SETthen    if 0AA4: [email protected] = get_proc_address "BASS_ChannelGetLength" library [email protected] // IF and SET    then        0AA7: call_function [email protected] num_params 2 pop 0 [email protected] 0 [email protected]        if and        0039:   [email protected] == -1        0AA4: [email protected] = get_proc_address "BASS_ErrorGetCode" library [email protected] // IF and SET        then            0AA7: call_function [email protected] num_params 0 pop 0 [email protected] // (always 5)        end    endendjump @Loop

 




EDIT: It's solved. But i have more question to ask.

Now i'm not actually a knowledgeable coder, so i have lot of things i don't understand when it comes to actual coding outside of scm.

One of functions, BASS_Bytes2Seconds requires a qword and returns a double.

 

double BASSDEF(BASS_ChannelBytes2Seconds)(DWORD handle, QWORD pos);
Qword param can be solved by passing two variables at once because it's just like double variables


0AA4: xProc = get_proc_address "BASS_ChannelBytes2Seconds" library xBass0AA7: call_function xProc num_params 3 pop 0 iPos2 iPos1 hBass dTime
But it can't return the double float value. It's just return 1 in byte. So how can i retrieve this value in cleo?



I'm also trying to use BASS_FXSetParameters.


(BASS_FXSetParameters)(DWORD fxHandle, void *params)
But they require parametric constructor (i just picked up the term) That by what i just catch, it's like an object that contains several parameters as one. It's supposed to be used like this
BASS_DX8_ECHO echo = new BASS_DX8_ECHO(value,value,value,value,value);Bass.BASS_FXSetParameters(fxHandle, echo);
Is it possible to re-interpret this in cleo? Or is it just isn't worth it?

 

Edited by MKKJ
Link to comment
Share on other sites

Yes. The CLEO sound system is a interface to BASS. The handle returned by opcodes 0x0AAC and 0x0AC1 can not be directly used by BASS API because it's a address pointing to a CAudioStream or C3dAudioStream object (concept of CLEO).

Edited by Guest
Link to comment
Share on other sites

Is there a way to retrieve the bass.dll handle?

I've been trying to figure out what is stored in CLEO handle, but only got some address at +0x0 and audio state (play/stop) at +0x8

Edited by MKKJ
Link to comment
Share on other sites

The CAudioStream class is composed of...

+0x00 hBassStream ; This is a HSTREAM type. It's provided by BASS API.

+0x04 uState

+0x08 bOk

 

I am not sure if a BASS function works fine when a CAudioStream->hBassStream is pushed to itself as parameter. Perhaps, you can load a stream by call BASS_StreamCreateFile function.

Edited by Guest
Link to comment
Share on other sites

Apparently pushing CAudioStream->hBassStream as parameter doesn't work, or any other values around.

Also AudioStream play/pause state is in +0x8 (unless that is what you meant), i don't know what value is in +0x4 but it seems important as it's always pushed before cleo call bass functions.

 

Considering my lack of knowledge around audiostream and bass.dll, I'll take my time to either figure to the handle from cleo's stream or streaming audio from BASS_StreamCreateFile (although its kinda redundant to do it in cleo).

 

 

EDIT:

CAudioStream + 0x4 does contain actual handle. Another thing i missed is that i supposed to reverse order of params to pass at 0AA7.

I can use command process (Play, Pause) with 0AA5, but not returned functions (0AA7). It always returns error code 37 (Requested data is not available)

Edited by MKKJ
Link to comment
Share on other sites

Perhaps have another value at 0x00 offset, so 0x04 potentially would be a HSTREAM. I have seen the CAudioStream class from CLEO 4(1/2) SDK, it had only hBassStream, uState e bOk; the remaining items are functions. I will try to find the CLEO SDK. It's hard to find anything in my HDD.

 

I had tried to use symbols of BASS, but the game crashed several times. Then i have preferred to use Miles Sound System.

Edited by Guest
Link to comment
Share on other sites

Thanks, but i've gotten around it just now.

The only problem might be some function just crashes the game for some reason. Like BASS_Bytes2Seconds. Maybe because one of required param is a qword.

if0AA2: [email protected] = load_library "bass.dll" // IF and SETthen    if and    0AA4: [email protected] = get_proc_address "BASS_ChannelGetLength" library [email protected] // IF and SET    0AA4: [email protected] = get_proc_address "BASS_ChannelPlay" library [email protected] // IF and SET    0AA4: [email protected] = get_proc_address "BASS_ChannelPause" library [email protected] // IF and SET    0AA4: [email protected] = get_proc_address "BASS_ChannelGetPosition" library [email protected] // IF and SET    0AA4: [email protected] = get_proc_address "BASS_ChannelBytes2Seconds" library [email protected] // IF and SET    0AA4: [email protected] = get_proc_address "BASS_ErrorGetCode" library [email protected] // IF and SET    then        0A8E: [email protected] = [email protected] + 0x4 // int        0A8D: [email protected] = read_memory [email protected] size 4 virtual_protect 0        //0AA7: call_function [email protected] num_params 2 pop 0 0 [email protected] [email protected]        //0AA5: call [email protected] num_params 2 pop 0 1 [email protected]        //0AA5: call [email protected] num_params 1 pop 0 [email protected]        0AA7: call_function [email protected] num_params 2 pop 0 0 [email protected] [email protected]        0AA7: call_function [email protected] num_params 2 pop 0 [email protected] [email protected] [email protected]      //  crash        0ACE: show_formatted_text_box "Proc Loaded~n~%d~n~%d~n~%d" [email protected] [email protected] [email protected]        0AA7: call_function [email protected] num_params 0 pop 0 [email protected]        0AD1: show_formatted_text_highpriority "Proc BASS_ErrorCode...~n~%d~n~0x%X~n~0x%X" time 6000 [email protected] [email protected] [email protected]    endend
Edited by MKKJ
Link to comment
Share on other sites

I had forgotten of this. It also has been one of reasons to do me try another solution. The file position is treated as QWORD and the fractional time as double.

double BASSDEF(BASS_ChannelBytes2Seconds)(DWORD handle, QWORD pos);
Edited by Guest
Link to comment
Share on other sites

So yeah, apparently CAudioStream struct that was posted earlier is correct, except it's should moved forward by 4 bytes

+0x0 ??? ; Idk what this is.

+0x4 hBassStream ; the actual handle as stated.

+0x8 uState ; the audio state (1 = playing | 2 = stop/pause)

+0x8 bOk ; idk what this is too.

 

I'm trying to manipulate Audiostream's time position with BASS functions.

I managed to get/set the byte position but can't convert it to time position unless by workaround. (BASS_Bytes2Seconds can't return double value. I just don't know how to solve it)

 

Still, i got what i wanted so i marked this as answered.

Edited by MKKJ
Link to comment
Share on other sites

I decided to continue this post for my new question, since it's still relevant.

 

 

Now i'm not actually a knowledgeable coder, so i have lot of things i don't understand when it comes to actual coding outside of scm.

One of functions, BASS_Bytes2Seconds requires a qword and returns a double.

 

double BASSDEF(BASS_ChannelBytes2Seconds)(DWORD handle, QWORD pos);

Qword param can be solved by passing two variables at once because it's just like double variables



0AA4: xProc = get_proc_address "BASS_ChannelBytes2Seconds" library xBass0AA7: call_function xProc num_params 3 pop 0 iPos2 iPos1 hBass dTime

But it can't return the double float value. It's just return 1 in byte. So how can i retrieve this value in cleo?



I'm also trying to use BASS_FXSetParameters.

 

(BASS_FXSetParameters)(DWORD fxHandle, void *params)

But they require parametric constructor (i just picked up the term) That by what i just catch, it's like an object that contains several parameters as one. It's supposed to be used like this

BASS_DX8_ECHO echo = new BASS_DX8_ECHO(value,value,value,value,value);Bass.BASS_FXSetParameters(fxHandle, echo);

Is it possible to re-interpret this in cleo? Or is it just isn't worth it?

 

Link to comment
Share on other sites

well, idk if function calling opcodes support returning floating point values, but you can write some sort of wrapper which will return double like int (float in eax). Not sure about using doubles in cleo, so theres also to float conversion.

int __declspec(dllexport, noinline)wrapper(double(__cdecl *func)(unsigned int, unsigned __int64), unsigned int a0, unsigned __int64 a1){	float a = func(a0, a1);	return reinterpret_cast<int&>(a);}compiled result55                    // push ebp8B EC                 // mov ebp,esp83 E4 F8              // and esp,-0883 EC 08              // sub esp,08FF 75 14              // push [ebp+14]FF 75 10              // push [ebp+10]FF 75 0C              // push [ebp+0C]FF 55 08              // call dword ptr [ebp+08]D9 5C 24 10           // fstp dword ptr [esp+10]8B 44 24 10           // mov eax,[esp+10]83 C4 0C              // add esp,0C8B E5                 // mov esp,ebp5D                    // pop ebpC3                    // ret 

insert these bytes in your script under some label and call it something like this

0AA7: call_function <get label address> num_params 4 pop 4 int int (qword), int, <get bass function address>, result to @

typedef struct {
float fWetDryMix;
float fFeedback;
float fLeftDelay;
float fRightDelay;
BOOL lPanDelay;
} BASS_DX8_ECHO;
if theres no export function in this library to construct this structure, then just set it by yourself. This is just an array of 4 floats and 1 bool, so... Idk about how function, which recieves this structure, is handling it (maybe stores pointer, maybe just copies params), so you can try something like: [email protected] = float, ... [email protected] = float, [email protected] = bool and pass var [email protected] addres in function, or just allocate memory and fill it in same way.
Edited by madleg
Link to comment
Share on other sites

Thanks for your help. The pointer to array of params perfectly solves it.

 

But the function you posted just crashes the game. Maybe i just did it wrong.

0AA4: [email protected] = get_proc_address "BASS_ChannelGetPosition" library [email protected] // IF and SET0AA4: [email protected] = get_proc_address "BASS_ChannelBytes2Seconds" library [email protected] // IF and SET        0AC6: [email protected] = label @Test offset0AA7: call_function [email protected] num_params 2 pop 0 0 hBASS [email protected]        0AA7: call_function [email protected] num_params 4 pop 4 qword [email protected] [email protected] handle hBASS bass_func [email protected] result [email protected]

On a less relevant note, what did exactly Bass boost and Bike's EQ do to the radio output?

I just assume Bike crappy radio just raises pitch while i Bass boost outputs sound in stereo (which was normally in mono).

Edited by MKKJ
Link to comment
Share on other sites

it was actually only for bass_channelbytes2seconds. is it working with it?

Edited by madleg
Link to comment
Share on other sites

Yes it crashes with BASS_ChannelBytes2Seconds.

 

Did i insert the value correctly?

Where does result variable belong, input param or output param?

0AA7: call_function [email protected] num_params 4 pop 4 qword [email protected] [email protected] handle hBASS bass_func [email protected] result [email protected]
Edited by MKKJ
Link to comment
Share on other sites

  • 1 year later...
Junior_Djjr

You still need help with this?

I created MDPMv5, which uses a lot of bass.dll functions. I can send you the source code.

I had not seen your thread before and I found it searching for bass.dll on Google.

 

On 8/15/2017 at 12:51 PM, MKKJ said:

I just assume Bike crappy radio just raises pitch while i Bass boost outputs sound in stereo (which was normally in mono).

It's totally wrong.
If you raises the pitch of a music, literally all notes will be raised and all song will be with wrong melody.
And stereo vs mono there is nothing to do with bass. Mono, the song plays in just 1 channel (so left and right is the same sound) and stereo is 2 (different sounds in each side, make it possible to create something immersive, separate the focus sound from ambient sound etc), nothing else.

It works making a equalization, i.e. removing (or increasing) the low frequencies.

This is created by the game audio system, bass.dll is just a CLEO choice for audio stuff.

Link to comment
Share on other sites

On 3/12/2019 at 6:14 PM, Junior_Djjr said:

You still need help with this?

I created MDPMv5, which uses a lot of bass.dll functions. I can send you the source code. 

I had not seen your thread before and I found it searching for bass.dll on Google. 

Nah i'm good. I did what i tried to do - including corrected the stupid idea of how equalizer works. I ended up imitating both bike EQ and bass boost by approximate tuning.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • 1 User Currently Viewing
    0 members, 0 Anonymous, 1 Guest

×
×
  • Create New...

Important Information

By using GTAForums.com, you agree to our Terms of Use and Privacy Policy.