The Daily Click ::. Forums ::. Klik Coding Help ::. Another CallDll Question - Structures?
 

Post Reply  Post Oekaki 
 

Posted By Message

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1971

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
15th February, 2005 at 22:54:33 -

i think i've got the caldll extension more or less sussed now (dont know what the buffers are about yet?) but i'm still having a problem - this time with the bass dll (v2.1) which i think should be pretty compatible with mmf.
specifically, i need to pass a pointer to a structure to the calldll object. the thing is, i dont know exactly what that means or if its even possible.

someone had mentioned it could be extremely difficult to do in mmf in a reply to my last question.

this is the stuff that has to go into the structure;

fCenter Center frequency, in hertz, in the range from 80 to 16000. This value cannot exceed one-third of the frequency of the channel.
fBandwidth Bandwidth, in semitones, in the range from 1 to 36.
fGain Gain, in the range from -15 to 15.

is the idea to put all these values into a single string and use that as an argument?


 
n/a

Long John Kickbag



Registered
  26/08/2002
Points
  148
16th February, 2005 at 04:57:40 -

Doubtful you'll be able to use a string since binary numbers will likely include characters that can't be displayed. Basically a structures a collection of variables. If structures are structured how I'd expect them to just be in a list, so I think passing your fCenter value, then your fBandwidth value and then your fGain value will work, just have to hope they wrote them variables in the order they actually appear in the structure.

 
Resize! - www.clicksplat.com/comparison.html

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1971

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
16th February, 2005 at 09:36:13 -

do you mean using the variables in the same argument, one after the other? would they not just overwrite the previous values?

 
n/a

Kris

Possibly Insane

Registered
  17/05/2002
Points
  2017
16th February, 2005 at 10:09:41 -

That wouldn't work. Passing a pointer to a structure is completely different from passing the whole structure at once

 
"Say you're hanging from a huge cliff at the top of mt. everest and a guy comes along and says he'll save you, and proceeds to throw religious pamphlets at you while simultaniously giving a sermon." - Dustin G

Tigerworks

Klik Legend

Registered
  15/01/2002
Points
  3882
16th February, 2005 at 12:49:03 -

Use the binary object. Make its size the size of the structure, set the values at the appropriate positions, and pass the address of the binary object.

 
- Tigerworks

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1971

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
16th February, 2005 at 15:48:04 -

i just found a post on the clickteam forum about using the binary object for this.

apparently someone has made an example but its no longer at 3ee (along with all the docs still). i dont suppose you or anyone else has a copy do you?
burkey gave a fairly in-depth description but without an example to look at or the binary documentation its pretty hard to follow.

with the structure below;

typedef struct {
float fCenter;
float fBandwidth;
float fGain;
} BASS_FXPARAMEQ;

how big would the binary need to be? (4 bytes per float = 12? or can i just use 2 byte shorts if i dont need the decimal point?)

should i be inserting or appending? (and do i use a string / short / long / byte?)

by "at the appropriate positions" do you mean in the right order or is there more to it?

passing the address is just using the memory location as an argument, right?

burkey mentioned needing to subtract 32,768 from all the values - is that right (and is it always 32,76 ?

is that all i need to do?

i've tried various combinations, but all seem to crash the app.
thanks for ther help

 
n/a

Kris

Possibly Insane

Registered
  17/05/2002
Points
  2017
16th February, 2005 at 17:12:13 -

You can't change the size of the arguments you're passing, it won't understand. you have to use the exact size specified by the struct (which is 12, yeah). Not sure about the subtracting thing, maybe that's just some easy way of converting an int to a float? And yup, the address is the memory location

 
"Say you're hanging from a huge cliff at the top of mt. everest and a guy comes along and says he'll save you, and proceeds to throw religious pamphlets at you while simultaniously giving a sermon." - Dustin G

Tigerworks

Klik Legend

Registered
  15/01/2002
Points
  3882
16th February, 2005 at 21:09:02 -

A float is by definition 4 bytes, so that struct is 12 bytes, the order being:
fCenter: bytes 0-3
fBandwidth: bytes 4-7
fGain: bytes 8-11
(which is pretty much common sense, the order they're listed)
Doesn't the binary object have a Set Float action? If not, then I think firemonkey had an object which could convert floats to ints...
Subtracting 32768 is only if you want to sign a short, so you don't need to worry about that here.

 
- Tigerworks

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1971

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
16th February, 2005 at 23:04:38 -

thanks very much for that.

I figured out why it kept crashing – it was because I was trying to set the fx parameters at the same time as reading the channel levels (something I’d started playing at when I couldn’t get the effects to work). With the level meter disabled I get the error messages to tell me the parameters are wrong.

This is the function i want to call;

BOOL WINAPI BASS_FXSetParameters(
HFX handle,
void *par
);

handle The effect handle.
par Pointer to the parameters structure

This is the parameter structure i want to use;

typedef struct {
float fCenter;
float fBandwidth;
float fGain;
} BASS_FXPARAMEQ;

Heres what i tried (among other things);

Button clicked ->
* resize binary to 12 bytes
* insert long (5000) at 0
* insert long (20) at 4
* insert long (14) at 8
* reset argument list
* set argument 1 to calldll return value (the fx handle)
* set argument 2 to binary object memory location
* call function "bass_fxsetparameters"

anything scream out as obviously wrong?

All the parameters are within the allowed ranges (ie. Center 80-16000 & <1/3 channel freq which is 16khz on the sample i'm testing with, bandwidth 1-36, gain –15-15.

I still get the “illparam” error code – this at least tells me the handle is ok (which I already knew), so theres something wrong with the structure still. According to the Bass dll help "One or more of the parameters are invalid, make sure all the values are within the valid ranges."

Any more suggestions are much appreciated

 
n/a

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1971

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
17th February, 2005 at 00:29:25 -

ive been experimenting some more and i have been able to call the same function with different parameters, to set the gargle effect which does not use floats.

i think the problem is one of two things;

* im not creating the structure correctly, somehow due to the fact that it contains floats rather than dwords (whatever they are). maybe that i need to use something other than longs?

* im using illegal values for the parameters, though i cant see how - according to the manual they should be ok, and i've tried many combinations.

About converting floats to ints - mmf has a built in feature to do that does it not, but surely i want to convert an int to a float if anything since thats what the structure takes?

 
n/a

Kris

Possibly Insane

Registered
  17/05/2002
Points
  2017
17th February, 2005 at 15:32:54 -

Long and DWORD are just the same thing. Floats and Longs use a totally different way of storing numbers (apart from 0), so you'll need to find a way to convert int->float, like the object Tigs mentioned


Image Edited by the Author.

 
"Say you're hanging from a huge cliff at the top of mt. everest and a guy comes along and says he'll save you, and proceeds to throw religious pamphlets at you while simultaniously giving a sermon." - Dustin G

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1971

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
17th February, 2005 at 17:13:10 -

has anyone actually been able to call a function using floats? i'm starting to think its not possible

i found an example of using the bass 1.6 dll with call dll, and it had the same problem - they couldnt set the effect parameters that used floats.

havent been able to find that extension - there doesnt seem to be one on the lists that would help. surely a float will only get converted back to an int anyway when its inserted into the binary, since theres no "insert float at" function. can you not convert a number to a float just by multiplying by 1.0 or something?

thanks for the help, but it looks like what i want to do is probably going to be impossible again.

 
n/a

Long John Kickbag



Registered
  26/08/2002
Points
  148
17th February, 2005 at 19:18:20 -

The extension is the Maths Army Knife. Use the Convert Float to Data expression which will return a long, then insert that long in.

 
Resize! - www.clicksplat.com/comparison.html

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1971

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
17th February, 2005 at 22:18:19 -

thanks. i must have an old version or something - it doesnt seem to have that expression. i'll redownload and see if it helps.

 
n/a

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1971

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
17th February, 2005 at 22:43:14 -

thanks very much everybody!

i've got it working

not doing quite what i want, but not complaining either.

turns out there was another problem as well as the whole floats business - it didnt like me calling the function too soon after setting the values in the binary. im surprised it matters as i do both in the same event, but for some reason the binary stuff has to be the first few actions - guess it takes a while or something.
might write a tutorial on the bass dll sometime - there have been a few mp3 players made with mmf already i think, so people might be interested (and its not exactly easy).

Image Edited by the Author.

 
n/a

McKack



Registered
  22/03/2005
Points
  33
2nd June, 2005 at 00:29:23 -

A tutorial on the calldll basicly would be nice anyways (3EE docs be gone) You guys lose me when you start to talk about pointers, bytes, floats and ways of storing things... I have this great idea for a program but it's based on being able to ping IP's (function nowhere to be found in any extensions) The way I understood it, windows own icmp.dll can do this with the IcmpSendEcho ( http://msdn.microsoft.com/library/default.asp?url=/library/en-us/iphlp/iphlp/icmpsendecho.asp ) function but thats it for me, you can guess what happens when I try to do anything with that dll.

Image Edited by the Author.

 
I'll klik yo butt!

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1971

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
2nd June, 2005 at 18:00:47 -

i remember this - i posted that question like 6 months ago (you might want to start a new thread next time). can't help you with the pings and echos an things though. sorry.

 
n/a
   

Post Reply



 



Advertisement

Worth A Click