I'm thinking about new innovative plugins. Effects that I wanted to find on my DJM2000nexus. (I wrote to pioneer for them to develop them on the touchscreen ... but to no avail).
For this next plugins, I need to exchange the addresses of some variables. I'm trying to create files that show the addresses. But I can't.
Here is the code :
void CMyPlugin8::SaveParam()
{
char dir[MAX_PATH];
wsprintf(dir, "Xchange.txt");
FILE* fp1;
fp1 = fopen(dir, "w");
if (fp1 != NULL)
{
fprintf(fp1, "%i\n%i\n%i\n", &bridgeValue1, &bridgeValue2, &bridgeValue3);
fclose(fp1);
}
}
For this next plugins, I need to exchange the addresses of some variables. I'm trying to create files that show the addresses. But I can't.
Here is the code :
void CMyPlugin8::SaveParam()
{
char dir[MAX_PATH];
wsprintf(dir, "Xchange.txt");
FILE* fp1;
fp1 = fopen(dir, "w");
if (fp1 != NULL)
{
fprintf(fp1, "%i\n%i\n%i\n", &bridgeValue1, &bridgeValue2, &bridgeValue3);
fclose(fp1);
}
}
Posté Sun 22 Nov 20 @ 12:13 pm
What do you mean by 'exchanging the addresses of some variables' ?
Anyway, you will need to add a path to your file name, otherwise it will probably default to the VirtualDJ folder, which by default is in Program Files and thus not allowed to write by non-administrator accounts.
Anyway, you will need to add a path to your file name, otherwise it will probably default to the VirtualDJ folder, which by default is in Program Files and thus not allowed to write by non-administrator accounts.
Posté Sun 22 Nov 20 @ 12:26 pm
OK I will try with a path file.
The idea is to have a plugin we can use as "master" or "slave".
Example :
Deck 1 : SidechainCompressor plugin. In master mode, determines the level of the track on Deck 1. The raw level is store in a float variable : fLevel.
The computor stores this variable in a memory address. I take this address by &fLevel.
I store the address in the bridge file (.txt")
Deck 2 : SidechainCompressor. In slave mode, read the address of fLevel in the .txt file. Thus the plugin can access to the level of Deck1.
The volume of the track on Deck 2 varies inversly according to volume of track on deck 1.
After reflection, using a pointer would be better...
The idea is to have a plugin we can use as "master" or "slave".
Example :
Deck 1 : SidechainCompressor plugin. In master mode, determines the level of the track on Deck 1. The raw level is store in a float variable : fLevel.
The computor stores this variable in a memory address. I take this address by &fLevel.
I store the address in the bridge file (.txt")
Deck 2 : SidechainCompressor. In slave mode, read the address of fLevel in the .txt file. Thus the plugin can access to the level of Deck1.
The volume of the track on Deck 2 varies inversly according to volume of track on deck 1.
After reflection, using a pointer would be better...
Posté Sun 22 Nov 20 @ 1:26 pm
I might not be following correctly but wouldn't a vdjScript variable do the job ? or does it need to be sample by sample info recording [but I can't see .txt being fast enough for that]
Posté Sun 22 Nov 20 @ 1:40 pm
After last post, there is a simple way to acheive this : set a global VDJScript variable '@$fLevel' which can be shared from within different plugins at a time
BUT any value in a plugin in any deck can be readed/written from another one using VDJScript and getinfo()
StrValue="Deck 1 effect_slider 'myplugin8' 1";
if (GetInfo(StrValue, &DblValue) == S_OK) {...}
EDIT: locodog is always faster :)
BUT any value in a plugin in any deck can be readed/written from another one using VDJScript and getinfo()
StrValue="Deck 1 effect_slider 'myplugin8' 1";
if (GetInfo(StrValue, &DblValue) == S_OK) {...}
EDIT: locodog is always faster :)
Posté Sun 22 Nov 20 @ 1:40 pm
Nicotux wrote :
locodog is always faster :)
He must be a greyhound :-)
Posté Sun 22 Nov 20 @ 1:50 pm
I don't know VDJScript variable. Not enough knowledge on c++
;-)
Yes the value changes every sample. But the address doesn't, it is still the same.
So the .txt file is read only once.
;-)
Yes the value changes every sample. But the address doesn't, it is still the same.
So the .txt file is read only once.
Posté Sun 22 Nov 20 @ 1:58 pm
get the memory address of the float, broadcast that via a global script variable for the slave to read [only needs to be set once]
or you could effect_command from the slave to the master when the slave is started
effect_command "MasterFX" 1 "HELLOIAMTHESLAVEFX"
then have the master send the memory address back
effect_command "SlaveFX" 1 "0xAddress"
or you could effect_command from the slave to the master when the slave is started
effect_command "MasterFX" 1 "HELLOIAMTHESLAVEFX"
then have the master send the memory address back
effect_command "SlaveFX" 1 "0xAddress"
Posté Sun 22 Nov 20 @ 2:14 pm
not 100% sure there won't be some kind of denial of access to the memory areas by crossing variable addresses like that
Posté Sun 22 Nov 20 @ 2:26 pm
I wouldn't use a text file for that.
Also, at least on windows, a dll file is only loaded once, so you don't need anything special to share variables between instances of your plugin.
Simply define it in your cpp file outside your function, or as a static inside the function and it will be available from all instances of your plugin.
You will have to take good care to clear the variable when the plugin is destructed so that you don't keep a pointer floating around to memory that is no longer available.
You may also need to take care of thread-sync issues, in case the plugin holding the memory is destroyed at the same time as the other plugin is trying to access that memory.
Also, at least on windows, a dll file is only loaded once, so you don't need anything special to share variables between instances of your plugin.
Simply define it in your cpp file outside your function, or as a static inside the function and it will be available from all instances of your plugin.
You will have to take good care to clear the variable when the plugin is destructed so that you don't keep a pointer floating around to memory that is no longer available.
You may also need to take care of thread-sync issues, in case the plugin holding the memory is destroyed at the same time as the other plugin is trying to access that memory.
Posté Sun 22 Nov 20 @ 2:36 pm
Nicotux wrote :
not 100% sure there won't be some kind of denial of access to the memory areas by crossing variable addresses like that
Currently VirtualDJ and its plugins run in the same process, so all memory addresses are in the same memory space.
It is indeed possible that this might change some day to have plugins run in their own process, but at the moment it would work.
Posté Sun 22 Nov 20 @ 2:38 pm
@Adion write : Simply define it in your cpp file outside your function, or as a static inside the function and it will be available from all instances of your plugin.
I've just tested. Works well. Thank you !
I've just tested. Works well. Thank you !
Posté Mon 23 Nov 20 @ 6:36 pm