public void SplitNote(Note note, float percentage = 0.5f) { var(firstNote, secondNote) = NotesUtils.SplitNote(note, 0.5); beatmap?.Add(firstNote); beatmap?.Add(secondNote); beatmap?.Remove(note); }
public void TestSeparateNoteOtherProperty() { const double percentage = 0.3; var lyric = new Lyric { Singers = new[] { 0 }, }; var note = new Note { StartTime = 1000, Duration = 2000, StartIndex = 1, EndIndex = 2, Text = "ka", Display = false, Tone = new Tone(-1, true), ParentLyric = lyric }; // create other property and make sure other class is applied value. var(firstNote, secondNote) = NotesUtils.SplitNote(note, percentage); Assert.AreEqual(firstNote.StartTime, 1000); Assert.AreEqual(secondNote.StartTime, 1600); Assert.AreEqual(firstNote.Duration, 600); Assert.AreEqual(secondNote.Duration, 1400); testRemainProperty(firstNote, note); testRemainProperty(firstNote, note);
static void MoveMail(object source, System.Timers.ElapsedEventArgs e) { NotesUtils pNotesUtils = null; Console.WriteLine("Notes Move!"); System.Timers.Timer pp = (System.Timers.Timer)source; pp.Enabled = false; try { //pNotesUtils = new NotesUtils(pNotesSession, "mail9you/runstar", "mail\\费亚平.nsf"); pNotesUtils = new NotesUtils(pNotesSession, "mail9you/runstar", "mail\\netadmin.nsf"); if (pNotesUtils.OpenDataBase("netadmin", "12341234")) { if (pNotesUtils.MoveMailInfo()) { } else { Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("Notes Move Exception : " + pNotesUtils.Message); Console.ForegroundColor = ConsoleColor.Gray; Console.WriteLine(""); } } else { Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("Notes Connect Exception : " + pNotesUtils.Message); Console.ForegroundColor = ConsoleColor.Gray; Console.WriteLine(""); } } catch (Exception ex) { Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("Notes Save Exception : " + ex.Message); Console.ForegroundColor = ConsoleColor.Gray; Console.WriteLine(""); } finally { if (pNotesUtils != null) { pNotesUtils.Dispose(); } } pp.Enabled = true; }
static void SendAuLog(object source, System.Timers.ElapsedEventArgs e) { NotesUtils pNotesUtils = null; try { string str_sql = "SELECT * FROM Au_Log"; MSSQLOperate pSendLog = new MSSQLOperate(strAnalyse); pSendLog.Connect(false); pSendLog.ExecuteQuery(str_sql); pSendLog.GetResult(RecordStyle.DATASET); DataSet pSet = (DataSet)pSendLog.RecordData; string _str = null; if (pSendLog.AffectRow > 0) { for (int i = 0; i < pSendLog.AffectRow; i++) { for (int j = 0; j < pSet.Tables[0].Columns.Count; j++) { _str += pSet.Tables[0].Rows[i][j].ToString(); _str += "\a\t\a\t"; } _str += "\r\n"; } //pNotesUtils = new NotesUtils(pNotesSession, "mail9you/runstar", "mail\\费亚平.nsf"); pNotesUtils = new NotesUtils(pNotesSession, "mail9you/runstar", "mail\\netadmin.nsf"); if (pNotesUtils.OpenDataBase("黄恒泰", "12341234")) { pNotesUtils.SendMailInfo("", "", "Au日志", _str); } } } catch { } finally { if (pNotesUtils != null) { pNotesUtils.Dispose(); } } }
public void TestSeparateNoteTime(double[] time, double percentage, double[] firstTime, double[] secondTime) { var note = new Note { StartTime = time[0], Duration = time[1], }; try { var(firstNote, secondNote) = NotesUtils.SplitNote(note, percentage); Assert.AreEqual(firstNote.StartTime, firstTime[0]); Assert.AreEqual(firstNote.Duration, firstTime[1]); Assert.AreEqual(secondNote.StartTime, secondTime[0]); Assert.AreEqual(secondNote.Duration, secondTime[1]); } catch { Assert.IsNull(firstTime); Assert.IsNull(secondTime); } }
void ProccessNotes(List <double> data) { var filterRange = 10; var myData = data.ToList(); data.RemoveRange(300, data.Count - 300); var firstIndex = myData.MaxIndex(); ArrayUtils.RemovePeakNeighbours(myData, firstIndex, filterRange); var secondIndex = myData.MaxIndex(); ArrayUtils.RemovePeakNeighbours(myData, secondIndex, filterRange); var thirdIndex = myData.MaxIndex(); var firstFreq = (firstIndex + 1) * SAMPLE_RATE / FFT_SIZE; var secondFreq = (secondIndex + 1) * SAMPLE_RATE / FFT_SIZE; var thirdFreq = (thirdIndex + 1) * SAMPLE_RATE / FFT_SIZE; if (data[firstIndex] < 0.5) { firstFreq = secondFreq = thirdFreq = -1; } if (data[secondIndex] < 0.25) { secondFreq = thirdFreq = -1; } if (data[thirdIndex] < 0.125) { thirdFreq = -1; } Invoke(new MethodInvoker(delegate() { _newFirstNote = NotesUtils.ComputeNote(firstFreq); _newSecondNote = NotesUtils.ComputeNote(secondFreq); _newThirdNote = NotesUtils.ComputeNote(thirdFreq); var previousNote = NotesUtils.GetPrevoiusNote(_newFirstNote); var nextNote = NotesUtils.GetNextNote(_newFirstNote); actualNoteLabel.Text = _newFirstNote.FullNoteName; previusNoteLabel.Text = previousNote.FullNoteName; nextNoteLabel.Text = nextNote.FullNoteName; firstTrackBar.Value = 50 + _newFirstNote.DifferenceFromReference; if (Math.Abs(_newFirstNote.DifferenceFromReference) > 10) { firstTrackBar.BackColor = Color.Red; actualNoteLabel.ForeColor = Color.Red; } else { firstTrackBar.BackColor = Color.Green; actualNoteLabel.ForeColor = Color.Green; } firstFreqLabel.Text = "First freq: " + firstFreq.ToString() + " Hz"; secondFreqLabel.Text = "Second freq: " + secondFreq.ToString() + " Hz"; thirdFreqLabel.Text = "Thrid freq: " + thirdFreq.ToString() + " Hz"; })); }
static void CheckMail(object source, System.Timers.ElapsedEventArgs e) { NotesUtils pNotesUtils = null; Console.WriteLine("Notes Check:"); System.Timers.Timer pp = (System.Timers.Timer)source; pp.Enabled = false; try { //pNotesUtils = new NotesUtils(pNotesSession, "mail9you/runstar", "mail\\费亚平.nsf"); pNotesUtils = new NotesUtils(pNotesSession, "mail9you/runstar", "mail\\netadmin.nsf"); if (pNotesUtils.OpenDataBase("netadmin", "12341234")) { if (pNotesUtils.GetMailInfo()) { MSSQLOperate pSaveMail = new MSSQLOperate(strAnalyse); CustomDataCollection pMailStruct = (CustomDataCollection)pNotesUtils.Records; CustomData[,] pMailInfo = pMailStruct[-1]; for (int i = 0; i < pMailStruct.RowCount; i++) { pSaveMail.Connect(false); string strProcParams = "SP_PUT_NOTESCONTENT"; DbParameter[] paramCache = DataUtilities.GetParameters(strProcParams); #region if (paramCache == null) { paramCache = new SqlParameter[] { new SqlParameter("@iFailure", SqlDbType.Int, 4), new SqlParameter("@iCategory", SqlDbType.Int, 4), new SqlParameter("@strUID", SqlDbType.VarChar, 100), new SqlParameter("@strPUID", SqlDbType.VarChar, 100), new SqlParameter("@strSubject", SqlDbType.VarChar, 100), new SqlParameter("@dtPost", SqlDbType.DateTime), new SqlParameter("@strSender", SqlDbType.VarChar, 50), new SqlParameter("@strRecive", SqlDbType.Text), new SqlParameter("@strContent", SqlDbType.Text), new SqlParameter("@strCount", SqlDbType.VarChar, 100), new SqlParameter("@iView", SqlDbType.Int, 4), new SqlParameter("@iGroup", SqlDbType.Int, 4) }; DataUtilities.SetParameters(strProcParams, paramCache); } paramCache[0].Value = 0; paramCache[1].Value = 0; paramCache[2].Value = pMailInfo[i, 0].Content; paramCache[3].Value = pMailInfo[i, 1].Content; paramCache[4].Value = pMailInfo[i, 2].Content; paramCache[5].Value = pMailInfo[i, 4].Content; paramCache[6].Value = pMailInfo[i, 3].Content; paramCache[7].Value = pMailInfo[i, 5].Content; paramCache[8].Value = pMailInfo[i, 6].Content; paramCache[9].Value = pMailInfo[i, 7].Content; paramCache[10].Value = 0; paramCache[11].Value = 2; #endregion pSaveMail.ExecuteQuery(false, strProcParams, paramCache); pSaveMail.GetResult(RecordStyle.NONE); } #region Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("Notes Recive Count : " + pMailStruct.RowCount); Console.ForegroundColor = ConsoleColor.Gray; Console.WriteLine(""); #endregion } else { #region Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("Notes Recive Exception : " + pNotesUtils.Message); Console.ForegroundColor = ConsoleColor.Gray; Console.WriteLine(""); #endregion } } else { #region Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("Notes Connect Exception : " + pNotesUtils.Message); Console.ForegroundColor = ConsoleColor.Gray; Console.WriteLine(""); #endregion } } catch (Exception ex) { #region Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("Notes Save Exception : " + ex.Message); Console.ForegroundColor = ConsoleColor.Gray; Console.WriteLine(""); #endregion } finally { if (pNotesUtils != null) { pNotesUtils.Dispose(); } } pp.Enabled = true; }