 |
|
|
11-07-2009, 04:07 AM
|
#1
|
|
Mortal
Join Date: Dec 2006
Location: Leicestershire, England
Posts: 426
|
3.14 tests GetSetItemState()
Looks good.
Test of Get
Code:
#
# GetSetItemState.pl
#
# "Get" example
#
use strict;
use warnings;
use constant CURR_PROJ => 0;
my ($bool, $it, $chunk, $maxlen);
my $result = "fail";
# Get the first selected item in the current project
$it = RPR_GetSelectedMediaItem(CURR_PROJ, 0);
# set-up for call to GetSetItemState
$chunk=""; # Get, not Set
$maxlen=1024; # max num of chars to return
($bool, $it, $chunk, $maxlen) = RPR_GetSetItemState($it, $chunk, $maxlen);
$result = "pass" if $bool;
RPR_ShowConsoleMsg("GetSetItemState reports $result\n$chunk\n");
With an item selected this prints:
Code:
GetSetItemState reports pass
<ITEM
POSITION 12.00000000000000
SNAPOFFS 0.00000000000000
LENGTH 8.81585503963759
LOOP 1
ALLTAKES 0
SEL 1
FADEIN 1 0.000000 0.000000
FADEOUT 1 0.000000 0.000000
MUTE 0
IGUID {967EE770-4144-472A-89D6-B72BB910A916}
NAME "lalala untitled MIDI item"
VOLPAN 1.000000 0.000000 1.000000 -1.000000
SOFFS 0.00000000000000 0.00000000000000
PLAYRATE 1.00000000000000 1 0.00000000000000 -1
CHANMODE 0
GUID {9C93A652-09A2-4A46-9E1B-EF83EB7CED29}
<SOURCE MIDI
HASDATA 1 960 QN
e 300 90 2b 60
e 60 80 2b 00
E 120 90 27 60
E 60 80 27 00
E 1200 90 2c 60
E 60 80 2c 00
E 60 90 29 60
E 60 80 29 00
E 360 90 2a 60
E 60 80 2a 00
E 120 90 26 60
E 60 80 26 00
E 540 90 2a 60
E 60 80 2a 00
E 120 90 2e 60
E 60 80 2e 00
E 540 b0 7b 00
GUID {9DAB52C8-6257-4A4E-9E60-323514C0DB9B}
IGNTEMPO 0 120.00000000 4 4
VELLANE 128 97 0
BANKPROGRAMFILE "C:\Program Files\REAPER/Data/GM.reabank"
CFGEDITVIEW 3787.833051 0.178906 0 48 0 0 0
CFGEDIT 1 1 0 1 1 16 1 1 1 1 1 0.06250000 -4 -4 1404 1001 0 2 0 0 0.00000000 0 0
EVTFILTER 0 -1 -1 -1 -1 0 1
>
>
With no item selected this prints:
Code:
GetSetItemState reports fail
__________________
Mike Lacey, Leicestershire, UK
|
|
|
11-07-2009, 04:27 AM
|
#2
|
|
Mortal
Join Date: Dec 2006
Location: Leicestershire, England
Posts: 426
|
Test of Set
Again, looks good.
Code:
#
# GetSetItemState-Test-Set.pl
#
# "Set" test
#
use constant CURR_PROJ => 0;
my ($bool, $it, $chunk, $maxlen);
my $result;
# Get the first selected item in the current project
$it = RPR_GetSelectedMediaItem(CURR_PROJ, 0);
# set-up for call to GetSetItemState
$chunk=""; # Get, not Set
$maxlen=1024; # max num of chars to return
$result = "fail";
($bool, $it, $chunk, $maxlen) = RPR_GetSetItemState($it, $chunk, $maxlen);
$result = "pass" if $bool;
RPR_ShowConsoleMsg("AFTER GET: GetSetItemState reports $result\n$chunk\n");
# Now set a couple of item properties
$chunk =~ s/LOOP.*\n/LOOP 0\n/;
$chunk =~ s/LENGTH.*\n/LENGTH 10\n/;
$result = "fail";
($bool, $it, $chunk, $maxlen) = RPR_GetSetItemState($it, $chunk, $maxlen);
$result = "pass" if $bool;
RPR_ShowConsoleMsg("AFTER SET: GetSetItemState reports $result\n$chunk\n");
Prints
Code:
AFTER GET: GetSetItemState reports pass
<ITEM
POSITION 12.00000000000000
SNAPOFFS 0.00000000000000
LENGTH 8.81585503963759
LOOP 1
ALLTAKES 0
SEL 1
FADEIN 1 0.000000 0.000000
FADEOUT 1 0.000000 0.000000
MUTE 0
IGUID {967EE770-4144-472A-89D6-B72BB910A916}
NAME "lalala untitled MIDI item"
VOLPAN 1.000000 0.000000 1.000000 -1.000000
SOFFS 0.00000000000000 0.00000000000000
PLAYRATE 1.00000000000000 1 0.00000000000000 -65536
CHANMODE 0
GUID {9C93A652-09A2-4A46-9E1B-EF83EB7CED29}
<SOURCE MIDI
HASDATA 1 960 QN
e 300 90 2b 60
e 60 80 2b 00
E 120 90 27 60
E 60 80 27 00
E 1200 90 2c 60
E 60 80 2c 00
E 60 90 29 60
E 60 80 29 00
E 360 90 2a 60
E 60 80 2a 00
E 120 90 26 60
E 60 80 26 00
E 540 90 2a 60
E 60 80 2a 00
E 120 90 2e 60
E 60 80 2e 00
E 540 b0 7b 00
GUID {9DAB52C8-6257-4A4E-9E60-323514C0DB9B}
IGNTEMPO 0 120.00000000 4 4
VELLANE 128 97 0
BANKPROGRAMFILE "C:\Program Files\REAPER/Data/GM.reabank"
CFGEDITVIEW 3787.833051 0.178906 0 48 0 0 0
CFGEDIT 1 1 0 1 1 16 1 1 1 1 1 0.06250000 -4 -4 1404 1001 0 2 0 0 0.00000000 0 0
EVTFILTER 0 -1 -1 -1 -1 0 1
>
>
AFTER SET: GetSetItemState reports pass
<ITEM
POSITION 12.00000000000000
SNAPOFFS 0.00000000000000
LENGTH 10
LOOP 0
ALLTAKES 0
SEL 1
FADEIN 1 0.000000 0.000000
FADEOUT 1 0.000000 0.000000
MUTE 0
IGUID {967EE770-4144-472A-89D6-B72BB910A916}
NAME "lalala untitled MIDI item"
VOLPAN 1.000000 0.000000 1.000000 -1.000000
SOFFS 0.00000000000000 0.00000000000000
PLAYRATE 1.00000000000000 1 0.00000000000000 -65536
CHANMODE 0
GUID {9C93A652-09A2-4A46-9E1B-EF83EB7CED29}
<SOURCE MIDI
HASDATA 1 960 QN
e 300 90 2b 60
e 60 80 2b 00
E 120 90 27 60
E 60 80 27 00
E 1200 90 2c 60
E 60 80 2c 00
E 60 90 29 60
E 60 80 29 00
E 360 90 2a 60
E 60 80 2a 00
E 120 90 26 60
E 60 80 26 00
E 540 90 2a 60
E 60 80 2a 00
E 120 90 2e 60
E 60 80 2e 00
E 540 b0 7b 00
GUID {9DAB52C8-6257-4A4E-9E60-323514C0DB9B}
IGNTEMPO 0 120.00000000 4 4
VELLANE 128 97 0
BANKPROGRAMFILE "C:\Program Files\REAPER/Data/GM.reabank"
CFGEDITVIEW 3787.833051 0.178906 0 48 0 0 0
CFGEDIT 1 1 0 1 1 16 1 1 1 1 1 0.06250000 -4 -4 1404 1001 0 2 0 0 0.00000000 0 0
EVTFILTER 0 -1 -1 -1 -1 0 1
>
>
__________________
Mike Lacey, Leicestershire, UK
|
|
|
11-07-2009, 12:42 PM
|
#3
|
|
Mortal
Join Date: Feb 2009
Location: Melbourne, Australia
Posts: 59
|
Thanks for the examples Mike. Very neat.
I've had sucess using GetSetItemState() too. Instead of using InsertMedia() and then calling SetMediaItemInfo_Value() a bunch of times, I'm now using AddMediaItemToTrack(), building a chunk with all the values I want (including the wave filename and source properties) and then calling GetSetItemState() to assign the chunk.
This works very well for me so far. A bonus for my particular purpose is that the current cursor position doesn't change whereas using InsertMedia() results in the cursor jumping to the end of new file at the end of the operation.
|
|
|
11-07-2009, 03:26 PM
|
#4
|
|
Mortal
Join Date: Dec 2006
Location: Leicestershire, England
Posts: 426
|
Sounds good, would love to see it, if that's possible.
Seems that the only limitations in ReaScript will be screen handling and performance issues, I think that mixing REAPER and Tkx would be quite difficult; we'll see.
You can't call RPR_ functions from a .pm at the moment, that's going to be a limitation quite quickly, people will want to share things.
Just with the functions we have at the moment you could create a project and populate it from scratch.
__________________
Mike Lacey, Leicestershire, UK
|
|
|
11-07-2009, 04:05 PM
|
#5
|
|
Mortal
Join Date: Feb 2009
Location: Melbourne, Australia
Posts: 59
|
Quote:
Originally Posted by MikeLacey
Sounds good, would love to see it, if that's possible.
|
Of course! I plan on sharing everything I make especialling since none of it would be possible without the assistance of others. What I've built so far (a kind of sample loader) would be of "limited to no use" for others because it's highly specialised and works a long a sample sequencing paradigm that I've arrived at after years of working with MIDI and a sampler before deciding that approach was flawed.
Once I've tidied it all up I'll post something. However, after seeing how clean and orderly your code is my pride prevents me from simply dumping my work in progress. I really need to do a Perl refresher ASAP to avoid further embarrassment.
Quote:
Originally Posted by MikeLacey
Just with the functions we have at the moment you could create a project and populate it from scratch.
|
Yes, I'm thinking of a few dreamy ideas along those lines.
|
|
|
11-07-2009, 04:20 PM
|
#6
|
|
Mortal
Join Date: Dec 2006
Location: Leicestershire, England
Posts: 426
|
"a Perl refresher ASAP"
Don't worry about it...
My problem at the moment is that.... *everything* seems possible, so I don't know what to go at - which is why I'm documenting and absorbing as much as possible. I've been using Perl since v2.something so I was quite excited to find support for it in REAPER.
One thing that did occur to me was that you could easily build a batch CD build maker, that built a project from a list of .WAVs in a config file, spread them out nicely, normalised them. All of the stuff that's just drudge work really. Just a thought really.
Or... You could stick a listener in a Perl script and control your REAPER instance from the other side of the world, or the next room. No idea why you'd *want* to do that mind you.
Or... You could create a Perl script that collected media files from somewhere, as they were created by ... something, and then add them into your project every ten minutes, or hours. The uses for this one are so obvious I won't be bothering to list them (cough)
__________________
Mike Lacey, Leicestershire, UK
Last edited by MikeLacey; 11-07-2009 at 04:28 PM.
|
|
|
11-08-2009, 08:37 AM
|
#7
|
|
Mortal
Join Date: Sep 2007
Location: Madison, WI
Posts: 359
|
Quote:
Originally Posted by sfzgeek
This works very well for me so far. A bonus for my particular purpose is that the current cursor position doesn't change whereas using InsertMedia() results in the cursor jumping to the end of new file at the end of the operation.
|
Slighty OT, sorry - that cursor moving to the end of the item after paste is a Reaper preference in "Editing Behavior->Move edit cursor when pasting/inserting media."
However, you can change it almost any preference programmatically: (C code, sorry, maybe this is impossible from ReaScript, if so I apologize) Here is an example from the SWS/Xen Repeat Paste action:
Code:
int unused;
int* pCursorMode = (int*)get_config_var("itemclickmovecurs", &unused);
// Bit 8 set means disable move cursor after paste
int saveCursorMode = *pCursorMode;
*pCursorMode &= ~8;
// Do the repeat paste code which relies on the cursor moving
*pCursorMode = saveCursorMode; // Restore the user's pref
AFAIK there isn't a list of parameters anywhere, it takes some investigation. Everything is stored to the reaper.ini file, so save a copy of reaper.ini, change your pref and apply, then do a diff of the reaper.ini with the copy. You should see what's changed and the parameter can be used as an argument to get_config_var.
Hope this helps somebody.
|
|
|
11-08-2009, 09:08 AM
|
#8
|
|
Mortal
Join Date: Dec 2006
Location: Leicestershire, England
Posts: 426
|
*Should* be able to do all that, we have access to get_config_var() for instance...
If you have any notes re config variables you don't mind sharing, I'd be happy to document them.
__________________
Mike Lacey, Leicestershire, UK
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -7. The time now is 09:06 PM.
|