[SPIP] v3.2.1-->v3.2.3
[lhc/web/www.git] / www / plugins-dist / medias / lib / getid3 / module.audio.midi.php
index 359aca2..770481c 100644 (file)
@@ -1,11 +1,11 @@
 <?php
+
 /////////////////////////////////////////////////////////////////
 /// getID3() by James Heinrich <info@getid3.org>               //
-//  available at http://getid3.sourceforge.net                 //
-//            or http://www.getid3.org                         //
-//          also https://github.com/JamesHeinrich/getID3       //
-/////////////////////////////////////////////////////////////////
-// See readme.txt for more details                             //
+//  available at https://github.com/JamesHeinrich/getID3       //
+//            or https://www.getid3.org                        //
+//            or http://getid3.sourceforge.net                 //
+//  see readme.txt for more details                            //
 /////////////////////////////////////////////////////////////////
 //                                                             //
 // module.audio.midi.php                                       //
@@ -19,8 +19,14 @@ define('GETID3_MIDI_MAGIC_MTRK', 'MTrk'); // MIDI track header magic
 
 class getid3_midi extends getid3_handler
 {
+       /**
+        * @var bool
+        */
        public $scanwholefile = true;
 
+       /**
+        * @return bool
+        */
        public function Analyze() {
                $info = &$this->getid3->info;
 
@@ -88,6 +94,7 @@ class getid3_midi extends getid3_handler
                        $CurrentMicroSecondsPerBeat       = 500000; // 120 beats per minute;  60,000,000 microseconds per minute -> 500,000 microseconds per beat
                        $CurrentBeatsPerMinute            = 120;    // 120 beats per minute;  60,000,000 microseconds per minute -> 500,000 microseconds per beat
                        $MicroSecondsPerQuarterNoteAfter  = array ();
+                       $MIDIevents                       = array();
 
                        foreach ($trackdataarray as $tracknumber => $trackdata) {
 
@@ -283,7 +290,8 @@ class getid3_midi extends getid3_handler
                                        $thisfile_midi['totalticks'] = max($thisfile_midi['totalticks'], $CumulativeDeltaTime);
                                }
                        }
-                       $previoustickoffset = null;
+                       $previoustickoffset      = null;
+                       $prevmicrosecondsperbeat = null;
 
                        ksort($MicroSecondsPerQuarterNoteAfter);
                        foreach ($MicroSecondsPerQuarterNoteAfter as $tickoffset => $microsecondsperbeat) {
@@ -312,7 +320,7 @@ class getid3_midi extends getid3_handler
                                        return false;
                                }
 
-                               $info['playtime_seconds'] += (($thisfile_midi['totalticks'] - $previoustickoffset) / $thisfile_midi_raw['ticksperqnote']) * ($microsecondsperbeat / 1000000);
+                               $info['playtime_seconds'] += (($thisfile_midi['totalticks'] - $previoustickoffset) / $thisfile_midi_raw['ticksperqnote']) * ($prevmicrosecondsperbeat / 1000000);
 
                        }
                }
@@ -329,6 +337,11 @@ class getid3_midi extends getid3_handler
                return true;
        }
 
+       /**
+        * @param int $instrumentid
+        *
+        * @return string
+        */
        public function GeneralMIDIinstrumentLookup($instrumentid) {
 
                $begin = __LINE__;
@@ -469,6 +482,11 @@ class getid3_midi extends getid3_handler
                return getid3_lib::EmbeddedLookup($instrumentid, $begin, __LINE__, __FILE__, 'GeneralMIDIinstrument');
        }
 
+       /**
+        * @param int $instrumentid
+        *
+        * @return string
+        */
        public function GeneralMIDIpercussionLookup($instrumentid) {
 
                $begin = __LINE__;