示例#1
0
        void OnGUI()
        {
            //if (!HelperDemo.CheckSFExists()) return;
            // Set custom Style. Good for background color 3E619800
            if (myStyle == null)
            {
                myStyle = new CustomStyle();
            }

            if (midiStreamPlayer != null)
            {
                //GUILayout.BeginArea(new Rect(0, 0, 1080, 2280));
                scrollerWindow = GUILayout.BeginScrollView(scrollerWindow, false, false, GUILayout.Width(Screen.width));

                // If need, display the popup  before any other UI to avoid trigger it hidden
                if (HelperDemo.CheckSFExists())
                {
                    PopBankInstrument.Draw(MidiPlayerGlobal.MPTK_ListBank, MidiPlayerGlobal.ImSFCurrent.DefaultBankNumber, myStyle);
                    PopPatchInstrument.Draw(MidiPlayerGlobal.MPTK_ListPreset, CurrentPreset, myStyle);
                    PopBankDrum.Draw(MidiPlayerGlobal.MPTK_ListBank, MidiPlayerGlobal.ImSFCurrent.DrumKitBankNumber, myStyle);
                    PopPatchDrum.Draw(MidiPlayerGlobal.MPTK_ListPresetDrum, CurrentPatchDrum, myStyle);

                    MainMenu.Display("Test Midi Stream - A very simple Generated Music Stream ", myStyle);

                    // Display soundfont available and select a new one
                    GUISelectSoundFont.Display(scrollerWindow, myStyle);

                    // Select bank & Patch for Instrument
                    // ----------------------------------
                    //GUILayout.Space(spaceVertival);
                    //GUILayout.Space(spaceVertival);
                    GUILayout.BeginVertical(myStyle.BacgDemos);
                    GUILayout.BeginHorizontal();
                    GUILayout.Label("Instrument", myStyle.TitleLabel3, GUILayout.Width(widthFirstCol));

                    // Open the popup to select a bank
                    if (GUILayout.Button(MidiPlayerGlobal.ImSFCurrent.DefaultBankNumber + " - Bank", GUILayout.Width(buttonWidth)))
                    {
                        PopBankInstrument.Show = !PopBankInstrument.Show;
                    }
                    PopBankInstrument.Position(ref scrollerWindow);

                    // Open the popup to select an instrument
                    if (GUILayout.Button(
                            CurrentPreset.ToString() + " - " +
                            MidiPlayerGlobal.MPTK_GetPatchName(MidiPlayerGlobal.ImSFCurrent.DefaultBankNumber,
                                                               CurrentPreset),
                            GUILayout.Width(buttonWidth)))
                    {
                        PopPatchInstrument.Show = !PopPatchInstrument.Show;
                    }
                    PopPatchInstrument.Position(ref scrollerWindow);
                    StreamChannel = (int)Slider("Channel", StreamChannel, 0, 15, true, 100);

                    GUILayout.EndHorizontal();

                    // Select bank & Patch for Drum
                    // ----------------------------
                    GUILayout.Space(spaceVertival);
                    GUILayout.BeginHorizontal();
                    GUILayout.Label("Drum", myStyle.TitleLabel3, GUILayout.Width(widthFirstCol));

                    // Open the popup to select a bank for drum
                    if (GUILayout.Button(MidiPlayerGlobal.ImSFCurrent.DrumKitBankNumber + " - Bank", GUILayout.Width(buttonWidth)))
                    {
                        PopBankDrum.Show = !PopBankDrum.Show;
                    }
                    PopBankDrum.Position(ref scrollerWindow);

                    // Open the popup to select an instrument for drum
                    if (GUILayout.Button(
                            CurrentPatchDrum.ToString() + " - " +
                            MidiPlayerGlobal.MPTK_GetPatchName(MidiPlayerGlobal.ImSFCurrent.DrumKitBankNumber, CurrentPatchDrum),
                            GUILayout.Width(buttonWidth)))
                    {
                        PopPatchDrum.Show = !PopPatchDrum.Show;
                    }
                    PopPatchDrum.Position(ref scrollerWindow);
                    GUILayout.EndHorizontal();
                }
                else
                {
                    GUILayout.BeginVertical(myStyle.BacgDemos);
                }

                GUILayout.Space(spaceVertival);

                HelperDemo.DisplayInfoSynth(midiStreamPlayer, 500, myStyle);

                GUILayout.Space(spaceVertival);

                GUILayout.BeginHorizontal(GUILayout.Width(350));
                GUILayout.Label("One Shot", myStyle.TitleLabel3, GUILayout.Width(widthFirstCol));
                if (GUILayout.Button("Play", myStyle.BtStandard, GUILayout.Width(buttonWidth * 0.666f)))
                {
                    Play(true);
                }

                if (GUILayout.Button("Stop", myStyle.BtStandard, GUILayout.Width(buttonWidth * 0.666f)))
                {
                    StopOneNote();
#if MPTK_PRO
                    StopChord();
#endif
                }
                if (GUILayout.Button("Clear", myStyle.BtStandard, GUILayout.Width(buttonWidth * 0.666f)))
                {
                    midiStreamPlayer.MPTK_ClearAllSound(true);
                    // midiStreamPlayer.MPTK_InitSynth();
                }
                if (GUILayout.Button("Re-init", myStyle.BtStandard, GUILayout.Width(buttonWidth * 0.666f)))
                {
                    midiStreamPlayer.MPTK_InitSynth();
                    CurrentPreset = CurrentPatchDrum = 0;
                }
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal(GUILayout.Width(500));
                CurrentNote = (int)Slider("Note", CurrentNote, 0, 127);
                int preset = (int)Slider("Preset", CurrentPreset, 0, 127, true);
                if (preset != CurrentPreset)
                {
                    CurrentPreset = preset;
                    midiStreamPlayer.MPTK_PlayEvent(new MPTKEvent()
                    {
                        Command = MPTKCommand.PatchChange,
                        Value   = CurrentPreset,
                        Channel = StreamChannel,
                    });
                }
                GUILayout.EndHorizontal();

                GUILayout.Space(spaceVertival);

                GUILayout.BeginHorizontal(GUILayout.Width(350));
                GUILayout.Label("Loop Notes", myStyle.TitleLabel3, GUILayout.Width(widthFirstCol));
                if (GUILayout.Button("Start / Stop", IsplayingLoopNotes ? myStyle.BtSelected : myStyle.BtStandard, GUILayout.Width(buttonWidth * 0.666f)))
                {
                    IsplayingLoopNotes = !IsplayingLoopNotes;
                }
                StartNote = (int)Slider("From", StartNote, 0, 127, true, 50);
                EndNote   = (int)Slider("To", EndNote, 0, 127, true, 50);
                GUILayout.EndHorizontal();

                GUILayout.Space(spaceVertival);

                GUILayout.BeginHorizontal(GUILayout.Width(350));
                GUILayout.Label("Loop Presets", myStyle.TitleLabel3, GUILayout.Width(widthFirstCol));
                if (GUILayout.Button("Start / Stop", IsplayingLoopPresets ? myStyle.BtSelected : myStyle.BtStandard, GUILayout.Width(buttonWidth * 0.666f)))
                {
                    IsplayingLoopPresets = !IsplayingLoopPresets;
                }
                StartPreset = (int)Slider("From", StartPreset, 0, 127, true, 50);
                EndPreset   = (int)Slider("To", EndPreset, 0, 127, true, 50);
                GUILayout.EndHorizontal();

                GUILayout.Space(spaceVertival);
#if DEBUG_MULTI
                GUILayout.BeginHorizontal();
                GUILayout.Label(" ", myStyle.TitleLabel3, GUILayout.Width(widthFirstCol));
                CountNoteToPlay = (int)Slider("Play Multiple Notes", CountNoteToPlay, 1, 200, false, 70);
                GUILayout.EndHorizontal();
#endif

                GUILayout.BeginHorizontal();
                GUILayout.Label(" ", myStyle.TitleLabel3, GUILayout.Width(widthFirstCol));
                //if (MidiPlayerGlobal.ImSFCurrent.DrumKitBankNumber >= 0)
                bool newDrumKit = GUILayout.Toggle(DrumKit, "Drum Kit", GUILayout.Width(120));
                if (newDrumKit != DrumKit)
                {
                    DrumKit = newDrumKit;
                    // Set canal to dedicated drum canal 9
                    StreamChannel = DrumKit  ? 9 : 0;
                }
                RandomPlay   = GUILayout.Toggle(RandomPlay, "Random", GUILayout.Width(120));
                ChordPlay    = GUILayout.Toggle(ChordPlay, "Play Chord", GUILayout.Width(120));
                ChordLibPlay = GUILayout.Toggle(ChordLibPlay, "Play Chord Lib", GUILayout.Width(120));
                GUILayout.EndHorizontal();

#if MPTK_PRO
                if (ChordPlay)
                {
                    GUILayout.BeginVertical(myStyle.BacgDemos1);
                    GUILayout.BeginHorizontal();
                    GUILayout.Label("Chord from Degree", myStyle.TitleLabel3, GUILayout.Width(widthFirstCol));
                    CountNoteChord = (int)Slider("Count", CountNoteChord, 2, 17, false, 70);
                    DegreeChord    = (int)Slider("Degree", DegreeChord, 1, 7, false, 70);
                    ArpeggioPlay   = (int)Slider("Arpeggio (ms)", ArpeggioPlay, 0, 500, false, 70);
                    GUILayout.EndHorizontal();

                    GUILayout.BeginHorizontal();
                    GUILayout.Label(" ", myStyle.TitleLabel3, GUILayout.Width(widthFirstCol));
                    int range = (int)Slider("Range", RangeChord, 0, MPTKRangeLib.RangeCount - 1, false, 70);
                    if (RangeChord != range)
                    {
                        RangeChord = range;
                        midiStreamPlayer.MPTK_RangeSelected = RangeChord;
                    }
                    GUILayout.Label(midiStreamPlayer.MPTK_RangeName, myStyle.TitleLabel3, GUILayout.MaxWidth(200));
                    GUILayout.Label("See file GammeDefinition.csv in folder Resources/GeneratorTemplate", myStyle.TitleLabel3, GUILayout.Width(500));
                    GUILayout.EndHorizontal();
                    GUILayout.EndVertical();
                }

                if (ChordLibPlay)
                {
                    GUILayout.BeginVertical(myStyle.BacgDemos1);
                    GUILayout.BeginHorizontal();
                    GUILayout.Label("Chord from Lib", myStyle.TitleLabel3, GUILayout.Width(widthFirstCol));
                    CurrentChord = (int)Slider("Chord", CurrentChord, 0, MPTKChordLib.ChordCount - 1, false, 70);
                    GUILayout.Label(MPTKChordLib.Chords[CurrentChord].Name, myStyle.TitleLabel3, GUILayout.MaxWidth(200));
                    GUILayout.Label("See file ChordLib.csv in folder Resources/GeneratorTemplate", myStyle.TitleLabel3, GUILayout.Width(500));
                    GUILayout.EndHorizontal();
                    GUILayout.EndVertical();
                }
#else
                if (ChordPlay || ChordLibPlay)
                {
                    GUILayout.BeginVertical(myStyle.BacgDemos1);
                    GUILayout.Space(spaceVertival);
                    GUILayout.Label("Chord and Range are available only with MPTK PRO", myStyle.TitleLabel3);
                    GUILayout.Space(spaceVertival);
                    GUILayout.EndVertical();
                }
#endif
                GUILayout.Space(spaceVertival);

                GUILayout.BeginHorizontal(GUILayout.Width(350));
                Frequency    = Slider("Frequency", Frequency, 0.05f, 10f);
                NoteDuration = Slider("Duration", NoteDuration, -1f, 100f, true, 80);
                NoteDelay    = Slider("Delay", NoteDelay, 0f, 10f, true, 80);
                GUILayout.EndHorizontal();

                GUILayout.Space(spaceVertival);

                GUILayout.BeginHorizontal(GUILayout.Width(350));
                midiStreamPlayer.MPTK_Volume = Slider("Volume", midiStreamPlayer.MPTK_Volume, 0, 1);
                float pitchChange = Slider("Pitch", PitchChange, 0, 127, true, 80);
                if (pitchChange != PitchChange)
                {
                    LastTimePitchChange = Time.realtimeSinceStartup;
                    PitchChange         = pitchChange;
                    //Debug.Log("Slider " + PitchChange);
                    midiStreamPlayer.MPTK_PlayEvent(new MPTKEvent()
                    {
                        Command = MPTKCommand.PitchWheelChange, Value = (int)PitchChange << 7, Channel = StreamChannel
                    });
                }

                GUILayout.EndHorizontal();

                GUILayout.Space(spaceVertival);

                GUILayout.BeginHorizontal(GUILayout.Width(350));
                midiStreamPlayer.MPTK_Transpose = (int)Slider("Transpose", midiStreamPlayer.MPTK_Transpose, -24, 24);
                GUILayout.Space(spaceHorizontal);
                Velocity = (int)Slider("Velocity", (int)Velocity, 0f, 127f, true, 80);
                GUILayout.EndHorizontal();

                GUILayout.Space(spaceVertival);

                GUILayout.BeginHorizontal(GUILayout.Width(350));
                int panChange = (int)Slider("Panoramic", PanChange, 0, 127);
                if (panChange != PanChange)
                {
                    PanChange = panChange;
                    midiStreamPlayer.MPTK_PlayEvent(new MPTKEvent()
                    {
                        Command = MPTKCommand.ControlChange, Controller = MPTKController.Pan, Value = PanChange, Channel = StreamChannel
                    });
                }
                //GUILayout.Space(spaceHorizontal);
                //midiStreamPlayer.ReverbMix = Slider("Reverb", midiStreamPlayer.ReverbMix, 0, 1, true, 80);
                //GUILayout.EndHorizontal();

                GUILayout.Space(spaceVertival);

                GUILayout.BeginHorizontal(GUILayout.Width(350));
                int modChange = (int)Slider("Modulation", ModChange, 0, 127);
                if (modChange != ModChange)
                {
                    ModChange = modChange;
                    midiStreamPlayer.MPTK_PlayEvent(new MPTKEvent()
                    {
                        Command = MPTKCommand.ControlChange, Controller = MPTKController.Modulation, Value = ModChange, Channel = StreamChannel
                    });
                }
                GUILayout.Space(spaceHorizontal);
                int expChange = (int)Slider("Expression", ExpChange, 0, 127, true, 80);
                if (expChange != ExpChange)
                {
                    ExpChange = expChange;
                    midiStreamPlayer.MPTK_PlayEvent(new MPTKEvent()
                    {
                        Command = MPTKCommand.ControlChange, Controller = MPTKController.Expression, Value = ExpChange, Channel = StreamChannel
                    });
                }
                GUILayout.EndHorizontal();

                GUILayout.Space(spaceVertival);

                //GUILayout.BeginHorizontal(GUILayout.Width(350));
                //GUILayout.Label(" ", myStyle.TitleLabel3, GUILayout.Width(widthFirstCol));
                //midiStreamPlayer.MPTK_WeakDevice = GUILayout.Toggle(midiStreamPlayer.MPTK_WeakDevice, "Weak Device", GUILayout.Width(widthLabel));
                //GUILayout.EndHorizontal();


                // end zone des parametres
                GUILayout.EndVertical();

                GUILayout.Space(spaceVertival);

                GUILayout.BeginVertical(myStyle.BacgDemos);
                GUILayout.Label("Go to your Hierarchy, select GameObject MidiStreamPlayer: inspector contains a lot of parameters to control the sound.", myStyle.TitleLabel2);
                GUILayout.EndVertical();

                GUILayout.EndScrollView();
            }
            else
            {
                GUILayout.Space(spaceVertival);
                GUILayout.Label("MidiStreamPlayer not defined, check hierarchy.", myStyle.TitleLabel3);
            }
            //GUILayout.EndArea();
        }
        void OnGUI()
        {
            int spaceV = 10;

            //  if (!HelperDemo.CheckSFExists()) return;

            // Set custom Style. Good for background color 3E619800
            if (myStyle == null)
            {
                myStyle = new CustomStyle();
            }

            if (midiFilePlayer != null)
            {
                scrollerWindow = GUILayout.BeginScrollView(scrollerWindow, false, false, GUILayout.Width(Screen.width));

                // Display popup in first to avoid activate other layout behind
                PopMidi.Draw(MidiPlayerGlobal.MPTK_ListMidi, midiFilePlayer.MPTK_MidiIndex, myStyle);

                MainMenu.Display("Test Midi File Player Scripting - Demonstrate how to use the MPTK API to Play Midi", myStyle);

                GUISelectSoundFont.Display(scrollerWindow, myStyle);

                //
                // Left column: Midi action
                // ------------------------

                GUILayout.BeginHorizontal();

                GUILayout.BeginVertical(myStyle.BacgDemos, GUILayout.Width(600));
                // Open the popup to select a midi
                if (GUILayout.Button("Current Midi file: '" + midiFilePlayer.MPTK_MidiName + (midiFilePlayer.MPTK_IsPlaying ? "' is playing" : "' is not playing"), GUILayout.Width(500), GUILayout.Height(40)))
                {
                    PopMidi.Show = !PopMidi.Show;
                }
                PopMidi.Position(ref scrollerWindow);

                HelperDemo.DisplayInfoSynth(midiFilePlayer, 600, myStyle);

                GUILayout.Space(spaceV);
                TimeSpan times        = TimeSpan.FromMilliseconds(midiFilePlayer.MPTK_Position);
                string   playTime     = string.Format("{0:00}:{1:00}:{2:00}:{3:000}", times.Hours, times.Minutes, times.Seconds, times.Milliseconds);
                string   realDuration = string.Format("{0:00}:{1:00}:{2:00}:{3:000}", midiFilePlayer.MPTK_Duration.Hours, midiFilePlayer.MPTK_Duration.Minutes, midiFilePlayer.MPTK_Duration.Seconds, midiFilePlayer.MPTK_Duration.Milliseconds);

                //string tickPosition = midiFilePlayer.MPTK_TickCurrent + " / " + midiFilePlayer.MPTK_TickLast;// + " / " + midiFilePlayer.miditoplay.CurrentTick + " / " + midiFilePlayer.miditoplay.NextPosEvent;
                //GUILayout.Label(string.Format("Time from start playing {0} / {1}    Tick:{2}", playTime, realDuration, tickPosition), myStyle.TitleLabel3, GUILayout.Width(600));

                if (midiFilePlayer.MPTK_IsPlaying)
                {
                    localDeltaMidi = DateTime.Now - localStartTimeMidi;
                }
                GUILayout.Label(string.Format("Real Time: {0} Delta: {1:F3}",
                                              string.Format("{0:00}:{1:00}:{2:00}:{3:000}", localDeltaMidi.Hours, localDeltaMidi.Minutes, localDeltaMidi.Seconds, localDeltaMidi.Milliseconds),
                                              (times - localDeltaMidi).TotalSeconds),
                                myStyle.TitleLabel3, GUILayout.Width(500));


                //GUILayout.Space(spaceV);
                GUILayout.BeginHorizontal();
                GUILayout.Label("Time Position: " + playTime + " / " + realDuration, myStyle.TitleLabel3, GUILayout.Width(300));
                double currentPosition = Math.Round(midiFilePlayer.MPTK_Position / 1000d, 2);
                double newPosition     = Math.Round(GUILayout.HorizontalSlider((float)currentPosition, 0f, (float)midiFilePlayer.MPTK_Duration.TotalSeconds, GUILayout.Width(150)), 2);
                if (newPosition != currentPosition)
                {
                    if (Event.current.type == EventType.Used)
                    {
                        //Debug.Log("New position " + currentPosition + " --> " + newPosition + " " + Event.current.type);
                        midiFilePlayer.MPTK_Position = newPosition * 1000d;
                    }
                }
                GUILayout.EndHorizontal();


                //Avoid slider with ticks position trigger
                GUILayout.BeginHorizontal();
                GUILayout.Label("Tick Position: " + midiFilePlayer.MPTK_TickCurrent + " / " + midiFilePlayer.MPTK_TickLast, myStyle.TitleLabel3, GUILayout.Width(300));
                long tick = (long)GUILayout.HorizontalSlider((float)midiFilePlayer.MPTK_TickCurrent, 0f, (float)midiFilePlayer.MPTK_TickLast, GUILayout.Width(150));
                if (tick != midiFilePlayer.MPTK_TickCurrent)
                {
                    if (Event.current.type == EventType.Used)
                    {
                        //Debug.Log("New tick " + midiFilePlayer.MPTK_TickCurrent + " --> " + tick + " " + Event.current.type);
                        midiFilePlayer.MPTK_TickCurrent = tick;
                    }
                }
                GUILayout.EndHorizontal();

                // Define the global volume
                GUILayout.Space(spaceV);
                GUILayout.BeginHorizontal();
                GUILayout.Label("Global Volume: " + Math.Round(midiFilePlayer.MPTK_Volume, 2), myStyle.TitleLabel3, GUILayout.Width(220));
                midiFilePlayer.MPTK_Volume = GUILayout.HorizontalSlider(midiFilePlayer.MPTK_Volume * 100f, 0f, 100f, GUILayout.Width(buttonWidth)) / 100f;
                GUILayout.EndHorizontal();

                // Transpose each note
                GUILayout.Space(spaceV);
                GUILayout.BeginHorizontal();
                GUILayout.Label("Note Transpose: " + midiFilePlayer.MPTK_Transpose, myStyle.TitleLabel3, GUILayout.Width(220));
                midiFilePlayer.MPTK_Transpose = (int)GUILayout.HorizontalSlider((float)midiFilePlayer.MPTK_Transpose, -24f, 24f, GUILayout.Width(buttonWidth));
                GUILayout.EndHorizontal();

                // Transpose each note
                GUILayout.Space(spaceV);
                GUILayout.BeginHorizontal();
                GUILayout.Label("Speed: " + Math.Round(midiFilePlayer.MPTK_Speed, 2), myStyle.TitleLabel3, GUILayout.Width(220));
                float speed = GUILayout.HorizontalSlider((float)midiFilePlayer.MPTK_Speed, 0.1f, 10f, GUILayout.Width(buttonWidth));
                if (speed != midiFilePlayer.MPTK_Speed)
                {
                    // Avoid event as layout triggered when speed is changed
                    if (Event.current.type == EventType.Used)
                    {
                        //Debug.Log("New speed " + midiFilePlayer.MPTK_Speed + " --> " + speed + " " + Event.current.type);
                        midiFilePlayer.MPTK_Speed = speed;
                    }
                }
                GUILayout.EndHorizontal();


                //GUILayout.Space(spaceV);
                //GUILayout.BeginHorizontal(GUILayout.Width(350));
                //GUILayout.Label("Voices Statistics ", myStyle.TitleLabel3, GUILayout.Width(220));
                //GUILayout.Label(string.Format("Played:{0,-4}   Free:{1,-3}   Active:{2,-3}   Reused:{3} %",
                //    midiFilePlayer.MPTK_StatVoicePlayed, midiFilePlayer.MPTK_StatVoiceCountFree, midiFilePlayer.MPTK_StatVoiceCountActive, Mathf.RoundToInt(midiFilePlayer.MPTK_StatVoiceRatioReused)),
                //    myStyle.TitleLabel3, GUILayout.Width(330));
                //GUILayout.EndHorizontal();

                // Enable or disable channel
                GUILayout.Space(spaceV);
                //GUILayout.Label("Channel / Preset, enable or disable channel: ", myStyle.TitleLabel3, GUILayout.Width(400));

                ChannelDisplay = GUILayout.Toggle(ChannelDisplay, "  Display Channels", GUILayout.Width(120));
                //GUILayout.EndHorizontal();

                if (ChannelDisplay)
                {
                    GUILayout.BeginVertical();
                    for (int channel = 0; channel < midiFilePlayer.MPTK_ChannelCount(); channel++)
                    {
                        GUILayout.BeginHorizontal();
                        GUILayout.Label(string.Format("   {0:00}", channel + 1), myStyle.TitleLabel3, GUILayout.Width(60));
                        GUILayout.Label(midiFilePlayer.MPTK_ChannelPresetGetName(channel) ?? "not set", myStyle.TitleLabel3, GUILayout.Width(200));

                        GUILayout.Label(string.Format("{0,5}", midiFilePlayer.MPTK_ChannelNoteCount(channel)), myStyle.LabelRight, GUILayout.Width(60));
                        GUILayout.Label("Enabled", myStyle.LabelRight, GUILayout.Width(60));

                        bool state = GUILayout.Toggle(midiFilePlayer.MPTK_ChannelEnableGet(channel), "", GUILayout.Width(20));
                        if (state != midiFilePlayer.MPTK_ChannelEnableGet(channel))
                        {
                            midiFilePlayer.MPTK_ChannelEnableSet(channel, state);
                            Debug.LogFormat("Channel {0} state:{1}, preset:{2}", channel + 1, state, midiFilePlayer.MPTK_ChannelPresetGetName(channel) ?? "not set");
                        }

                        GUILayout.Label("  Volume: " + Math.Round(midiFilePlayer.MPTK_ChannelVolumeGet(channel), 2), myStyle.LabelRight, GUILayout.Width(80));
                        float volume = GUILayout.HorizontalSlider((float)midiFilePlayer.MPTK_ChannelVolumeGet(channel), 0f, 1f, myStyle.SliderBar, myStyle.SliderThumb, GUILayout.Width(80));
                        if (volume != midiFilePlayer.MPTK_ChannelVolumeGet(channel))
                        {
                            midiFilePlayer.MPTK_ChannelVolumeSet(channel, volume);
                        }

                        GUILayout.EndHorizontal();
                    }
                    GUILayout.EndVertical();
                }

                // Random playing ?
                GUILayout.Space(spaceV);
                GUILayout.BeginHorizontal();
                IsRandomPlay = GUILayout.Toggle(IsRandomPlay, "  Random Play Midi", GUILayout.Width(220));

                // Weak device ?
                //midiFilePlayer.MPTK_WeakDevice = GUILayout.Toggle(midiFilePlayer.MPTK_WeakDevice, "Weak Device", GUILayout.Width(220));
                GUILayout.EndHorizontal();
                GUILayout.Space(spaceV);

                // Play/Pause/Stop/Restart actions on midi
                GUILayout.BeginHorizontal(GUILayout.Width(500));
                if (midiFilePlayer.MPTK_IsPlaying && !midiFilePlayer.MPTK_IsPaused)
                {
                    GUI.color = ButtonColor;
                }
                if (GUILayout.Button(new GUIContent("Play", "")))
                {
                    midiFilePlayer.MPTK_Play();
                }
                GUI.color = Color.white;

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

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

                if (GUILayout.Button(new GUIContent("Restart", "")))
                {
                    midiFilePlayer.MPTK_RePlay();
                }

                if (GUILayout.Button(new GUIContent("Clear", "")))
                {
                    midiFilePlayer.MPTK_ClearAllSound(true);
                }

                GUILayout.EndHorizontal();

                // Previous and Next button action on midi
                GUILayout.BeginHorizontal(GUILayout.Width(500));
                if (GUILayout.Button(new GUIContent("Previous", "")))
                {
                    midiFilePlayer.MPTK_Previous();
                    CurrentIndexPlaying = midiFilePlayer.MPTK_MidiIndex;
                }
                if (GUILayout.Button(new GUIContent("Next", "")))
                {
                    midiFilePlayer.MPTK_Next();
                    CurrentIndexPlaying = midiFilePlayer.MPTK_MidiIndex;
                    Debug.Log("MPTK_Next - CurrentIndexPlaying " + CurrentIndexPlaying);
                }
                GUILayout.EndHorizontal();
                GUILayout.EndVertical();

                if (!string.IsNullOrEmpty(infoMidi) || !string.IsNullOrEmpty(infoLyrics) || !string.IsNullOrEmpty(infoCopyright) || !string.IsNullOrEmpty(infoSeqTrackName))
                {
                    //
                    // Right Column: midi infomation, lyrics, ...
                    // ------------------------------------------
                    GUILayout.BeginVertical(myStyle.BacgDemos);
                    if (!string.IsNullOrEmpty(infoMidi))
                    {
                        scrollPos1 = GUILayout.BeginScrollView(scrollPos1, false, true);//, GUILayout.Height(heightLyrics));
                        GUILayout.Label(infoMidi, myStyle.TextFieldMultiLine);
                        GUILayout.EndScrollView();
                    }
                    GUILayout.Space(5);
                    if (!string.IsNullOrEmpty(infoLyrics))
                    {
                        GUILayout.Label("Lyrics");
                        //Debug.Log(scrollPos + " " + countline+ " " + myStyle.TextFieldMultiLine.CalcHeight(new GUIContent(lyrics), 400));
                        //float heightLyrics = myStyle.TextFieldMultiLine.CalcHeight(new GUIContent(infoLyrics), 400);
                        //scrollPos.y = - 340;
                        //if (heightLyrics > 200) heightLyrics = 200;
                        scrollPos2 = GUILayout.BeginScrollView(scrollPos2, false, true);//, GUILayout.Height(heightLyrics));
                        GUILayout.Label(infoLyrics, myStyle.TextFieldMultiLine);
                        GUILayout.EndScrollView();
                        //if (GUILayout.Button(new GUIContent("Add", ""))) lyrics += "\ntestest testetst";
                    }
                    GUILayout.Space(5);
                    if (!string.IsNullOrEmpty(infoCopyright))
                    {
                        GUILayout.Label("Copyright");
                        scrollPos3 = GUILayout.BeginScrollView(scrollPos3, false, true);
                        GUILayout.Label(infoCopyright, myStyle.TextFieldMultiLine);
                        GUILayout.EndScrollView();
                    }
                    GUILayout.Space(5);
                    if (!string.IsNullOrEmpty(infoSeqTrackName))
                    {
                        GUILayout.Label("Track Name");
                        scrollPos4 = GUILayout.BeginScrollView(scrollPos4, false, true);
                        GUILayout.Label(infoSeqTrackName, myStyle.TextFieldMultiLine);
                        GUILayout.EndScrollView();
                    }
                    GUILayout.EndVertical();
                }
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal(myStyle.BacgDemos);
                GUILayout.Label("Go to your Hierarchy, select GameObject MidiFilePlayer: inspector contains a lot of parameters to control the sound.", myStyle.TitleLabel2);
                GUILayout.EndHorizontal();

                GUILayout.EndScrollView();
            }
        }