示例#1
0
        void Start()
        {
            if (midiStreamPlayer != null)
            {
                if (!midiStreamPlayer.OnEventSynthStarted.HasEvent())
                {
                    midiStreamPlayer.OnEventSynthStarted.AddListener(StartLoadingSynth);
                }
                if (!midiStreamPlayer.OnEventSynthStarted.HasEvent())
                {
                    midiStreamPlayer.OnEventSynthStarted.AddListener(EndLoadingSynth);
                }
            }
            else
            {
                Debug.LogWarning("No Stream Midi Player associed to this game object");
            }

            LastTimeChange = Time.realtimeSinceStartup;
            ///midiStreamPlayer.MPTK_Play(new MPTKEvent() { Command = MPTKCommand.PatchChange, Patch = CurrentPatchInstrument, Channel = StreamChannel, });
            PanChange      = 64;
            LastTimeChange = -9999999f;


            PopBankInstrument = new PopupListItem()
            {
                Title = "Select A Bank", OnSelect = BankPatchChanged, Tag = "BANK_INST", ColCount = 5, ColWidth = 150,
            };
            PopPatchInstrument = new PopupListItem()
            {
                Title = "Select A Patch", OnSelect = BankPatchChanged, Tag = "PATCH_INST", ColCount = 5, ColWidth = 150,
            };
            PopBankDrum = new PopupListItem()
            {
                Title = "Select A Bank", OnSelect = BankPatchChanged, Tag = "BANK_DRUM", ColCount = 5, ColWidth = 150,
            };
            PopPatchDrum = new PopupListItem()
            {
                Title = "Select A Patch", OnSelect = BankPatchChanged, Tag = "PATCH_DRUM", ColCount = 5, ColWidth = 150,
            };


            for (i = 0; i < 128; i++)
            {
                curNote[i]       = false;
                pressed[i]       = false;
                played[i]        = false;
                playedPressed[i] = false;
            }

            totalSensorNum = 24;
            for (i = 0; i <= totalSensorNum; i++)
            {
                numSensorArray[i] = 0;
            }
            SetSensorNum();
            sensorPerStr = totalSensorNum / hwStrNum;
            // sensorPerStr = 4;
            // Debug.Log(sensorPerStr);
        }
示例#2
0
 private void Start()
 {
     PopMidi = new PopupListItem()
     {
         Title    = "Select A Midi File",
         OnSelect = MidiChanged,
         Tag      = "NEWMIDI",
         ColCount = 3,
         ColWidth = 250,
     };
     MidiChanged(null, MidiIndex);
 }
示例#3
0
        static public void Display(Vector2 scrollerWindow, CustomStyle myStyle)
        {
            SoundFonts = new List <MPTKListItem>();
            foreach (string name in MidiPlayerGlobal.MPTK_ListSoundFont)
            {
                if (name == MidiPlayerGlobal.CurrentMidiSet.ActiveSounFontInfo.Name)
                {
                    selectedSf = SoundFonts.Count;
                }
                SoundFonts.Add(new MPTKListItem()
                {
                    Index = SoundFonts.Count, Label = name
                });
            }

            if (PopSoundFont == null)
            {
                PopSoundFont = new PopupListItem()
                {
                    Title    = "Select A SoundFont",
                    OnSelect = SoundFontChanged,
                    ColCount = 1,
                    ColWidth = 500,
                }
            }
            ;

            if (SoundFonts != null)
            {
                PopSoundFont.Draw(SoundFonts, selectedSf, myStyle);
                GUILayout.BeginHorizontal(myStyle.BacgDemos);

                if (buttonIconNote == null)
                {
                    buttonIconNote = Resources.Load <Texture2D>("Textures/Note");
                }
                if (GUILayout.Button(new GUIContent(buttonIconNote, "Select A SoundFont"), GUILayout.Width(48), GUILayout.Height(48)))
                {
                    PopSoundFont.Show = !PopSoundFont.Show;
                }
                GUILayout.Space(20);
                GUILayout.Label("Current SoundFont: " + MidiPlayerGlobal.CurrentMidiSet.ActiveSounFontInfo.Name, myStyle.TitleLabel2, GUILayout.Height(48));
                GUILayout.EndHorizontal();

                PopSoundFont.Position(ref scrollerWindow);
            }
            else
            {
                GUILayout.Label("No Soundfont found");
            }
        }
    }
        private void Start()
        {
            if (MidiLoader == null)
            {
                Debug.LogError("TestMidiFileLoad: there is no MidiFileLoader Prefab set in Inspector.");
            }

            PopMidi = new PopupListItem()
            {
                Title    = "Select A Midi File",
                OnSelect = MidiChanged,
                Tag      = "NEWMIDI",
                ColCount = 3,
                ColWidth = 250,
            };
            MidiChanged(null, MidiIndex);
        }
示例#5
0
        // Use this for initialization
        void Start()
        {
            if (midiStreamPlayer != null)
            {
                if (!midiStreamPlayer.OnEventSynthStarted.HasEvent())
                {
                    midiStreamPlayer.OnEventSynthStarted.AddListener(StartLoadingSynth);
                }
                if (!midiStreamPlayer.OnEventSynthStarted.HasEvent())
                {
                    midiStreamPlayer.OnEventSynthStarted.AddListener(EndLoadingSynth);
                }
            }
            else
            {
                Debug.LogWarning("No Stream Midi Player associed to this game object");
            }

            //Debug.Log(MPTKChordLib.ChordCount);

            PopBankInstrument = new PopupListItem()
            {
                Title = "Select A Bank", OnSelect = BankPatchChanged, Tag = "BANK_INST", ColCount = 5, ColWidth = 150,
            };
            PopPatchInstrument = new PopupListItem()
            {
                Title = "Select A Patch", OnSelect = BankPatchChanged, Tag = "PATCH_INST", ColCount = 5, ColWidth = 150,
            };
            PopBankDrum = new PopupListItem()
            {
                Title = "Select A Bank", OnSelect = BankPatchChanged, Tag = "BANK_DRUM", ColCount = 5, ColWidth = 150,
            };
            PopPatchDrum = new PopupListItem()
            {
                Title = "Select A Patch", OnSelect = BankPatchChanged, Tag = "PATCH_DRUM", ColCount = 5, ColWidth = 150,
            };

            LastTimeChange = Time.realtimeSinceStartup;
            ///midiStreamPlayer.MPTK_Play(new MPTKEvent() { Command = MPTKCommand.PatchChange, Patch = CurrentPatchInstrument, Channel = StreamChannel, });
            CurrentNote     = StartNote;
            PanChange       = 64;
            LastTimeChange  = -9999999f;
            PitchChange     = DEFAULT_PITCH;
            CountNoteToPlay = 1;
        }
        private void Start()
        {
            if (!HelperDemo.CheckSFExists())
            {
                return;
            }

            // Warning: when defined by script, this event is not triggered at first load of MPTK
            // because MidiPlayerGlobal is loaded before any other gamecomponent
            if (!MidiPlayerGlobal.OnEventPresetLoaded.HasEvent())
            {
                // To be done in Start event (not Awake)
                MidiPlayerGlobal.OnEventPresetLoaded.AddListener(EndLoadingSF);
            }

            PopMidi = new PopupListItem()
            {
                Title    = "Select A Midi File",
                OnSelect = MidiChanged,
                Tag      = "NEWMIDI",
                ColCount = 3,
                ColWidth = 250,
            };

            if (midiFilePlayer == null)
            {
                Debug.Log("No MidiFilePLayer defined with the editor inspector, try to find one");
                MidiFilePlayer fp = FindObjectOfType <MidiFilePlayer>();
                if (fp == null)
                {
                    Debug.Log("Can't find a MidiFilePLayer in the Hierarchy. No music will be played");
                }
                else
                {
                    midiFilePlayer = fp;
                }
            }

            if (midiFilePlayer != null)
            {
                // There is two methods to trigger event:
                //      1) in inpector from the Unity editor
                //      2) by script, see below
                // ------------------------------------------

                SetStartEvent();

                // Event trigger when midi file end playing
                if (!midiFilePlayer.OnEventEndPlayMidi.HasEvent())
                {
                    // Set event by script
                    Debug.Log("OnEventEndPlayMidi defined by script");
                    midiFilePlayer.OnEventEndPlayMidi.AddListener(EndPlay);
                }
                else
                {
                    Debug.Log("OnEventEndPlayMidi defined by Unity editor");
                }

                // Event trigger for each group of notes read from midi file
                if (!midiFilePlayer.OnEventNotesMidi.HasEvent())
                {
                    // Set event by scripit
                    Debug.Log("OnEventNotesMidi defined by script");
                    midiFilePlayer.OnEventNotesMidi.AddListener(MidiReadEvents);
                }
                else
                {
                    Debug.Log("OnEventNotesMidi defined by Unity editor");
                }

                InitPlay();
            }
        }
示例#7
0
        static public void Display(Vector2 scrollerWindow, CustomStyle myStyle)
        {
            SoundFonts = new List <MPTKListItem>();
            foreach (string name in MidiPlayerGlobal.MPTK_ListSoundFont)
            {
                if (MidiPlayerGlobal.CurrentMidiSet != null && MidiPlayerGlobal.CurrentMidiSet.ActiveSounFontInfo != null && name == MidiPlayerGlobal.CurrentMidiSet.ActiveSounFontInfo.Name)
                {
                    selectedSf = SoundFonts.Count;
                }
                SoundFonts.Add(new MPTKListItem()
                {
                    Index = SoundFonts.Count, Label = name
                });
            }

            if (PopSoundFont == null)
            {
                PopSoundFont = new PopupListItem()
                {
                    Title    = "Select A SoundFont",
                    OnSelect = SoundFontChanged,
                    ColCount = 1,
                    ColWidth = 500,
                }
            }
            ;

            if (SoundFonts != null)
            {
                PopSoundFont.Draw(SoundFonts, selectedSf, myStyle);
                GUILayout.BeginHorizontal(myStyle.BacgDemos);

                if (buttonIconNote == null)
                {
                    buttonIconNote = Resources.Load <Texture2D>("Textures/Note");
                }
                if (GUILayout.Button(new GUIContent(buttonIconNote, "Select A SoundFont"), GUILayout.Width(60), GUILayout.Height(60)))
                {
                    PopSoundFont.Show = !PopSoundFont.Show;
                }
                GUILayout.Space(20);
                if (MidiPlayerGlobal.ImSFCurrent != null)
                {
                    if (MidiPlayerGlobal.ImSFCurrent.LiveSF)
                    {
                        GUILayout.Label("Live SoundFont: " + MidiPlayerGlobal.ImSFCurrent.SoundFontName, myStyle.TitleLabel2, GUILayout.Height(60));
                    }
                    else
                    {
                        GUILayout.Label("Current SoundFont: " + MidiPlayerGlobal.CurrentMidiSet.ActiveSounFontInfo.Name, myStyle.TitleLabel2, GUILayout.Height(60));
                    }
                    GUILayout.Label(string.Format("Load Time:{0} s    Samples:{1} s    Count Presets:{2}   Samples:{3}",
                                                  Math.Round(MidiPlayerGlobal.MPTK_TimeToLoadSoundFont.TotalSeconds, 3),
                                                  Math.Round(MidiPlayerGlobal.MPTK_TimeToLoadWave.TotalSeconds, 3),
                                                  MidiPlayerGlobal.MPTK_CountPresetLoaded,
                                                  MidiPlayerGlobal.MPTK_CountWaveLoaded),
                                    myStyle.TitleLabel2, GUILayout.Height(60));
                }
                else
                {
                    GUILayout.Label("No SoundFont loaded", myStyle.TitleLabel2, GUILayout.Height(60));
                }

                GUILayout.EndHorizontal();

                PopSoundFont.Position(ref scrollerWindow);
            }
            else
            {
                GUILayout.Label("No SoundFont found");
            }
        }
    }
示例#8
0
        void Start()
        {
            if (midiStreamPlayer != null)
            {
                if (!midiStreamPlayer.OnEventSynthStarted.HasEvent())
                {
                    midiStreamPlayer.OnEventSynthStarted.AddListener(StartLoadingSynth);
                }
                if (!midiStreamPlayer.OnEventSynthStarted.HasEvent())
                {
                    midiStreamPlayer.OnEventSynthStarted.AddListener(EndLoadingSynth);
                }
            }
            else
            {
                Debug.LogWarning("No Stream Midi Player associed to this game object");
            }

            LastTimeChange = Time.realtimeSinceStartup;
            ///midiStreamPlayer.MPTK_Play(new MPTKEvent() { Command = MPTKCommand.PatchChange, Patch = CurrentPatchInstrument, Channel = StreamChannel, });
            PanChange      = 64;
            LastTimeChange = -9999999f;

            PopBankInstrument = new PopupListItem()
            {
                Title = "Select A Bank", OnSelect = BankPatchChanged, Tag = "BANK_INST", ColCount = 5, ColWidth = 150,
            };
            PopPatchInstrument = new PopupListItem()
            {
                Title = "Select A Patch", OnSelect = BankPatchChanged, Tag = "PATCH_INST", ColCount = 5, ColWidth = 150,
            };
            PopBankDrum = new PopupListItem()
            {
                Title = "Select A Bank", OnSelect = BankPatchChanged, Tag = "BANK_DRUM", ColCount = 5, ColWidth = 150,
            };
            PopPatchDrum = new PopupListItem()
            {
                Title = "Select A Patch", OnSelect = BankPatchChanged, Tag = "PATCH_DRUM", ColCount = 5, ColWidth = 150,
            };


            for (i = 0; i < 128; i++)
            {
                curNote[i] = false;
                pressed[i] = false;
            }
            if (SceneManager.GetActiveScene().name == "3-1 Pn_FreeMode" || SceneManager.GetActiveScene().name == "3-2 pn_PracMode")
            {
                minOctave = 5;
            }


            minNote = (minOctave) * 12;
            //totalSensorNum = sp.ReadLine().ToCharArray().Length;
            totalSensorNum = 18;

            Debug.Log("total num " + totalSensorNum + " with minNote " + minNote);
            for (i = 0; i <= totalSensorNum; i++)
            {
                numSensorArray[i] = 0;
            }
            SetSensorNum();
        }