Exemple #1
0
        private void CheckFile(ref Int64 CMI, String str)
        {
            MIDI   MIDIInfo    = null;
            String ErrorReason = "";

            if (Path.GetExtension(str).ToLower() == ".mid" ||
                Path.GetExtension(str).ToLower() == ".midi" ||
                Path.GetExtension(str).ToLower() == ".kar" ||
                Path.GetExtension(str).ToLower() == ".rmi" ||
                Path.GetExtension(str).ToLower() == ".riff")
            {
                ErrorReason = GetInfoMIDI(ref CMI, str, out MIDIInfo);

                if (MIDIInfo != null)
                {
                    Program.MIDIList.Add(MIDIInfo);
                    ValidFiles++;
                    return;
                }
            }
            else
            {
                ErrorReason = "Unrecognized file extension.";
            }

            this.Invoke((MethodInvoker) delegate {
                InvalidMIDI MIDIT = new InvalidMIDI(str, ErrorReason, Program.Error);
                MIDIT.Dock        = DockStyle.Top;
                LogPanel.Controls.Add(MIDIT);
            });

            InvalidFiles++;
        }
Exemple #2
0
        // Check if file is valid
        private String GetInfoMIDI(ref Int64 CMI, string str, out MIDI MIDIStruct)
        {
            // Set MIDIStruct as null first
            String ID = IDGenerator.GetID();

            MIDIStruct = null;

            Debug.PrintToConsole("ok", String.Format("{0} - Analysis of {1}", ID, str));

            try
            {
                MIDIStruct = MIDI.LoadFromFile(CMI, str, Path.GetFileName(str), (p, t) => Console.WriteLine(p + "/" + t));

                Debug.PrintToConsole("ok", String.Format("{0} - Analysis finished for MIDI {1}.", ID, str));
                return("No error.");
            }
            catch (Exception ex)
            {
                return(String.Format("A {0} exception has occured while loading the file.", ex.InnerException.ToString()));
            }
        }