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

Reply
 
Thread Tools Display Modes
Old 02-05-2019, 10:07 AM   #1
MiyagiTwin
Human being with feelings
 
Join Date: Jan 2017
Posts: 2
Default Render different versions of project by iterating through (and replacing) media file

Hi,

I am new to reascript and maybe someone would be so kind to give me some pointers:

I want to render the same project over and over again and only want to swap out one media item in one track (or the entire track if that is easier) in the process:
ie I have a project with 3 tracks: Track number 3 consists of media item 'a.wav'. I now want to create a script that renders the file with the same settings replacing 'a.wav' with 'b.wav', then 'c.wav',...all the way to 'z.wav'

I see three challenges:
1- replace the media item: I see that there is a reaper.AddMediaItemToTrack().
but also reaper.DeleteTrackMediaItem() and reaper.DeleteTrack()
can someone give me their advice what would be more practical here?
2- render the track once the item is replaced:
I am reading here, that is not straight forward/has become possible only recently: https://forum.cockos.com/showthread.php?t=94199&page=2
Am I making this too complicated or is there an easier way?
3- lastly I will need to loop though all the items in a folder (e.g. 'a.wav', 'b.wav' ... 'z.wav'...) and gradually replace them:
I have found this but I don't entire understand the code: https://forum.cockos.com/showthread.php?t=203235
Do I understand that EnumerateFiles is already returning a table(?). If so, how do I loop through that table then(?)

If someone could give me some pointers, I would be very thankful.
Thanks,
M
MiyagiTwin is offline   Reply With Quote
Old 02-05-2019, 10:44 AM   #2
geraintluff
Human being with feelings
 
geraintluff's Avatar
 
Join Date: Nov 2009
Location: mostly inside my own head
Posts: 346
Default

If it can be done from within REAPER, that sounds ideal.

If that doesn't work, it might be possible to render using the REAPER command-line interface ("reaper -h" pops up a help window on my machine). The REAPER project file format is text-based, so it would be reasonable to replace the WAV file and repeatedly render to different output files, from any other language you prefer (Python etc.).
__________________
JSFX set | Bandcamp/SoundCloud/Spotify
geraintluff is offline   Reply With Quote
Old 02-05-2019, 12:56 PM   #3
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,621
Default

Yes, it is possible using my Ultraschall-API.

Another thing would be to do it using the Render-Queue. Add it to the render-queue, change the item, add it to the render-queue, change the item, etc etc.

You would need to set the option of "automatically increment filename".

After that: render all projects in the render-queue.


Replacing the sourcefiles can be done using: https://mespotin.uber.space/Mespotin...SourceFromFile
__________________
Use you/she/her.Ultraschall-Api Lua Api4Reaper - Donate, if you wish

On vacation for the time being...
Meo-Ada Mespotine is offline   Reply With Quote
Old 02-14-2019, 07:50 AM   #4
MiyagiTwin
Human being with feelings
 
Join Date: Jan 2017
Posts: 2
Default Found a solution

@geraintluff and @mespotine thank you so much for your help
I found a solution now. First up, my mind was blown that there is a CLI for reaper. amazing. So 'reaper -renderproject filename' actually renders the file. However, it has one annoying problem that took me a while to figure out: once the project has been rendered, something in the project needs to be changed for it to be rendered again. Hence, just swapping the underlying mediafile (and keeping the same name) will not work.

However, my mind was blown again when I found out that reaper saves its projects in text format <3 ... hence you can manipulate the .rpp with whatever you want.

My weapon of choice is Python, so this is quite simple then:

```
import subprocess
import fileinput


path_to_reaper_install = 'C:\\Program Files\\REAPER (x64)\\reaper'
path_to_reaper_project = 'C:\\test_reaper_project.rpp'

original_mediafile_filename = 'awesome_axe_1'
new_mediafile_filename = 'awesome_axe_2'
original_output_filename = 'track_with_awesome_ax_1'
new_output_filename = 'track_with_awesome_ax_2'


subprocess.call([path_to_reaper_install ,'-renderproject', path_to_reaper_project])

with fileinput.FileInput(path_to_reaper_project, inplace=True, backup='.bak') as file:
for line in file:
new_line = line.replace(original_mediafile_filename, new_mediafile_filename)
new_line = new_line.replace(original_output_filename, new_output_filename)
print(new_line, end='')


subprocess.call([path_to_reaper_install ,'-renderproject', path_to_reaper_project])
```
MiyagiTwin 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:42 AM.


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