Go Back   Cockos Incorporated Forums > REAPER Forums > REAPER Feature Requests

Reply
 
Thread Tools Display Modes
Old 10-20-2021, 01:20 AM   #1
Mordi
Human being with feelings
 
Mordi's Avatar
 
Join Date: May 2014
Location: Norway
Posts: 987
Default Add Media Explorer reascript functionality

I'm currently cleaning up my audio library, renaming files and consolidating them from single one-off sounds into longer sequential files separated by cues.

It would be really handy if the Media Explorer exposed functions like these in Lua scripts:
- Get currently selected files
- Get current folder path
- Rename file (without opening dialog)
- Get/set metadata field
- Get Media Explorer time selection start/end

Implementing some or all of these would greatly enhance the usefulness of the Media Explorer.
__________________

Last edited by Mordi; 12-10-2021 at 11:59 AM.
Mordi is offline   Reply With Quote
Old 10-26-2021, 12:29 PM   #2
acendan
Human being with feelings
 
acendan's Avatar
 
Join Date: Jun 2020
Location: Florida, US
Posts: 41
Default

+1 - Get/Set metadata would be a huge gamechanger. Especially for iXML.
acendan is offline   Reply With Quote
Old 10-26-2021, 01:43 PM   #3
Phazma
Human being with feelings
 
Join Date: Jun 2019
Posts: 2,875
Default

+1 - This would supercharge the media explorer and allow users to create scripts for it to turn it into a tool for not just browsing but also organizing big sound libraries. I imagine a sophisticated batch renaming utility that adds/removes certain characters to/from all selected file's names.
Phazma is offline   Reply With Quote
Old 10-27-2021, 01:50 AM   #4
sijam
Human being with feelings
 
Join Date: Jan 2017
Posts: 36
Default

+1 I've been sitting on requesting something like this for a little while. Editing all the new available metadata fields would be ace, a set of scripts for batch editing would be huge!
sijam is offline   Reply With Quote
Old 10-28-2021, 03:36 AM   #5
Buy One
Human being with feelings
 
Buy One's Avatar
 
Join Date: Sep 2019
Posts: 1,146
Default

Even though native API is always welcome and preferable, this can be attempted with Julian Sader's API


Quote:
Originally Posted by X-Raym View Post
Do you think we can get selected media files from Media Explorer and start doing some Media Explorer script ? :P
Quote:
Originally Posted by juliansader View Post
As Edgemeal answered, yes you can! (I am actually using some myself.)

Three remarks:

* You can open the Media Explorer (and get its HWND) using reaper.OpenMediaExplorer("", false).

* You can run any action from the Actions list's Media Explorer context (or even any item from the ME's menu), using JS_Window_OnCommand.

* If you are publishing a script that searches for any of REAPER's standard windows, such as the Media Explorer, use JS_Localize to get the translated title.
Edgemeal's example 1
Edgemeal's example 2
.
.
.

Last edited by Buy One; 10-28-2021 at 03:46 AM.
Buy One is offline   Reply With Quote
Old 11-27-2021, 08:17 AM   #6
Mordi
Human being with feelings
 
Mordi's Avatar
 
Join Date: May 2014
Location: Norway
Posts: 987
Default

Thanks for the tip. That should work well as a plan B for media explorer scripts.
__________________
Mordi is offline   Reply With Quote
Old 11-30-2021, 11:19 PM   #7
airon
Human being with feelings
 
airon's Avatar
 
Join Date: Aug 2006
Location: Berlin
Posts: 11,818
Default

Mass tagging BWF and iXML fields with wildcards would sell well amongst sound designers, if such scripts don’t already exist.
__________________
Using Latch Preview (Video) - Faderport 16 setup for CSI 1.1 , CSI 3.10
Website
"My ego comes pre-shrunk" - Randy Thom
airon is offline   Reply With Quote
Old 12-01-2021, 10:01 AM   #8
Rodilab
Human being with feelings
 
Rodilab's Avatar
 
Join Date: Jan 2021
Location: Paris
Posts: 255
Default

+1000 for Set metadata API
Get one already exist.
Rodilab is offline   Reply With Quote
Old 12-20-2021, 06:59 PM   #9
tingshuo
Human being with feelings
 
Join Date: Dec 2018
Posts: 30
Default

+1
I'm looking for a way for the 'Replace Source' command to respect the time selection start point on the file in Media Explorer. It seems this request would make what I need scriptable.
tingshuo is offline   Reply With Quote
Old 04-25-2022, 07:17 AM   #10
BenjyO
Human being with feelings
 
Join Date: Nov 2011
Posts: 308
Default

+1 for all of these but mostly for Set metadata and Get time selection
__________________
Check out some of my music
BenjyO is offline   Reply With Quote
Old 04-25-2022, 08:11 AM   #11
FeedTheCat
Human being with feelings
 
FeedTheCat's Avatar
 
Join Date: May 2019
Location: Berlin
Posts: 2,198
Default

Quote:
Originally Posted by BenjyO View Post
+1 for all of these but mostly for Set metadata and Get time selection
Just FYI, reading out time selection is cumbersome, but possible with JS_ReaScriptAPI. I did it for my RS5K link script.



Big +1 on this FR though. A little bit of ReaScript access would go a long way here.
__________________
Featured scripts: REAPER Update UtilityLil ChordboxGridbox/Adaptive gridMX TunerRS5K LinkMIDI Editor Magic Donate💝: PayPal|ko-fi
FeedTheCat is online now   Reply With Quote
Old 04-25-2022, 11:25 AM   #12
BenjyO
Human being with feelings
 
Join Date: Nov 2011
Posts: 308
Default

Quote:
Originally Posted by FeedTheCat View Post
Just FYI, reading out time selection is cumbersome, but possible with JS_ReaScriptAPI. I did it for my RS5K link script.

Big +1 on this FR though. A little bit of ReaScript access would go a long way here.
Oh I know about your script and I use it a lot along with the other MX scripts you wrote. Super useful! Thank you very much for sharing it with the community

Haven't looked at the code of your scripts yet but I think I know what you did since I already messed around with JS_ReaScriptAPI and the MX window's controls before and I hit a wall when I realized the mouse cursor needs to be in the waveform area. Your script is deferred but what I tried to do was a "one-shot" script which would be triggered by a hotkey after you've already made your time selection. Well .. you know what the issue is
__________________
Check out some of my music
BenjyO is offline   Reply With Quote
Old 04-25-2022, 11:56 AM   #13
FeedTheCat
Human being with feelings
 
FeedTheCat's Avatar
 
Join Date: May 2019
Location: Berlin
Posts: 2,198
Default

Quote:
Originally Posted by BenjyO View Post
Oh I know about your script and I use it a lot along with the other MX scripts you wrote. Super useful! Thank you very much for sharing it with the community

Haven't looked at the code of your scripts yet but I think I know what you did since I already messed around with JS_ReaScriptAPI and the MX window's controls before and I hit a wall when I realized the mouse cursor needs to be in the waveform area. Your script is deferred but what I tried to do was a "one-shot" script which would be triggered by a hotkey after you've already made your time selection. Well .. you know what the issue is
Yeah... it's messy... you have to simulate a mouse event for the values to be shown. Here's the function MediaExplorer_GetTimeSelection (and a simple example) in case you still want it.

Code:
local mx = reaper.OpenMediaExplorer('', false)

function MediaExplorer_GetTimeSelection(force_readout)
    if force_readout then
        -- Simulate mouse event on waveform to read out time selection
        local wave_hwnd = reaper.JS_Window_FindChildByID(mx, 1046)
        local x, y = reaper.GetMousePosition()
        local c_x, c_y = reaper.JS_Window_ScreenToClient(wave_hwnd, x, y)
        reaper.JS_WindowMessage_Send(wave_hwnd, 'WM_MOUSEFIRST', c_y, 0, c_x, 0)
    end

    -- If a time selection exists, it will be shown in the wave info window
    local wave_info_hwnd = reaper.JS_Window_FindChildByID(mx, 1014)
    local wave_info = reaper.JS_Window_GetTitle(wave_info_hwnd)
    local pattern = ': ([^%s]+) .-: ([^%s]+)'
    local start_timecode, end_timecode = wave_info:match(pattern)

    if not start_timecode then return false end

    -- Convert timecode to seconds
    local start_mins, start_secs = start_timecode:match('^(.-):(.-)$')
    start_secs = tonumber(start_secs) + tonumber(start_mins) * 60

    local end_mins, end_secs = end_timecode:match('^(.-):(.-)$')
    end_secs = tonumber(end_secs) + tonumber(end_mins) * 60

    -- Note: When no media file is loaded, start and end are both 0
    return start_secs ~= end_secs, start_secs, end_secs
end

ret, start_pos, end_pos = MediaExplorer_GetTimeSelection(true)
__________________
Featured scripts: REAPER Update UtilityLil ChordboxGridbox/Adaptive gridMX TunerRS5K LinkMIDI Editor Magic Donate💝: PayPal|ko-fi
FeedTheCat is online now   Reply With Quote
Old 04-25-2022, 12:43 PM   #14
BenjyO
Human being with feelings
 
Join Date: Nov 2011
Posts: 308
Default

Quote:
Originally Posted by FeedTheCat View Post
Yeah... it's messy... you have to simulate a mouse event for the values to be shown. Here's the function MediaExplorer_GetTimeSelection (and a simple example) in case you still want it.

Code:
local mx = reaper.OpenMediaExplorer('', false)

function MediaExplorer_GetTimeSelection(force_readout)
    if force_readout then
        -- Simulate mouse event on waveform to read out time selection
        local wave_hwnd = reaper.JS_Window_FindChildByID(mx, 1046)
        local x, y = reaper.GetMousePosition()
        local c_x, c_y = reaper.JS_Window_ScreenToClient(wave_hwnd, x, y)
        reaper.JS_WindowMessage_Send(wave_hwnd, 'WM_MOUSEFIRST', c_y, 0, c_x, 0)
    end

    -- If a time selection exists, it will be shown in the wave info window
    local wave_info_hwnd = reaper.JS_Window_FindChildByID(mx, 1014)
    local wave_info = reaper.JS_Window_GetTitle(wave_info_hwnd)
    local pattern = ': ([^%s]+) .-: ([^%s]+)'
    local start_timecode, end_timecode = wave_info:match(pattern)

    if not start_timecode then return false end

    -- Convert timecode to seconds
    local start_mins, start_secs = start_timecode:match('^(.-):(.-)$')
    start_secs = tonumber(start_secs) + tonumber(start_mins) * 60

    local end_mins, end_secs = end_timecode:match('^(.-):(.-)$')
    end_secs = tonumber(end_secs) + tonumber(end_mins) * 60

    -- Note: When no media file is loaded, start and end are both 0
    return start_secs ~= end_secs, start_secs, end_secs
end

ret, start_pos, end_pos = MediaExplorer_GetTimeSelection(true)
Thanks!
__________________
Check out some of my music
BenjyO is offline   Reply With Quote
Old 04-26-2022, 12:16 AM   #15
wastee
Human being with feelings
 
Join Date: Mar 2015
Location: Mainland China
Posts: 157
Default

+1 Happy to see if there's native API in ME.
wastee is offline   Reply With Quote
Old 05-12-2022, 01:35 PM   #16
grandfougue
Human being with feelings
 
grandfougue's Avatar
 
Join Date: Sep 2016
Posts: 513
Default

So good But how did you manage to put your toolbar at the bottom of the media explorer?
grandfougue is offline   Reply With Quote
Old 05-12-2022, 10:31 PM   #17
FeedTheCat
Human being with feelings
 
FeedTheCat's Avatar
 
Join Date: May 2019
Location: Berlin
Posts: 2,198
Default

Quote:
Originally Posted by grandfougue View Post
So good But how did you manage to put your toolbar at the bottom of the media explorer?
I have it docked in the toolbar docker, not the media explorer itself. (It's just 2 docked windows, ctrl-drag the tabs to position them).

Btw, just saw this in prerelease:

Quote:
Originally Posted by matt_t View Post
+ ReaScript: support GetMediaFileMetadata(src, "Generic:BPM") to get any BPM metadata
Really nice to see, let's hope that they also add SetMediaFileMetadata at some point.
__________________
Featured scripts: REAPER Update UtilityLil ChordboxGridbox/Adaptive gridMX TunerRS5K LinkMIDI Editor Magic Donate💝: PayPal|ko-fi
FeedTheCat is online now   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 01:22 AM.


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