Merge Songs

Here’s a cleaner version of the script.

  • More verbose.
  • Try to find the user’s temp directory if set incorrectly in variables.
  • Abort and clean up if resulting merge would create more than 255 instruments (needs peer review)
  • Moved zip/unzip out of variables, into functions.
  • Cleaned up a few other things.
  • EDIT: Use double quotes in case temp dir has spaces.
EDIT: Scroll Down...  

Yes, 0xff is the highest instrument index that you can be used in the pattern editor, so you should check this and bail out, or warn that some notes from song2 will be missing…

in this holidays i will have some free time and will try to rewrite it to C# dll

A question for Taktic:

In my test cases:

  
EDIT: Scroll down...  
  

Uhm yeah. My fault. The only place where hex ints are used is in the patterns (for the instrument shifts in your case). So you should use simple unpadded decimal ints everywhere else…

One more thing:

You are shifting “VstiProperties->AutoAssignedTrack” by the instrument count of the first song. Should be the track count in this case.
Also this is even needed for song1 when AutoAssignedTrack is the master track (may be a rare case, but possible). We all love details, dont we ;)

Doh, OK. I will fix this.

Also, please confirm:

  • MidiCCDevice expects and int?
  • Padding is useless, everywhere?

Thanks.

On second thought, I don’t understand this.

I understand “You are shifting “VstiProperties->AutoAssignedTrack” by the instrument count of the first song. Should be the track count in this case.” which I have fixed… But how do I shift a master track if there can only be 1? As song #2’s master track gets dropped in the merge, do you mean I have to not shift if it’s pointing at the master track? Something along the lines of && $x->VstiProperties->AutoAssignedTrack != ($offset2 - 1) i.e.

  
  
$offset = count($sx1->Tracks->SequencerTrack);  
$offset2 = count($sx2->Tracks->SequencerTrack);  
  
foreach ($sx2->Instruments->Instrument as $x) {   
 if ($x->VstiProperties->AutoAssignedTrack >= 0 && $x->VstiProperties->AutoAssignedTrack != ($offset2 - 1)) {   
 $shift = str_pad(($x->VstiProperties->AutoAssignedTrack + $offset), 2, '0', STR_PAD_LEFT);  
 $x->VstiProperties->AutoAssignedTrack = $shift;   
 }  
}  
  
  

Ok… I’m lost.

THE XML generated when I assign MASTER to Assign to Track on a VSTi is:

  
<autoassigntrack>false</autoassigntrack>  
<autoassignedtrack>-1</autoassignedtrack>  
  

So i don’t have to check for anything at all…

  
foreach ($sx2->Instruments->Instrument as $x) {   
 if ($x->VstiProperties->AutoAssignedTrack >= 0) {   
 $shift = str_pad(($x->VstiProperties->AutoAssignedTrack + $offset), 2, '0', STR_PAD_LEFT);  
 $x->VstiProperties->AutoAssignedTrack = $shift;   
 }  
}  
  

Should cover all cases?

Upon further review… MidiCCDevice->…->LinkedInstrument should probably remain HEX. Please find attached what I believe to be the final version of the script. All superfluous padding has been removed.

:dribble: :drummer: :guitar: :huh: :lol: :o :panic: :(

  
EDIT: Scroll down...  
  

I was able to generate a Warning: DOMDocument::schemaValidate(): Element ‘LinkedInstrument’: ‘1E’ is not a valid value of the atomic type ‘xs:int’. in /Users/dac514/Desktop/xrns_merge/xrns_merge.php on line 407 so I guess it’s not HEX.

For real… the final version?

EDIT: Scroll down...  

After an email discussion with Taktik, I believe we’re done.

I’ve set up a web page here:

http://www.trotch.com/xrns_merge/

If Renoise.Com wants to host this page, then by all means contact me and i’ll send you the files. If anyone cares to test the script and provide feedback. That’s cool too.

Thanks!

:badteethslayer:

Can you send me these songs? Also change the $schema variable to something that exists on line 21. This will cause Renoise to validate your xml and abort if it fails. If $schema points somewhere non-exstant, it skips the validation step.

Permissions? I don’t know why it decides it can’t remove Track02 but it can remove Track01. I had this happen to me at work on XP a few times. I changed the obliterate_directory() function to avoid this, but it started happening again last week. I believe permissions are the issue, and at work I don’t control my own permissions, the IT department does. At home on my OS X machines it works fine. If anyone can figure this out it would be greatly appreciated.

Fixed.

I’ve made a few changes:

http://www.trotch.com/xrns_merge/

  • Will warn insetad of die if there is a problem deleting temporary files.
  • Will warn if path to RenoiseSong4.xsd is not found.

SearMeIII is failing XML validation, the doctype is which I’ve never seen before and it doesn’t validate as correct XML. Where did that come from? A beta?

Hi there I’m a retarded PC user and these two files don’t work for me. The zip seems broken and the exe gives an error. I’m probably doing something wrong.

btw, Conner thanks a million for taking on this idea! Can’t wait to have it up and running!

The GUI version is not here, and I won’t be the one to write it. Yeah, it sucks you have to actually learn how to use a computer to work this script, but that’s the best I can do I don’t know how to create GUI apps quickly enough to justify the endeavor. I too am looking forward to a GUI version, but for now…

What zip and exe are you guys talking about? You mean zip & unzip? Basically, for Windows users, the goal is to get the open source zip.exe and unzip.exe extracted from Info-Zip. (How to Unhide File Extensions for Known File Types in Windows) What version of Windows are you running? Is it 64 bit or something? In any case, try to find the correct version of the file for your OS. I’m pretty sure these will work for you but if they don’t, see previous link to Info-Zip,

UNZIP: ftp://ftp.info-zip.org/pub/infozip/win32/unz552xn.exe
ZIP: ftp://ftp.info-zip.org/pub/infozip/win32/zip232xn.zip

As explained by Bantai, the first is self-extracting, the second is a regular zip file. Extract these files and pull out zip.exe and unzip.exe in your path (example C:\Windows\System32) You only need zip.exe and unzip.exe. All the other files aren’t necessary. If you don’t want them, don’t keep them.

Next it’s a matter of installing PHP5 on your system. You could download it directly from PHP.NET or you can download a webserver package like XAMPP which comes with Apache, Mysql, a bunch of other necessary stuff if you are interested in web development. This “other stuff” is not needed for the xrns_merge script. But, you might want to consider it if you want to explore making web apps in the future. Maybe also write your own scripts?

Next, get a text editor that doesn’t suck. I use Jedit but should probably use something like Context as Jedit comes with another set of dependencies you’ll need to work at in order to get it running. There are other choices, I just gave you two free ones, but feel free to use whatever.

Is all that shit installed now? Good.

Next, find the command prompt. On my XP box at work it’s Start -> Accessories -> Command Prompt. Double click it. Type zip -v If that doesn’t work you messed up. Type unzip -v If that doesn’t work, see previous comment about messing up. Go back to square one.

Type php -v If that doesn’t work or returns something lower than PHP 5.2.X, you need to set the path to PHP. Exit the command prompt and read this. Add the PHP dir to the path. In my case it’s C:\Program Files\xampp\php. Optionally, instead of setting up the path type “C:\Program Files\xampp\php\php” instead of php every time you want to run a script.

Next, download the script (i.e. cut and paste it into your text editor and save it as xrns_merge.php somewhere).

Next, go back to the command prompt, go to the directory you saved your script. (CD - Change Directory Command)

Finally, php xrns_merge.php “C:\Some Path\To\Song1.xrns” “C:\Some Path\To\Song2.xrns” newname.xrns

If a bunch of shit appears on the screen, read it, that’s an error message that will help you solve the problem. If everything worked, then newname.xrns will have been created in your current working directory.

My guess is most of the above was worthless as most probably know how to do it. I don’t mean to sound condescending, but i’m just trying to include as much info as possible.

Hope it works out!

Link to xrns_merge.php webpage for good measure:

http://www.trotch.com/xrns_merge/

Wow thanks for the effort! There’s no way I would have figured that out. Just not, well, savy enough. Flat out thinking about how to make my songs more innovative and interesting, let alone becoming a PHP lord.

Edit: ahh my problem was WinRAR with the zip232xn.zip file - works with winzip. Please ignore me.

Edit2: Script works here. I merged the bb5 tracks by alexstrain and Carmazine. Results as expected!

Hurray!

this is ‘an absolute must have’ in my book.

Conner, do you have a paypal account to accept good will Donations?

oh my, is this line:
“OS X and Linux users should already have zip / unzip installed by default.”

inferring something? ;)

Seriously, thanks! But, I don’t need the support. I appreciate people checking out the script I had fun writing it. In fact, by doing so I can now pretty much shit out PHP5 scripts as seen in this thread for this who might have missed it.

Seriously, the most daunting part of the code is packing and unpacking the songs. The XML took a while to understand. But writing this script allows me to think of how to approach other problems such as randomizing. It’s a shame I can’t make GUI tools, but with simple XML manipulation and ideas, I can now confidently say I can do a whole lot more at the command prompt. I think other users could too if they just tried.

Cheers!

EDIT: Seriously.