if ($_POST["midixmlformhidden"]) { // Require PHP MIDI class require 'lib/midi_class_v178/classes/midi.class.php'; // Decode post data $mxml = urldecode($_POST["midixmlformhidden"]); // TMP save directory $save_dir = 'tmp/'; // Random filename string srand((double) microtime() * 1000000); $tmpfile = $save_dir . rand() . '.mid'; // Time-limit @set_time_limit(600); # 10 minutes // Convert XMP and save MIDI file $midi = new Midi(); $midi->importXml($mxml); $midi->saveMidFile($tmpfile, 0666); // Download file $destfilename = 'bassline_explorer.mid'; //$midi->downloadMidFile($destFilename, $tmpfile); // Delete tmp file (not working) //sleep(30); //unlink($tmpfile); } else { // No post data echo "Error: No MIDIXML data received"; } ?> <input id="downloadbutton" type="button" name="download" value="Download MIDI File" onclick="self.location.href='download.php?f=<?php echo urlencode($tmpfile); ?>
</div> </form> <div style="margin-top:20px"> <?php if (isset($_POST['txt'])) { $save_dir = 'tmp/'; srand((double) microtime() * 1000000); $file = $save_dir . rand() . '.mid'; /**************************************************************************** MIDI CLASS CODE ****************************************************************************/ require './classes/midi.class.php'; @set_time_limit(600); # 10 minutes $midi = new Midi(); $midi->importXml($txt); $midi->saveMidFile($file, 0666); $midi->playMidFile($file, $visible, $autostart, $loop, $player); ?> <br /><br /><input type="button" name="download" value="Save as SMF (*.mid)" onclick="self.location.href='download.php?f=<?php echo urlencode($file); ?> '" /> <?php } ?> </div> </body> </html>