private void RealTimePlayBack_DoWork(object sender, DoWorkEventArgs e)
 {
     try
     {
         try
         {
             PlayConversionStart();
             bool KeepLooping = true;
             BASSInitSystem(1);
             while (KeepLooping)
             {
                 foreach (ListViewItem itemerino in getListViewItems(MIDIList))
                 {
                     string str = itemerino.Text;
                     string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(str);
                     string encpath = null;
                     BASSStreamSystem(str, 1);
                     BASSVSTInit(KMCGlobals._recHandle);
                     BASSEffectSettings();
                     Bass.BASS_ChannelPlay(KMCGlobals._recHandle, false);
                     long pos = Bass.BASS_ChannelGetLength(KMCGlobals._recHandle);
                     int count = BassMidi.BASS_MIDI_StreamGetEvents(KMCGlobals._recHandle, -1, BASSMIDIEvent.MIDI_EVENT_NOTE, null);
                     // cac
                     BASS_MIDI_EVENT[] events = new BASS_MIDI_EVENT[count];
                     BassMidi.BASS_MIDI_StreamGetEvents(KMCGlobals._recHandle, -1, BASSMIDIEvent.MIDI_EVENT_NOTE, events);
                     int notes = 0;
                     for (int a = 0; a < count; a++) { if ((events[a].param & 0xff00) != 0) { notes++; } }
                     KMCGlobals._mySync = new SYNCPROC(NoteSyncProc);
                     int sync = Bass.BASS_ChannelSetSync(KMCGlobals._recHandle, BASSSync.BASS_SYNC_MIDI_EVENT, (long)BASSMIDIEvent.MIDI_EVENT_NOTE, KMCGlobals._mySync, IntPtr.Zero);
                     KMCGlobals.notecount = 0;
                     int length = Convert.ToInt32(Bass.BASS_ChannelSeconds2Bytes(KMCGlobals._recHandle, 0.0275));
                     while (Bass.BASS_ChannelIsActive(KMCGlobals._recHandle) == BASSActive.BASS_ACTIVE_PLAYING)
                     {
                         if (KMCGlobals.CancellationPendingValue != 1)
                         {
                             notes = BASSPlayBackEngine(notes, length, pos);
                         }
                         else if (KMCGlobals.CancellationPendingValue == 1)
                         {
                             BASSCloseStream(res_man.GetString("PlaybackAborted", cul), res_man.GetString("PlaybackAborted", cul), 0);
                             KMCGlobals.PlaybackMode = false;
                             break;
                         }
                     }
                     if (KMCGlobals.CancellationPendingValue == 1)
                     {
                         events = null;
                         KeepLooping = false;
                         break;
                     }
                     else
                     {
                         Bass.BASS_StreamFree(KMCGlobals._recHandle);
                         continue;
                     }
                 }
                 if (KMCGlobals.CancellationPendingValue == 1)
                 {
                     BASSCloseStream(res_man.GetString("PlaybackAborted", cul), res_man.GetString("PlaybackAborted", cul), 1);
                 }
                 else
                 {
                     BASSCloseStream("null", "null", 1);
                 }
             }
         }
         catch (Exception exception)
         {
             WriteToConsole(exception);
             KMCGlobals.PlaybackMode = false;
         }
     }
     catch (Exception exception2)
     {
         BASSCloseStreamCrash(exception2);
     }
 }
        private string[] GetMoreInfoMIDI(string str)
        {
            try
            {
                string[] strings;
                long length = new System.IO.FileInfo(str).Length;
                if (length / 1024f >= 9860)
                {
                    if (ModifierKeys == Keys.Control)
                    {

                    }
                    else
                    {
                        strings = new string[] { "N/A", "N/A" };
                        return strings;
                    }
                }
                Bass.BASS_Init(0, 22050, BASSInit.BASS_DEVICE_NOSPEAKER, IntPtr.Zero);
                int time = BassMidi.BASS_MIDI_StreamCreateFile(str, 0L, 0L, BASSFlag.BASS_STREAM_DECODE, 0);
                long pos = Bass.BASS_ChannelGetLength(time);
                double num9 = Bass.BASS_ChannelBytes2Seconds(time, pos);
                TimeSpan span = TimeSpan.FromSeconds(num9);
                string str4 = span.Minutes.ToString() + ":" + span.Seconds.ToString().PadLeft(2, '0');
                int count = BassMidi.BASS_MIDI_StreamGetEvents(time, -1, BASSMIDIEvent.MIDI_EVENT_NOTE, null);
                BASS_MIDI_EVENT[] events = new BASS_MIDI_EVENT[count];
                BassMidi.BASS_MIDI_StreamGetEvents(time, -1, BASSMIDIEvent.MIDI_EVENT_NOTE, events);

                int notes = 0;
                for (int a = 0; a < count; a++) { if ((events[a].param & 0xff00) != 0) { notes++; } }

                Bass.BASS_Free();
                strings = new string[] { str4, notes.ToString("N0") };
                return strings;
            }
            catch (Exception ex) {
                string[] strings = new string[] { "N/A", "N/A" };
                return strings;
            }
        }