Old 05-24-2019, 09:23 AM   #481
DaveKeehl
Human being with feelings
 
DaveKeehl's Avatar
 
Join Date: Nov 2015
Location: Switzerland
Posts: 1,966
Default

Hi, I just started coding some scripts in lua for reaper and I don't understand what HWND means (for example in reaper.GetMainHwnd). Can someone explain it to me?
__________________
REAPER Contest
DaveKeehl is offline   Reply With Quote
Old 05-24-2019, 09:26 AM   #482
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,612
Default

Quote:
Originally Posted by DaveKeehl View Post
Hi, I just started coding some scripts in lua for reaper and I don't understand what HWND means (for example in reaper.GetMainHwnd). Can someone explain it to me?
It's an object, that reflects a window or a gui-element in a window.

For instance GetMainHwnd returns the object of Reaper's main window(the one with the arrangeview in it) and you can manipulate it using appropriate functions.
If you use the most recent version of SWS and/or the js-extension, there are functions, who allow you to do that, like getting/changing position, title, scrollstate of the window, etc.

When I say, gui-element: not all Gui-elements in Reaper have a hwnd, only the ones that are system-dialogs/elements. For instance, all elements in the Render to File-dialog have hwnds, the solo button of a track has not(afaik)


Edit: try experimenting with JS_Window_SetTitle to get an idea.
https://mespotin.uber.space/Ultrasch...indow_SetTitle

Needs the js-extension-plugin, which you can get here: https://forum.cockos.com/showthread.php?t=212174
__________________
Use you/she/her.Ultraschall-Api Lua Api4Reaper - Donate, if you wish

On vacation for the time being...
Meo-Ada Mespotine is offline   Reply With Quote
Old 05-29-2019, 06:50 AM   #483
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,093
Default

Adding to mespotine,
https://docs.microsoft.com/en-us/cpp...d?view=vs-2019

So, a handle (specific type of pointer)* to a window.

*Though handle and pointer are not fully equivalent:
https://stackoverflow.com/questions/...things/1923646
nofish is offline   Reply With Quote
Old 05-31-2019, 07:30 AM   #484
sw_
Human being with feelings
 
Join Date: Oct 2018
Posts: 99
Default

How do I convert the volume and pan from GetTrackUIVolPan to a 0-127 CC value? In other words I'd like to convert the pan (-1 to 1) range to 0-127 and the tracks max and min volume to 0-127.

I get the internal values in the console, it's just that I have to reformat them before passing the values along with StuffMIDIMessage since that wound pass negative values. Please help ! I need this for my diy motorized fader to work.
sw_ is offline   Reply With Quote
Old 05-31-2019, 02:26 PM   #485
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 4,910
Default

Code:
round((floatValue + 1.0) * (127.0 / 2.0))

Last edited by cfillion; 05-31-2019 at 02:37 PM.
cfillion is offline   Reply With Quote
Old 06-01-2019, 08:32 AM   #486
sw_
Human being with feelings
 
Join Date: Oct 2018
Posts: 99
Default

Quote:
Originally Posted by cfillion View Post
Code:
round((floatValue + 1.0) * (127.0 / 2.0))
Amazing!! Thanks!! Do you by any chance know this?

How do I send a 14 bit midi message over midi? I only seem to be able to send up to 255 with stufffmidimessage.
sw_ is offline   Reply With Quote
Old 06-01-2019, 10:46 AM   #487
Breeder
Human being with feelings
 
Breeder's Avatar
 
Join Date: Nov 2010
Posts: 2,436
Default

TrackFX_GetInstrument() returns -1 if instrument is offline? Any simple way around this?
Breeder is offline   Reply With Quote
Old 06-16-2019, 11:19 PM   #488
danerius
Human being with feelings
 
Join Date: Oct 2018
Posts: 173
Default Help explaining code

Hi. Im having trouble understanding this bit of code. Its from Losers Waveshaping Distortion.

Mostly the second line "hdistr =....". How does the "100,.999" bit work? I get that It gives a value for "foo" to be calculated and then used in the formula. How would I enter these values in a regular calculator? Slider range is 0-100.

/thx

@slider
hdistr = min(slider1/100,.999);
foo = 2*hdistr/(1-hdistr);

@sample
spl0 = min(max(spl0,-1),1);
spl1 = min(max(spl1,-1),1);

spl0 = (1+foo)*spl0/(1+foo*abs(spl0));
spl1 = (1+foo)*spl1/(1+foo*abs(spl1));
danerius is offline   Reply With Quote
Old 06-17-2019, 12:16 AM   #489
Fabian
Human being with feelings
 
Fabian's Avatar
 
Join Date: Sep 2008
Location: Sweden
Posts: 7,407
Default

Quote:
Originally Posted by danerius View Post
Hi. Im having trouble understanding this bit of code. Its from Losers Waveshaping Distortion.

Mostly the second line "hdistr =....". How does the "100,.999" bit work? I get that It gives a value for "foo" to be calculated and then used in the formula. How would I enter these values in a regular calculator? Slider range is 0-100.

/thx

@slider
hdistr = min(slider1/100,.999);
foo = 2*hdistr/(1-hdistr);

@sample
spl0 = min(max(spl0,-1),1);
spl1 = min(max(spl1,-1),1);

spl0 = (1+foo)*spl0/(1+foo*abs(spl0));
spl1 = (1+foo)*spl1/(1+foo*abs(spl1));
I am not sure exactly what you are asking. Do you mean
Code:
min(slider1/100,.999)
It divides the value of slider1 by 100, then takes the minimum of that value and 0.999. Is this what you mean?

Or do you mean to ask why the value of foo is calculated the way it is? Of that, I have no idea, sorry.
__________________
// MVHMF
I never always did the right thing, but all I did wasn't wrong...
Fabian is offline   Reply With Quote
Old 06-17-2019, 02:45 AM   #490
danerius
Human being with feelings
 
Join Date: Oct 2018
Posts: 173
Default

Quote:
Originally Posted by Fabian View Post
I am not sure exactly what you are asking. Do you mean
Code:
min(slider1/100,.999)
It divides the value of slider1 by 100, then takes the minimum of that value and 0.999. Is this what you mean?

Or do you mean to ask why the value of foo is calculated the way it is? Of that, I have no idea, sorry.
Hi + massor med tack Both actually. But theyre kind of separate questions

I understand the 'slider1 divided by 100'. But is it adding .0999 to the result? Multiplying?

/thx
danerius is offline   Reply With Quote
Old 06-17-2019, 03:28 AM   #491
Fabian
Human being with feelings
 
Fabian's Avatar
 
Join Date: Sep 2008
Location: Sweden
Posts: 7,407
Default

Quote:
Originally Posted by danerius View Post
Hi + massor med tack Both actually. But theyre kind of separate questions

I understand the 'slider1 divided by 100'. But is it adding .0999 to the result? Multiplying?

/thx
Code:
min(x, y)
returns the smallest value of x and y.

So in the particular case of
Code:
min(slider1/100, 0.999)
when slider1 is 100, 0.999 will be returned, not 1. This is to not get a divide by zero on the next line
Code:
foo = 2*hdistr/(1-hdistr);
as hdistr is guaranteed to never be exactly 1.
__________________
// MVHMF
I never always did the right thing, but all I did wasn't wrong...
Fabian is offline   Reply With Quote
Old 06-17-2019, 05:01 AM   #492
danerius
Human being with feelings
 
Join Date: Oct 2018
Posts: 173
Default

Quote:
Originally Posted by Fabian View Post
Code:
min(x, y)
returns the smallest value of x and y.

So in the particular case of
Code:
min(slider1/100, 0.999)
when slider1 is 100, 0.999 will be returned, not 1. This is to not get a divide by zero on the next line
Code:
foo = 2*hdistr/(1-hdistr);
as hdistr is guaranteed to never be exactly 1.
Oh... Excellent. Got it now

Im guessing its best practice to include a minimum value?

/thx
danerius is offline   Reply With Quote
Old 06-17-2019, 05:52 AM   #493
Fabian
Human being with feelings
 
Fabian's Avatar
 
Join Date: Sep 2008
Location: Sweden
Posts: 7,407
Default

Quote:
Originally Posted by danerius View Post
Oh... Excellent. Got it now

Im guessing its best practice to include a minimum value?

/thx
Well... Not necessarily, it depends on what you want to do.

In this case it is definitely good. Divide by zero is something you absolutely want to avoid.
__________________
// MVHMF
I never always did the right thing, but all I did wasn't wrong...
Fabian is offline   Reply With Quote
Old 06-17-2019, 06:32 AM   #494
danerius
Human being with feelings
 
Join Date: Oct 2018
Posts: 173
Default

Quote:
Originally Posted by Fabian View Post
Well... Not necessarily, it depends on what you want to do.

In this case it is definitely good. Divide by zero is something you absolutely want to avoid.
Awesome. Thanks again
danerius is offline   Reply With Quote
Old 06-17-2019, 09:35 AM   #495
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,612
Default

Are extension-functions able to find out, in which script they run? Like get_action_context for C++ in ReaScripts or something?

And if yes, can they run automatically at script-startup, before the script is run actually?
__________________
Use you/she/her.Ultraschall-Api Lua Api4Reaper - Donate, if you wish

On vacation for the time being...
Meo-Ada Mespotine is offline   Reply With Quote
Old 06-19-2019, 01:35 AM   #496
danerius
Human being with feelings
 
Join Date: Oct 2018
Posts: 173
Default Flipping Waveforms

Hi

Chris from Airwindows told me he often converts negative waves to positive ones for processing. Then flips them back again. Is thats whats happening in this bit of code? The "abs" flips the negative part to positive. And the lines above that flips it backa again?

Im trying to learn... so any other examples of this practice would be awesome. thx

@sample
spl0 = min(max(spl0,-1),1);
spl1 = min(max(spl1,-1),1);

spl0 = (1+foo)*spl0/(1+foo*abs(spl0));
spl1 = (1+foo)*spl1/(1+foo*abs(spl1));
danerius is offline   Reply With Quote
Old 07-07-2019, 08:50 AM   #497
sai'ke
Human being with feelings
 
sai'ke's Avatar
 
Join Date: Aug 2009
Location: NL
Posts: 1,451
Default

Ask him what he means. The sentence is ambiguous and could refer to any number of things.

Quote:
Originally Posted by danerius View Post
@sample
spl0 = min(max(spl0,-1),1);
spl1 = min(max(spl1,-1),1);
Clamps the input between -1 and 1, any higher signal will be clipped to -1 or 1.

Quote:
Originally Posted by danerius View Post
spl0 = (1+foo)*spl0/(1+foo*abs(spl0));
spl1 = (1+foo)*spl1/(1+foo*abs(spl1));
This interpolates between no distortion to a smooth clipper for positive values of foo. For negative values all hell can break loose.

I don't really see why you would want to clip the signal before the smooth function in this case, since the smooth function already nicely goes into saturation.
__________________
[Tracker Plugin: Thread|Github|Reapack] | [Routing Plugin: Thread|Reapack] | [More JSFX: Thread|Descriptions|Reapack]
sai'ke is offline   Reply With Quote
Old 07-07-2019, 08:54 AM   #498
sai'ke
Human being with feelings
 
sai'ke's Avatar
 
Join Date: Aug 2009
Location: NL
Posts: 1,451
Default

Have a question of my own, is there a non-ambiguous way to detect whether a user has changed a preset on a JSFX?
__________________
[Tracker Plugin: Thread|Github|Reapack] | [Routing Plugin: Thread|Reapack] | [More JSFX: Thread|Descriptions|Reapack]
sai'ke is offline   Reply With Quote
Old 07-07-2019, 09:14 AM   #499
danerius
Human being with feelings
 
Join Date: Oct 2018
Posts: 173
Default

Quote:
Originally Posted by sai'ke View Post
I don't really see why you would want to clip the signal before the smooth function in this case, since the smooth function already nicely goes into saturation.
Me neither. Im still a bit befuddled by what the actual numbers are for audio samples. Between -1 to 1. with a bit of leeway for overs? How much is that?

Thanks /Bo
danerius is offline   Reply With Quote
Old 07-07-2019, 09:40 AM   #500
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,612
Default

Quote:
Originally Posted by sai'ke View Post
Have a question of my own, is there a non-ambiguous way to detect whether a user has changed a preset on a JSFX?
Changed a preset or selected another preset?
__________________
Use you/she/her.Ultraschall-Api Lua Api4Reaper - Donate, if you wish

On vacation for the time being...
Meo-Ada Mespotine is offline   Reply With Quote
Old 07-07-2019, 09:44 AM   #501
sai'ke
Human being with feelings
 
sai'ke's Avatar
 
Join Date: Aug 2009
Location: NL
Posts: 1,451
Default

Quote:
Originally Posted by mespotine View Post
Changed a preset or selected another preset?
Ah sorry, selected.
__________________
[Tracker Plugin: Thread|Github|Reapack] | [Routing Plugin: Thread|Reapack] | [More JSFX: Thread|Descriptions|Reapack]
sai'ke is offline   Reply With Quote
Old 07-07-2019, 09:47 AM   #502
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,612
Default

You could monitor them, using
https://mespotin.uber.space/Ultrasch...GetPresetIndex
https://mespotin.uber.space/Ultrasch...GetPresetIndex

Would that work?
__________________
Use you/she/her.Ultraschall-Api Lua Api4Reaper - Donate, if you wish

On vacation for the time being...
Meo-Ada Mespotine is offline   Reply With Quote
Old 07-07-2019, 09:51 AM   #503
sai'ke
Human being with feelings
 
sai'ke's Avatar
 
Join Date: Aug 2009
Location: NL
Posts: 1,451
Default

Quote:
Originally Posted by mespotine View Post
Ah, sorry, I should have specified. I meant in JSFX. I'd rather not use an additional extra script for monitoring it.

That's a nice function though! Good to know it exists for future reference.
__________________
[Tracker Plugin: Thread|Github|Reapack] | [Routing Plugin: Thread|Reapack] | [More JSFX: Thread|Descriptions|Reapack]
sai'ke is offline   Reply With Quote
Old 08-05-2019, 06:50 AM   #504
Schöpke
Human being with feelings
 
Join Date: Jan 2013
Posts: 134
Default De-Doppler an audio signal by function?

Timestretching usually is constant. Few programs offer bézier handles and such to control the lead-in and lead-out. But that's all. I need better.

So the audio I have was in fact recorded in nonlinearly timestretched form, because the sound source was moving toward the microphone -- geometry, speed, and distances are all known at this point. Basically I want to "de-Doppler" the signal!

The means to take out the Doppler effect is sqrt(1+x^2), x being the ratio of linear to offset distance (by courtesy of geraintluff).

I would now like to apply that function to control the amount of stretching (NOT the stretching algorithm itself!) of the signal at any given point. That function would then serve as kind of an automation curve, only that its done algorithmically instead of by "Touch". This "stretch factor(t)" could be derived from the ratio "actual moment/total length".

Is this at all possible?

Dieter

Last edited by Schöpke; 08-05-2019 at 07:13 AM.
Schöpke is offline   Reply With Quote
Old 08-06-2019, 08:15 PM   #505
shady
Human being with feelings
 
Join Date: Jun 2017
Posts: 110
Default

I'm trying to select an Automation Item in the Media Explorer.. (later to be inserted into Arrange)

reaper.OpenMediaExplorer("file", false) seems to be defaulting to the Search box..
Are there multiple HWNDs to choose from in the Media Explorer?

when I type in the absolute path ala Script: me2beats_Open folder with media item active take source media.lua,
it doesn't like the \backslash\.. do I need to do a conversion?

EDIT: I just needed to switch to /forward slash/ :0
__________________
twitch.tv/suprshady trying to stream REAPER stuff.. more than twice a year

Last edited by shady; 08-06-2019 at 11:21 PM.
shady is offline   Reply With Quote
Old 08-08-2019, 06:26 PM   #506
shady
Human being with feelings
 
Join Date: Jun 2017
Posts: 110
Default

I expect
reaper.GetEnvelopeStateChunk(env, "<POOLEDENV", false)
to return
<POOLEDENV2
ID 1
NAME "bana"
SRCLEN 9.6
LFO 0 0 50 1 0 0

but I just get VOLENV2 data..

the goal is to identify a pool by it's ID and set it's position..
maybe I could use the ultraschall API instead?
__________________
twitch.tv/suprshady trying to stream REAPER stuff.. more than twice a year
shady is offline   Reply With Quote
Old 08-13-2019, 04:34 AM   #507
pianogineer
Human being with feelings
 
Join Date: Nov 2011
Posts: 105
Default

I'm trying to use Reaper for live, mainly for backing tracks, but also potentially some keyboard patches. I'm using 1 project per song/set of patches.

I'm trying to replicate Mainstage's "Master Fader" concept, where there's an over-riding master fader for an entire "Concert" (which would be set of Reaper projects in this case). What I'd like to do is, when opening a new project (song/patch), to set the Master fader to whatever it was immediately prior in the previous project.

It seems like SetExtState is a good place to continually store the Master Fader changes, but what I'm struggling with is how to know that a new project was opened and therefore to set the Master Fader from external state as opposed to storing its value into external state.

Of course open to other ways to achieve my broader use case. I've played around a bit with SWS startup actions. Even for the project startup action (which wouldn't be ideal for me to use as I'd have to set the startup action per project), it's not clear to me how to make sure the action gets run prior to overwriting the external state (though I guess I could create an "is_initialized" external state to prevent that).
pianogineer is offline   Reply With Quote
Old 08-13-2019, 06:09 AM   #508
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,093
Default

Hi,

an idea would be to have a dedicated project open in a tab which monitors for active project change in a background script.
Something like this:

Code:
function msg(m)
  reaper.ShowConsoleMsg(tostring(m) .. "\n")
end

lastReaProj = reaper.EnumProjects(-1, "")
function main()
  activeReaProj =  reaper.EnumProjects(-1, "")
  if activeReaProj ~= lastReaProj then
    -- do something...
    msg("project changed!")
  end
  lastReaProj = activeReaProj
  reaper.defer(main)
end

main()


It also triggers when opening a new project in a new tab.
A drawback for live use may be if you (accidently) close the monitoring project you'd loose the trigger of course, hm..
Maybe someone comes up with a more clever idea.

In which language are you doing this by the way?
If in C++ (doing a Reaper extension) we can use callbacks from Reaper which aren't available for scripting.
nofish is offline   Reply With Quote
Old 08-13-2019, 06:11 AM   #509
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 14,636
Default

Quote:
Originally Posted by pianogineer View Post
I'm trying to use Reaper for live, mainly for backing tracks, but also potentially some keyboard patches. I'm using 1 project per song/set of patches.
AFAIK, routing Midi and/or audio between multiple project tabs is not perfectly provided, hence I doubt that the "multiple projects" way leads to a decently viable solution.

But let me know what you can accomplish.

When using LiveConfigs to switch (mute/unmute) multiple tracks, I needed to impse a delay to Midi messages I send to the VSTs in the just activated track, as the VSTs first need to wake up after unmuting to be able to receive anything.

See you in the "Live" subforum.

-Michael
mschnell is offline   Reply With Quote
Old 08-13-2019, 09:39 AM   #510
pianogineer
Human being with feelings
 
Join Date: Nov 2011
Posts: 105
Default

Wow, thanks for all the quick replies! I think I was able to get something working with a slight modification to look at the filename, since I'm not using multiple project tabs, and it seems like the ReaProj pointer doesn't change if you simply open a new project (not in tab).

Code:
last_ReaProj, last_projfn = reaper.EnumProjects(-1, "")

function main()
  active_ReaProj, active_projfn =  reaper.EnumProjects(-1, "")
  if active_projfn == last_projfn then
    -- save volume state if project is unchanged
    vol = reaper.GetMediaTrackInfo_Value(reaper.GetMasterTrack(0), "D_VOL")
    reaper.SetExtState("josh","master_vol",vol,false)
  
  else
    -- update master volume if project changes
    saved_vol = reaper.GetExtState("josh","master_vol")
    reaper.SetMediaTrackInfo_Value(reaper.GetMasterTrack(0),"D_VOL",saved_vol)
  end
  last_projfn = active_projfn
  reaper.defer(main)
end

main()
Quote:
Originally Posted by nofish View Post
an idea would be to have a dedicated project open in a tab which monitors for active project change in a background script.
..
A drawback for live use may be if you (accidently) close the monitoring project you'd loose the trigger of course, hm..
Why would I need a dedicated project tab open to keep the script running? From what I can tell, scripts run independently of projects, so if I kick off an endless defer, it seems to continue running even as I switch my (only open) project.

This leads to another question -- how do I actually stop endless defer scripts?? I've read elsewhere that ReaScripts act like toggles, and if you run an endless defer script again it'll stop, but this doesn't seem to work for me.

Quote:
Originally Posted by mschnell View Post
AFAIK, routing Midi and/or audio between multiple project tabs is not perfectly provided, hence I doubt that the "multiple projects" way leads to a decently viable solution.
Not sure I follow. I basically have a project per backing track which I'm opening (not in tabs) via SWS Resources. I'm not having to route audio between projects. Perhaps you're referring to a use case where I wanted VST's open continually in one project, while new backing tracks opening in additional projects? Haven't gotten to that need in my workflow yet, but was potentially thinking about multiple reaper instances in that case, or maybe just routing to different channels of my multi-channel interface and mixing things there. Reason for multiple projects is needing to loop over different regions per song controlled by same MIDI CC (foot pedal), but this is becoming a topic for the Live Forum..

Thanks all!
pianogineer is offline   Reply With Quote
Old 08-13-2019, 10:56 AM   #511
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,093
Default

Quote:
Originally Posted by pianogineer View Post
Why would I need a dedicated project tab open to keep the script running? From what I can tell, scripts run independently of projects, so if I kick off an endless defer, it seems to continue running even as I switch my (only open) project.
Ah right.
Somehow I thought of a case where you close your playing project first before opening a new one (using project tabs).
If you have your playing project always running this should work yes.

Quote:
This leads to another question -- how do I actually stop endless defer scripts?? I've read elsewhere that ReaScripts act like toggles, and if you run an endless defer script again it'll stop, but this doesn't seem to work for me.
It should work when you run it again from action list while running , but not from the IDE. Then this should pop up:


If you then click 'Terminate' and 'Remember' you can toggle it on / off from action list or a toolbar button.

edit:
Slight pitfall (for me anyway): The script mustn't be edited in the IDE when trying to run it from action list or toolbar button.

Last edited by nofish; 08-13-2019 at 11:17 AM.
nofish is offline   Reply With Quote
Old 08-14-2019, 06:13 AM   #512
Barafu Albino Cheetah
Human being with feelings
 
Barafu Albino Cheetah's Avatar
 
Join Date: May 2018
Location: Mordor, Russia
Posts: 34
Default Virtual keyboard

Hello!
Is it possible to code my own Virtual Keyboard for Reaper, with custom picture and mappings? Could you please advise me the shortest route to that? Can I use Python?

I am an experienced programmer, but beginner in music, so I am not interested in learning coding for Reaper beyond what is needed for this task. So I am looking for shortcuts. Thanks!
Barafu Albino Cheetah is offline   Reply With Quote
Old 08-14-2019, 06:18 AM   #513
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
Default

Quote:
Originally Posted by Barafu Albino Cheetah View Post
Hello!
Is it possible to code my own Virtual Keyboard for Reaper, with custom picture and mappings? Could you please advise me the shortest route to that? Can I use Python?
Making a JSFX plugin that outputs MIDI sounds the most feasible solution. JSFX uses the Cockos Eel language, so no Python.
__________________
I am no longer part of the REAPER community. Please don't contact me with any REAPER-related issues.
Xenakios is offline   Reply With Quote
Old 08-14-2019, 10:49 AM   #514
Barafu Albino Cheetah
Human being with feelings
 
Barafu Albino Cheetah's Avatar
 
Join Date: May 2018
Location: Mordor, Russia
Posts: 34
Default

They are per-track, aren't they? It will be very inconvenient to use even if I find a way to sync state between instances.
Barafu Albino Cheetah is offline   Reply With Quote
Old 10-20-2019, 04:57 PM   #515
WyattRice
Human being with feelings
 
WyattRice's Avatar
 
Join Date: Sep 2009
Location: Virginia
Posts: 2,067
Default Win32 Api Combo Box Noob Question

I have an extension that is a dialog box with two combo boxes.

In my dlgprocess in WM_INITDIALOG:

I'm populating both combo boxes.

I want to try and join, or connect the combobox1 index to combobox2, so when I change combobox 1, combobox 2 changes too.
Code:
//combo1
case IDC_COMBO1: {
	{
		if (HIWORD(wParam) == CBN_SELCHANGE)
		{
			int index = SendDlgItemMessage(g_hwnd, IDC_COMBO2,
				CB_SETCURSEL, (WPARAM)index, (LPARAM)0);

		}

		return 0;
	}
}
Years ago I did this with vb.net like:
Code:
    Private Sub ComboBox2_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handles ComboBox2.SelectedIndexChanged
        ComboBox1.SelectedIndex = ComboBox2.SelectedIndex
Was wondering if it was possible with just plain win32?
Any help would be appreciated.

Edit:
Got it working. Had to get index first.
Code:
	case IDC_COMBO2: 
	{
		HWND hwndCB1 = GetDlgItem(g_hwnd, IDC_COMBO1);
		HWND hwndCB2 = GetDlgItem(g_hwnd, IDC_COMBO2);

		if (HIWORD(wParam) == CBN_SELCHANGE && (LOWORD(wParam) == IDC_COMBO2))
		{
			int idx;
			idx = SendMessage(hwndCB2, CB_GETCURSEL, 0, 0);
			SendMessage(hwndCB1, CB_SETCURSEL, idx, 0);
			break;
			}
		}


Many Thanks,
Wyatt
__________________
DDP To Cue Writer. | DDP Marker Editor.

Last edited by WyattRice; 10-21-2019 at 10:38 AM.
WyattRice is offline   Reply With Quote
Old 10-21-2019, 09:38 AM   #516
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,612
Default

Does somebody know, what the Mac-equivalent of Window's GetModuleFileName-function is?
https://docs.microsoft.com/en-us/win...odulefilenamea

We need it to document some of Reaper's Mac-specific behavior.
__________________
Use you/she/her.Ultraschall-Api Lua Api4Reaper - Donate, if you wish

On vacation for the time being...
Meo-Ada Mespotine is offline   Reply With Quote
Old 10-21-2019, 09:53 AM   #517
WyattRice
Human being with feelings
 
WyattRice's Avatar
 
Join Date: Sep 2009
Location: Virginia
Posts: 2,067
Default

Quote:
Originally Posted by mespotine View Post
Does somebody know, what the Mac-equivalent of Window's GetModuleFileName-function is?
https://docs.microsoft.com/en-us/win...odulefilenamea

We need it to document some of Reaper's Mac-specific behavior.
For Reaper, it would be in WDL/swell, I think.
In swell-functions.h
Code:
SWELL_API_DEFINE(DWORD, GetModuleFileName,(HINSTANCE hInst, char *fn, DWORD nSize))
Also in swell.cpp file
__________________
DDP To Cue Writer. | DDP Marker Editor.
WyattRice is offline   Reply With Quote
Old 10-23-2019, 07:44 AM   #518
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,612
Default

Quote:
Originally Posted by WyattRice View Post
For Reaper, it would be in WDL/swell, I think.
In swell-functions.h
Code:
SWELL_API_DEFINE(DWORD, GetModuleFileName,(HINSTANCE hInst, char *fn, DWORD nSize))
Also in swell.cpp file
Thank you very much, we will try that

Edit: in which file are the swell and WDL-functions defined? I may attempt to add them to my docs too.
__________________
Use you/she/her.Ultraschall-Api Lua Api4Reaper - Donate, if you wish

On vacation for the time being...
Meo-Ada Mespotine is offline   Reply With Quote
Old 10-23-2019, 07:59 AM   #519
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,093
Default

Quote:
Originally Posted by mespotine View Post
Thank you very much, we will try that

Edit: in which file are the swell and WDL-functions defined? I may attempt to add them to my docs too.
https://github.com/justinfrankel/WDL...swell.cpp#L953
nofish is offline   Reply With Quote
Old 10-27-2019, 08:22 PM   #520
Zamyen
Human being with feelings
 
Join Date: Dec 2008
Posts: 78
Default

I have seen this statement in a few lua scripts and had to include it in some of my own scripts calling Main_OnCommand

for key in pairs(reaper) do _G[key]=reaper[key] end

Could someone who knows a lot more about this explain why this is necessary? (copying the functions to the Lua global namespace?)

Printing the same keys to console is an expensive operation, as more functions are added any scripts with this command would slow down over time also.

Is there any way to do this more efficiently e.g. copying specific/selected functions to the Lua global?

Thanks a lot in advance for such a basic question.
Zamyen is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 03:19 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.