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
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,450
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
__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)
amagalma is offline   Reply With Quote
Old 12-10-2018, 04:00 AM   #2
poplomop
Human being with feelings
 
Join Date: Jan 2010
Posts: 201
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: 9,866
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
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,450
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.
__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)
amagalma is offline   Reply With Quote
Old 12-10-2018, 03:04 PM   #5
Vagelis
Human being with feelings
 
Vagelis's Avatar
 
Join Date: Oct 2017
Location: Larisa, Greece
Posts: 3,782
Default

Nice!!
Vagelis is online now   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: 9,866
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
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,450
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!
__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)
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: 9,866
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: 24
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
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,450
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.
__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)
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: 2,640
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 offline   Reply With Quote
Old 03-30-2019, 11:15 AM   #12
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,450
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
__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)
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: 2,640
Default

Thanks, much appreciated.
MusoBob is offline   Reply With Quote
Old 05-20-2019, 10:26 PM   #14
MusoBob
Human being with feelings
 
MusoBob's Avatar
 
Join Date: Sep 2014
Posts: 2,640
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
STASH Downloads https://stash.reaper.fm/u/ReaTrak
MusoBob is offline   Reply With Quote
Old 11-14-2019, 01:34 PM   #15
MusoBob
Human being with feelings
 
MusoBob's Avatar
 
Join Date: Sep 2014
Posts: 2,640
Default

Could you mod that to do Write ACID Chunk ?
__________________
ReaTrakStudio Chord Track for Reaper forum
www.reatrak.com
STASH Downloads https://stash.reaper.fm/u/ReaTrak
MusoBob is offline   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: 9,866
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
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,450
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.
__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)
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: 9,866
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
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,450
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
__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)
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: 9,866
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: 9,866
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: 9,866
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: 9,866
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
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,450
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!
__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)
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: 9,866
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
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,450
Default

Great! Thanks!
__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)
amagalma is offline   Reply With Quote
Old 05-24-2020, 11:28 AM   #27
JonasHAnd
Human being with feelings
 
Join Date: Apr 2015
Posts: 99
Default

Hi!

Is there a way to only delete the cues and not the whole chunk?

The start offset gets deleted when using amagalmas scripts. That makes it impossible to use the "move item to source prefered position" after removing the media cues.

Thanks
JonasHAnd is offline   Reply With Quote
Old 05-25-2020, 01:50 AM   #28
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,450
Default

Hello! My script is currently abandoned and would require some time in order to be fixed.. So, for the moment I can't promise anything..
__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)
amagalma is offline   Reply With Quote
Old 05-25-2020, 10:36 PM   #29
JonasHAnd
Human being with feelings
 
Join Date: Apr 2015
Posts: 99
Default

Ok, I understand... Is there another tool that you could recommend for removing cues without rendering a new file?

thanks
JonasHAnd is offline   Reply With Quote
Old 05-26-2020, 03:03 AM   #30
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,866
Default

It could be done via my codebase but scripting for Cue takes lot of times so this kind of request would fit by sponsored dev plan better. I havent shared Cue marker script pack yet.
X-Raym is offline   Reply With Quote
Old 05-26-2020, 08:50 AM   #31
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,450
Default

Working with wav chunks is very time consuming... And I'll need more time to understand what I already did there It's not an easy fix
__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)
amagalma is offline   Reply With Quote
Old 05-26-2020, 09:18 AM   #32
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,866
Default

@amaglama
It took me times to understand what you did, but ultimately I found way to optimize it and make the code cleaner, and I even was able to make script from it ^^
It required Hex inspection of wavefile etc.... Really complex stuff to debug.



It was a very precious start though.


I had various approach of this as you know, using python parser, other lua parser, NodeJS etc... I tried everything ^^.
X-Raym is offline   Reply With Quote
Old 05-27-2020, 05:57 AM   #33
JonasHAnd
Human being with feelings
 
Join Date: Apr 2015
Posts: 99
Default

What about using this package?
It is called "wavefile" by Rafael da Silva Rocha

https://developer.aliyun.com/mirror/...efile/v/10.2.0
https://github.com/rochars/wavefile?...244017cf1brXWY


From the manual;

Quote:
To delete a cue point use WaveFile.deleteCuePoint() informing the index of the point. Points are ordered according to their position. The first point is indexed as 1.

wav.deleteCuePoint(1);

Mind that creating or deleting cue points will change the index of other points if they exist.

To list all the cue points in a file, in the order they appear:

let cuePoints = wav.listCuePoints();

Would it be possible to call this package from reaper?
JonasHAnd is offline   Reply With Quote
Old 05-27-2020, 06:11 AM   #34
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,450
Default

This is in javascript, so unfortunately no..
__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)
amagalma is offline   Reply With Quote
Old 05-27-2020, 07:01 AM   #35
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,866
Default

@JonasHAnd
Actually it is, via Node.js, and a custom JavaScript wrapper to make it works as a command line.



The first CUE markers scripts I made actually used this library :


https://forum.cockos.com/showthread.php?t=207539


But trust me it is Slow. And really heavy if you include Node.js.



I tried python wavefile library too etc



The pure Lua solution I have based on amalgama solutions is quicker than all these alternatoive by an order of magnitude, way more light weight (few ko compared to 50Mo of Node), way more maintainable etc.


All this cue markers injection Research and Development took me weeks so that's why I would rather build a custom script pack form it. I also need to bring some food on the table from time to time ^^
X-Raym is offline   Reply With Quote
Old 05-27-2020, 10:38 AM   #36
JonasHAnd
Human being with feelings
 
Join Date: Apr 2015
Posts: 99
Default

I understand. Sound like a lot of work testing out all these methods and then converting to lua etc.

If you would make a script pack, what would it consist of?
What functions could be performed with it?
And what would be the price?
JonasHAnd is offline   Reply With Quote
Old 05-27-2020, 11:14 AM   #37
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,866
Default

Quote:
What functions could be performed with it?
Anything is possible but for pack the scripts have to be pretty polyvalent,
so "simple" things like take markers to cue marker, project marker to cue markers, item section to cue markers, delete all or specific take markers... Price will depend on the pack size of course.



Too early to make a list. I have higher priority script task (for which I'm actually sponsored ^^) to perform for now. :P
X-Raym is offline   Reply With Quote
Old 05-27-2020, 11:39 AM   #38
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,450
Default

@JonasHAnd: If you're willing to sponsor and since X-Raym is busy, and I have all my musical performances cancelled due to coronavirus, I could fix my original script or add things if you like...
__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)
amagalma is offline   Reply With Quote
Old 05-27-2020, 01:24 PM   #39
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,866
Default

@amagalma
It would be too bad ifyou can't take advantage of my improvements.


Maybe should I open source it...
X-Raym is offline   Reply With Quote
Old 05-28-2020, 04:17 PM   #40
JonasHAnd
Human being with feelings
 
Join Date: Apr 2015
Posts: 99
Default

I found that CS_Glue with handles works for my use case. I get rid of the cues as they don't follow along to the new item and handles are intact unlike regular glue.

It is a bit annoying that I have to delete the old files manually and rename the new ones so they dont say "glue", but it works. The source position gets written again into the new file so as long as I do it directly after import I minimize chances of burning in incorrect source position.

After testing some more I see amagalmas script seems to work fine when removing cues created by the script itself (and possibly other sources as well but I have not tested). The problem occurs with cues that are created in logic pro x. When removing them the whole chunk gets removed; originator, cues, start offset, everything! I dont understand what could be different from cues created by the script.

Anyway, I dont have a recurring workflow that needs this, I was just curious if it was easy to fix the bug(?) in amagalmas script so I could perhaps keep the source files, but It's not too bad with the workaround above.

Anyway I thank you both for your offers amagalma and X-raym

I'll donate a small amount to X-Raym to show my support for creating a cue pack someday, when the time is right.
JonasHAnd 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:30 AM.


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