Skip to main content
Topic: Pause aware MIDI conversion - rg_toMIDI.php (Read 15911 times) previous topic - next topic

Pause aware MIDI conversion - rg_toMIDI.php

The attached NWC 2.5+ User Tool will export MIDI files that sound like NWC playback even if the song file contains Fermata, Breath Mark, and/or Caesura pauses.

NWC 2.5 (currently beta) is available to registered users <here>.
The tool requires the 2.5 User Tool Starter Kit available <here>.

The tool requires installation of these 2 packages from http://www.midiox.com/

Installation
Save the attachment to your User Tool scripts folder as: rg_toMIDI.php
Open a song into NWC 2.5.

Press ALT+F8, click on 'New...'
For 'Name:', I simply called it 'to MIDI'
Click on 'Browse...' and open rg_toMIDI.php from the list.
Add ' -v' to the end. It should look something like:
Quote
php\php.exe Scripts\rg_toMIDI.php -v
Under 'Input Type', select 'File Text'
Under 'Options', check 'Prompts for User Input'.

Use
  • It is best to start with a small file. These will typically convert in less than a second.
  • Conversion of moonlite.nwc takes about 2 seconds. If you add a pause to 1812.nwc, conversion will take about 6 seconds.
  • If you remove ' -v' (VERBOSE mode) from the command, the closing screen will not appear unless there is an error.

Comments welcome. I am unable to test this on anything but XP Pro and am eager to read that it will work on other Windows versions.

Note: the tool creates some temporary files. If the tool errs, these may not be deleted. If this happens, remove them manually.

2011May31 edit: update to version 1.1
2012Jan08 edit: update toolkit link
Registered user since 1996

Re: Pause aware MIDI conversion - rg_toMIDI.php

Reply #1
Attempting to run using Windows 7 64 bit machine.

This version of windows has two different program areas.

The program areas that are 64 bit programs all get installed into
c:\Program Files

whereas any 32 bit (or less) program gets installed into

c:\Program Files (x86)

When your program runs, it is assuming that the Midi2Mtx and Mtx2Midi programs are in c:\Program Files.
But on a 64bit windows 7 machine, they will be in C:\Program Files (x86)

So the procedure fails.

After editing your php file so that the early definitions point to the correct program folder, the program ran without error.

Here is the output screen for the first attempt

Quote
  15  477464   0.000       main (449024)
 212  496768   0.232       main (484272)
 219       0   0.003      fcopy (Resource id #1,user.nwctxt)
 220       0   0.554    nwcConv (user.nwctxt,user.mid,-1)
 222   16400   0.001   hasPause (Resource id #1)
 229       0   0.006      fcopy (user.mid,Calypso.mid)
 233  519936   0.803       main (497248)

       51213  user.nwctxt
       24143  user.mid
       24143  Calypso.mid


This is the result for the 1812 overture with a pause of 12 added to bar 4


Quote
  15  477464   0.000       main (449024)
 212  496768   0.022       main (484272)
 219       0   0.010      fcopy (Resource id #1,user.nwctxt)
 220       0   6.707    nwcConv (user.nwctxt,user.mid,-1)
 222   16416   0.009   hasPause (Resource id #1)
 223     504   1.321    midConv (user.mid,user.txt)
 224   32136   0.145   nwcPause (Resource id #1,timing.nwctxt)
 225       0   2.663    nwcConv (timing.nwctxt,timing.mid,-1)
 226       0   0.112    midConv (timing.mid,timing.txt)
 227    3352   0.803      merge (timing.txt,user.txt,out.txt)
 228       0   0.262    midConv (out.txt,1812.mid)
 233  555968  12.062       main (498760)

     1643564  user.nwctxt
      303653  user.mid
     1914568  user.txt
      927662  timing.nwctxt
        1929  timing.mid
        7273  timing.txt
     1914859  out.txt
      303653  1812.mid


The pause due to the fermata was successfully generated in the midi file.

Excellent!

Rich.
Rich.

Re: Pause aware MIDI conversion - rg_toMIDI.php

Reply #2
Rick

Thanks for the amendment that finds Midi2Mtx and Mtx2Midi  whichever windows program area they reside in.

I have tested this a number of times now including using Van Basco as the midi player to test karaoke and all is as expected.

This is an excellent solution for those nwc users that have been asking for midi export of fermata and the like. Note that I said solution rather than work around. It is just as easy to run your user tool as it is to export to midi. An inovative approach if I am reading your process correctly:
Roughly : Export to midi - convert midi to txt -  convert nwc to nwctxt - find out where the fermata etc are - work out the timings - put this into the text midi file as appropriate - convert the textmidi file back to midi.

Impressive.

One point I think that you may want to include is to put in a routine that detects if the output midi file name already exists. At the moment, if it already exists, it is overwritten without a dialogue box. That does not happen with a straight midi export.

Not a great problem for me, but may be for others so thought I would mention it.



Rich.

Re: Pause aware MIDI conversion - rg_toMIDI.php

Reply #3
Thanks for the amendment that finds Midi2Mtx and Mtx2Midi whichever windows program area they reside in.
Thanks. The amendment is incorporated into version 1.1.

One point I think that you may want to include is to put in a routine that detects if the output midi file name already exists. At the moment, if it already exists, it is overwritten without a dialogue box. That does not happen with a straight midi export.
Down around line 25 you'll find:
Quote from: rg_toMIDI.php
      $dlg->SetWindowStyle(wxFD_SAVE); // |wxFD_OVERWRITE_PROMPT);
Change it to:
Quote
      $dlg->SetWindowStyle(wxFD_SAVE|wxFD_OVERWRITE_PROMPT);
and it will prompt for overwrites.
Registered user since 1996

Re: Pause aware MIDI conversion - rg_toMIDI.php

Reply #4
Updated to version 1.1
This version should work with 64bit Windows versions.
Mostly due to changes in NWC 2.5 Beta Preview 7, speed is improved.
Registered user since 1996