to modulr an who else is interested

Discussion about: tracktion.com
RELATED
PRODUCTS

Post

with this code added to your senderella i had managed to react to keystrokes like your idea of the other thread. (in this example pressing ctrl+shift+1 toggles the keystate i'm reacting to in the process)

.
.
int randomCheck;
int keystate=0;

#pragma data_seg()

#pragma comment(linker, "/section:SHARED,RWS")


HHOOK g_hhk;

struct HookStruct{
int vkCode,scanCode,flags,time,dwExtraInfo;
}hs;

extern "C" __declspec(dllexport)
LRESULT CALLBACK KeyProc(int nCode, WPARAM wParam, LPARAM lParam)
{
//do only if its really a key event
if(nCode == HC_ACTION){
//copy data lParam pointes to (lParam is defined as long but is in fact a pointer)
memcpy(&hs,(void*)lParam,sizeof(HookStruct));
//257->keyup 256->keydown 49 is keycode for key 1 and
//scancode 2 for key 1 is released while ctrl and shift is pressed, for key 2 the scancode is 3, key 3 its 4...
if(wParam == 257 && hs.vkCode == 49 && hs.scanCode == 2){
keystate = (keystate) ? 0:1;
}
}
return CallNextHookEx(g_hhk, nCode, wParam, lParam);
}
......
......
//folowing added to your constructor

//load its self to use exported function and tell windows to use it for keystrokes on a low level
HMODULE hLib = LoadLibrary("senderella.dll");
HOOKPROC proc = (HOOKPROC)GetProcAddress(hLib, "KeyProc");
g_hhk=SetWindowsHookEx(WH_KEYBOARD_LL,proc,hLib,0);
.
.
.

i think with visual c you don't need to export the function like i have done. (mingw here)

thanx for the inspiration, now i have the quickest solofunction ever :) i'm thinking now of a version, where i only have to place one receiver in the main out, but as i said on mingw simply renaming the .dll s won't work, so either the sends have all the same name (doing it like your normal senderella) or i have to live with, till i have visual c :)

Post

Oh yes!! schweeeet! :love: Now that's how it's s'posed to be! sharing info! w00t! you rock! thanks for posting it!
ModuLR / Radio

Post

oopps, a little error. put ALL the new stuff in the shared memory to work smarter :)

int keystate=0;
struct HookStruct{
int vkCode,scanCode,flags,time,dwExtraInfo;
}hs;

extern "C" __declspec(dllexport)
LRESULT CALLBACK KeyProc(int nCode, WPARAM wParam, LPARAM lParam)
{
//do only if its really a key event
if(nCode == HC_ACTION){
//copy data lParam pointes to (lParam is defined as long but is in fact a pointer)
memcpy(&hs,(void*)lParam,sizeof(HookStruct));
//257->keyup 256->keydown 49 is keycode for key 1 and
//scancode 2 for key 1 is released while ctrl and shift is pressed, for key 2 the scancode is 3, key 3 its 4...
if(wParam == 257 && hs.vkCode == 49 && hs.scanCode == 2){
keystate = (keystate) ? 0:1;
}
}
return CallNextHookEx(g_hhk, nCode, wParam, lParam);
}
HMODULE hLib = LoadLibrary("senderella.dll");
HOOKPROC proc = (HOOKPROC)GetProcAddress(hLib, "KeyProc");
HHOOK g_hhk=SetWindowsHookEx(WH_KEYBOARD_LL,proc,hLib,0);
#pragma data_seg()

#pragma comment(linker, "/section:SHARED,RWS")


lucky to give you back something :) thx.

Post

what is keystate?
ModuLR / Radio

Post

that's just the global variable that i use to indicate if the key is pressed. it toggles between 1 and 0 so i can check for that in the process function.

here is what i have changed in your code off the process:
.
.
.
if(keystate){
*outs[0] = (*outs[0]) * temp_Vol;
*outs[1] = (*outs[1]) * temp_Vol;
} else {
*outs[0] = *ins[0];
*outs[1] = *ins[1];
}

for (int j=0; j < NUM_INPUTS; j++) ins[j]++;
for (int j=0; j < NUM_OUTPUTS; j++) outs[j]++;
}

clearBuffer = false;

Post

that is in fact all that has changed, no other definitions or #includes and stuff.
i need a lunch break

Post

so can we get 1? :shrug:

Post

till now it only works for one solo sender at a time (because i have this oh so ANSI/ISO compliant mingw32 compiler ;) ) but i'll do a practicable version soon (if modulr allows me to and maybe he is faster than i :) )
i need a lunch break

Post

I'm all about sharing! :D
ModuLR / Radio

Post

Im not going to pretend to understand any of this, but I think its damn cool you guys can work together on these things. Bravo.

Post

Why does code like this look nothing like the c++ I learnt at college.

No main()?

pragma ?

LRESULT CALLBACK KeyProc(...) // why 2 identifiers?

I seem to remember asking the tutor what a void pointer was for - I don't think he knew. Perhaps I need to get some proper tuition coz this looks like fun.

:shock:


Lol
I draw the line at power tools for the under 5's.

Post

lshea wrote:Why does code like this look nothing like the c++ I learnt at college.
Lol
Well OK it does look a bit like it.
I draw the line at power tools for the under 5's.

Post

no main, because it's a .dll that's generated (a plugin) and so for it self it has to be loaded by a MAIN program.

pragmas aren't realy c++ code, there are some many compilers are understanding, it's a littlebit of enhancing the code.

LRESULT CALLBACK... not both are identifiers, one is just a #define CALLBACK __stdcall tells the compiler how to handle this "function"

a void pointer is a pointer that points to nothing specific (not int or long...) so it just points to somwhere in the memory.

that's all not explaining it very well but you should give a sh.. and just code :)
i need a lunch break

Post

Thanks for that Aldi...

Is there a "Hello World" example plugin that explains the structure of a vst - eg a vst to say take an input audio stream and half the level of it?


Appetite whetted

Lol
I draw the line at power tools for the under 5's.

Post

just download the vst 2.3 sdk from steinberg. it's all in there. start with the delay example, use it as a template. it's not that complicated and well documented in the sdk (software development kit).

but, it only directly works with visual c++ from microsoft, if you use another tool to programm (dev-c++ with mingw32 here (it's free)) you need to make some changes to the code. tell me what you'll use, if it will be dev-cpp i can send you a template, but you'll still need the sdk from steinberg.

Post Reply

Return to “Tracktion”