OSC integration DLL

Post your working scripts, libraries and tools for AHK v1.1 and older
nyquist
Posts: 25
Joined: 25 Mar 2021, 15:44

Re: OSC integration DLL

16 Aug 2021, 15:33

@potscrubber
Thanks, nice to hear that you can make good use of the DLL :D
potscrubber
Posts: 36
Joined: 09 Sep 2017, 01:51
Location: Aotearoa
Contact:

Re: OSC integration DLL

09 Sep 2021, 23:56

nyquist wrote:
16 Aug 2021, 15:33
@potscrubber
Thanks, nice to hear that you can make good use of the DLL :D
Hey nyquist,

The only issue I've experienced, is a propensity for a script's process to not shutdown timely with OSC2AHK before it is reloaded - blocking the OSC ports until I go in with task manager and kill the process. This is only really an issue in development, but I haven't found a reliable workaround. I'm using LoadLibrary. Below is a basic example of how I'm initiating and shutting down.

Have you experienced this or possibly have a solution?

Code: Select all

; Load DLL and open network port for OSC
hModule := DllCall("LoadLibrary", "Str", "OSC2AHK.dll", "Ptr")  ; Avoids the need for DllCall() in the loop to load the library.
result := DllCall("OSC2AHK\open", UInt, Hwnd, UInt, 9010)

; Setting up a listener
result := DllCall("OSC2AHK\addListener", AStr, "/report_mons_router", UInt, 0x7F01, UInt, oscTypeInt)
OnMessage(0x7F01, "msghandler_router")

; Closing down
result := DllCall("OSC2AHK\close", UInt, 1)  ;1= remove all listeners also
DllCall("FreeLibrary", "Ptr", hModule)  ; To conserve memory, the DLL may be unloaded after using it.

Lastly, on a seperate topic, I read that you use TMFX - you may find this handy... just a csv map of dB values in 0.5 increments to floating point numbers that TMFX uses. I used it in my hacky cli osc sender I mentioned before.

Code: Select all

TMFX dB,OSC Float
-65,0
-64.5,0.00327084
-64,0.00655504
-63.5,0.00985273
-63,0.0131641
-62.5,0.0164894
-62,0.0198287
-61.5,0.0231823
-61,0.0265502
-60.5,0.0299327
-60,0.03333
-59.5,0.0367423
-59,0.0401697
-58.5,0.0436126
-58,0.047071
-57.5,0.0505452
-57,0.0540354
-56.5,0.057542
-56,0.0610649
-55.5,0.0646046
-55,0.0681612
-54.5,0.071735
-54,0.0753263
-53.5,0.0789352
-53,0.0825621
-52.5,0.0862073
-52,0.089871
-51.5,0.0935535
-51,0.0972551
-50.5,0.100976
-50,0.104717
-49.5,0.108477
-49,0.112258
-48.5,0.11606
-48,0.119883
-47.5,0.123727
-47,0.127593
-46.5,0.131481
-46,0.135391
-45.5,0.139325
-45,0.143281
-44.5,0.147262
-44,0.151266
-43.5,0.155295
-43,0.159349
-42.5,0.163429
-42,0.167535
-41.5,0.171667
-41,0.175826
-40.5,0.180013
-40,0.184228
-39.5,0.188471
-39,0.192744
-38.5,0.197047
-38,0.20138
-37.5,0.205745
-37,0.210141
-36.5,0.21457
-36,0.219033
-35.5,0.223529
-35,0.228061
-34.5,0.232628
-34,0.237232
-33.5,0.241873
-33,0.246552
-32.5,0.251271
-32,0.256031
-31.5,0.260831
-31,0.265675
-30.5,0.270562
-30,0.275494
-29.5,0.280472
-29,0.285497
-28.5,0.290572
-28,0.295696
-27.5,0.300873
-27,0.306103
-26.5,0.311388
-26,0.31673
-25.5,0.322131
-25,0.327593
-24.5,0.333117
-24,0.338707
-23.5,0.344364
-23,0.350091
-22.5,0.355891
-22,0.361766
-21.5,0.36772
-21,0.373755
-20.5,0.379876
-20,0.386085
-19.5,0.392388
-19,0.398787
-18.5,0.405289
-18,0.411897
-17.5,0.418617
-17,0.425456
-16.5,0.43242
-16,0.439515
-15.5,0.44675
-15,0.454133
-14.5,0.461673
-14,0.469382
-13.5,0.477271
-13,0.485352
-12.5,0.493642
-12,0.502157
-11.5,0.510917
-11,0.519943
-10.5,0.529262
-10,0.538904
-9.5,0.548905
-9,0.559309
-8.5,0.570169
-8,0.581551
-7.5,0.593537
-7,0.606236
-6.5,0.619793
-6,0.634409
-5.5,0.649642
-5,0.664875
-4.5,0.680108
-4,0.695341
-3.5,0.710573
-3,0.725806
-2.5,0.741039
-2,0.756272
-1.5,0.771505
-1,0.786738
-0.5,0.801971
0,0.817204
0.5,0.832437
1,0.84767
1.5,0.862903
2,0.878136
2.5,0.893369
3,0.908602
3.5,0.923835
4,0.939068
4.5,0.954301
5,0.969534
5.5,0.984767
6,1
nyquist
Posts: 25
Joined: 25 Mar 2021, 15:44

Re: OSC integration DLL

06 Nov 2021, 14:20

Sorry for the silence - I really can't get myself to look here more often and I only get E-Mail notifications sometimes...

I worked at the library a bit again and now there is a new version including a solution to most of the suggestions/issues, e.g.:

@EErreErre Now you can send two parameters per message, e.g. two floats with the function sendOscMessageFloat2().
Only two parameters of the same type at the moment, I think including functions for every combination of parameter types (and possible 3 or more parameters) would generate a lot of clutter...

@potscrubber I could find the problem and improve on the open() and close() functions so the network port is only occupied when it was opened (and not again closed) by the DLL. Thanks for the hint!
Also thanks for the dB table but I don't know what TMFX is? Google only brings up a embroidery machine ;)
potscrubber
Posts: 36
Joined: 09 Sep 2017, 01:51
Location: Aotearoa
Contact:

Re: OSC integration DLL

06 Nov 2021, 14:42

nyquist wrote:
06 Nov 2021, 14:20
I worked at the library a bit again and now there is a new version including a solution to most of the suggestions/issues, e.g.:

..

@potscrubber I could find the problem and improve on the open() and close() functions so the network port is only occupied when it was opened (and not again closed) by the DLL. Thanks for the hint!
Also thanks for the dB table but I don't know what TMFX is? Google only brings up a embroidery machine ;)
Brilliant... thanks.. I will check out the new version. I think you also did a lot of work on the documentation which is very nice for users. This is a really great niche tool for us Windows / OSC hackers.

TMFX = RME TotalMix FX

cheers
Last edited by potscrubber on 04 Feb 2022, 02:59, edited 1 time in total.
EErreErre
Posts: 2
Joined: 22 Jul 2021, 09:45

Re: OSC integration DLL

03 Feb 2022, 05:34

nyquist wrote:
06 Nov 2021, 14:20
Sorry for the silence - I really can't get myself to look here more often and I only get E-Mail notifications sometimes...

I worked at the library a bit again and now there is a new version including a solution to most of the suggestions/issues, e.g.:

@EErreErre Now you can send two parameters per message, e.g. two floats with the function sendOscMessageFloat2().
Only two parameters of the same type at the moment, I think including functions for every combination of parameter types (and possible 3 or more parameters) would generate a lot of clutter...

@potscrubber I could find the problem and improve on the open() and close() functions so the network port is only occupied when it was opened (and not again closed) by the DLL. Thanks for the hint!
Also thanks for the dB table but I don't know what TMFX is? Google only brings up a embroidery machine ;)
Thanks a lot !!!!
This update is very very important for ours workflow !!!!
foxdanger
Posts: 83
Joined: 11 Jun 2019, 13:48

Re: OSC integration DLL

04 Jun 2022, 09:32

@nyquist HI friend!

My project is perfect and working great with your OSC2AHK.DLL, thanks a lot my friend!

Now, Tangent launch a new version of their software that permits send messages to the controller panel, not only receive.

And this can make my software way better if I get some things working.

I made two questions on the github of your project as "issues" there. Can you please help me?

I'll put it here because can be helpful for someone in the future too:


First question:

The software that I'm working with has this on it's manual:

"NOTE: a random return port will be chosen when the application makes first contact
with the OSC Server so you should interrogate the client socket to determine the return
port number to use"

OSC2AHK has a way to do this?


Second Question:

If I create a listener like this on my software:

Code: Select all

DllCall("OSC2AHK.dll\addListener", AStr, "/testFunction", UInt, 0x3000, UInt, oscTypeString)
        OnMessage(0x3000, "_testFunction")
And then I send the dllcall to send this message, it works. My software listen the osc command and execute the testFunction

Code: Select all

DllCall("OSC2AHK.dll\sendOscMessageString", AStr, "127.0.0.1", UInt, 7002, AStr, "/testFunction", AStr, "THIS IS A TEST")
BUT, my software can listen the osc shout, but the data arrives as 0 instead the string that I'm sending.


Will be great if you can help me!
Thx a lot!
nyquist
Posts: 25
Joined: 25 Mar 2021, 15:44

Re: OSC integration DLL

04 Jun 2022, 12:44

Hi!
foxdanger wrote:First question:
Hm, I don't really understand what they want the "OSC server" do, to find out which port is open for receiving OSC messages in their software? If I try and send a test message to all possible ports (which are 65535), this will take basically forever to find out which ones are open (and wait for timeouts for all the not-open ports). And even if we find an open port, how should we know that this is the OSC receiving port of the tangent software? I also found the manual you quoted from here https://www.tangentwave.co.uk/download/tangent-mapper-user-manual/ but it does not give any more useful information.

Maybe send them a message and kindly ask how we can find out about the right port from outside (possibly even from another PC on the same network).

foxdanger wrote:Second Question:
You have to get the string payload from the DLL after a message was recived as strings cannot be transmitted natively in Windows messages. See here (and also the linked string_example.ahk): https://files.eleton-audio.de/gitea/Ludwig/OSC2AHK#user-content-get-string-data

Regards,
Ludwig
foxdanger
Posts: 83
Joined: 11 Jun 2019, 13:48

Re: OSC integration DLL

05 Jun 2022, 17:53

nyquist wrote:
04 Jun 2022, 12:44
Hi!

Hm, I don't really understand what they want the "OSC server" do, to find out which port is open for receiving OSC messages in their software? If I try and send a test message to all possible ports (which are 65535), this will take basically forever to find out which ones are open (and wait for timeouts for all the not-open ports). And even if we find an open port, how should we know that this is the OSC receiving port of the tangent software? I also found the manual you quoted from here https://www.tangentwave.co.uk/download/tangent-mapper-user-manual/ but it does not give any more useful information.

Maybe send them a message and kindly ask how we can find out about the right port from outside (possibly even from another PC on the same network).
The manual is this one (they are in beta for this new feature of receiveing OSC messages): https://s3.eu-west-2.amazonaws.com/tangentwave.co.uk/wp-content/uploads/2022/05/23123406/Mapper-Made-Simple-v1-r8.pdf

I agree with you, looks crazy right?

What I notice is: When I send messages from the panel to my software or to Protokol, it goes with the IP (which is always 127.0.0.1) and it has the port that can receive messages ont it. Maybe I can start my software asking for the user press some button on the controller, get this message and in some way find the port on it.

This is how it looks on protokol:

https://ibb.co/pWDJkPJ

As you can see, that is the door opened where panel are receiveing messages, that changes every time you restart the tangent hub software. So, I could ask to the user press a button and get this info. I have to see if OSC2AHK can get all this info like Protokol can. Do you know if it's possible?


You have to get the string payload from the DLL after a message was recived as strings cannot be transmitted natively in Windows messages. See here (and also the linked string_example.ahk): https://files.eleton-audio.de/gitea/Ludwig/OSC2AHK#user-content-get-string-data
Ok, I'll look for it and how to do it. Thx a lot for the answers my friend!
foxdanger
Posts: 83
Joined: 11 Jun 2019, 13:48

Re: OSC integration DLL

06 Jun 2022, 16:25

@nyquist

Talked with Tangent guys today and there's an error on the manual, the misstyped the adress /hubcommand, it is /HubComman so that's why I couldn't send messages to change things in the pannel. I'll test it today.

But the other questions remains... How to find the listening port... As I said, probably the best solution is asking the user at the beging of my ahk code to press any button on the controller and get the message as Protokol gets. But I need to know if OSC2AHK can get that info too.
nyquist
Posts: 25
Joined: 25 Mar 2021, 15:44

Re: OSC integration DLL

08 Jun 2022, 13:41

@foxdanger
I hope to be able to look at this a bit more during the weekend, got a lot to do atm (fortunately).
Right now I only can tell you that currently this is not possible with OSC2AHK (as far as I understand)...
BuggyB
Posts: 44
Joined: 25 Mar 2019, 17:59

Re: OSC integration DLL

23 Jul 2022, 11:17

I call
hModule := DllCall("LoadLibrary", "Str", "OSC2AHK.dll", "Ptr")

It sets A_LastError to 126 and hModule to 0. And this with the DLL in the script directory, and also with the DLL full path in DllCall. It works on another computer though.
Both computers are on Windows 10 Pro x64 uptodate.

Any idea? Would there be a dependency for the DLL?
BuggyB
Posts: 44
Joined: 25 Mar 2019, 17:59

Re: OSC integration DLL

23 Jul 2022, 11:57

BuggyB wrote:
23 Jul 2022, 11:17
hModule := DllCall("LoadLibrary", "Str", "OSC2AHK.dll", "Ptr")

It sets A_LastError to 126 and hModule to 0.
It works after installing Visual C++ Redistributable : https://docs.microsoft.com/fr-FR/cpp/windows/latest-supported-vc-redist?view=msvc-170
So, "Just download the latest version of OSC2AHK.dll from the releases page and place it in the same directory as your AutoHotkey scripts" from https://files.eleton-audio.de/gitea/Ludwig/OSC2AHK#user-content-osc2ahk is a bit misleading. ;)
nyquist
Posts: 25
Joined: 25 Mar 2021, 15:44

Re: OSC integration DLL

24 Jul 2022, 15:28

@BuggyB
Hm, interesting. I didn't know that this would be necessary, but I'm not too firm with DLL development and also have the redistributables installed on all my PCs. So it totally could be possible that they are necessary.

I'll further investigate this and update the documentation when I'm sure! Thanks for the hint!
crayolon
Posts: 1
Joined: 25 Sep 2023, 08:48

Re: OSC integration DLL

25 Sep 2023, 09:04

Hi @nyquist, thank you very much for writing and sharing this library! I've found it invaluable for controlling my RME hardware using a macro pad and a programmable mouse, and I also use it to poll and track hardware states to swap AHK tray icons, informing me at a glance whether e.g. my mic is hot, collapse-to-mono is enabled, and so on.

Unfortunately for others who might come across this thread when looking for a similar solution, your links to the library and its documentation now seem to be broken. I'm getting a 502 bad gateway response from all /gitea paths on files.eleton-audio.de, although eleton-audio.de itself loads fine.

Please could you take a look at the webserver config to see if it can be restored? Otherwise perhaps you'd consider sharing the repository on some other platform such as GitHub so that others can help maintain the codebase (unless you have ideological objections - some do, and that's fair enough!). No worries if not, you owe us nothing - but again, I'm very grateful. Thanks!
nyquist
Posts: 25
Joined: 25 Mar 2021, 15:44

Re: OSC integration DLL

26 Sep 2023, 04:47

Hi @crayolon

Thanks for the hint, the links should work again now. Seems the database backend had a little hickup.

I mainly use my own git server because next to the few public projects I keep lots of private/work ones there and don't want to pay for github. Also I like the idea of a decentralized internet and selfhosting in general (you could call that ideolocigal objections?). But of course everybody is welcome to share their contributions to the project, in every possible way!
User avatar
alin89c
Posts: 6
Joined: 14 Sep 2021, 23:26
Contact:

Re: OSC integration DLL

17 Feb 2024, 01:31

Dear @nyquist
Would you please build a 32-bit version of OSC2AHK.dll? I tried to do this myself (in VS2019), but with no luck (not even a 64-bit version). Thank you.
nyquist
Posts: 25
Joined: 25 Mar 2021, 15:44

Re: OSC integration DLL

17 Feb 2024, 11:27

Hi @alin89c!
Out of the box a 32-bit build is not successful for me either, something about the oscpack project does not want to compile right away (some error about pre compiled headers). I will keep your request but right now have not the time to look into it deeper. Could you explain why you need a 32-bit build? I always thought it wouldn't be used much nowadays.
64-bit builds do work for me in VS2019, just using the included OSC2AHK.sln file!
User avatar
alin89c
Posts: 6
Joined: 14 Sep 2021, 23:26
Contact:

Re: OSC integration DLL

17 Feb 2024, 13:44

I will keep your request but right now have not the time to look into it deeper. Could you explain why you need a 32-bit build?
I really appreciate you keeping my request. Now the reason I need a 32-bit build is because I have a very cheap Windows 10 x86 Tablet (Kiano IntelectX3HD) and a very old Apple MacBook Pro. Ok, not that old, but still... Anyway, the tablet usually connects to my O-S-C session that I use with Cubase's MIDI Generic Remote (the O-S-C server runs on my MacBook). This is its main purpose. Now what I'd also like to do with it is controlling it using another device (that sends OSC messages) and AHK.
I always thought it wouldn't be used much nowadays.
If only my tablet had a x64 EFI. It has a 64-bit CPU though... Very nice! :headwall:
It can run x64 operating systems, but can't install them. Really really nice! :cry:
64-bit builds do work for me in VS2019, just using the included OSC2AHK.sln file!
The errors I get:
https://theodor1st.files.wordpress.com/2024/02/error-list-and-output.pdf
The above PDF content (unformatted)
If you can't make a 32-bit version, it's ok. A big thanks for the 64-bit version!

Return to “Scripts and Functions (v1)”

Who is online

Users browsing this forum: No registered users and 60 guests