MidiPlayer.Play C# (CSharp) Method

Play() public method

public Play ( TextAsset midiFile = null ) : void
midiFile UnityEngine.TextAsset
return void
    public void Play(TextAsset midiFile=null)
    {
        if (midiFile == null) {
            midiFile = this.midiFile;
        }
        MidiPlayer.instance = this;
        StartMidi(midiFile);
    }

Usage Example

Exemplo n.º 1
0
    void FixedUpdate()
    {
        //dsptime = AudioSettings.dspTime;

        if (playTuggle == true && TargetFound == false)
        {
            LoadMidiPath();
        }

        if (playTuggle == true && TargetFound == true)
        {
            if (firstPlay)
            {
                //LoadMidiPath ();
                midi_p.LoadMidi(new MidiFile(midiSource));
                dsptime = AudioSettings.dspTime;
                midi_p.Play();
                firstPlay = false;
            }

            if (midi_p.Sequencer.IsPlaying == true && midi_p.Sequencer.EndTime - midi_p.Sequencer.CurrentTime < 1500)
            {
                LoadMidiPath();
                midi_pb.LoadMidi(new MidiFile(midiSource));
            }
            if (midi_pb.Sequencer.IsPlaying == true && midi_pb.Sequencer.EndTime - midi_pb.Sequencer.CurrentTime < 1500)
            {
                LoadMidiPath();
                midi_p.LoadMidi(new MidiFile(midiSource));
            }

            wakarantime += Time.fixedDeltaTime;
            //if (wakarantime > 0.49 * 4) {
            //if (wakarantime > (midi_p.bpm * 0.00412 * 4)) {
            //if (wakarantime >= ((1 / (((float)midi_p.bpm / 60)) - 0.015) * 4)) {
            if ((AudioSettings.dspTime - dsptime) >= ((1 / (((float)midi_p.bpm / 60)) - 0.015) * 4))
            {
                //Debug.Log ("calc : " + ((1 / ((float)midi_p.bpm / 60)) - 0.005));
                if (count == 0)
                {
                    midi_pb.Play();
                    count++;
                    //LoadMidiPath ();
                    //midi_p.LoadMidi (new MidiFile (midiSource));
                }
                else
                {
                    midi_p.Play();
                    count--;
                    //LoadMidiPath ();
                    //midi_pb.LoadMidi (new MidiFile (midiSource));
                }
                wakarantime = 0;
                dsptime     = AudioSettings.dspTime;
            }
        }
    }
All Usage Examples Of MidiPlayer::Play