コード例 #1
0
ファイル: Str_FPlayNote.cs プロジェクト: HZie/MusicAssembler
        void OnGUI()
        {
            // Set custom Style. Good for background color 3E619800
            if (myStyle == null)
            {
                myStyle = new CustomStyle();
            }

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

                // If need, display the popup  before any other UI to avoid trigger it hidden
                PopBankInstrument.Draw(MidiPlayerGlobal.MPTK_ListBank, MidiPlayerGlobal.ImSFCurrent.DefaultBankNumber, myStyle);
                PopPatchInstrument.Draw(MidiPlayerGlobal.MPTK_ListPreset, CurrentPatchInstrument, 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(widthLabel));

                // 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(
                        CurrentPatchInstrument.ToString() + " - " +
                        MidiPlayerGlobal.MPTK_GetPatchName(MidiPlayerGlobal.ImSFCurrent.DefaultBankNumber,
                                                           CurrentPatchInstrument),
                        GUILayout.Width(buttonWidth)))
                {
                    PopPatchInstrument.Show = !PopPatchInstrument.Show;
                }
                PopPatchInstrument.Position(ref scrollerWindow);

                GUILayout.EndHorizontal();
                GUILayout.EndScrollView();
            }
            else
            {
                GUILayout.Space(spaceVertival);
                GUILayout.Label("MidiStreamPlayer not defined, check hierarchy.", myStyle.TitleLabel3);
            }
        }
コード例 #2
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
                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);

                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();

                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)))
                {
                    PlayOneNote();
                }
                if (GUILayout.Button("Stop", myStyle.BtStandard, GUILayout.Width(buttonWidth * 0.666f)))
                {
                    StopOneNote();
                }
                if (GUILayout.Button("Clear", myStyle.BtStandard, GUILayout.Width(buttonWidth * 0.666f)))
                {
                    midiStreamPlayer.MPTK_ClearAllSound(true);
                }
                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);

                GUILayout.BeginHorizontal(GUILayout.Width(500));
                CurrentNote   = (int)Slider("Current note", CurrentNote, 0, 127);
                CurrentPreset = (int)Slider("Current preset", CurrentPreset, 0, 127, true);
                GUILayout.EndHorizontal();

                GUILayout.Space(spaceVertival);

                GUILayout.BeginHorizontal();
                GUILayout.Label(" ", myStyle.TitleLabel3, GUILayout.Width(widthFirstCol));
                //if (MidiPlayerGlobal.ImSFCurrent.DrumKitBankNumber >= 0)
                DrumKit      = GUILayout.Toggle(DrumKit, "Drum Kit", GUILayout.Width(120));
                RandomPlay   = GUILayout.Toggle(RandomPlay, "Random", GUILayout.Width(120));
                ChordPlay    = GUILayout.Toggle(ChordPlay, "Chord Play", GUILayout.Width(120));
                ArpeggioPlay = GUILayout.Toggle(ArpeggioPlay, "Arpeggio Play", GUILayout.Width(120));
                GUILayout.EndHorizontal();

                GUILayout.Space(spaceVertival);

                GUILayout.BeginHorizontal(GUILayout.Width(350));
                GUILayout.Label("Voices Statistics ", myStyle.TitleLabel3, GUILayout.Width(widthFirstCol));
                GUILayout.Label(string.Format("Played:{0}   Free:{1}   Active:{2}   Reused:{3} %",
                                              midiStreamPlayer.MPTK_StatVoicePlayed, midiStreamPlayer.MPTK_StatVoiceCountFree, midiStreamPlayer.MPTK_StatVoiceCountActive, Mathf.RoundToInt(midiStreamPlayer.MPTK_StatVoiceRatioReused)),
                                myStyle.TitleLabel3, GUILayout.Width(500));

                GUILayout.EndHorizontal();

                GUILayout.Space(spaceVertival);

                GUILayout.BeginHorizontal(GUILayout.Width(350));
                DelayTimeChange = Slider("Delay note", DelayTimeChange, 0.001f, 10f);
                DeltaDelay      = Slider("Delta delay", DeltaDelay, -10f, 100f, 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();
        }
コード例 #3
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();
        }
コード例 #4
0
        void OnGUI()
        {
            if (!HelperDemo.CheckSFExists())
            {
                return;
            }

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

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

                // If need, display the popup  before any other UI to avoid trigger it hidden
                PopBankInstrument.Draw(MidiPlayerGlobal.MPTK_ListBank, MidiPlayerGlobal.ImSFCurrent.DefaultBankNumber, myStyle);
                PopPatchInstrument.Draw(MidiPlayerGlobal.MPTK_ListPreset, CurrentPatchInstrument, 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(widthLabel));

                // 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(
                        CurrentPatchInstrument.ToString() + " - " +
                        MidiPlayerGlobal.MPTK_GetPatchName(MidiPlayerGlobal.ImSFCurrent.DefaultBankNumber,
                                                           CurrentPatchInstrument),
                        GUILayout.Width(buttonWidth)))
                {
                    PopPatchInstrument.Show = !PopPatchInstrument.Show;
                }
                PopPatchInstrument.Position(ref scrollerWindow);

                GUILayout.EndHorizontal();

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

                // 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();
                GUILayout.Space(spaceVertival);
                GUILayout.BeginHorizontal(GUILayout.Width(350));
                if (GUILayout.Button("Play Loop", IsplayingLoop ? myStyle.BtSelected : myStyle.BtStandard, GUILayout.Width(buttonWidth * 0.666f)))
                {
                    IsplayingLoop = !IsplayingLoop;
                }
                if (GUILayout.Button("Play One Shot", myStyle.BtStandard, GUILayout.Width(buttonWidth * 0.666f)))
                {
                    PlayOneNote();
                }
                if (GUILayout.Button("Stop One Shot", myStyle.BtStandard, GUILayout.Width(buttonWidth * 0.666f)))
                {
                    StopOneNote();
                }
                if (GUILayout.Button("Clear", myStyle.BtStandard, GUILayout.Width(buttonWidth * 0.666f)))
                {
                    midiStreamPlayer.MPTK_ClearAllSound(true);
                }

                GUILayout.EndHorizontal();

                GUILayout.Space(spaceVertival);
                midiStreamPlayer.MPTK_Volume = Slider("Volume", midiStreamPlayer.MPTK_Volume, 0, 1);

                GUILayout.Space(spaceVertival);
                GUILayout.BeginHorizontal(GUILayout.Width(350));
                DelayTimeChange = Slider("Delay note", DelayTimeChange, 0.1f, 10f);
                GUILayout.EndHorizontal();

                GUILayout.Space(spaceVertival);
                GUILayout.BeginHorizontal(GUILayout.Width(500));
                StartNote = (int)Slider("Start note", StartNote, 0, 127);
                GUILayout.Space(spaceHorizontal);
                EndNote = (int)Slider("End note", EndNote, 0, 127);
                GUILayout.Space(spaceHorizontal);
                CurrentNote = (int)Slider("Current note", CurrentNote, 0, 127);
                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);
                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);
                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);
                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();
                RandomPlay = GUILayout.Toggle(RandomPlay, "   Random Play", GUILayout.Width(widthLabel));
                if (MidiPlayerGlobal.ImSFCurrent.DrumKitBankNumber >= 0)
                {
                    bool newDrumKit = GUILayout.Toggle(DrumKit, "   Drum Kit", GUILayout.Width(widthLabel));
                    if (newDrumKit != DrumKit)
                    {
                        DrumKit = newDrumKit;
                        if (DrumKit)
                        {
                            // Set canal to dedicated drum canal (9 if canal start from 0, canal 10 is displayed in log)
                            StreamChannel = 9;
                        }
                        else
                        {
                            StreamChannel = 0;
                        }
                        CurrentPatchInstrument = 0;
                    }
                }
                midiStreamPlayer.MPTK_WeakDevice = GUILayout.Toggle(midiStreamPlayer.MPTK_WeakDevice, "   Weak Device", GUILayout.Width(widthLabel));
                GUILayout.EndHorizontal();
                GUILayout.Space(spaceVertival);
                GUILayout.EndVertical();

                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);
            }
        }