Esempio n. 1
0
        internal void CallBack(eMidiMsgType mtype, int?val, clsFileStream filestream, clsMTime.clsBBT BASSbbt)
        {
            //Debug.Write("*");
            //MTime = P.frmStart.GetMTime();
            //if (MTime == null) return;
            switch (mtype)
            {
            /* may want use in future???
             * case eMidiMsgType.Beat:  //from sustain pedal - beats only (no bars)
             * LocateBeat(BeatCount++);
             * break;
             */
            case eMidiMsgType.SPP:
                //* sent by Sonar
                //* not sent by BIAB
                //if (indPlayActive != ePlay.None) return;
                //if (indPlayActive == ePlay.SyncEnabled) indPlayActive = ePlay.SyncActive;
                MidiClockCount = val.Value * 6;
                Debug.WriteLine("Callback: SPP: MidiClockCount = " + MidiClockCount);
                StartMidiClockCount = MidiClockCount;
                int ticksspp = (MidiClockCount * P.F.MTime.TicksPerQNote) / P.F.MTime.MidiClocksPerQNote;
                RefreshBBT(new clsMTime.clsBBT(ticksspp));
                //LocateBeat(MidiClockCount / MTime.MidiClocksPerBeat);
                break;

            //case clsMidiIn.eMidiMsgType.BarBeat:  //midistream
            //  LocateBeat(BeatCount++);
            //  break;
            case eMidiMsgType.StreamBASS: //waitplay
                if (BASSbbt.TicksRemBeat == 0)
                {
                    RefreshBBT(BASSbbt);
                    //Debug.WriteLine("global refreshbbt = " + BASSbbt.ToStringBBT());
                    //P.F.frmTrackMap.FileStream.RecordBeatNM();
                    P.F.FSTrackMap.RecordBeatNM();
                }
                return;

            case eMidiMsgType.MidiClock: //external sequencer with start/stop/continue/clock
                if (indPlayActive != ePlay.SyncActive && indPlayActive != ePlay.SyncEnabled)
                {
                    return;
                }
                if (P.frmStart.chkMidiStartStop.Checked && indPlayActive != ePlay.SyncActive)
                {
                    return;
                }
                //if (filestream == null) {  //sync
                //  if (!P.frmStart.chkMidiStartStop.Checked) return;
                //  if (indPlayActive == ePlay.Stream) return;
                //}

                //{
                //  int ticks = (MidiClockCount * P.F.MTime.TicksPerQNote) / P.F.MTime.MidiClocksPerQNote;
                //  Debug.WriteLine("MidiClockCount = " + MidiClockCount
                //    + " Ticks = " + ticks
                //    + " QNotes*100 = " + (ticks * 100) / P.F.MTime.TicksPerQNote);
                //}

                int ticks = (MidiClockCount * P.F.MTime.TicksPerQNote) / P.F.MTime.MidiClocksPerQNote;
                if (ticks <= P.F.MaxBBT.Ticks)
                {
                    if (ticks >= 0)
                    {
                        clsMTime.clsBBT bbt = new clsMTime.clsBBT(ticks);
                        //if (bbt.TicksRemBeat == 0 && MidiClockCount > (StartMidiClockCount + LeadInClocks)) {
                        if (bbt.TicksRemBeat == 0 && MidiClockCount > StartMidiClockCount)
                        {
                            //P.F.CurrentBBT = bbt;
                            RefreshBBT(bbt);
                        }
                        Debug.WriteLine("Callback: MidiClock: MidiClockCount = " + MidiClockCount);

                        //if (((MidiClockCount % MTime.MidiClocksPerBeat) == 0)  //next beat
                        //&& (MidiClockCount > StartMidiClockCount + LeadInClocks)) {
                        //  LocateBeat(MidiClockCount / MTime.MidiClocksPerBeat);
                        //}
                    }
                    MidiClockCount++;
                }
                return;

            case eMidiMsgType.StreamEnded:
                if (!indPause)
                {
                    //P.F.CurrentBBT = new clsMTime.clsBBT(0);
                    P.frmSC.Play?.NewReset();
                    RefreshBBT(new clsMTime.clsBBT(P.F.StartBar, 0, 0));
                    indPause = true;
                }
                return;

            case eMidiMsgType.Stop:
                if (MidiPlay.MidiInSync != null)
                {
                    indPlayActive = ePlay.SyncEnabled;
                }
                return;

            case eMidiMsgType.Start:
                //* should only be called if starting from beginning of song
                //* BIAB sends this whenever song is started, from any position
                if (P.frmStart.chkMidiStartStop.Checked)
                {
                    if (indPlayActive == ePlay.SyncEnabled)
                    {
                        indPlayActive = ePlay.SyncActive;
                    }
                    //StartMidiClockCount = 0;
                    //LeadInClocks = P.F.MTime.GetTSig(0).MidiClocksPerBar * (int)P.frmStart.nudLeadInBars.Value;
                    //MidiClockCount = -LeadInClocks;
                    //P.F.CurrentBBT = new clsMTime.clsBBT(0);
                    //StartSync();
                }
                return;

            case eMidiMsgType.Continue: //does not appear to be sent by BIAB
                if (P.frmStart.chkMidiStartStop.Checked)
                {
                    if (indPlayActive == ePlay.SyncEnabled)
                    {
                        indPlayActive = ePlay.SyncActive;
                    }
                    StartSync();
                }
                return;
            }
        }
Esempio n. 2
0
 internal void CallBack(eMidiMsgType mtype, clsFileStream filestream)
 {
     //* called from stream
     CallBack(mtype, null, filestream, null);
 }
Esempio n. 3
0
 internal void CallBack(eMidiMsgType mtype, int val)
 {
     //* called from sync
     CallBack(mtype, val, null, null);
 }
Esempio n. 4
0
        //private void LocateTicks(int ticks) {
        //  RefreshBBT(new clsMTime.clsBBT(ticks));
        //}

        //private void LocateBeat(int beatnum) {
        //  RefreshBBT(new clsMTime.clsBBT(beatnum, true));
        //}

        internal void CallBack(eMidiMsgType mtype)
        {
            //* called from sync or beat pedal
            CallBack(mtype, null, null, null);
        }