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

Reply
 
Thread Tools Display Modes
Old 12-09-2018, 06:57 PM   #1
amagalma
Human being with feelings
 
Join Date: Apr 2011
Posts: 1,690
Default Write project markers as media cues to selected items' active takes' source




amagalma_Write project markers as media cues to selected items' active takes' source files (WAV only)
(in ReaPack)

# Writes the project markers that cross the selected items as media cues of the selected items' active takes' source files

- Overwrites the files
- Issues warning if markers are going to appear to other items in the project that share the same source file
- To erase an existing media cue, place an unnamed project marker at the position of the cue
amagalma is offline   Reply With Quote
Old 12-10-2018, 04:00 AM   #2
poplomop
Human being with feelings
 
Join Date: Jan 2010
Posts: 191
Default

Cool thank you amagalma!
poplomop is offline   Reply With Quote
Old 12-10-2018, 12:48 PM   #3
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 6,369
Default

You suucceeded to make it work without render ? :P
X-Raym is offline   Reply With Quote
Old 12-10-2018, 03:01 PM   #4
amagalma
Human being with feelings
 
Join Date: Apr 2011
Posts: 1,690
Default

Yes :P

I even have a version where the old cue/list chunks get turned to junk chunks (if they are mid file) and the new ones are appended, or they get overwritten if at the end, as we had discussed. In that version, writing cues is instantaneous, but I finally chose to go the other route as I feel it safer. In this version a new temp file is created and after checking that all went well, the old one is erased and the temp is renamed as the old one.
amagalma is offline   Reply With Quote
Old 12-10-2018, 03:04 PM   #5
Vagelis
Human being with feelings
 
Join Date: Oct 2017
Location: Larisa, Greece
Posts: 545
Default

Nice!!
Vagelis is offline   Reply With Quote
Old 12-10-2018, 10:48 PM   #6
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 6,369
Default

@amalgama
Very great job I can drop dev of my version of this then, you succeeded to make something more optimized and actually ready for public release :P
X-Raym is offline   Reply With Quote
Old 12-11-2018, 05:33 AM   #7
amagalma
Human being with feelings
 
Join Date: Apr 2011
Posts: 1,690
Default

Thanks for the kind words by a script guru! I didn't mean to spoil the development of your version though.. It is just something I wanted for my personal use and I shared (actually all my scripts in ReaPack are made for me in the first place).
If you have some other idea (I liked the window list with the cues you had made), and you think you could use part of my code for its development, please feel free to do it! Or we could collaborate if you want!
amagalma is offline   Reply With Quote
Old 12-11-2018, 08:54 AM   #8
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 6,369
Default

dont worry for my version ^^ the dev was on hold, so the path was clear and open for you All that matterd is that we know have a working public version. and this is good !
X-Raym is offline   Reply With Quote
Old 12-29-2018, 09:50 PM   #9
brookhinton
Human being with feelings
 
Join Date: Nov 2018
Posts: 2
Default

This is fantastic. Until we get item markers we can now at least simulate them.
Does this also work with regions? Or just markers?
brookhinton is offline   Reply With Quote
Old 12-30-2018, 01:46 AM   #10
amagalma
Human being with feelings
 
Join Date: Apr 2011
Posts: 1,690
Default

Just markers. I could make it work with regions too but I am not sure what would be the best workflow to add/remove them, and since markers were enough for my personal use, I did not add the region functionality.
amagalma is offline   Reply With Quote
Old 03-30-2019, 12:32 AM   #11
MusoBob
Human being with feelings
 
MusoBob's Avatar
 
Join Date: Sep 2014
Posts: 1,355
Default

Thanks for this ! I have been looking for something to do this without have to render.
Is it possible to modify it so you can get user input for the name @ cursor pos of selected item
rather than markers or region name ?
MusoBob is online now   Reply With Quote
Old 03-30-2019, 11:15 AM   #12
amagalma
Human being with feelings
 
Join Date: Apr 2011
Posts: 1,690
Default

You are welcome! It is possible to do another script that does what you say, but I have no time at the moment... When I have time I 'll do it
amagalma is offline   Reply With Quote
Old 03-30-2019, 02:43 PM   #13
MusoBob
Human being with feelings
 
MusoBob's Avatar
 
Join Date: Sep 2014
Posts: 1,355
Default

Thanks, much appreciated.
MusoBob is online now   Reply With Quote
Old 05-20-2019, 10:26 PM   #14
MusoBob
Human being with feelings
 
MusoBob's Avatar
 
Join Date: Sep 2014
Posts: 1,355
Default

This seems to work ok, I only had to change a couple of lines.
Thanks again !
(it wasn't working at first because unknowingly the same wav was in use in another app !)

right click save Target/Link As
ReaTrak insert media cue to selected item active take wav source file.lua

__________________
ReaTrakStudio Chord Track for Reaper forum
www.reatrak.com
MusoBob is online now   Reply With Quote
Old 11-14-2019, 01:34 PM   #15
MusoBob
Human being with feelings
 
MusoBob's Avatar
 
Join Date: Sep 2014
Posts: 1,355
Default

Could you mod that to do Write ACID Chunk ?
__________________
ReaTrakStudio Chord Track for Reaper forum
www.reatrak.com
MusoBob is online now   Reply With Quote
Old 02-23-2020, 03:36 PM   #16
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 6,369
Default

Hi !



I'm exploring your amagalma_Write project markers as media cues to selected items' active takes' source files (WAV only) script,



I'm suprised that you almost don't create any functions ^^


I would love a function to send a list of markers / regions multidimensional array to a wav file name (no item, take or other reaper related consideration),


trying to understand your code, I can see some things special like conditions for less than 2Mo files etc... How come ?


Quite complex code anyway !
X-Raym is offline   Reply With Quote
Old 02-23-2020, 04:17 PM   #17
amagalma
Human being with feelings
 
Join Date: Apr 2011
Posts: 1,690
Default

I am not in front of a PC now to check the code, but if I remember correctly the 2MB thing is the file chunk size that is read in memory. For example, imagine that you have only 1GB of memory and your audio file is 2GB. If you try to read it in one go, it will be a disaster. After doing tests with various chunk sizes, I found out that 2MB was the fastest setting (at least in my PC).

Code may be complex because I am not a proper programmer but a self-taught.
amagalma is offline   Reply With Quote
Old 02-23-2020, 04:47 PM   #18
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 6,369
Default

Your code seems fully functionnal so really well done with that, I really struggle with wav parsing there is some key concept I'm not fluent with and the more I look at it, the more I'm blocked ^^
And I alreayd dig this subject several time !


Question : what is your core concept to update the "cue " and "list" chunk from the script ?


Do you first erased it from the file and then push new infos at the end ?
Do you copy original file chunk by chunk to a temp copy and then put some "cue " and "list" there,
updating the RIFF size header when everything is copied...

What is your magic ? ^^


You did put some nice comments but it is really the lack of function and nested comments which confuse me a bit :P

(I can wait for you to be in front of PC for answers of course !)
X-Raym is offline   Reply With Quote
Old 02-24-2020, 02:22 AM   #19
amagalma
Human being with feelings
 
Join Date: Apr 2011
Posts: 1,690
Default

Quote:
Originally Posted by X-Raym View Post
Your code seems fully functionnal so really well done with that, I really struggle with wav parsing there is some key concept I'm not fluent with and the more I look at it, the more I'm blocked ^^
And I alreayd dig this subject several time !


Question : what is your core concept to update the "cue " and "list" chunk from the script ?


Do you first erased it from the file and then push new infos at the end ?
Do you copy original file chunk by chunk to a temp copy and then put some "cue " and "list" there,
updating the RIFF size header when everything is copied...

What is your magic ? ^^


You did put some nice comments but it is really the lack of function and nested comments which confuse me a bit :P

(I can wait for you to be in front of PC for answers of course !)

If I am not mistaken (just had a quick look at the code), it is done like this:
- store all existing marker data in a table
- see if we want to erase, update, or add markers. All this is done in the table
- make a copy of the file without the existing markers
- add the chunks that results from the markers table (if there are updates or additions)
- calculate and update riff size and close file
- if all good then erase original file and replace with new one in project

No magic involved
amagalma is offline   Reply With Quote
Old 02-25-2020, 05:08 AM   #20
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 6,369
Default

Thx for the infos, it helps !


I'm very close to have stripped down your script to a single re-usable funciton which would take file path and new marker array as argument,



though I can see that your script doesn't support region loop ! ^^


There is loop support in my wavefile.py script fork (I corrected this part but the main thing isn't by me so I cant explain the details) : https://github.com/X-Raym/wavfile.py...avfile.py#L349


The infos for loops is written under the smpl chunk.


are you interested in bringing region-loop support to this script ?
X-Raym is offline   Reply With Quote
Old 02-25-2020, 07:37 AM   #21
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 6,369
Default

Also, I noticed a bug with your script,


if the item already has a loop region,


and that you use the script to write a marker BEFORE that region,


then the region-marker destinction of that marker is messed up,

Look how the BUG marker become a loop poin in item whil the Green loop in item become a marker.




My guess is that is determined by marker ID in the smpl chunk, which isn't touched by your script so can lead to error if the items has loop points.
X-Raym is offline   Reply With Quote
Old 02-25-2020, 07:42 AM   #22
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 6,369
Default

Here is some code from my own wavefile parser which might help:




Code:
    elseif chunk_id == "smpl" then
      local str = file:read(36)
      local manuf, prod, sampleperiod, midiunitynote, midipitchfraction, smptefmt, smpteoffs, numsampleloops, samplerdata = string.unpack('< I4 I4 I4 I4 I4 I4 I4 I4', str)

      Msg("\tidx\tdatatype\tpos_start\tpos_end\tfraction\tplaycount")
      for i = 1, numsampleloops do
        local str = file:read(24)
        local cuepointid, datatype, pos_start, pos_end, fraction, playcount = string.unpack( "< I4 I4 I4 I4 I4 I4", str )
        Msg( "\t" .. cuepointid .. "\t" .. datatype .. "\t" .. pos_start  .. "\t" .. pos_end  .. "\t" .. fraction .. "\t" ..playcount)

      end
X-Raym is offline   Reply With Quote
Old 02-26-2020, 05:58 AM   #23
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 6,369
Default

Note I have succeed to do basic smpl chunk parsing,


I will soon have code to add regions as well
(and not break existing one !)
X-Raym is offline   Reply With Quote
Old 03-02-2020, 05:01 AM   #24
amagalma
Human being with feelings
 
Join Date: Apr 2011
Posts: 1,690
Default

Quote:
Originally Posted by X-Raym View Post
though I can see that your script doesn't support region loop ! ^^
..
are you interested in bringing region-loop support to this script ?
I hadn't done it because I never use them.. But, why not?

Quote:
Originally Posted by X-Raym View Post
Also, I noticed a bug with your script,
if the item already has a loop region,
and that you use the script to write a marker BEFORE that region,
then the region-marker destinction of that marker is messed up,
Oops! Got to fix that!

Quote:
Originally Posted by X-Raym View Post
Note I have succeed to do basic smpl chunk parsing,
I will soon have code to add regions as well
(and not break existing one !)
Great! Looking forward to it!
amagalma is offline   Reply With Quote
Old 03-02-2020, 09:59 AM   #25
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 6,369
Default

I have built a successfull cue/loop function injector which doesnt break existing stuffs, I share the code with you ASAP.
X-Raym is offline   Reply With Quote
Old 03-02-2020, 02:40 PM   #26
amagalma
Human being with feelings
 
Join Date: Apr 2011
Posts: 1,690
Default

Great! Thanks!
amagalma 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 08:11 PM.


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