// 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); }
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 :) } }
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; }
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(); }
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(); } }
void SetupNextMIDI() { if (_midiIndex >= MIDISongs.Length - 1) { if (RepeatType != RepeatType.NoRepeat) { _midiIndex = 0; } else { _midi = null; return; } } else { if (RepeatType != RepeatType.RepeatOne) { _midiIndex++; } } PlayCurrentMIDI(); }