コード例 #1
0
        /// <summary>
        /// Begin drawing a note. Initializes variabes.
        /// </summary>
        /// <param name="startPos">Represents the position that is the center of the piano roll slot to draw the note on</param>
        public static void BeginNoteDraw(PRoll_Slot slot)
        {
            float absoluteSizeY = .0035f;

            Vector3 startPos = new Vector3();

            startPos.y = slot.transform.position.y + (ScaleOfSquare / -4) * absoluteSizeY / (ScaleOfSquare / 2);
            startPos.x = slot.transform.position.x - (ScaleOfSquare / -4) * absoluteSizeY / (ScaleOfSquare / 2);

            currentNoteBeingDrawn = ((GameObject)(GameObject.Instantiate(Note))).transform;
            currentNoteBeingDrawn.SetParent(slot.transform, false);
            float nSize = .0035f; //absoulte size in meters of the note geometry

            currentNoteBeingDrawn.transform.localPosition = new Vector3(nSize * .5f, nSize * -.5f, 0);

            PRoll_Note note = currentNoteBeingDrawn.GetComponent <PRoll_Note>();

            note.Init(slot, slot.PitchIndex, slot.PositionIndex);
            slot.NoteGeo = note;

            thresholdRank = 0;

            //TODO: Keep track of earliest placed note in a row, and use that to determine the max scale. If no other notes, than use based off of final threshold value
            int indexOfNextNote = slot.Controller.GetIndexOfNextNote(slot.PositionIndex, slot.PitchIndex);

            maxThresholdInc = Mathf.Clamp(indexOfNextNote - slot.PositionIndex - 1, 0, thresholdValues.Length - 1);
        }
コード例 #2
0
        /// <summary>
        /// Create a new piano roll user interface
        /// </summary>
        private void InitializePianoRoll(Vector2 size)
        {
            //Instantiate piano roll prefab.
            //12 rows of 16 columns
            for (byte r = 0; r < 12; r++)
            {
                for (byte c = 0; c < 16; c++)
                {
                    GameObject g = (GameObject)GameObject.Instantiate(NoteSlot);
                    g.transform.SetParent(NoteSlotContainer, false);
                    g.transform.localPosition = new Vector3(size.x * -c, size.y * r, 0);

                    PRoll_Slot slot = g.GetComponent <PRoll_Slot>();
                    if (slot == null)
                    {
                        Debug.LogError("Missing PRoll_Slot class");
                        break;
                    }

                    matrix[c, r] = slot;

                    slot.Note          = new MIDINote(Settings.MidiFromPitchIndex(r, octave), 1, 1);
                    slot.PositionIndex = c;
                    slot.PitchIndex    = r;
                    slot.Controller    = this;
                }
            }
        }
コード例 #3
0
 //Instantly create a note visual without manually drawing it in
 public static void InsertNoteGeo(PRoll_Slot slot)
 {
     if (slot.Note == null)
     {
         Debug.LogError("No note information in this slot to insert note geometry: " + slot.PositionIndex + " " + slot.PitchIndex);
         return;
     }
     BeginNoteDraw(slot);
     thresholdRank = (byte)(slot.Note.duration - 1);
     EndNoteDraw();
 }
コード例 #4
0
        private void AddNoteToStream(PRoll_Slot n)
        {
            instrument.NoteOn(n.Note);

            //get sample at which we should call noteOff on this note
            uint endSample = globalSample + (uint)(n.Note.duration * Settings.BeatLength_s);

            //if not already part of the dictionary, add it
            if (!noteStream.ContainsKey(endSample))
            {
                noteStream[endSample] = new List <PRoll_Slot>();
            }

            noteStream[endSample].Add(n);
        }