示例#1
0
 public MidiNote(int _delta, NOTEL _notel, NOTE _note, int _vel)
 {
     note = _note;
     delta = _delta;
     notel = _notel;
     vel = _vel;
 }
示例#2
0
        /// <summary>
        /// Handles the Click event of the SaveNoteButton control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="RoutedEventArgs"/> instance containing the event data.</param>
        private async void SaveNoteButton_Click(object sender, RoutedEventArgs e)
        {
            NOTE note = new NOTE();

            note.TITLE       = this.noteTitle.Text;
            note.CONTENT     = this.noteContent.Text;
            note.LESSON_ID   = allLessons[selectLessonComboBox.SelectedIndex].ID;
            note.CUSTOMER_ID = Constants.User.ID;
            note.DATE        = DateTime.Now;
            note.SHARE       = sharableCheckBox.IsChecked ?? false;

            if (note == null)
            {
                System.Diagnostics.Debug.WriteLine("note is null!");
            }

            ctx.AddToNOTE(note);
            ctx.BeginSaveChanges(onNoteSaved, null);

            this.addNotePopup.IsOpen = false;
            ClearNote();
            MessageDialog md = new MessageDialog("Note Saved", "Your note have been saved!");
            await md.ShowAsync();

            //md.Content = "Your note have been saved!";
        }
 void SyncLogs(VesselNotesLogs syncToNote)
 {
     for (int n = 0; n < logList.list.Count; n++)
     {
         if (!logList.list[n].privateNote && !logList.list[n].locked)
         {
             NOTE_LIST syncToLogList = syncToNote.logList;
             NOTE      foundLog      = syncToLogList.list.SingleOrDefault(r => r.guid == logList.list[n].guid);
             if (foundLog == null)
             {
                 if (logList.list[n].noteListGuid == syncToLogList.listGuid)
                 {
                     syncToLogList.list.Add(new NOTE(
                                                logList.list[n].title,
                                                logList.list[n].note,
                                                logList.list[n].guid,
                                                syncToLogList.listGuid,
                                                false));
                 }
             }
             else
             {
                 foundLog.title = logList.list[n].title;
                 foundLog.note  = logList.list[n].note;
                 foundLog.id    = logList.list[n].id;
             }
         }
     }
     syncToNote.SetSelectedLog(syncToNote.selectedLog);
 }
        public void GetTrashFromController()
        {
            TrashBinPageController LoadNote = new TrashBinPageController();

            dataGridView1.DataSource = LoadNote.GetAllTrash(Username);
            for (int i = 0; i < dataGridView1.RowCount; i++)
            {
                NOTE N = new NOTE();
                N.PpOrder      = Int32.Parse(dataGridView1[0, i].Value.ToString());
                N.PpHeader     = dataGridView1[1, i].Value.ToString();
                N.PpContent    = dataGridView1[2, i].Value.ToString();
                N.PpTag        = dataGridView1[3, i].Value.ToString();
                N.PpFontFamily = dataGridView1[4, i].Value.ToString();
                N.PpFontSize   = Int32.Parse(dataGridView1[5, i].Value.ToString());
                N.PpFontColor  = dataGridView1[6, i].Value.ToString();
                if (dataGridView1[7, i].Value != null)
                {
                    N.PpPictureName = dataGridView1[7, i].Value.ToString();
                }
                if (dataGridView1[8, i].Value != null)
                {
                    N.PpDrawPictureName = dataGridView1[8, i].Value.ToString();
                }
                ListOfTrash.Add(N);
            }
            LoadNoteForPage();
        }
示例#5
0
            /// <summary>
            /// Helper method for invoking kevent with a single argument
            /// </summary>
            /// <param name="kq">The kqueue descriptor.</param>
            /// <param name="handle">The handle to register</param>
            /// <param name="filter">The filter to use</param>
            /// <param name="flags">The flags to use</param>
            /// <param name="fflags">The fflags</param>
            /// <param name="data">The data to associate</param>
            /// <param name="udata">The udata to associate</param>
            /// <returns></returns>
            public static int kevent(int kq,IDENTTYPE handle,EVFILT filter,EV flags,NOTE fflags = 0,INTPTR data = default(INTPTR),INTPTR udata = default(INTPTR))
            {
                var kev = new [] {
                    new struct_kevent()
                    {
                        ident  = new INTPTR((long)handle),
                        filter = filter,
                        flags  = flags,
                        fflags = fflags,
                        data   = data,
                        udata  = udata
                    }
                };

                var timeout = new[] { new Timespec()
                                      {
                                          tv_sec = 10
                                      } };

                var ret = PInvoke.kevent(kq,kev,1,null,0,timeout);

                if (ret < 0)
                {
                    throw new IOException($"Failed to {flags} handle on kqueue: {Stdlib.GetLastError()}");
                }
                if (kev[0].flags.HasFlag(EV.ERROR))
                {
                    throw new IOException($"Failed to {flags} handle on kqueue: {kev[0].data}");
                }

                return(ret);
            }
示例#6
0
 public IHttpActionResult UpdateNote(string seflink, [FromBody] NOTE note)
 {
     try
     {
         int id = UserInf.GetUser();
         using (MynoteDBEntities db = new MynoteDBEntities())
         {
             var gnote = db.NOTES.FirstOrDefault(x => x.NoteSefLink == seflink);
             if (gnote != null)
             {
                 if (note.NoteCategoryId != null)
                 {
                     gnote.NoteTitle        = note.NoteTitle;
                     gnote.NoteDescription  = note.NoteDescription;
                     gnote.NoteContent      = note.NoteContent;
                     gnote.NoteCategoryId   = note.NoteCategoryId;
                     gnote.NoteModifiedDate = note.NoteModifiedDate;
                     gnote.NoteModifiedId   = id;
                     int result = db.SaveChanges();
                     if (result != 0)
                     {
                         return(Ok());
                     }
                     else
                     {
                         return(BadRequest());
                     }
                 }
                 else
                 {
                     gnote.NoteTitle             = note.NoteTitle;
                     gnote.NoteDescription       = note.NoteDescription;
                     gnote.NoteContent           = note.NoteContent;
                     gnote.privateNoteCategoryId = note.privateNoteCategoryId;
                     gnote.NoteModifiedDate      = note.NoteModifiedDate;
                     gnote.NoteModifiedId        = id;
                     int result = db.SaveChanges();
                     if (result != 0)
                     {
                         return(Ok());
                     }
                     else
                     {
                         return(BadRequest());
                     }
                 }
             }
             else
             {
                 return(NotFound());
             }
         }
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }
示例#7
0
            /// <summary>
            /// 音符の追加
            /// </summary>
            /// <param name="notel"></param>
            /// <param name="note"></param>
            /// <param name="vel"></param>
            public void AddNote(NOTEL notel, NOTE note, int vel)
            {
                //  発音
                noteList.Add(new MidiNote(mDelta, notel, note, vel));
                mDelta += (int)notel;

                //  消音
                noteList.Add(new MidiNote(mDelta, NOTEL.N4, note, 0));
            }
示例#8
0
            public void Initialize(NOTEL _dur = NOTEL.N1, NOTE _n = NOTE.x, string voice = "")
            {
                dur = (int)_dur;
                n   = (int)_n;
                v   = 64;
                y   = new XmlDocument().CreateCDataSection(VoiceChar[voice].hiragana);
                p   = new XmlDocument().CreateCDataSection(VoiceChar[voice].pronunce);

                nStyle _nStyle = new nStyle();

                nStyle = _nStyle;
            }
示例#9
0
        public ActionResult getNote()
        {
            IEnumerable <NOTES> notes = _context.notes.AsEnumerable();

            List <NOTE> note = new List <NOTE>();

            _log.LogInformation("Getting the node");
            statsDPublisher.Increment("_NOTE_GET_API");

            string username = getUsername();
            IEnumerable <Attachments> at = _context.attachments.AsEnumerable();

            foreach (NOTES item in notes)
            {
                if (item.EMAIL == username)
                {
                    NOTE n = new NOTE();

                    n.noteID          = item.noteID;
                    n.content         = item.content;
                    n.created_on      = item.created_on;
                    n.title           = item.title;
                    n.last_updated_on = item.last_updated_on;


                    List <mAttachments> newat = new List <mAttachments>();

                    foreach (Attachments attachment in at)
                    {
                        if (attachment.noteID == n.noteID)
                        {
                            mAttachments m = new mAttachments();
                            m.AID = attachment.AID;
                            m.url = attachment.url;
                            newat.Add(m);
                        }
                    }
                    n.attachments = newat;
                    note.Add(n);
                }
            }
            if (note.Capacity != 0)
            {
                IEnumerable <NOTE> newnote = note;
                string             Json    = JsonConvert.SerializeObject(newnote, Formatting.Indented);
                return(StatusCode(200, Json));
            }
            else
            {
                return(StatusCode(200, new{ result = "You Don't have any notes!!! Sorry" }));
            }
        }
示例#10
0
    public void noteClick(int sTime)
    {
        // NOTE CLICK
        Debug.Log("Note Erase");

        swNote.Close();     // 지금 까지 한것을 저장

        // 그리고 다시 읽기
        TextAsset textAsset = Resources.Load("Data/Level" + Singleton.getInstance.level + "/Note/song" + Singleton.getInstance.songNum) as TextAsset;
        string    str       = textAsset.text;

        char sp = ',';

        string[] spString = str.Split(sp);

        NOTE note = new NOTE(0, Vector2.zero);

        // 다시 쓰기
        path   = pathForDocuments("Assets/Resources/Data/Level" + Singleton.getInstance.level + "/Note" + "/song" + Singleton.getInstance.songNum + ".txt");
        file   = new FileStream(path, FileMode.Create, FileAccess.Write);
        swNote = new StreamWriter(file);

        for (int i = 0; i < spString.Length - 1; i++)
        {
            // string을 float형으로 변환
            float numFloat = System.Convert.ToSingle(spString[i]);

            if (i % 3 == 0)
            {
                if (((int)numFloat) == sTime)
                {
                    note.sTime = -1;
                    i         += 2;
                    break;
                }
                else
                {
                    note.sTime = (int)numFloat;
                }
            }
            else if (i % 3 == 1)
            {
                note.sPos.x = numFloat;
            }
            else if (i % 3 == 2)
            {
                note.sPos.y = numFloat;

                swNote.WriteLine(note.sTime + ", " + note.sPos.x + ", " + note.sPos.y + ", ");
            }
        }
    }
示例#11
0
    /// <summary>
    ///  기본 노트
    /// </summary>
    /// <param name="fileName"></param>
    /// <returns></returns>
    string readStringFromFile(string fileName)
    {
        string path = pathForDocuments(fileName);

        if (File.Exists(path))
        {
            // 파일 일기
            FileStream   file = new FileStream(path, FileMode.Open, FileAccess.Read);
            StreamReader sr   = new StreamReader(file);

            string str = null;
            str = sr.ReadToEnd();

            // 단어 분리
            char     sp       = ',';
            string[] spString = str.Split(sp);

            NOTE note = new NOTE(0, Vector2.zero);

            for (int i = 0; i < spString.Length - 1; i++)
            {
                // string을 float형으로 변환
                float numFloat = System.Convert.ToSingle(spString[i]);

                if (i % 3 == 0)
                {
                    note.sTime = (int)numFloat;
                }
                else if (i % 3 == 1)
                {
                    note.sPos.x = numFloat;
                }
                else if (i % 3 == 2)
                {
                    note.sPos.y = numFloat;
                    _noteList.Add(note);
                }
            }
            sr.Close();
            file.Close();

            return(str);
        }
        else
        {
            return(null);
        }
    }
示例#12
0
        /// <summary>
        /// Handles the Click event of the SaveNoteButton control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="RoutedEventArgs"/> instance containing the event data.</param>
        private async void SaveNoteButton_Click(object sender, RoutedEventArgs e)
        {
            NOTE updatedNote = null;

            try
            {
                DataServiceQuery <NOTE> naDsq = (DataServiceQuery <NOTE>)(from selNote in ctx.NOTE
                                                                          where selNote.ID == changedNote.ID
                                                                          select selNote);

                TaskFactory <IEnumerable <NOTE> > changeNote = new TaskFactory <IEnumerable <NOTE> >();
                updatedNote = (await changeNote.FromAsync(naDsq.BeginExecute(null, null), iar => naDsq.EndExecute(iar))).FirstOrDefault();
            }
            catch
            {
                ShowMessageDialog("Network connection error!24");
                return;
            }

            updatedNote.TITLE     = noteTitle.Text;
            updatedNote.CONTENT   = noteContent.Text;
            updatedNote.LESSON_ID = changedLessonID;
            updatedNote.DATE      = DateTime.Now;
            updatedNote.SHARE     = sharableCheckBox.IsChecked ?? false;

            try
            {
                ctx.UpdateObject(updatedNote);
                TaskFactory <DataServiceResponse> tf = new TaskFactory <DataServiceResponse>();
                await tf.FromAsync(ctx.BeginSaveChanges(null, null), iar => ctx.EndSaveChanges(iar));
            }
            catch
            {
                ShowMessageDialog("Update error25! Please check your network.");
                addNotePopup.IsOpen = false;
                return;
            }

            ShowMessageDialog("Update successfully!");
            addNotePopup.IsOpen = false;
        }
示例#13
0
    /// <summary>
    ///  기본 노트
    /// </summary>
    /// <param name="fileName"></param>
    /// <returns></returns>
    string readStringFromFile(string fileName, int sTime)
    {
        TextAsset textAsset = Resources.Load(fileName) as TextAsset;
        string    str       = textAsset.text;

        char sp = ',';

        string[] spString = str.Split(sp);

        NOTE note = new NOTE(0, Vector2.zero);

        for (int i = 0; i < spString.Length - 1; i++)
        {
            // string을 float형으로 변환
            float numFloat = System.Convert.ToSingle(spString[i]);

            if (i % 3 == 0)
            {
                if (sTime == 0)
                {
                    note.sTime = (int)numFloat;
                }
                else if (((int)numFloat) == sTime)
                {
                    i += 2;
                    return(str);
                }
            }
            else if (i % 3 == 1)
            {
                note.sPos.x = numFloat;
            }
            else if (i % 3 == 2)
            {
                note.sPos.y = numFloat;
                _noteList.Add(note);
            }
        }
        return(str);
    }
示例#14
0
        public bool MergeNote(string note)
        {
            var oldNote = NOTE;

            if (!string.IsNullOrEmpty(note))
            {
                if (string.IsNullOrEmpty(NOTE))
                {
                    NOTE = note;
                }
                else
                {
                    var lst = NOTE.Split(',').ToList();
                    if (!lst.Contains(note))
                    {
                        lst.Add(note);
                    }
                    NOTE = string.Join(",", lst);
                }
            }
            return(oldNote != NOTE);
        }
示例#15
0
        public IHttpActionResult CreateNote(NOTE note)
        {
            int id = UserInf.GetUser();

            try
            {
                using (MynoteDBEntities db = new MynoteDBEntities())
                {
                    note.NoteUserId = id;
                    db.NOTES.Add(note);
                    int feed = db.SaveChanges();
                    if (feed != 0)
                    {
                        return(Ok());
                    }
                    return(BadRequest());
                }
            }
            catch (Exception e)
            {
                return(BadRequest(e.Message));
            }
        }
示例#16
0
        public NOTE Create(NoteApiModel apiModel)
        {
            var newNote = new NOTE();

            newNote.NoteBody = apiModel.body;
            if (apiModel.account != 0)
            {
                newNote.ACCOUNT_ID = apiModel.account;
            }
            if (apiModel.campaign != 0)
            {
                newNote.CAMPAIGN_ID = apiModel.campaign;
            }
            if (apiModel.contact != 0)
            {
                newNote.CONTACT_ID = apiModel.contact;
            }
            if (apiModel.deal != 0)
            {
                newNote.DEAL_ID = apiModel.deal;
            }
            if (apiModel.lead != 0)
            {
                newNote.LEAD_ID = apiModel.lead;
            }
            if (apiModel.taskTemplate != 0)
            {
                newNote.TASK_TEMPLATE_ID = apiModel.taskTemplate;
            }
            newNote.CreatedAt = DateTime.Now;
            newNote.CreatedBy = apiModel.createdBy.id.GetValueOrDefault();

            db.NOTEs.Add(newNote);
            db.SaveChanges();
            return(newNote);
        }
示例#17
0
 /// <summary>
 /// 音符の追加
 /// </summary>
 /// <param name="_dur"></param>
 /// <param name="_n"></param>
 /// <param name="_voice"></param>
 public void AddNote(NOTEL _dur, NOTE _n, string _voice)
 {
     vsPart.AddNote(new note(_dur, _n, _voice));
 }
示例#18
0
        /*
         * readTrack
         *  Takes a Binaryreader and reads the track data
         *
         * The header should be as follows:
         *      4D 54 72 6B xx xx xx xx
         *          xx xx xx xx : Track length
         *
         *  Event Data is as follows:
         *      dd ff
         *          dd : Delta Time - A delta time is the number of ticks after which the midi event is to be executed.
         *                            The number of ticks per quarter note was defined previously in the file header chunk.
         *                            TODO: This can be many bytes long, but for now I only read in one byte since I have yet to see
         *                            multiple byte delta times in a GH song.  Will fix this later
         *          ff : Event - A midi event.  Refer to the midi reference.  If it is 0xFF, it's a meta event, otherwise a normal command.
         */
        private void readTrack(int track, BinaryReader midi)
        {
            try
            {
                // Verify the track header matches and get track length
                for (int i = 0; i < TRACK_HEADER.Length; i++)
                {
                    if (midi.ReadByte() != TRACK_HEADER[i])
                        throw new FormatException("Invalid Midi File - Track Header incorrect" + TRACK_HEADER[i].ToString());
                }
            }
            catch (EndOfStreamException e)
            {
                //out of bytes!
                Console.WriteLine("Error writing the data.");
                Console.WriteLine(e.ToString());
            }
            byte[] length = new Byte[4];
            //THIS LENGTH IS NOT VERIFIED
            length = midi.ReadBytes(4);
            long fullDelta = 0;

            // Read the midi events
            do {
                NOTE n = new NOTE();

                //delta-time: execute the midi-event after this number of ticks
                n.delta = readVariableLength(midi);
                //total number of ticks?
                fullDelta += n.delta;
                n.absoluteTicks = fullDelta;

                //META or COMMAND. Assuming that there's no omissision of the command itself, which would have meant "execute the last command again"
                byte flag;
                try
                {
                    flag = midi.ReadByte();
                }
                catch (EndOfStreamException e)
                {
                    //out of bytes!
                    Console.WriteLine("Error writing the data.");
                    Console.WriteLine(e.ToString());
                    return;
                }
                if (flag == 0xFF)
                {
                    /* Meta Event.  All meta events have the format 0xFF xx nn dd
                     *  xx : The meta command
                     *  nn : The length of data associated with the command
                     *  dd x nn : The data
                     */
                    n.type = TYPE.META;

                    n.value = midi.ReadByte();

                    switch (n.value)
                    {
                        //SET TEMPO EVENT
                        case 0x51:
                            n.tempo = readInt24(midi);
                            n.eventName = "TEMPO    ";
                            NOTE t = new NOTE();
                            t.delta = fullDelta;
                            t.absoluteTicks = fullDelta;
                            t.tempo = n.tempo;
                            tempos.Add(t);
                            break;

                        //0x58 could be interesting:time signature
                        case 0x58:
                            n.data = midi.ReadString();
                            char[] timesigData = n.data.ToCharArray();
                            int numerator = timesigData[0];
                            int denominator = timesigData[1];
                            int ticksPerClick = timesigData[2];
                            int thirtySecondToQuarter = timesigData[3];
                            n.data = String.Format("{0}/{1}, {2}, {3}",
                                numerator,
                                denominator,
                                ticksPerClick,
                                thirtySecondToQuarter
                            );
                            n.eventName = "TIMESIG  ";
                            //n.data = midi.ReadString().Length.ToString();
                            break;

                        default:
                            //does this work for all cases? Does it get all the bytes? Are they readable?
                            n.data = midi.ReadString();
                            break;

                    }

                    //SEQUENCE OR TRACK NAME
                    //This could probably be a Dictionary.
                    if (n.value == 0x00)
                    {
                        n.eventName = "TRACKSEQ ";
                    }
                    else if (n.value == 0x01)
                    {
                        n.eventName = "TEXTANY  ";
                    }
                    else if (n.value == 0x02)
                    {
                        n.eventName = "TEXTCOPY ";
                    }
                    else if (n.value == 0x03) {
                        midi_data.trackNames[track] = n.data;
                        if (n.data == "PART GUITAR")
                        {
                            guitarTrackIndex = track;
                        }
                        else
                        {
                            if (RB_MODE && n.data == "PART DRUMS")
                            {
                                bassTrackIndex = track;
                            }
                            else if (!RB_MODE && n.data == "PART BASS")
                            {
                                bassTrackIndex = track;
                            }
                        }
                        n.eventName = "TRACKNAME";
                    }
                    else if (n.value == 0x04)
                    {
                        n.eventName = "INSTNAME ";
                    }
                    else if (n.value == 0x05)
                    {
                        n.eventName = "LYRIC    ";
                    }
                    else if (n.value == 0x06)
                    {
                        n.eventName = "MARKER   ";
                    }
                    else if (n.value == 0x07)
                    {
                        n.eventName = "CUEPOINT ";
                    }
                    else if (n.value == 0x59)
                    {
                        n.eventName = "KEYSIG   ";
                    }
                    else if (n.value == 0x7F)
                    {
                        n.eventName = "SEQUENCER";
                    }
                    //END OF TRACK
                    if (n.value == 0x2F)
                        return;

                }
                else
                {
                    n.type = TYPE.COMMAND;

                    //top 4 bits of first byte is the command
                    int cmd = flag >> 4;
                    //last 4 bits is the channel number
                    n.channel = flag & 0x0F;

                    switch (cmd)
                    {
                        case 0x08: // Note OFF.  Followed by note number and velocity
                            n.value = 0;
                            n.data = String.Format("Note off heard for note number {0}", midi.ReadByte());
                            n.velocity = midi.ReadByte();
                            break;
                        case 0x09: // Note ON.  Followed by note number and velocity
                            // WHY NO DATA SET HERE?
                            n.value = midi.ReadByte();
                            n.data = "Note ON";
                            n.velocity = midi.ReadByte();
                            break;
                        case 0x0A: // Key after-touch.  Followed by Note Number and Velocity
                            n.value = 0;
                            n.data = "BAD CMD: Key after-touch";
                            n.value = midi.ReadByte();
                            n.velocity = midi.ReadByte();
                            break;
                        case 0x0B: // Control Change. Followed by controller number and new value
                            n.value = 0;
                            n.data = "BAD CMD: Control Change";
                            n.value = midi.ReadByte();
                            n.velocity = midi.ReadByte();
                            break;
                        case 0x0C: // Program (patch) change). Followed by new program name
                            n.value = 0;
                            n.data = "BAD CMD: Program change";
                            n.value = midi.ReadByte();
                            break;
                        case 0x0D: // Channel after-touch. Followed by channel number
                            n.value = 0;
                            n.data = "BAD CMD: Channel after-touch";
                            n.value = midi.ReadByte();
                            break;
                        case 0x0E: // Pitch wheel change followed by 2 bytes of value
                            n.value = 0;
                            n.data = "BAD CMD: Pitch wheel";
                            n.value = midi.ReadByte();
                            n.velocity = midi.ReadByte();
                            break;
                        default:
                            if (RB_MODE)
                            {
                                n.value = flag;//midi.ReadByte();
                                n.data = "Note ON";
                                n.velocity = midi.ReadByte();
                            }
                            else
                            {
                                n.value = 0;
                                n.data = String.Format("Unknown command {0:X}", cmd);
                            }
                            break;

                    }
                }
                //if (!RB_MODE || n.velocity == 100)
                //{
                midi_data.tracks[track].Add(n);
                //}

            } while (true);
        }
示例#19
0
 public void AddToNOTE(NOTE nOTE)
 {
     base.AddObject("NOTE", nOTE);
 }
示例#20
0
 public static NOTE CreateNOTE(string cONTENT, int lESSON_ID, int ID, global::System.DateTime dATE, bool sHARE)
 {
     NOTE nOTE = new NOTE();
     nOTE.CONTENT = cONTENT;
     nOTE.LESSON_ID = lESSON_ID;
     nOTE.ID = ID;
     nOTE.DATE = dATE;
     nOTE.SHARE = sHARE;
     return nOTE;
 }
示例#21
0
 /// <summary>
 /// Deletes the note.
 /// </summary>
 /// <param name="note">The note.</param>
 /// <param name="onComplete">The on complete.</param>
 public void DeleteNote(NOTE note, OnQueryComplete onComplete)
 {
     ctx.DeleteObject(note);
     this.onUQC = onComplete;
     ctx.BeginSaveChanges(onQueryComplete2, null);
 }
示例#22
0
 /// <summary>
 /// Inserts the note.
 /// </summary>
 /// <param name="note">The note.</param>
 /// <param name="onComplete">The on complete.</param>
 public void InsertNote(NOTE note, OnQueryComplete onComplete)
 {
     ctx.AddToNOTE(note);
     this.onUQC = onComplete;
     ctx.BeginSaveChanges(onQueryComplete2, null);
 }
示例#23
0
        /*
         * readTrack
         *  Takes a Binaryreader and reads the track data
         *
         * The header should be as follows:
         *      4D 54 72 6B xx xx xx xx
         *          xx xx xx xx : Track length
         *
         *  Event Data is as follows:
         *      dd ff
         *          dd : Delta Time - A delta time is the number of ticks after which the midi event is to be executed.
         *                            The number of ticks per quarter note was defined previously in the file header chunk.
         *                            TODO: This can be many bytes long, but for now I only read in one byte since I have yet to see
         *                            multiple byte delta times in a GH song.  Will fix this later
         *          ff : Event - A midi event.  Refer to the midi reference.  If it is 0xFF, it's a meta event, otherwise a normal command.
         */
        private void readTrack(int track, BinaryReader midi)
        {
            // Verify the track header matches and get track length
            for (int i = 0; i < TRACK_HEADER.Length; i++)
            {
                if (midi.ReadByte() != TRACK_HEADER[i])
                {
                    throw new FormatException("Invalid Midi File - Track Header incorrect");
                }
            }

            byte[] length = new Byte[4];
            length = midi.ReadBytes(4);

            // Read the midi events
            do
            {
                NOTE n = new NOTE();

                n.delta = readVariableLength(midi);

                byte flag = midi.ReadByte();
                if (flag == 0xFF)
                {
                    /* Meta Event.  All meta events have the format 0xFF xx nn dd
                     *  xx : The meta command
                     *  nn : The length of data associated with the command
                     *  dd x nn : The data
                     */
                    n.type = TYPE.META;

                    n.value = midi.ReadByte();
                    n.data  = midi.ReadString();

                    if (n.value == 0x03)
                    {
                        midi_data.trackNames[track] = n.data;
                    }

                    if (n.value == 0x2F)
                    {
                        return;
                    }
                }
                else
                {
                    n.type = TYPE.COMMAND;

                    int cmd = flag >> 4;
                    n.channel = flag & 0x0F;

                    switch (cmd)
                    {
                    case 0x08:     // Note OFF.  Followed by note number and velocity
                        n.value    = 0;
                        n.data     = String.Format("Note off heard for {0}", midi.ReadByte());
                        n.velocity = midi.ReadByte();
                        break;

                    case 0x09:     // Note ON.  Followed by note number and velocity
                        n.value    = midi.ReadByte();
                        n.velocity = midi.ReadByte();
                        break;

                    case 0x0A:     // Key after-touch.  Followed by Note Number and Velocity
                        n.value = 0;
                        n.data  = "Unknown CMD: 0A";
                        midi.ReadByte();
                        midi.ReadByte();
                        break;

                    case 0x0B:
                        n.value = 0;
                        n.data  = "Unknown CMD: B";
                        midi.ReadByte();
                        midi.ReadByte();
                        break;

                    case 0x0C:
                        n.value = 0;
                        n.data  = "Unknown CMD: C";
                        midi.ReadByte();
                        break;

                    case 0x0D:
                        n.value = 0;
                        n.data  = "Unknown CMD: D";
                        midi.ReadByte();
                        break;

                    case 0x0E:
                        n.value = 0;
                        n.data  = "Unknown CMD: E";
                        midi.ReadByte();
                        midi.ReadByte();
                        break;

                    default:
                        n.value = 0;
                        n.data  = String.Format("Unknown command {0:X}", cmd);
                        break;
                    }
                }

                midi_data.tracks[track].Add(n);
            } while (true);
        }
        /*
         * readTrack
         *  Takes a Binaryreader and reads the track data
         *
         * The header should be as follows:
         *      4D 54 72 6B xx xx xx xx
         *          xx xx xx xx : Track length
         *
         *  Event Data is as follows:
         *      dd ff
         *          dd : Delta Time - A delta time is the number of ticks after which the midi event is to be executed.
         *                            The number of ticks per quarter note was defined previously in the file header chunk.
         *                            TODO: This can be many bytes long, but for now I only read in one byte since I have yet to see
         *                            multiple byte delta times in a GH song.  Will fix this later
         *          ff : Event - A midi event.  Refer to the midi reference.  If it is 0xFF, it's a meta event, otherwise a normal command.
         */
        private void readTrack(int track, BinaryReader midi)
        {
            // Verify the track header matches and get track length
            for (int i = 0; i < TRACK_HEADER.Length; i++)
            {
                if (midi.ReadByte() != TRACK_HEADER[i])
                    throw new FormatException("Invalid Midi File - Track Header incorrect");
            }

            byte[] length = new Byte[4];
            length = midi.ReadBytes(4);

            // Read the midi events
            do {
                NOTE n = new NOTE();

                n.delta = readVariableLength(midi);

                byte flag = midi.ReadByte();
                if (flag == 0xFF)
                {
                    /* Meta Event.  All meta events have the format 0xFF xx nn dd
                     *  xx : The meta command
                     *  nn : The length of data associated with the command
                     *  dd x nn : The data
                     */
                    n.type = TYPE.META;

                    n.value = midi.ReadByte();
                    n.data = midi.ReadString();

                    if (n.value == 0x03)
                        midi_data.trackNames[track] = n.data;

                    if (n.value == 0x2F)
                        return;
                }
                else
                {
                    n.type = TYPE.COMMAND;

                    int cmd = flag >> 4;
                    n.channel = flag & 0x0F;

                    switch (cmd)
                    {
                        case 0x08: // Note OFF.  Followed by note number and velocity
                            n.value = 0;
                            n.data = String.Format("Note off heard for {0}", midi.ReadByte());
                            n.velocity = midi.ReadByte();
                            break;
                        case 0x09: // Note ON.  Followed by note number and velocity
                            n.value = midi.ReadByte();
                            n.velocity = midi.ReadByte();
                            break;
                        case 0x0A: // Key after-touch.  Followed by Note Number and Velocity
                            n.value = 0;
                            n.data = "Unknown CMD: 0A";
                            midi.ReadByte();
                            midi.ReadByte();
                            break;
                        case 0x0B:
                            n.value = 0;
                            n.data = "Unknown CMD: B";
                            midi.ReadByte();
                            midi.ReadByte();
                            break;
                        case 0x0C:
                            n.value = 0;
                            n.data = "Unknown CMD: C";
                            midi.ReadByte();
                            break;
                        case 0x0D:
                            n.value = 0;
                            n.data = "Unknown CMD: D";
                            midi.ReadByte();
                            break;
                        case 0x0E:
                            n.value = 0;
                            n.data = "Unknown CMD: E";
                            midi.ReadByte();
                            midi.ReadByte();
                            break;
                        default:
                            n.value = 0;
                            n.data = String.Format("Unknown command {0:X}", cmd);
                            break;
                    }
                }

                midi_data.tracks[track].Add(n);

            } while (true);
        }
示例#25
0
 private bool isNotePlayed(NOTE n, int difficultyStart)
 {
     return (n.type == TYPE.COMMAND) && (n.value > 0) &&
         isNotePlayedInDifficulty(n.value, difficultyStart) && (!RB_MODE || n.velocity > 0);
         //(n.value >= difficultyStart) && (n.value < (difficultyStart + 5));
 }
示例#26
0
 public note(NOTEL _dur, NOTE _n, string voice)
 {
     Initialize(_dur, _n, voice);
 }
示例#27
0
 private bool isNotePlayed(NOTE n, int difficultyStart)
 {
     return((n.type == TYPE.COMMAND) && (n.value > 0) &&
            isNotePlayedInDifficulty(n.value, difficultyStart));
     //(n.value >= difficultyStart) && (n.value < (difficultyStart + 5));
 }
示例#28
0
        private void updateTextbox()
        {
            if (midi_data.numTracks == 0 || selectedTrack == -1)
            {
                eventBox.Text = "Load a song and select a track.";
            }
            else if (difficulty == "Raw")
            {
                string txt = String.Format("Format {0}\tTracks {1}\tTempo {2}\tTempos {3}\r\n\r\n",
                                           midi_data.fileFormat,
                                           midi_data.numTracks,
                                           midi_data.tempo,
                                           tempos.Count
                                           );
                txt += "NAME:      \tTICKS\tABSOL\tVALUE (HEX) \tDATA w/Velocity\r\n\r\n";
                foreach (NOTE n in midi_data.tracks[selectedTrack])
                {
                    string value = n.value.ToString();
                    if (n.type == TYPE.COMMAND)
                    {
                        if (notes.ContainsKey(n.value))
                        {
                            value = notes[n.value];
                        }
                    }
                    //NAME:   TICK_DELAY   ABSOLUTE_DELAY   VALUE (hex) - DATA
                    txt += String.Format("{0}:\t{1}\t{2}\t{3} (0x{3:X})      \t{4}\r\n",
                                         n.type == TYPE.META ? n.eventName : "Note         ",
                                         n.delta,
                                         n.absoluteTicks,
                                         value,
                                         (n.type == TYPE.META && n.value == 0x51) ? n.tempo.ToString() : ((n.type == TYPE.COMMAND) ? n.data.ToString() + " " + n.velocity : n.data)
                                         );
                }
                eventBox.Text = txt;
            }
            else if (selectedTrack == midi_data.numTracks) //CO-OP
            {
                int    diff = difficulties[difficulty];
                string txt  = ""; //final string to display in the text box

                string line        = "";
                string bassLine    = "";
                bool   guitarStrum = false; //if there are guitar notes, strum guitar
                bool   bassStrum   = false; //if there are bass notes, strum bass

                int    guitarIndex  = 0;
                int    bassIndex    = 0;
                int    tempoIndex   = 0;               // array index of tempo change events
                long   now          = 0;               // absolute ticks since the start of song that have already been calculated
                long   currentTempo = midi_data.tempo; // tempo value of the tempo change event currently being evaluated
                double nDelayInMS   = 0;               // calculated sum of milliseconds to wait since the last note before playing the current note

                List <NOTE> guitarNotes = midi_data.tracks[guitarTrackIndex];
                List <NOTE> bassNotes   = midi_data.tracks[bassTrackIndex];

                int guitarSize = guitarNotes.Count;
                int bassSize   = bassNotes.Count;
                int tempoSize  = tempos.Count;

                while (guitarIndex < guitarSize || bassIndex < bassSize)
                {
                    while (guitarIndex < guitarSize &&
                           guitarNotes[guitarIndex].absoluteTicks == now)
                    {
                        if (isNotePlayed(guitarNotes[guitarIndex], diff))
                        {
                            line       += noteStr[guitarNotes[guitarIndex].value - diff];
                            guitarStrum = true;
                        }
                        guitarIndex++;
                    }

                    while (bassIndex < bassSize &&
                           bassNotes[bassIndex].absoluteTicks == now)
                    {
                        if (isNotePlayed(bassNotes[bassIndex], diff))
                        {
                            bassLine += bassNoteStr[bassNotes[bassIndex].value - diff];
                            bassStrum = true;
                        }
                        bassIndex++;
                    }

                    if (line.Length > 0 || bassLine.Length > 0)
                    {
                        txt += nDelayInMS + "\r\n";

                        if (guitarStrum)
                        {
                            line += GUITAR_STRUM;
                        }
                        if (bassStrum)
                        {
                            bassLine += BASS_STRUM;
                        }

                        if (line.Length > 0)
                        {
                            txt += line;
                        }
                        if (bassLine.Length > 0)
                        {
                            txt += "|" + bassLine;
                        }

                        txt += "\r\n";

                        nDelayInMS  = 0;
                        line        = "";
                        bassLine    = "";
                        guitarStrum = false;
                        bassStrum   = false;
                    }

                    //corner case
                    while (tempoIndex < tempos.Count &&
                           tempos[tempoIndex].absoluteTicks == now)
                    {
                        currentTempo = tempos[tempoIndex].tempo;
                        tempoIndex++;
                    }

                    //advance note tracks to a playable note.
                    while (guitarIndex < guitarSize && !isNotePlayed(guitarNotes[guitarIndex], diff))
                    {
                        guitarIndex++;
                    }
                    while (bassIndex < bassSize && !isNotePlayed(bassNotes[bassIndex], diff))
                    {
                        bassIndex++;
                    }

                    //still have tempos and have at least one note track left
                    //Calculate all tempo change delays before the next playable note in either track
                    while ((tempoIndex < tempos.Count) &&
                           (guitarIndex >= guitarSize || tempos[tempoIndex].absoluteTicks < guitarNotes[guitarIndex].absoluteTicks) &&
                           (bassIndex >= bassSize || tempos[tempoIndex].absoluteTicks < bassNotes[bassIndex].absoluteTicks))
                    {
                        // Add them together
                        nDelayInMS  += calculateMSDelay(tempos[tempoIndex].absoluteTicks, now, currentTempo, midi_data.tempo);
                        currentTempo = tempos[tempoIndex].tempo;
                        now          = tempos[tempoIndex].absoluteTicks;
                        tempoIndex++;
                    }

                    if (guitarIndex < guitarSize &&
                        (guitarNotes[guitarIndex].absoluteTicks <= bassNotes[bassIndex].absoluteTicks))
                    {
                        nDelayInMS += calculateMSDelay(guitarNotes[guitarIndex].absoluteTicks, now, currentTempo, midi_data.tempo);
                        now         = guitarNotes[guitarIndex].absoluteTicks;
                    }
                    else if (bassIndex < bassSize)
                    {
                        nDelayInMS += calculateMSDelay(bassNotes[bassIndex].absoluteTicks, now, currentTempo, midi_data.tempo);
                        now         = bassNotes[bassIndex].absoluteTicks;
                    }
                }

                if (nDelayInMS > 0)
                {
                    while (tempoIndex < tempos.Count)
                    {
                        nDelayInMS  += calculateMSDelay(tempos[tempoIndex].absoluteTicks, now, currentTempo, midi_data.tempo);
                        currentTempo = tempos[tempoIndex].tempo;
                        now          = tempos[tempoIndex].absoluteTicks;
                        tempoIndex++;
                    }
                    if (guitarNotes[guitarIndex - 1].absoluteTicks > now)
                    {
                        nDelayInMS += calculateMSDelay(guitarNotes[guitarIndex].absoluteTicks, now, currentTempo, midi_data.tempo);
                        now         = guitarNotes[guitarIndex - 1].absoluteTicks;
                    }
                    if (bassNotes[bassIndex - 1].absoluteTicks > now)
                    {
                        nDelayInMS += calculateMSDelay(bassNotes[bassIndex].absoluteTicks, now, currentTempo, midi_data.tempo);
                    }
                    txt += nDelayInMS + "\r\n" + line + "G\r\n";;
                }
                eventBox.Text = txt;
            }
            else
            {
                int    diff = difficulties[difficulty];
                string txt  = "";
                string line = "";

                // ERIC additions
                //!! BUG: LAST NOTE IS NOT SUSTAINED!
                int    tempoIndex   = 0;               // array index of tempo change events
                long   now          = 0;               // absolute ticks since the start of song that have already been calculated
                long   currentTempo = midi_data.tempo; // tempo value of the tempo change event currently being evaluated
                double nDelayInMS   = 0;               // calculated sum of milliseconds to wait since the last note before playing the current note

                List <NOTE> trackNotes = midi_data.tracks[selectedTrack];
                int         trackSize  = trackNotes.Count;
                for (int noteIndex = 0; noteIndex < trackSize; noteIndex++)
                {
                    NOTE n = trackNotes[noteIndex];

                    // META events in instrument tracks aren't displayed and aren't read by the RPC
                    if (n.type == TYPE.COMMAND)
                    {
                        // ERIC additions
                        if (n.delta > 0)
                        {
                            // Calculate the MS for each of the tempo changes since the last note and before the current note.
                            // Most notes will not have a tempo change between them.
                            // Tempo changes exactly at this note will only affect later notes.
                            while (tempoIndex < tempos.Count &&
                                   tempos[tempoIndex].absoluteTicks < n.absoluteTicks)
                            {
                                // Add them together
                                nDelayInMS  += calculateMSDelay(tempos[tempoIndex].absoluteTicks, now, currentTempo, midi_data.tempo);
                                currentTempo = tempos[tempoIndex].tempo;
                                now          = tempos[tempoIndex].absoluteTicks;
                                tempoIndex++;
                            }

                            // Calculate the MS between the last tempo change and the current note.
                            // Add it to the total
                            nDelayInMS += calculateMSDelay(n.absoluteTicks, now, currentTempo, midi_data.tempo);
                            now         = n.absoluteTicks;
                        }

                        // this is currently the only way to detect a NOTE OFF command
                        // Track 1 has a case that needs them to affect the tempo counts above:
                        //Note         :	180	9840	0 (0x0)         Note off heard for note number 60 127
                        //Note         :	0	9840	GREEN, expert (C) (0xGREEN, expert (C))         Note ON 127
                        if (n.value == 0)
                        {
                            continue;
                        }

                        // Note values are within a span of 6 for each difficulty
                        if (isNotePlayedInDifficulty(n.value, diff))
                        {
                            line += noteStr[n.value - diff];
                        }

                        //Sometimes, there's no note for given difficulty within a block of NOTE ON commands.
                        //So only write the line when it's non-empty; not just when there's a delta in the next note.
                        if (noteIndex + 1 >= trackSize ||
                            (trackNotes[noteIndex + 1].delta > 0 && line.Length > 0))
                        {
                            txt       += nDelayInMS + "\r\n" + line + "S\r\n";
                            line       = "";
                            nDelayInMS = 0;
                        }
                    }
                }
                //HACK TO HOLD LAST NOTE
                txt          += "700000\r\nGS\r\n";
                eventBox.Text = txt;
            }
        }
示例#29
0
        /// <summary>
        /// Method used to add a property to the instance. Will be placed in the correct class Property.
        /// </summary>
        /// <param name="input">The vCard.Property to add.</param>
        public void AddProperty(Props.IProperty input)
        {
            if (input == null || input.IsValueNull)
            {
                return;
            }

            switch (input.Property)
            {
            case KnownProperties.ADR:
                ADR.AddIfNotNull(input as Props.ADR);
                break;

            case KnownProperties.ANNIVERSARY:
                ANNIVERSARY = input as Props.ANNIVERSARY;
                break;

            case KnownProperties.BDAY:
                BDAY = input as Props.BDAY;
                break;

            case KnownProperties.CALADRURI:
                CALADRURI.AddIfNotNull(input as Props.CALADRURI);
                break;

            case KnownProperties.CALURI:
                CALURI.AddIfNotNull(input as Props.CALURI);
                break;

            case KnownProperties.CATEGORIES:
                CATEGORIES.AddIfNotNull(input as Props.CATEGORIES);
                break;

            case KnownProperties.CLIENTPIDMAP:
                CLIENTPIDMAP.AddIfNotNull(input as Props.CLIENTPIDMAP);
                break;

            case KnownProperties.EMAIL:
                EMAIL.AddIfNotNull(input as Props.EMAIL);
                break;

            case KnownProperties.FBURL:
                FBURL.AddIfNotNull(input as Props.FBURL);
                break;

            case KnownProperties.FN:
                FN.AddIfNotNull(input as Props.FN);
                break;

            case KnownProperties.GENDER:
                GENDER = input as Props.GENDER;
                break;

            case KnownProperties.GEO:
                GEO.AddIfNotNull(input as Props.GEO);
                break;

            case KnownProperties.IMPP:
                IMPP.AddIfNotNull(input as Props.IMPP);
                break;

            case KnownProperties.KEY:
                KEY.AddIfNotNull(input as Props.KEY);
                break;

            case KnownProperties.KIND: {
                char k = (input as Props.KIND).Value.ToLower()[0];
                if (k == 'i')
                {
                    KIND = Kinds.Individual;
                }
                else if (k == 'g')
                {
                    KIND = Kinds.Group;
                }
                else if (k == 'o')
                {
                    KIND = Kinds.Org;
                }
                else if (k == 'l')
                {
                    KIND = Kinds.Location;
                }
                else
                {
                    KIND = Kinds.Individual;
                }
                break;
            }

            case KnownProperties.LANG:
                LANG.AddIfNotNull(input as Props.LANG);
                break;

            case KnownProperties.LOGO:
                LOGO.AddIfNotNull(input as Props.LOGO);
                break;

            case KnownProperties.MEMBER:
                MEMBER.AddIfNotNull(input as Props.MEMBER);
                break;

            case KnownProperties.N:
                N = input as Props.N;
                break;

            case KnownProperties.NICKNAME:
                NICKNAME.AddIfNotNull(input as Props.NICKNAME);
                break;

            case KnownProperties.NOTE:
                NOTE.AddIfNotNull(input as Props.NOTE);
                break;

            case KnownProperties.ORG:
                ORG.AddIfNotNull(input as Props.ORG);
                break;

            case KnownProperties.PHOTO:
                PHOTO.AddIfNotNull(input as Props.PHOTO);
                break;

            case KnownProperties.PRODID:
                PRODID = input as Props.PRODID;
                break;

            case KnownProperties.RELATED:
                RELATED.AddIfNotNull(input as Props.RELATED);
                break;

            case KnownProperties.REV:
                REV = input as Props.REV;
                break;

            case KnownProperties.ROLE:
                ROLE.AddIfNotNull(input as Props.ROLE);
                break;

            case KnownProperties.SOUND:
                SOUND.AddIfNotNull(input as Props.SOUND);
                break;

            case KnownProperties.SOURCE:
                SOURCE.AddIfNotNull(input as Props.SOURCE);
                break;

            case KnownProperties.TEL:
                TEL.AddIfNotNull(input as Props.TEL);
                break;

            case KnownProperties.TITLE:
                TITLE.AddIfNotNull(input as Props.TITLE);
                break;

            case KnownProperties.TZ:
                TZ.AddIfNotNull(input as Props.TZ);
                break;

            case KnownProperties.UID:
                UID = input as Props.UID;
                break;

            case KnownProperties.URL:
                URL.AddIfNotNull(input as Props.URL);
                break;

            case KnownProperties.VERSION:
                VERSION = input as Props.VERSION;
                break;

            case KnownProperties.XML:
                XML.AddIfNotNull(input as Props.XML);
                break;

            default:
                return;
            }
        }
示例#30
0
 public void initData(NOTE no)
 {
     myData = no;
 }
示例#31
0
        /*
         * readTrack
         *  Takes a Binaryreader and reads the track data
         *
         * The header should be as follows:
         *      4D 54 72 6B xx xx xx xx
         *          xx xx xx xx : Track length
         *
         *  Event Data is as follows:
         *      dd ff
         *          dd : Delta Time - A delta time is the number of ticks after which the midi event is to be executed.
         *                            The number of ticks per quarter note was defined previously in the file header chunk.
         *                            TODO: This can be many bytes long, but for now I only read in one byte since I have yet to see
         *                            multiple byte delta times in a GH song.  Will fix this later
         *          ff : Event - A midi event.  Refer to the midi reference.  If it is 0xFF, it's a meta event, otherwise a normal command.
         */
        private void readTrack(int track, BinaryReader midi)
        {
            // Verify the track header matches and get track length
            for (int i = 0; i < TRACK_HEADER.Length; i++)
            {
                if (midi.ReadByte() != TRACK_HEADER[i])
                {
                    throw new FormatException("Invalid Midi File - Track Header incorrect" + TRACK_HEADER[i].ToString());
                }
            }

            byte[] length = new Byte[4];
            //THIS LENGTH IS NOT VERIFIED
            length = midi.ReadBytes(4);
            long fullDelta = 0;

            // Read the midi events
            do
            {
                NOTE n = new NOTE();

                //delta-time: execute the midi-event after this number of ticks
                n.delta = readVariableLength(midi);
                //total number of ticks?
                fullDelta      += n.delta;
                n.absoluteTicks = fullDelta;

                //META or COMMAND. Assuming that there's no omissision of the command itself, which would have meant "execute the last command again"
                byte flag = midi.ReadByte();
                if (flag == 0xFF)
                {
                    /* Meta Event.  All meta events have the format 0xFF xx nn dd
                     *  xx : The meta command
                     *  nn : The length of data associated with the command
                     *  dd x nn : The data
                     */
                    n.type = TYPE.META;

                    n.value = midi.ReadByte();

                    switch (n.value)
                    {
                    //SET TEMPO EVENT
                    case 0x51:
                        n.tempo     = readInt24(midi);
                        n.eventName = "TEMPO    ";
                        NOTE t = new NOTE();
                        t.delta         = fullDelta;
                        t.absoluteTicks = fullDelta;
                        t.tempo         = n.tempo;
                        tempos.Add(t);
                        break;

                    //0x58 could be interesting:time signature
                    case 0x58:
                        n.data = midi.ReadString();
                        char[] timesigData           = n.data.ToCharArray();
                        int    numerator             = timesigData[0];
                        int    denominator           = timesigData[1];
                        int    ticksPerClick         = timesigData[2];
                        int    thirtySecondToQuarter = timesigData[3];
                        n.data = String.Format("{0}/{1}, {2}, {3}",
                                               numerator,
                                               denominator,
                                               ticksPerClick,
                                               thirtySecondToQuarter
                                               );
                        n.eventName = "TIMESIG  ";
                        //n.data = midi.ReadString().Length.ToString();
                        break;

                    default:
                        //does this work for all cases? Does it get all the bytes? Are they readable?
                        n.data = midi.ReadString();
                        break;
                    }

                    //SEQUENCE OR TRACK NAME
                    //This could probably be a Dictionary.
                    if (n.value == 0x00)
                    {
                        n.eventName = "TRACKSEQ ";
                    }
                    else if (n.value == 0x01)
                    {
                        n.eventName = "TEXTANY  ";
                    }
                    else if (n.value == 0x02)
                    {
                        n.eventName = "TEXTCOPY ";
                    }
                    else if (n.value == 0x03)
                    {
                        midi_data.trackNames[track] = n.data;
                        if (n.data == "PART GUITAR")
                        {
                            guitarTrackIndex = track;
                        }
                        else if (n.data == "PART BASS")
                        {
                            bassTrackIndex = track;
                        }
                        n.eventName = "TRACKNAME";
                    }
                    else if (n.value == 0x04)
                    {
                        n.eventName = "INSTNAME ";
                    }
                    else if (n.value == 0x05)
                    {
                        n.eventName = "LYRIC    ";
                    }
                    else if (n.value == 0x06)
                    {
                        n.eventName = "MARKER   ";
                    }
                    else if (n.value == 0x07)
                    {
                        n.eventName = "CUEPOINT ";
                    }
                    else if (n.value == 0x59)
                    {
                        n.eventName = "KEYSIG   ";
                    }
                    else if (n.value == 0x7F)
                    {
                        n.eventName = "SEQUENCER";
                    }
                    //END OF TRACK
                    if (n.value == 0x2F)
                    {
                        return;
                    }
                }
                else
                {
                    n.type = TYPE.COMMAND;

                    //top 4 bits of first byte is the command
                    int cmd = flag >> 4;
                    //last 4 bits is the channel number
                    n.channel = flag & 0x0F;

                    switch (cmd)
                    {
                    case 0x08:     // Note OFF.  Followed by note number and velocity
                        n.value    = 0;
                        n.data     = String.Format("Note off heard for note number {0}", midi.ReadByte());
                        n.velocity = midi.ReadByte();
                        break;

                    case 0x09:     // Note ON.  Followed by note number and velocity
                        // WHY NO DATA SET HERE?
                        n.value    = midi.ReadByte();
                        n.data     = "Note ON";
                        n.velocity = midi.ReadByte();
                        break;

                    case 0x0A:     // Key after-touch.  Followed by Note Number and Velocity
                        n.value    = 0;
                        n.data     = "BAD CMD: Key after-touch";
                        n.value    = midi.ReadByte();
                        n.velocity = midi.ReadByte();
                        break;

                    case 0x0B:     // Control Change. Followed by controller number and new value
                        n.value    = 0;
                        n.data     = "BAD CMD: Control Change";
                        n.value    = midi.ReadByte();
                        n.velocity = midi.ReadByte();
                        break;

                    case 0x0C:     // Program (patch) change). Followed by new program name
                        n.value = 0;
                        n.data  = "BAD CMD: Program change";
                        n.value = midi.ReadByte();
                        break;

                    case 0x0D:     // Channel after-touch. Followed by channel number
                        n.value = 0;
                        n.data  = "BAD CMD: Channel after-touch";
                        n.value = midi.ReadByte();
                        break;

                    case 0x0E:     // Pitch wheel change followed by 2 bytes of value
                        n.value    = 0;
                        n.data     = "BAD CMD: Pitch wheel";
                        n.value    = midi.ReadByte();
                        n.velocity = midi.ReadByte();
                        break;

                    default:
                        n.value = 0;
                        n.data  = String.Format("Unknown command {0:X}", cmd);
                        break;
                    }
                }

                midi_data.tracks[track].Add(n);
            } while (true);
        }
示例#32
0
 static void AddMidi(AdlivMidi.MidiTrack track, NOTEL notel, NOTE note)
 {
     track.AddNote(notel, note, 64);
 }