private void InitNote(GameObject newNoteObject, SongItem.MidiNote note) { var pos = Vector3.zero; var time = note.time; var beatUnit = time / songManager.secPerBeat; pos.y = beatUnit * beatSize + (songManager.delay / songManager.secPerBeat * beatSize); //The note is being positioned in the track and offset with the delay. newNoteObject.transform.localPosition = pos; var noteScript = newNoteObject.GetComponent <Note>(); noteScript.songManager = songManager; noteScript.InitNoteLength(note.noteLength); noteScript.noteTime = note.time; //For the SyncMode.IndividualNote, we activate the note object later on if (syncMode == SyncMode.Track) { newNoteObject.SetActive(true); } //Notifying the onNoteInit event onNoteInit.Invoke(noteScript); }
public bool CompareMidiMapping(Track target, SongItem.MidiNote note) { //The root octave for the wetdrymidi library is 4 var rootOffset = 4 - referenceRootOctave; if (ignoreOctave) { return(target.noteTarget == note.noteName); } return(target.noteTarget == note.noteName && target.noteOctave == note.noteOctave - rootOffset); }
public int GetNoteType(SongItem.MidiNote note) { if (mapping != null && mapping.Count > 0) { for (int i = 0; i < mapping.Count; i++) { var target = mapping[i]; if (CompareNoteMapping(target, note)) { return(target.notePrefabIndex); } } } return(0); }
public GameObject GetNotePrefab(SongItem.MidiNote note) { GameObject prefab = null; if (mapping != null && mapping.Count > 0) { var o = mapping.Find(target => { return(CompareNoteMapping(target, note)); }); if (o != null) { prefab = notesPrefab[o.notePrefabIndex].prefab; } } return(prefab ? prefab : notesPrefab.FirstOrDefault().prefab); }