Go Back   Cockos Incorporated Forums > REAPER Forums > ReaScript, JSFX, REAPER Plug-in Extensions, Developer Forum

Reply
 
Thread Tools Display Modes
Old 08-25-2019, 02:30 AM   #1
Thonex
Human being with feelings
 
Join Date: May 2018
Location: Los Angeles
Posts: 1,719
Default Function to tell whether an audio item is at top or tail of Source Media

HI guys,

I almost like amagalma'a smart_crossfade script, but it will crossfade an audio item beyond it's actual audio content of the Source Media by moving the item's left or right edges beyond where there is audio.

Is there a way to tell if an item start or end is at the boundary of it's Source Media's audio? Or asked a different way, is there a way to detect where the item would no longer have audio?

Lastly, is there a way (a pref?) to prohibit Reaper from allowing you to move an item's edges beyond its content?

I hope this makes sense.

Cheers,

Andrew K
__________________
Cheers... Andrew K
Reaper v6.80+dev0621 - June 21 2023 • Catalina • Mac Mini 2020 6 core i7 • 64GB RAM • OS: Catalina • 4K monitor • RME RayDAT card with Sync Card and extended Light Pipe.
Thonex is offline   Reply With Quote
Old 08-25-2019, 05:19 AM   #2
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,875
Default

On script side, the simplest way is to compare length of item before / after using the native Set item end to end of its source action. (not sure it is propper name but you have the keywords).
And then restore original lebgth if needed.
X-Raym is offline   Reply With Quote
Old 08-25-2019, 09:04 AM   #3
Thonex
Human being with feelings
 
Join Date: May 2018
Location: Los Angeles
Posts: 1,719
Default

Quote:
Originally Posted by X-Raym View Post
On script side, the simplest way is to compare length of item before / after using the native Set item end to end of its source action. (not sure it is propper name but you have the keywords).
And then restore original lebgth if needed.

Thanks X-Rahm!!

I’ll search for those key words. But it sounds like it would be a clever work around.

Now, the questuon is if it would work with your awesome script: vertical group according to item order (or whatever it’s called)?

Cheers,

Andrew K
__________________
Cheers... Andrew K
Reaper v6.80+dev0621 - June 21 2023 • Catalina • Mac Mini 2020 6 core i7 • 64GB RAM • OS: Catalina • 4K monitor • RME RayDAT card with Sync Card and extended Light Pipe.
Thonex is offline   Reply With Quote
Old 08-25-2019, 01:00 PM   #4
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

These functions might help:

Code:
number retval, boolean lengthIsQN = reaper.GetMediaSourceLength(PCM_source source)

Returns the length of the source media. If the media source is beat-based, the length will be in quarter notes, otherwise it will be in seconds.
Code:
number reaper.GetMediaItemTakeInfo_Value(MediaItem_Take take, string parmname)

Get media item take numerical-value attributes.
D_STARTOFFS : double *, start offset in take of item
D_VOL : double *, take volume (negative if take polarity is flipped)
D_PAN : double *, take pan
D_PANLAW : double *, take pan law (-1.0=default, 0.5=-6dB, 1.0=+0dB, etc)
D_PLAYRATE : double *, take playrate (1.0=normal, 2.0=doublespeed, etc)
D_PITCH : double *, take pitch adjust (in semitones, 0.0=normal, +12 = one octave up, etc)
B_PPITCH : bool *, preserve pitch when changing rate
I_CHANMODE : int *, channel mode (0=normal, 1=revstereo, 2=downmix, 3=l, 4=r)
I_PITCHMODE : int *, pitch shifter mode, -1=proj default, otherwise high word=shifter low word = parameter
I_CUSTOMCOLOR : int *, custom color, OS dependent color|0x100000 (i.e. ColorToNative(r,g,b)|0x100000). If you do not |0x100000, then it will not be used (though will store the color anyway).
IP_TAKENUMBER : int, take number within the item (read-only, returns the take number directly)
P_TRACK : pointer to MediaTrack (read-only)
P_ITEM : pointer to MediaItem (read-only)
P_SOURCE : PCM_source *. Note that if setting this, you should first retrieve the old source, set the new, THEN delete the old.
Code:
number reaper.GetMediaItemInfo_Value(MediaItem item, string parmname)

Get media item numerical-value attributes.
B_MUTE : bool * to muted state
B_LOOPSRC : bool * to loop source
B_ALLTAKESPLAY : bool * to all takes play
B_UISEL : bool * to ui selected
C_BEATATTACHMODE : char * to one char of beat attached mode, -1=def, 0=time, 1=allbeats, 2=beatsosonly
C_LOCK : char * to one char of lock flags (&1 is locked, currently)
D_VOL : double * of item volume (volume bar)
D_POSITION : double * of item position (seconds)
D_LENGTH : double * of item length (seconds)
D_SNAPOFFSET : double * of item snap offset (seconds)
D_FADEINLEN : double * of item fade in length (manual, seconds)
D_FADEOUTLEN : double * of item fade out length (manual, seconds)
D_FADEINDIR : double * of item fade in curve [-1; 1]
D_FADEOUTDIR : double * of item fade out curve [-1; 1]
D_FADEINLEN_AUTO : double * of item autofade in length (seconds, -1 for no autofade set)
D_FADEOUTLEN_AUTO : double * of item autofade out length (seconds, -1 for no autofade set)
C_FADEINSHAPE : int * to fadein shape, 0=linear, ...
C_FADEOUTSHAPE : int * to fadeout shape
I_GROUPID : int * to group ID (0 = no group)
I_LASTY : int * to last y position in track (readonly)
I_LASTH : int * to last height in track (readonly)
I_CUSTOMCOLOR : int * : custom color, OS dependent color|0x100000 (i.e. ColorToNative(r,g,b)|0x100000). If you do not |0x100000, then it will not be used (though will store the color anyway).
I_CURTAKE : int * to active take
IP_ITEMNUMBER : int, item number within the track (read-only, returns the item number directly)
F_FREEMODE_Y : float * to free mode y position (0..1)
F_FREEMODE_H : float * to free mode height (0..1)
P_TRACK : MediaTrack * (read only)
spk77 is offline   Reply With Quote
Old 08-25-2019, 01:28 PM   #5
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,875
Default

Quote:
Now, the questuon is if it would work with your awesome script: vertical group according to item order (or whatever it’s called)?
Yes, cause it wont alter item position (only item end)
X-Raym is offline   Reply With Quote
Old 08-25-2019, 01:41 PM   #6
Thonex
Human being with feelings
 
Join Date: May 2018
Location: Los Angeles
Posts: 1,719
Default

Quote:
Originally Posted by spk77 View Post
These functions might help:

Code:
number retval, boolean lengthIsQN = reaper.GetMediaSourceLength(PCM_source source)

Returns the length of the source media. If the media source is beat-based, the length will be in quarter notes, otherwise it will be in seconds..
.
.
.
number reaper.GetMediaItemTakeInfo_Value(MediaItem_Take take, string parmname)

Get media item take numerical-value attributes.
D_STARTOFFS : double *, start offset in take of item

D_PLAYRATE : double *, take playrate (1.0=normal, 2.0=doublespeed, etc)
.
.
.
number reaper.GetMediaItemInfo_Value(MediaItem item, string parmname)

Get media item numerical-value attributes.

D_POSITION : double * of item position (seconds)
D_LENGTH : double * of item length (seconds)
Awesome SPK77... now I have to roll up my sleeves!! These look like they would give me all the criteria I need for a Boolean... and without having to do any moving of anything beforehand.

Thanks!
__________________
Cheers... Andrew K
Reaper v6.80+dev0621 - June 21 2023 • Catalina • Mac Mini 2020 6 core i7 • 64GB RAM • OS: Catalina • 4K monitor • RME RayDAT card with Sync Card and extended Light Pipe.
Thonex 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 04:32 AM.


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