/// <summary> /// Converts note data into .mn file-compatible format. /// </summary> /// <param name="noteData">The note data to convert.</param> /// <returns>Converted note data.</returns> private List <string> WriteNotes(SongParser.NoteData noteData) { List <string> _fileDataNotes = new List <string>(); string _currLine = ""; _currLine = "#NOTES:"; _fileDataNotes.Add(_currLine); int _barCounter = 1; foreach (List <SongParser.Notes> bar in noteData.bars) { _currLine = "// measure " + _barCounter; _fileDataNotes.Add(_currLine); foreach (SongParser.Notes note in bar) { // _currLine = note.bottom.ToString() + note.middle.ToString() + note.top.ToString(); _currLine = (Convert.ToByte(note.bottom)).ToString() + (Convert.ToByte(note.middle)).ToString() + (Convert.ToByte(note.top)).ToString(); _fileDataNotes.Add(_currLine); } _currLine = ","; _fileDataNotes.Add(_currLine); _barCounter++; } _fileDataNotes[_fileDataNotes.Count - 1] = ";"; return(_fileDataNotes); }
/// <summary> /// Records the song. /// </summary> private IEnumerator Record() { // Debug.Log("Recording begun."); noteData = new SongParser.NoteData(); noteData.bars = new List <List <SongParser.Notes> >(); while (audioSource.isPlaying) { // float _timeOffset = 10.0f / (noteSpeed / Time.deltaTime); // songTimer = audioSource.time; //if (!canRecord && songTimer - _timeOffset >= (barExecutedTime - barTime)) //{ // canRecord = true; //} // Debug.Log(songTimer - _timeOffset); //if (!isRecordingBar && (songTimer - _timeOffset >= (barExecutedTime - barTime))) //{ // Debug.Log((songTimer - _timeOffset) + " >= " + (barExecutedTime - barTime)); // StartCoroutine(RecordBar()); // barExecutedTime += barTime; //} if (!isRecordingBar) { StartCoroutine(RecordBar()); } yield return(null); } songData.noteData = this.noteData; SongWriter _songWriter = new SongWriter(); _songWriter.Write(songData, targetPath); promptText.text = "RECORDING FINISHED"; yield break; }
// Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.Space)) { SongParser.Metadata _tempSongData = new SongParser.Metadata(); _tempSongData.title = "JOURNEI"; _tempSongData.subtitle = ""; _tempSongData.artist = "Hans"; _tempSongData.bannerPath = ""; _tempSongData.backgroundPath = ""; _tempSongData.musicPath = "JOURNEI.mp3"; _tempSongData.offset = 0.0f; _tempSongData.sampleStart = 97.33f; _tempSongData.sampleLength = 10.58f; _tempSongData.bpm = 125; SongParser.NoteData _tempNoteData = new SongParser.NoteData(); List <SongParser.Notes> _tempBar = new List <SongParser.Notes>(); SongParser.Notes _tempNotes = new SongParser.Notes(); _tempNotes.bottom = 0; _tempNotes.middle = SongParser.NoteType.Air; _tempNotes.top = 0; _tempBar.Add(_tempNotes); _tempNoteData.bars = new List <List <SongParser.Notes> >(); _tempNoteData.bars.Add(_tempBar); _tempSongData.noteData = _tempNoteData; SongWriter _songWriter = new SongWriter(); _songWriter.Write(_tempSongData, Application.persistentDataPath); Debug.Log("Song should be written now."); } }
// iniatialises variables and sets arrow speed public void InitNotes(SongParser.Metadata newSongData) { songData = newSongData; isInit = true; // Debug.Log("isInit set to: " + isInit); // estimate how many seconds a single 'bar' will be in the // song using the bpm in song data // Debug.Log("BPM: " + songData.bpm); barTime = (60.0f / songData.bpm) * 4.0f; Debug.Log("barTime: " + barTime); distance = originalDistance; // Debug.Log("distance: " + distance); // TO-DO: Integrate note speed into song data // how fast the arrow will be going if (noteSpeed <= 0.0f) { noteSpeed = 0.05f; } // noteSpeed = 0.009f; // TEMPORARY MAGIC NUMBER noteData = songData.noteData; }