//        private void OnLostFocus()
        //        {
        //#if UNITY_2017_1_OR_NEWER
        //            // Trig an  error before v2017...
        //            if (Application.isPlaying)
        //            {
        //                window.Close();
        //            }
        //#endif
        //        }

        /// <summary>
        /// Reload data
        /// </summary>
        private void OnFocus()
        {
            // Load description of available soundfont
            try
            {
                ToolsEditor.LoadMidiSet();
                ToolsEditor.CheckMidiSet();
                if (MidiPlayerGlobal.ImSFCurrent != null)
                {
                    KeepAllPatchs     = MidiPlayerGlobal.ImSFCurrent.KeepAllPatchs;
                    KeepAllZones      = MidiPlayerGlobal.ImSFCurrent.KeepAllZones;
                    RemoveUnusedWaves = MidiPlayerGlobal.ImSFCurrent.RemoveUnusedWaves;
                }
                // cause catch if call when playing (setup open on run mode)
                if (!Application.isPlaying)
                {
                    AssetDatabase.Refresh();
                }
                // Exec after Refresh, either cause errror
                ToolsEditor.LoadImSF();
            }
            catch (Exception ex)
            {
                MidiPlayerGlobal.ErrorDetail(ex);
            }
        }
 private void OnFocus()
 {
     // Load description of available soundfont
     try
     {
         ToolsEditor.LoadMidiSet();
         ToolsEditor.CheckMidiSet();
         AssetDatabase.Refresh();
     }
     catch (Exception ex)
     {
         MidiPlayerGlobal.ErrorDetail(ex);
     }
 }
示例#3
0
 void OnEnable()
 {
     try
     {
         instance = (MidiStreamPlayer)target;
         // Load description of available soundfont
         if (MidiPlayerGlobal.CurrentMidiSet == null || MidiPlayerGlobal.CurrentMidiSet.ActiveSounFontInfo == null)
         {
             ToolsEditor.LoadMidiSet();
             ToolsEditor.CheckMidiSet();
         }
     }
     catch (System.Exception ex)
     {
         MidiPlayerGlobal.ErrorDetail(ex);
     }
 }
示例#4
0
        //static private GUIStyle styleInfoMidi;

        // PopupSelectMidi PopMidi;


        void OnEnable()
        {
            try
            {
                //Debug.Log("OnEnable MidiFilePlayerEditor");
                CustomEventStartPlayMidi  = serializedObject.FindProperty("OnEventStartPlayMidi");
                CustomEventListNotesEvent = serializedObject.FindProperty("OnEventNotesMidi");
                CustomEventEndPlayMidi    = serializedObject.FindProperty("OnEventEndPlayMidi");

                instance = (MidiFilePlayer)target;
                // Load description of available soundfont
                if (MidiPlayerGlobal.CurrentMidiSet == null || MidiPlayerGlobal.CurrentMidiSet.ActiveSounFontInfo == null)
                {
                    ToolsEditor.LoadMidiSet();
                    ToolsEditor.CheckMidiSet();
                }
            }
            catch (System.Exception ex)
            {
                MidiPlayerGlobal.ErrorDetail(ex);
            }
        }
        /// <summary>
        /// Display, add, remove Soundfont
        /// </summary>
        /// <param name="localstartX"></param>
        /// <param name="localstartY"></param>
        private void ShowListSoundFonts(float localstartX, float localstartY, float width, float height)
        {
            try
            {
                Rect zone = new Rect(localstartX, localstartY, width, height);
                GUI.color = new Color(.8f, .8f, .8f, 1f);
                GUI.Box(zone, "");
                GUI.color = Color.white;
                if (MidiPlayerGlobal.CurrentMidiSet != null && MidiPlayerGlobal.CurrentMidiSet.SoundFonts != null)
                {
                    string caption = "SoundFont available";
                    if (MidiPlayerGlobal.CurrentMidiSet.SoundFonts.Count == 0)
                    {
                        caption = "No SoundFont available yet";
                        MidiPlayerGlobal.ImSFCurrent = null;
                    }

                    GUIContent content = new GUIContent()
                    {
                        text = caption, tooltip = "Each SoundFonts contains a set of bank of sound. \nOnly one SoundFont can be active at the same time for the midi player"
                    };
                    EditorGUI.LabelField(new Rect(localstartX + xpostitlebox, localstartY + ypostitlebox, 300, itemHeight), content, styleBold);
                    Rect rect = new Rect(width - buttonWidth, localstartY + ypostitlebox, buttonWidth, buttonHeight);
#if MPTK_PRO
                    if (GUI.Button(rect, "Add SoundFont"))
                    {
                        //if (EditorUtility.DisplayDialog("Import SoundFont", "This action could take time, do you confirm ?", "Ok", "Cancel"))
                        {
                            SoundFontOptim.AddSoundFont();
                            scrollPosSoundFont = Vector2.zero;
                            KeepAllPatchs      = false;
                            KeepAllZones       = false;
                            //listPatchs = PatchOptim.PatchUsed();
                        }
                    }
#else
                    if (GUI.Button(rect, "Add SoundFont [PRO]"))
                    {
                        try
                        {
                            PopupWindow.Show(rect, new GetVersionPro());
                        }
                        catch (Exception)
                        {
                            // generate some weird exception ...
                        }
                    }
#endif

                    Rect listVisibleRect = new Rect(localstartX, localstartY + itemHeight, width - 5, height - itemHeight - 5);
                    Rect listContentRect = new Rect(0, 0, width - 20, MidiPlayerGlobal.CurrentMidiSet.SoundFonts.Count * itemHeight + 5);

                    scrollPosSoundFont = GUI.BeginScrollView(listVisibleRect, scrollPosSoundFont, listContentRect);
                    float boxY = 0;

                    for (int i = 0; i < MidiPlayerGlobal.CurrentMidiSet.SoundFonts.Count; i++)
                    {
                        SoundFontInfo sf = MidiPlayerGlobal.CurrentMidiSet.SoundFonts[i];

                        GUI.color = new Color(.7f, .7f, .7f, 1f);
                        float boxX = 5;
                        GUI.Box(new Rect(boxX, boxY + 5, width - 30, itemHeight), "");
                        GUI.color = Color.white;

                        content = new GUIContent()
                        {
                            text = sf.Name, tooltip = ""
                        };
                        EditorGUI.LabelField(new Rect(boxX, boxY + 9, 200, itemHeight), content);

                        if (sf.Name == MidiPlayerGlobal.CurrentMidiSet.ActiveSounFontInfo.Name)
                        {
                            GUI.color = ToolsEditor.ButtonColor;
                        }

                        boxX += 200 + espace;
                        if (GUI.Button(new Rect(boxX, boxY + 9, 80, buttonHeight), "Select"))
                        {
#if MPTK_PRO
                            OptimInfo = new BuilderInfo();
#endif
                            MidiPlayerGlobal.CurrentMidiSet.SetActiveSoundFont(i);
                            string soundPath = Path.Combine(Application.dataPath + "/", MidiPlayerGlobal.PathToSoundfonts);
                            soundPath = Path.Combine(soundPath + "/", sf.Name);
                            ToolsEditor.LoadImSF(soundPath, sf.Name);
                            MidiPlayerGlobal.CurrentMidiSet.Save();
                            if (MidiPlayerGlobal.ImSFCurrent != null)
                            {
                                KeepAllPatchs     = MidiPlayerGlobal.ImSFCurrent.KeepAllPatchs;
                                KeepAllZones      = MidiPlayerGlobal.ImSFCurrent.KeepAllZones;
                                RemoveUnusedWaves = MidiPlayerGlobal.ImSFCurrent.RemoveUnusedWaves;
                                if (Application.isPlaying)
                                {
                                    MidiPlayerGlobal.MPTK_SelectSoundFont(null);
                                }
                            }
                            //listPatchs = PatchOptim.PatchUsed();
                        }
                        boxX += 80 + espace;

                        GUI.color = Color.white;
                        rect      = new Rect(boxX, boxY + 9, 80, buttonHeight);
                        if (GUI.Button(rect, "Remove"))
                        {
#if MPTK_PRO
                            OptimInfo = new BuilderInfo();
                            string soundFontPath = Path.Combine(Application.dataPath + "/", MidiPlayerGlobal.PathToSoundfonts);
                            string path          = Path.Combine(soundFontPath, sf.Name);
                            if (!string.IsNullOrEmpty(path) && EditorUtility.DisplayDialog("Delete SoundFont", "Are you sure to delete all the content of this folder ? " + path, "ok", "cancel"))
                            {
                                try
                                {
                                    Directory.Delete(path, true);
                                    File.Delete(path + ".meta");
                                }
                                catch (Exception ex)
                                {
                                    Debug.Log("Remove SF " + ex.Message);
                                }
                                AssetDatabase.Refresh();
                                ToolsEditor.CheckMidiSet();
                            }
#else
                            try
                            {
                                PopupWindow.Show(rect, new GetVersionPro());
                            }
                            catch (Exception)
                            {
                                // generate some weird exception ...
                            }
#endif
                        }

                        GUI.color = Color.white;

                        //boxX = 5;
                        //boxY += itemHeight;
                        //if (MidiPlayerGlobal.ImSFCurrent.WaveSize < 1000000)
                        //    strSize = Math.Round((double)MidiPlayerGlobal.ImSFCurrent.WaveSize / 1000d).ToString() + " Ko";
                        //else
                        //    strSize = Math.Round((double)MidiPlayerGlobal.ImSFCurrent.WaveSize / 1000000d).ToString() + " Mo";
                        //string.Format("Patch count: {0} Wave count:{1} Wave size:{2}", MidiPlayerGlobal.ImSFCurrent.PatchCount, MidiPlayerGlobal.ImSFCurrent.WaveCount, strSize);

                        //content = new GUIContent() { text = sf.Name, tooltip = "" };
                        //EditorGUI.LabelField(new Rect(boxX, boxY + 9, 200, itemHeight), content);

                        boxY += itemHeight;
                    }
                    GUI.EndScrollView();
                }
            }
            catch (Exception ex)
            {
                MidiPlayerGlobal.ErrorDetail(ex);
            }
        }
        /// <summary>
        /// Display, add, remove Midi file
        /// </summary>
        /// <param name="localstartX"></param>
        /// <param name="localstartY"></param>
        private void ShowListMidiFiles(float localstartX, float localstartY)
        {
            try
            {
                Rect zone = new Rect(localstartX, localstartY, widthLeft, heightList);
                GUI.color = new Color(.8f, .8f, .8f, 1f);
                GUI.Box(zone, "");
                GUI.color = Color.white;

                string caption = "Midi file available";
                if (MidiPlayerGlobal.CurrentMidiSet.MidiFiles == null || MidiPlayerGlobal.CurrentMidiSet.MidiFiles.Count == 0)
                {
                    caption  = "No Midi file available yet";
                    ScanInfo = new BuilderInfo();
                }

                GUIContent content = new GUIContent()
                {
                    text = caption, tooltip = ""
                };
                EditorGUI.LabelField(new Rect(localstartX + xpostitlebox, localstartY + ypostitlebox, 300, itemHeight), content, styleBold);

                if (GUI.Button(new Rect(widthLeft - buttonWidth - espace, localstartY + ypostitlebox, buttonWidth, buttonHeight), "Add Midi file"))
                {
                    AddMidifile();
                }

                if (MidiPlayerGlobal.CurrentMidiSet.MidiFiles != null)
                {
                    Rect listVisibleRect = new Rect(localstartX, localstartY + itemHeight, widthLeft - 5, heightList - itemHeight - 5);
                    Rect listContentRect = new Rect(0, 0, widthLeft - 20, MidiPlayerGlobal.CurrentMidiSet.MidiFiles.Count * itemHeight + 5);

                    scrollPosMidiFile = GUI.BeginScrollView(listVisibleRect, scrollPosMidiFile, listContentRect);
                    float boxY = 0;

                    for (int i = 0; i < MidiPlayerGlobal.CurrentMidiSet.MidiFiles.Count; i++)
                    {
                        GUI.color = new Color(.7f, .7f, .7f, 1f);
                        float boxX = 5;
                        GUI.Box(new Rect(boxX, boxY + 5, widthLeft - 30, itemHeight), "");
                        GUI.color = Color.white;

                        content = new GUIContent()
                        {
                            text = MidiPlayerGlobal.CurrentMidiSet.MidiFiles[i], tooltip = MidiPlayerGlobal.CurrentMidiSet.MidiFiles[i]
                        };
                        EditorGUI.LabelField(new Rect(boxX, boxY + 9, 200, itemHeight), content);

                        boxX += 200 + espace;
                        if (GUI.Button(new Rect(boxX, boxY + 9, 80, buttonHeight), "Analyse"))
                        {
                            ScanInfo = new BuilderInfo();
                            midifile = MidiPlayerGlobal.CurrentMidiSet.MidiFiles[i];
                            ScanInfo.Add(midifile);
                            MidiScan.GeneralInfo(midifile, ScanInfo);
                            scrollPosAnalyze = Vector2.zero;
                        }
                        boxX += 80 + espace;

                        GUI.color = Color.white;

                        if (GUI.Button(new Rect(boxX, boxY + 9, 80, buttonHeight), "Remove"))
                        {
                            if (!string.IsNullOrEmpty(MidiPlayerGlobal.CurrentMidiSet.MidiFiles[i]))
                            {
                                DeleteResource(MidiLoad.BuildOSPath(MidiPlayerGlobal.CurrentMidiSet.MidiFiles[i]));
                                AssetDatabase.Refresh();
                                ToolsEditor.CheckMidiSet();
                            }
                        }
                        boxY += itemHeight;
                    }
                    GUI.EndScrollView();
                }
            }
            catch (Exception ex)
            {
                MidiPlayerGlobal.ErrorDetail(ex);
            }
        }
示例#7
0
        public override void OnInspectorGUI()
        {
            try
            {
                GUI.changed = false;
                GUI.color   = Color.white;

                //mDebug.Log(Event.current.type);

                string soundFontSelected = "No SoundFont selected.";
                if (MidiPlayerGlobal.CurrentMidiSet != null && MidiPlayerGlobal.CurrentMidiSet.ActiveSounFontInfo != null)
                {
                    soundFontSelected = MidiPlayerGlobal.CurrentMidiSet.ActiveSounFontInfo.Name;
                    EditorGUILayout.LabelField(new GUIContent("SoundFont: " + soundFontSelected, "Define SoundFont from the menu 'Tools/MPTK - SoundFont Setup' or alt-f"));
                    EditorGUILayout.Separator();

                    float volume = EditorGUILayout.Slider(new GUIContent("Volume", "Set global volume for this midi playing"), instance.MPTK_Volume, 0f, 1f);
                    if (instance.MPTK_Volume != volume)
                    {
                        instance.MPTK_Volume = volume;
                    }


                    EditorGUILayout.BeginHorizontal();
                    string tooltipDistance = "Playing is paused if distance between AudioListener and this component is greater than MaxDistance";
                    instance.MPTK_PauseOnDistance = EditorGUILayout.Toggle(new GUIContent("Pause With Distance", tooltipDistance), instance.MPTK_PauseOnDistance);
                    EditorGUILayout.LabelField(new GUIContent("Current:" + Math.Round(instance.distanceEditorModeOnly, 2), tooltipDistance));
                    EditorGUILayout.EndHorizontal();

                    float distance = EditorGUILayout.Slider(new GUIContent("Max Distance", tooltipDistance), instance.MPTK_MaxDistance, 0f, 500f);
                    if (instance.MPTK_MaxDistance != distance)
                    {
                        instance.MPTK_MaxDistance = distance;
                    }

                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.PrefixLabel("Transpose");
                    instance.MPTK_Transpose = EditorGUILayout.IntSlider(instance.MPTK_Transpose, -24, 24);
                    EditorGUILayout.EndHorizontal();

                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.PrefixLabel("Release Time (sec.)");
                    instance.MPTK_TimeToRelease = EditorGUILayout.Slider(instance.MPTK_TimeToRelease, 0.05f, 1f);
                    EditorGUILayout.EndHorizontal();

                    instance.MPTK_LogWaves = EditorGUILayout.Toggle(new GUIContent("Log Waves", "Log information about wave for each notes played"), instance.MPTK_LogWaves);
                }
                else
                {
                    EditorGUILayout.LabelField(new GUIContent("SoundFont: " + soundFontSelected, "Define SoundFont from the menu 'Tools/MPTK - SoundFont Setup' or alt-f"));
                    ToolsEditor.LoadMidiSet();
                    ToolsEditor.CheckMidiSet();
                }

                if (GUI.changed)
                {
                    EditorUtility.SetDirty(instance);
                }
            }
            catch (System.Exception ex)
            {
                MidiPlayerGlobal.ErrorDetail(ex);
            }
        }
示例#8
0
        public override void OnInspectorGUI()
        {
            try
            {
                //if (styleInfoMidi == null)
                //{
                //    styleInfoMidi = new GUIStyle(EditorStyles.textArea);
                //    styleInfoMidi.normal.textColor = new Color(0, 0, 0.99f);
                //    styleInfoMidi.alignment = TextAnchor.UpperLeft;
                //    //styleDragZone.border = new RectOffset(2, 2, 2, 2);
                //}



                GUI.changed = false;
                GUI.color   = Color.white;

                //Transform t = (Transform)target;
                //Debug.Log(t.localPosition+" " + t.position);

                //mDebug.Log(Event.current.type);
                Event e = Event.current;

                string soundFontSelected = "No SoundFont selected.";
                if (MidiPlayerGlobal.CurrentMidiSet != null && MidiPlayerGlobal.CurrentMidiSet.ActiveSounFontInfo != null)
                {
                    soundFontSelected = MidiPlayerGlobal.CurrentMidiSet.ActiveSounFontInfo.Name;
                    EditorGUILayout.LabelField(new GUIContent("SoundFont: " + soundFontSelected, "Define SoundFont from the menu 'Tools/MPTK - SoundFont Setup' or alt-f"));
                    EditorGUILayout.Separator();

                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.LabelField(new GUIContent("Midi ", "Select Midi File to play"), GUILayout.Width(150));

                    //if (GUILayout.Button(new GUIContent("Refresh", "Reload all Midi from resource folder"))) MidiPlayerGlobal.CheckMidiSet();
                    if (MidiPlayerGlobal.CurrentMidiSet.MidiFiles != null && MidiPlayerGlobal.CurrentMidiSet.MidiFiles.Count > 0)
                    {
                        // Search index from midi name
                        int selectedMidi = instance.MPTK_MidiIndex;
                        if (selectedMidi < 0)
                        {
                            selectedMidi           = 0;
                            instance.MPTK_MidiName = MidiPlayerGlobal.CurrentMidiSet.MidiFiles[selectedMidi];
                        }
                        int newSelectMidi = EditorGUILayout.Popup(selectedMidi, MidiPlayerGlobal.CurrentMidiSet.MidiFiles.ToArray());
                        // Is midifile has changed ?
                        if (newSelectMidi != selectedMidi)
                        {
                            instance.MPTK_MidiIndex = newSelectMidi;
                            instance.MPTK_RePlay();
                        }
                    }
                    else
                    {
                        EditorGUILayout.LabelField("No Midi defined, go to menu 'Tools/MPTK - Midi File Setup' or alt-m");
                        instance.MPTK_MidiName = "";
                    }
                    EditorGUILayout.EndHorizontal();

                    float volume = EditorGUILayout.Slider(new GUIContent("Volume", "Set global volume for this midi playing"), instance.MPTK_Volume, 0f, 1f);
                    if (instance.MPTK_Volume != volume)
                    {
                        instance.MPTK_Volume = volume;
                    }


                    instance.MPTK_PlayOnStart        = EditorGUILayout.Toggle(new GUIContent("Play At Startup", "Start playing midi when the application starts"), instance.MPTK_PlayOnStart);
                    instance.MPTK_DirectSendToPlayer = EditorGUILayout.Toggle(new GUIContent("Direct send to player", "Midi events are send to the midi player directly"), instance.MPTK_DirectSendToPlayer);

                    EditorGUILayout.BeginHorizontal();
                    string tooltipDistance = "Playing is paused if distance between AudioListener and this component is greater than MaxDistance";
                    instance.MPTK_PauseOnDistance = EditorGUILayout.Toggle(new GUIContent("Pause With Distance", tooltipDistance), instance.MPTK_PauseOnDistance);
                    EditorGUILayout.LabelField(new GUIContent("Current:" + Math.Round(instance.distanceEditorModeOnly, 2), tooltipDistance));
                    EditorGUILayout.EndHorizontal();

                    float distance = EditorGUILayout.Slider(new GUIContent("Max Distance", tooltipDistance), instance.MPTK_MaxDistance, 0f, 500f);
                    if (instance.MPTK_MaxDistance != distance)
                    {
                        instance.MPTK_MaxDistance = distance;
                    }

                    instance.MPTK_Loop = EditorGUILayout.Toggle(new GUIContent("Loop", "Enable loop on midi play"), instance.MPTK_Loop);

                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.PrefixLabel("Speed");
                    float speed = EditorGUILayout.Slider(instance.MPTK_Speed, 0.1f, 5f);
                    if (instance.MPTK_Speed != speed)
                    {
                        instance.MPTK_Speed = speed;
                    }
                    EditorGUILayout.EndHorizontal();


                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.PrefixLabel("Transpose");
                    instance.MPTK_Transpose = EditorGUILayout.IntSlider(instance.MPTK_Transpose, -24, 24);
                    EditorGUILayout.EndHorizontal();

                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.PrefixLabel("Release Time (sec.)");
                    instance.MPTK_TimeToRelease = EditorGUILayout.Slider(instance.MPTK_TimeToRelease, 0.05f, 1f);
                    EditorGUILayout.EndHorizontal();

                    instance.MPTK_LogWaves = EditorGUILayout.Toggle(new GUIContent("Log Waves", "Log information about wave for each notes played"), instance.MPTK_LogWaves);

                    if (EditorApplication.isPlaying)
                    {
                        EditorGUILayout.Separator();
                        EditorGUILayout.LabelField("Time", instance.playTimeEditorModeOnly + " / " + instance.durationEditorModeOnly);

                        EditorGUILayout.BeginHorizontal();
                        EditorGUILayout.PrefixLabel("Position");
                        float pos = EditorGUILayout.Slider(instance.MPTK_Position, 0f, (float)instance.MPTK_Duration.TotalMilliseconds);
                        if (instance.MPTK_Position != pos)
                        {
                            instance.MPTK_Position = pos;
                        }
                        EditorGUILayout.EndHorizontal();

                        EditorGUILayout.BeginHorizontal();

                        if (instance.MPTK_IsPlaying && !instance.MPTK_IsPaused)
                        {
                            GUI.color = ToolsEditor.ButtonColor;
                        }
                        if (GUILayout.Button(new GUIContent("Play", "")))
                        {
                            instance.MPTK_Play();
                        }
                        GUI.color = Color.white;

                        if (instance.MPTK_IsPaused)
                        {
                            GUI.color = ToolsEditor.ButtonColor;
                        }
                        if (GUILayout.Button(new GUIContent("Pause", "")))
                        {
                            if (instance.MPTK_IsPaused)
                            {
                                instance.MPTK_Play();
                            }
                            else
                            {
                                instance.MPTK_Pause();
                            }
                        }
                        GUI.color = Color.white;

                        if (GUILayout.Button(new GUIContent("Stop", "")))
                        {
                            instance.MPTK_Stop();
                        }

                        if (GUILayout.Button(new GUIContent("Restart", "")))
                        {
                            instance.MPTK_RePlay();
                        }
                        EditorGUILayout.EndHorizontal();

                        EditorGUILayout.BeginHorizontal();
                        if (GUILayout.Button(new GUIContent("Previous", "")))
                        {
                            instance.MPTK_Previous();
                        }
                        if (GUILayout.Button(new GUIContent("Next", "")))
                        {
                            instance.MPTK_Next();
                        }
                        EditorGUILayout.EndHorizontal();
                    }

                    showMidiParameter = EditorGUILayout.Foldout(showMidiParameter, "Show Midi Parameters");
                    if (showMidiParameter)
                    {
                        EditorGUILayout.BeginHorizontal();
                        EditorGUILayout.LabelField(new GUIContent("Quantization", ""), GUILayout.Width(150));
                        int newLevel = EditorGUILayout.Popup(instance.MPTK_Quantization, popupQuantization);
                        if (newLevel != instance.MPTK_Quantization && newLevel >= 0 && newLevel < popupQuantization.Length)
                        {
                            instance.MPTK_Quantization = newLevel;
                        }
                        EditorGUILayout.EndHorizontal();
                        EditorGUILayout.BeginHorizontal();
                        instance.MPTK_EnableChangeTempo = EditorGUILayout.Toggle(new GUIContent("Enable Tempo Change", "Enable midi event tempo change when playing"), instance.MPTK_EnableChangeTempo);
                        EditorGUILayout.LabelField(new GUIContent("Current:" + Math.Round(instance.MPTK_Tempo, 0), "Current tempo defined in Midi"));
                        EditorGUILayout.EndHorizontal();
                        instance.MPTK_EnablePanChange = EditorGUILayout.Toggle(new GUIContent("Enable Pan Change", "Enable midi event pan change when playing"), instance.MPTK_EnablePanChange);
                        instance.MPTK_KeepNoteOff     = EditorGUILayout.Toggle(new GUIContent("Keep Midi NoteOff", "Keep Midi NoteOff and NoteOn with Velocity=0 (need to restart the playing Midi)"), instance.MPTK_KeepNoteOff);
                        instance.MPTK_LogEvents       = EditorGUILayout.Toggle(new GUIContent("Log Midi Events", "Log information about each midi events read"), instance.MPTK_LogEvents);
                    }

                    showMidiInfo = EditorGUILayout.Foldout(showMidiInfo, "Show Midi Info");
                    if (showMidiInfo)
                    {
                        if (!string.IsNullOrEmpty(instance.MPTK_SequenceTrackName))
                        {
                            if (taSequence == null)
                            {
                                taSequence = new TextArea("Sequence");
                            }
                            taSequence.Display(instance.MPTK_SequenceTrackName);
                        }

                        if (!string.IsNullOrEmpty(instance.MPTK_ProgramName))
                        {
                            if (taProgram == null)
                            {
                                taProgram = new TextArea("Program");
                            }
                            taProgram.Display(instance.MPTK_ProgramName);
                        }

                        if (!string.IsNullOrEmpty(instance.MPTK_TrackInstrumentName))
                        {
                            if (taInstrument == null)
                            {
                                taInstrument = new TextArea("Instrument");
                            }
                            taInstrument.Display(instance.MPTK_TrackInstrumentName);
                        }

                        if (!string.IsNullOrEmpty(instance.MPTK_TextEvent))
                        {
                            if (taText == null)
                            {
                                taText = new TextArea("TextEvent");
                            }
                            taText.Display(instance.MPTK_TextEvent);
                        }

                        if (!string.IsNullOrEmpty(instance.MPTK_Copyright))
                        {
                            if (taCopyright == null)
                            {
                                taCopyright = new TextArea("Copyright");
                            }
                            taCopyright.Display(instance.MPTK_Copyright);
                        }
                    }

                    showEvents = EditorGUILayout.Foldout(showEvents, "Show Events");
                    if (showEvents)
                    {
                        EditorGUILayout.PropertyField(CustomEventStartPlayMidi);
                        EditorGUILayout.PropertyField(CustomEventListNotesEvent);
                        EditorGUILayout.PropertyField(CustomEventEndPlayMidi);
                        serializedObject.ApplyModifiedProperties();
                    }


                    //showDefault = EditorGUILayout.Foldout(showDefault, "Show default editor");
                    //if (showDefault) DrawDefaultInspector();
                }
                else
                {
                    EditorGUILayout.LabelField(new GUIContent("SoundFont: " + soundFontSelected, "Define SoundFont from the menu 'Tools/MPTK - SoundFont Setup' or alt-f"));
                    ToolsEditor.LoadMidiSet();
                    ToolsEditor.CheckMidiSet();
                }

                if (GUI.changed)
                {
                    EditorUtility.SetDirty(instance);
                }
            }
            catch (System.Exception ex)
            {
                MidiPlayerGlobal.ErrorDetail(ex);
            }
        }