コード例 #1
0
        public List <myNote> getAllNotes()
        {
            List <myNote> notes    = new List <myNote>();
            TempoMap      tempoMap = midiFile.GetTempoMap();

            MetricTimeSpan metricTime;
            MetricTimeSpan musicalLength;

            var chunks = midiFile.GetTrackChunks();

            foreach (Note note in midiFile.GetNotes())
            {
                metricTime    = note.TimeAs <MetricTimeSpan>(tempoMap);
                musicalLength = note.LengthAs <MetricTimeSpan>(tempoMap);
                myNote n = new myNote()
                {
                    name       = note.NoteName.ToString(),
                    octave     = note.Octave,
                    time       = metricTime.TotalMicroseconds / 1000,
                    length     = (int)(musicalLength.TotalMicroseconds / 1000),
                    velocity   = note.Velocity,
                    noteNumber = note.NoteNumber
                };
                metricTime = note.TimeAs <MetricTimeSpan>(tempoMap);

                //string str = string.Format("Name: {0}, Octave: {1}, Time: {2}, Length: {3} \r\n", n.name, n.octave, n.time, n.length);

                notes.Add(n);
            }

            return(notes);
        }
コード例 #2
0
        private void produceNewNote(myNote note)
        {
            string str = string.Format("T:{3}, Name: {0}, Octave: {1},Length: {2} \r\n"
                                       , note.name, note.octave, note.length, currentPlayedTime);

            addToNote(str);
            playForm.invokeNote(note);
        }
コード例 #3
0
        public void invokeNote(myNote in_note)
        {
            playingNote newNote = new playingNote()
            {
                note       = in_note,
                posX       = (int)(Setting.middlePosX + (noteOffset[in_note.name] - 3 + 7 * (in_note.octave - Setting.baseOctave)) * Setting.blockWidth),
                onScreen   = false,
                color      = in_note.name.Length > 2 ? this.blackBlock : this.whiteBlock,
                joinedTime = Form1.currentPlayedTime,
            };

            //Console.WriteLine(String.Format("middle pos is:{0}", Setting.middlePosX));
            //Console.WriteLine(String.Format("note {0}{3} added, posX is: {1}, offset: {2}",newNote.note.name,newNote.posX, (noteOffset[in_note.name] + 7 * (in_note.octave - Setting.baseOctave)),in_note.octave));
            this.onScreenNotes.Add(newNote);
            //pictureBox.Refresh();
        }