Example #1
0
    // Creates a nice stream of notes
    public List <Note> getNotes(string _filename)
    {
        MidiFileInspector mInspector = new MidiFileInspector();

        mInspector.Describe(_filename); //sets the channels

        //My Processed version of it stored in "channels"
        mChannels = mInspector.Channels;

        //Make all the notes into one stream
        foreach (Channel currentCh in mChannels)
        {
            string instrument = currentCh.ChannelName.Trim();
            foreach (Note currentNt in currentCh.Notes)
            {
                currentNt.instrumentName = instrument;
                NotesToPlay.Add(currentNt);
            }
        }

        sortTheNotes(); //Long time to calculate!

        //displayTheNotes(); //Lot of displaying
        return(NotesToPlay);
    }
Example #2
0
    void Start()
    {
        PianoKeyDetector = PianoKeyController.Instance;
        OnPlayTrack      = new UnityEvent();    // <----------	A ver si no es necesario al ser publico

        #region [------------	FOR NOW WE DON'T NEED THIS EVENT	------------]
        //OnPlayTrack.AddListener(delegate{FindObjectOfType<MusicText>().StartSequence(MIDISongs[_midiIndex].Details);});
        #endregion

        _midiIndex = 0;

        if (!_preset)
        {
            PlayCurrentMIDI();
        }
        else
        {
#if UNITY_EDITOR
            _path = string.Format("{0}/MIDI/{1}.mid", Application.streamingAssetsPath, MIDISongs[0].MIDIFile.name);
#else
            _path = string.Format("{0}/MIDI/{1}.mid", Application.streamingAssetsPath, MIDISongs[0].SongFileName);
#endif

            _midi = new MidiFileInspector(_path);

            #region [------------	EVENT MAY BE NULL	------------]
            //OnPlayTrack.Invoke();
            #endregion

            OnPlayTrack?.Invoke();              // This will never be null :)
        }
    }
Example #3
0
    void PresetFirstMIDI()
    {
#if UNITY_EDITOR
        _path = string.Format("{0}/MIDI/{1}.mid", Application.streamingAssetsPath, MIDISongs[0].MIDIFile.name);
#else
        _path = string.Format("{0}/MIDI/{1}.mid", Application.streamingAssetsPath, MIDISongs[0].SongFileName);
#endif
        _midi     = new MidiFileInspector(_path);
        MidiNotes = _midi.GetNotes();

        _preset = true;
    }
Example #4
0
    void PlayCurrentMIDI()
    {
        _timer = 0;

#if UNITY_EDITOR
        _path = string.Format("{0}/MIDI/{1}.mid", Application.streamingAssetsPath, MIDISongs[_midiIndex].MIDIFile.name);
#else
        _path = string.Format("{0}/MIDI/{1}.mid", Application.streamingAssetsPath, MIDISongs[_midiIndex].SongFileName);
#endif
        _midi      = new MidiFileInspector(_path);
        MidiNotes  = _midi.GetNotes();
        _noteIndex = 0;

        OnPlayTrack.Invoke();
    }
Example #5
0
    void Start()
    {
        OnPlayTrack = new UnityEvent();
        OnPlayTrack.AddListener(delegate { FindObjectOfType <MusicText>().StartSequence(MIDISongs[_midiIndex].Details); });

        _midiIndex = 0;

        if (!_preset)
        {
            PlayCurrentMIDI();
        }
        else
        {
#if UNITY_EDITOR
            _path = string.Format("{0}/MIDI/{1}.mid", Application.streamingAssetsPath, MIDISongs[0].MIDIFile.name);
#else
            _path = string.Format("{0}/MIDI/{1}.mid", Application.streamingAssetsPath, MIDISongs[0].SongFileName);
#endif
            _midi = new MidiFileInspector(_path);

            OnPlayTrack.Invoke();
        }
    }
Example #6
0
    void SetupNextMIDI()
    {
        if (_midiIndex >= MIDISongs.Length - 1)
        {
            if (RepeatType != RepeatType.NoRepeat)
            {
                _midiIndex = 0;
            }
            else
            {
                _midi = null;
                return;
            }
        }
        else
        {
            if (RepeatType != RepeatType.RepeatOne)
            {
                _midiIndex++;
            }
        }

        PlayCurrentMIDI();
    }