internal void StartCmdSyncPlayAndRecord() { Cmd = eCmd.PlayAndRecord; if (!MP3Player.CheckCmdSync()) { return; } if (P.frmSC.Play != null) { P.frmSC.Play.BBTSwitch = null; } if (Forms.frmSC.MenuMonitor) { clsPlay.InitStopwatch(); } Forms.frmSC.ShowfrmPCKBIn(); lock (this) { _indMP3Playing = true; StartBar = P.F.CurrentBBT.Bar; indFirstSwitchKey = true; //clsPlay.indFirstSwitchChordBarBeat = true; UpdateUndo(); //could go in first SwitchKey() ... MP3Player.StartSync(); } }
private void Action(delAction action, eCmd cmd) //cmd note used? //if (P.F == null || AutoSync == null) return; { if (clsAudioSync.StaticMP3Playing) { return; } //int topindex = clbEla.TopIndex; if (cmd != eCmd.Undo && cmd != eCmd.Redo && cmd != eCmd.Merge) { AudioSync.UpdateUndo(); } action(cmd); //AutoSync.indSave = true; ShowList(); //clbEla.TopIndex = topindex; PlayableForms.CmdState_Stopped(); //possible Play.IsEmpty changed cmdSave.Enabled = (P.F.AudioSync != null && !P.F.AudioSync.IsEmpty()); //P.frmSC.mnuSaveAutoSyncFile.Enabled = cmdSave.Enabled; //* update Elapsed.Play display in bars panes if (P.F?.frmTrackMap != null) { P.F.frmTrackMap.picBars.Refresh(); } if (P.F?.frmChordMap != null) { P.F.frmChordMap.picBars.Refresh(); } clsAudioSync.SetPlayAudioText(P.F?.AudioSync); }
private void Register(eCmd cmd, Action<Message> fun) { if (m_MsgCallDic.ContainsKey(cmd)) { Debug.LogError("Msg Register Error. cmd repeated. cmd:" + cmd.ToString()); return; } m_MsgCallDic[cmd] = fun; }
//private void InitMP3Player() { //external // MP3Player = new clsMP3Ext(this); //} //Elapsed.MP3Resolution = (int)P.frmStart.nudMP3Res.Value * 1000; //if (Elapsed.Play.Count < 2 || Elapsed.Play[0] != 0) { // FinalizeStop(); // return; //} //CurrentBBT = P.F.CurrentBBT.Copy(); //int startbeat = CurrentBBT.Beats; ////int playstartbeat = (Elapsed.Play[startbeat] > 0) ? startbeat : Elapsed.GetPrevActiveBeat(startbeat); //long playstartpos = (Elapsed.Play[startbeat] > 0) ? // Elapsed.Play[startbeat] : Elapsed.GetPrevActivePos(startbeat); //clsMTime.clsBBT bbt = new MPlay.clsMTime.clsBBT(startbeat, true); //StartBar = bbt.Bar; //int? playsigbeat = Elapsed.GetNextActiveBeat(startbeat); //if (!playsigbeat.HasValue) { // FinalizeStop(); // return; //} //MP3Player.PlayFile(this, playstartpos, Elapsed.Play[playsigbeat.Value]); //wait for OnWMPTimer() trigger //if (P.F.frmAutoSync != null) P.F.frmAutoSync.UpdateCurrentPos(); ////indStartSync = true; //indMP3Playing = true; //P.frmStart.StreamPlayOnAll(); //enable/disable StartPlay/StopPlay etc. //P.frmStart.FormsStreamOnOff(true); //enable/disable controls (not StartPlay/StopPlay etc.) //CurrentBBT = new MPlay.clsMTime.clsBBT(playsigbeat.Value, true); //refreshBBT on next OnMP3Timer call ////Debug.WriteLine("AutoSyncBeat: StartSyncPlay: CurrentBBT.Beats = " + CurrentBBT.Beats); //return; //} internal void StartCmdSyncPlay() //play { Cmd = eCmd.Play; //indRecord = false; if (P.F.AudioSync != null) { if (!MP3Player.CheckCmdSync()) { return; } } if (P.frmSC.Play != null) { P.frmSC.Play.BBTSwitch = null; } Forms.frmSC.ShowfrmPCKBIn(); lock (this) { _indMP3Playing = true; StartBar = P.F.CurrentBBT.Bar; indFirstSwitchKey = true; //clsPlay.indFirstSwitchChordBarBeat = true; MP3Player.StartSync(); } }
// 构建一个发送包 public Message(eCmd _cmd) { m_cmd = _cmd; m_len = LEN_LEN + CMD_LEN; // START_LEN, END_LEN }
public bool Decode(byte[] bytes) { m_position = 0; Debug.Log("UnPackage 1:" + bytes.Length); // 验证头部 if (!CheckHead(bytes)) { return false; } m_position += START_LEN; // 获取长度 Debug.Log("UnPackage 2"); Len = DecodeLen(bytes); m_position += LEN_LEN; // 验证尾部 Debug.Log("UnPackage 3, m_len:" + Len); if (!CheckEnd(bytes)) { return false; } Debug.Log("UnPackage 4"); m_cmd = DecodeCmd(bytes); m_position += CMD_LEN; Debug.Log("UnPackage 5, cmd:" + (int)Cmd); Content = GetContent(bytes); return true; }