示例#1
0
        internal bool?Compare(clsCFPC cf, int seg)
        {
            //* compare key from this to key from txtkey - return true if the same
            clsKeyTicks algkey = Keys[seg];

            if (algkey == null)
            {
                return(null);
            }
            //algkey = algkey.Transpose(-cf.Transpose_File);
            int seglo = seg - ErrorMargin;
            int seghi = seg + ErrorMargin;

            for (int s = seglo; s <= seghi; s++)
            {
                if (s < 0 || s >= Keys.Count)
                {
                    continue;
                }
                int ticks = new clsMTime.clsBBT(s, 0, 0).Ticks;
                //int ticks = cf.MTime.GetTicks(s);
                clsKeyTicks txtkey = P.F.Keys[ticks];
                if (algkey.IsEquiv(txtkey))
                {
                    return(true);
                }
            }
            return(false);
        }
示例#2
0
        private void ChordsRawToRun()
        {
            //* convert ChordsRaw to ChordsRun
            string runningtxt = "#";

            for (int b = 0; b < BeatToBBT[NumBeats].Beats; b++) //BarToBBT includes bar after last (Numbars+1)
            {
                clsMTime.clsBBT bbt   = BeatToBBT[b];
                int             bar   = bbt.Bar;
                int             beat  = bbt.BeatsRemBar;
                clsChord        chord = ChordsRaw[bar, beat];
                string          txt   = chord.Txt;
                if (txt == null || txt == "")
                {
                    LogicError.Throw(eLogicError.X006, "txt = " + txt); //invalid beat (> NN) or not raw
                    ChordsRun[bar, beat] = new clsChord("", 0);
                }
                //if (txt != runningtxt || (beat == 0 && P.F.CF.Sections.Boundaries[bar])) {
                //if (txt != runningtxt || P.F.CF.QSections.FirstBeatName(bbt) != '*') {
                if (txt != runningtxt || (bar == 0 && beat == 0))
                {
                    ChordsRun[bar, beat] = chord.Copy();
                }
                else
                {
                    ChordsRun[bar, beat] = new clsChord("", 0);
                }
                runningtxt = txt;
            }
        }
示例#3
0
        //internal void CopyQI(int srcqi, int destqi) {
        //  //* copy one qi - no transpose or undo/redo (used by frmNoteMap.ChSymbols...)
        //  SetChordAndAtts(destqi, NewMap[srcqi], ChordAtt[srcqi]);
        //}

        internal bool PropagateNoteMapBeat(clsMTime.clsBBT bbt, string txt, int qilo, int qihi)
        {
            clsCFPC.clsEv ev; //temp ev
            try {
                ev = new clsCFPC.clsEvPC(P.F.CF, new string[] { "", txt });
            }
            catch (ChordFileException) { //invalid chord
                return(false);
            }
            ev.OnBBT  = bbt;
            ev.OffBBT = new clsMTime.clsBBT(bbt.Beats + 1, true); //one beat
            bool[] boolarray = new bool[12];
            foreach (clsCFPC.clsEv.clsNote note in ev.Notes)
            {
                boolarray[note.PC[eKBTrans.None]] = true;
            }
            for (int qi = qilo; qi < qihi; qi++) //was <=
            {
                int       root = (ev.Root) ? ev.Notes[0].PC[eKBTrans.None] : -1;
                sChordAtt att  = new sChordAtt(
                    (sbyte)root,
                    clsNoteMap.DescToPtr(ev.ChordQualifier));
                SetChordAndAtts(qi, boolarray, att);
                //if (qi == 9) qi = qi;  //temp debugging
            }
            return(true);
        }
示例#4
0
            internal clsWChord(clsMTime.clsBBT bbt, bool[] chord)
            {
                clsFileStream csvfileconv = P.F.frmChordMap.CSVFileConv;

                BBT   = bbt;
                Chord = chord;
            }
示例#5
0
            internal clsWChord(int qi, bool[] chord)
            {
                clsFileStream csvfileconv = P.F.frmChordMap.CSVFileConv;

                BBT   = new clsMTime.clsBBT(qi * P.F.TicksPerQI);
                Chord = chord;
            }
示例#6
0
 internal void Add(int midikey, string scale, int ticks)
 {
     //* called by loadmidifile
     if (Keys.Count > 0)
     {
         clsKeyTicks prevkey = Keys[Keys.Count - 1];
         //if (ticks < prevkey.Ticks) throw new FatalException();
         if (ticks < prevkey.Ticks)
         {
             LogicError.Throw(eLogicError.X081);
             return;
         }
         clsMTime.clsBBT bbt = new clsMTime.clsBBT(ticks); //should have (partial) mtime created by now
         if (bbt.TicksRemBeat != 0)
         {
             LogicError.Throw(eLogicError.X104, "key ticks not aligned to bar");
             clsMTime.clsBBT bbtbar = new ChordCadenza.clsMTime.clsBBT(bbt.Bar, 0, 0);
             ticks = bbtbar.Ticks;
         }
         if (ticks == prevkey.Ticks)
         {
             //* replace key, but retain ticks
             Keys.RemoveAt(Keys.Count - 1);
             Keys.Add(new clsKeyTicks(midikey, scale, prevkey.Ticks));
             return;
         }
     }
     Keys.Add(new clsKeyTicks(midikey, scale, ticks));
     Finish();
 }
        //private delegate void delegUpdatePos();
        //private delegRefreshBBT dUpdatePos;
        internal void FinalizeStop(bool indpause) //called by callback or cmdStop
        {
            _indMP3Playing = false;
            MP3Player.RemovePosSync();
            MP3Player.RemoveEndSync();
            P.F.frmAutoSync?.StopPlay();
            MidiPlay.Sync.CallBack(clsSync.eMidiMsgType.StreamEnded);
            //SetCmdRecordInactive();
            //if (Cmd != eCmd.Play && P.frmStart.chkAutoSyncMerge.Checked) MergeElapsed();
            P.frmSC.Invoke(dStreamEnd);
            int startbar;

            //if (P.frmStart.chkNoAudioSync.Checked) CurrentBBT = P.F.CurrentBBT.Copy();
            if (!StaticAudioSyncEna)
            {
                CurrentBBT = P.F.CurrentBBT.Copy();
            }
            if (indpause)
            {
                int beat = CurrentBBT.Beats - 1;
                if (beat < 0)
                {
                    beat = 0;
                }
                if (Elapsed.Play.Count - 1 >= beat && Elapsed.Play[beat] == 0)
                {
                    Elapsed.GetPrevActive(beat, out beat);
                }
                startbar = new clsMTime.clsBBT(beat, true).Bar;
            }
            else
            {
                startbar = StartBar;
            }
            //int startbar = (indpause) ? CurrentBBT.Bar : StartBar;
            CurrentBBT = new clsMTime.clsBBT(startbar, 0, 0);
            //RefreshBBT();
            P.frmSC.Play?.NewReset();
            P.frmSC.BeginInvoke(new delegRefreshBBTNoParam(Forms.frmStart.RefreshBBT));
            //if (P.F.frmAutoSync != null) {
            //P.F.frmAutoSync.BeginInvoke(
            //  new delegUpdatePos(P.F.frmAutoSync.UpdatePos), MP3Player.GetStartPosUnits());
            P.frmPCKBIn?.Invoke(new clsSync.delegClosefrmPCKBIn(P.frmPCKBIn.Close));
            if (indpause)
            {
                if (Elapsed.Play.Count - 1 >= CurrentBBT.Beats)
                {
                    long pos = Elapsed.Play[CurrentBBT.Beats];
                    P.frmSC.BeginInvoke(
                        new delegUpdatePos(UpdatePos), pos);
                }
            }
            else
            {
                P.frmSC?.Play?.Reset();
                P.frmSC.BeginInvoke(
                    new delegUpdatePos(UpdatePos), MP3Player.GetStartPosUnits());
            }
            //}
        }
示例#8
0
            internal clsEvPC(clsCFPC chordfile, clsMTime.clsBBT onbbt, bool[] chord, List <int> chnotes) //create from notemap etc.
            //* chnotes optional
            {
                CF    = chordfile;
                OnBBT = onbbt;
                if (chnotes == null || chnotes.Count == 0)
                {
                    chnotes = new List <int>();
                    Root    = false;
                    for (int i = 0; i < 12; i++)
                    {
                        if (chord[i])
                        {
                            chnotes.Add(i);
                        }
                    }
                }
                else
                {
                    Root = true;
                }
                List <clsNotePC> listnpw = new List <clsNotePC>();

                foreach (int n in chnotes)
                {
                    listnpw.Add(new clsNotePC(n));
                }
                _Notes = listnpw.ToArray();
            }
示例#9
0
 internal void RefreshBBT(clsMTime.clsBBT bbt)
 {
     if (Forms.frmSC.MenuMonitor /*&& clsPlay.PlayExists()*/)
     {
         lock (clsPlay.MonitorTimes) {
             StopWatch.Reset();
             StopWatch.Start();
             clsPlay.MonitorTimes.Add(int.MinValue);
             //int cnt = GC.CollectionCount(2);
             clsPlay.GCCnt0.Add(GC.CollectionCount(0));
             clsPlay.GCCnt1.Add(GC.CollectionCount(1));
             clsPlay.GCCnt2.Add(GC.CollectionCount(2));
         }
     }
     if (Cfg.LatencyMidiPlay <= 0)
     {
         P.frmSC.BeginInvoke(new delegBBT(Forms.frmStart.RefreshBBT), bbt);
     }
     else
     {
         BBTQueue.Enqueue(bbt.Copy());
         RefreshBBTTimer.Interval = Cfg.LatencyMidiPlay;
         RefreshBBTTimer.Start();
     }
 }
示例#10
0
        //internal static clsAutoSync New(string chtfilepath) {  //load chtfilepath
        //  if (!File.Exists(chtfilepath)) return null;
        //  List<string> lines = Utils.ReadLines(chtfilepath);
        //  try {
        //    if (lines.Count == 0) return null;  //empty file
        //    //if (lines[0] == "#Sections") {
        //    if (lines[0].Trim().Contains(" ")) {  //sections (2 integers)
        //      return new clsAutoSyncSection(chtfilepath, lines);
        //      //} else if (lines[0] == "#Bars") {
        //    } else {  //bars (1 integer)
        //      return new clsAutoSyncBar(chtfilepath, lines);
        //    }
        //    //} else {
        //    //  return null;  //invalid header on .cht file
        //    //}
        //  }
        //  catch {  //eg invalid .cht file
        //    MessageBox.Show("Invalid or missing .cht file");
        //    return null;
        //  }
        //}

        protected void BaseConstructor() //was internal clsAutoSync() {  //called from load
        //if (P.F.CHPFilePath.Length == 0) return;
        //clsMTime.clsBBT maxbbt = new clsMTime.clsBBT(P.F.MaxTicks);
        //MaxBar = maxbbt.Bar;
        //MaxBeatMidi = maxbbt.Beats;
        //MaxBar = P.F.MaxBBT.Bar;
        {
            MaxBeatMidi = P.F.MaxBBT.Beats;

            int capacity = (int)P.frmStart.nudUndoRedoCapacity.Value;

            UndoStack = new LLStack <clsElapsed>(capacity);
            RedoStack = new LLStack <clsElapsed>(capacity);

            CurrentBBT = new clsMTime.clsBBT(StartBar, 0, 0);
            if (P.F.BarPaneBBTLo == null)
            {
                P.F.BarPaneBBTLo = new clsMTime.clsBBT(0);
            }
            if (P.F.BarPaneBBTHi == null)
            {
                P.F.BarPaneBBTHi = new clsMTime.clsBBT(0);
            }
            dStreamEnd = new delegStreamEnd(P.frmStart.StreamPlayOffAll);
        }
示例#11
0
        private static void DumpScores(StreamWriter xsw, int showcount, clsKey mkey, clsMTime.clsBBT bbt,
                                       List <clsScore> ret, string inchordstr)
        {
            //int ShowCount = 9;
            if (showcount < 0)
            {
                showcount = int.MaxValue;
            }
            xsw.WriteLine(""); //delimit bbt entries
            if (bbt != null)
            {
                xsw.WriteLine("BBT: " + bbt.ToString());
            }
            xsw.WriteLine("InChord: " + inchordstr);
            xsw.WriteLine("Key: " + mkey.KeyStrLong);
            xsw.WriteLine("MaxType: " + MaxType);
            xsw.WriteLine("MaxNotes: " + MaxNotes);

            //* print header
            xsw.WriteLine(Fmt, "Agg", "Scr", "RKD", "Typ", "Len", "Chr", "TI", "RT", "Name", "Notes");
            if (indFlush)
            {
                xsw.Flush();
            }

            for (int i = 0; i < showcount && i < ret.Count; i++)
            {
                clsScore sc = ret[i];
                //foreach (clsScore sc in ret) {
                xsw.Write(Fmt,
                          sc.Agg,
                          sc.Score,
                          sc.COFRootKeyDistance,
                          //Templates[sc.TIndex].Rank,
                          //Templates[sc.TIndex].Length,
                          FileSeqToTemplate[sc.TIndex].Rank,
                          FileSeqToTemplate[sc.TIndex].Length,
                          sc.ChromaticNotes,
                          sc.TIndex,
                          GetNoteName(sc.Root, mkey),
                          sc.Desc,
                          "");

                for (int n = 0; n < 12; n++)
                {
                    //if (Templates[sc.TIndex].PC[n]) {
                    if (FileSeqToTemplate[sc.TIndex].PC[n])
                    {
                        xsw.Write(GetNoteName(n + sc.Root, mkey) + " ");
                    }
                }
                //if (sc.Dup) xsw.Write("***");
                xsw.WriteLine("");
            }
            if (indFlush)
            {
                xsw.Flush();
            }
        }
示例#12
0
 private void ResetSW(clsMTime.clsBBT bbt)
 {
     TempoFactor       = P.frmStart.TempoFactor;
     FactoredMidiTempo = clsFileStream.clsPlay.FactorMidiTempo(FileStream, MidiTempo);
     P.frmSC.BeginInvoke(dUpdateTempo, FactoredMidiTempo, bbt.Ticks);
     SW.Restart();
     //PIStart = bbt.Ticks / P.F.TicksPerPI;
     TicksStart = bbt.Ticks;
 }
示例#13
0
 private void MidiPlayTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
 {
     if (BBTQueue.Count == 0)
     {
         return;
     }
     clsMTime.clsBBT bbt = BBTQueue.Dequeue();
     P.frmSC.BeginInvoke(new delegBBT(Forms.frmStart.RefreshBBT), bbt);
 }
示例#14
0
 internal void ShowDGVCells(DataGridView dgv)
 {
     for (int bar = 0; bar < NumBars; bar++)
     {
         clsMTime.clsBBT  bbt  = new clsMTime.clsBBT(bar, 0, 0);
         DataGridViewCell cell = dgv.Rows[0].Cells[bar];
         cell.Value = GetBarText(bar);
     }
 }
示例#15
0
 private void PopulateDGV(int beatfrom, int beatto)
 {
     for (int b = beatfrom; b < beatto; b++)
     {
         clsMTime.clsBBT  bbt  = BeatToBBT[b];
         int              bar  = bbt.Bar;
         int              beat = bbt.BeatsRemBar;
         DataGridViewCell cell = DGV.Rows[beat].Cells[bar];
         cell.Value = ChordsRun[bar, beat];
     }
 }
示例#16
0
 private void OnEnd(int syncHandle, int channel, int data, IntPtr user)
 {
     lock (AudioSync) {
         EndSyncHandle          = 0;
         MidiPlay.Sync.indPause = false;
         AudioSync.FinalizeStop(false);
         CurrentBBT = new clsMTime.clsBBT(P.F.StartBar, 0, 0);
         P.frmSC.Play?.NewReset();
         AudioSync.RefreshBBT();
     }
 }
示例#17
0
            }                            //clone for different time

            internal clsEvPC(clsCFPC cf, clsMTime.clsBBT onbbt, string[] ll)
                : this(cf, ll) //read .chp lines
            {
                OnBBT = onbbt;
                int ontime = onbbt.Ticks;

                if (ontime < 0)
                {
                    throw new ChordFileException();
                }
            }
示例#18
0
            internal clsMTime.clsBBT GetNextActiveBBT(clsMTime.clsBBT bbt)
            {
                int inbeat = bbt.Beats;
                int?outbeat;

                if (!GetNextActive(inbeat, out outbeat).HasValue)
                {
                    return(null);
                }
                return(new clsMTime.clsBBT(outbeat.Value, true));
            }
示例#19
0
        private void ChordsRawToNoteMap(clsChord[,] copy)
        {
            //* update notemap with chord changes
            for (int b = 0; b < NumBeats; b++)
            {
                clsMTime.clsBBT bbt   = BeatToBBT[b];
                int             bar   = bbt.Bar;
                int             beat  = bbt.BeatsRemBar;
                clsChord        chord = ChordsRaw[bar, beat];
                if (chord.Txt == "***")
                {
                    continue;
                }
                if (copy[bar, beat].IsEquiv(chord))
                {
                    continue;
                }
                string txt = chord.Txt;

                //* transpose if necessary
                //int diff = (Frm.ChordTransposeNamesVal - Frm.ChordTransposeNotesVal).Mod12();
                int diff = Frm.TransposeChordNamesVal;
                if (diff != 0 && txt != "null")
                {
                    string qualifier;
                    int    pc = NoteName.GetPitchAndQualifier(chord.Txt, out qualifier);
                    if (pc < 0)
                    {
                        LogicError.Throw(eLogicError.X007, "pc = " + pc);
                        pc = 0;
                    }
                    pc  = Frm.ChordTransposeReverse(pc);
                    txt = NoteName.PitchToKeyStr(pc, P.F.Keys[0].Scale).TrimEnd() + qualifier;
                }

                int qilo = bbt.Ticks / P.F.TicksPerQI;
                int qihi = new clsMTime.clsBBT(b + 1, true).Ticks / P.F.TicksPerQI;
                if (qihi > P.F.MaxBBT.QI)
                {
                    break;                //???
                }
                string dottxt = (chord.Txt == "null") ? "null" : "." + txt;
                if (!P.F.CF.NoteMap.PropagateNoteMapBeat(bbt, dottxt, qilo, qihi))
                {
                    LogicError.Throw(eLogicError.X008);
                    P.F.CF.NoteMap.PropagateNoteMapBeat(bbt, "null", qilo, qihi);
                }
            }

            //Frm.picNoteMapFile.Refresh();
            Frm.RefreshpicNoteMapFile();
        }
示例#20
0
 private void OnPos(int syncHandle, int channel, int data, IntPtr user)
 {
     lock (AudioSync) {
         if (PosSyncHandle == 0)
         {
             return;              //set to zero by RemovePosSync()
         }
         PosSyncHandle = 0;
         //Debug.WriteLine("clsMP3Bass: OnPos: Beats = " + CurrentBBT.Beats);
         if (CurrentBBT.Beats >= Elapsed.Play.Count)
         {
             //PlayableForms.CmdState_Stopped();
             //MidiPlay.Sync.indPause = false;
             //AudioSync.Stop();
             return;
         }
         long userpos = user.ToInt64();
         if (Elapsed.Play[CurrentBBT.Beats] != userpos)
         {
             //* should not happen!!!
             //Debug.WriteLine("clsMP3Bass: OnPos: Beats = " + CurrentBBT.Beats
             //  + " currentpos = " + Elapsed.Play[CurrentBBT.Beats]
             //  + " userpos = " + userpos);
             int newbeat = CurrentBBT.Beats;
             //* try to get actual beat corresponding to userpos
             while (Elapsed.Play[newbeat] > userpos)
             {
                 newbeat--;
             }
             while (Elapsed.Play[newbeat] < userpos)
             {
                 newbeat++;
             }
             if (newbeat != CurrentBBT.Beats)
             {
                 CurrentBBT = new clsMTime.clsBBT(newbeat, true);
             }
         }
         if (clsAudioSync.Cmd == clsAudioSync.eCmd.PlayAndRecord &&
             CurrentBBT.Beats >= P.F.BarPaneBBTLo.Beats) //wait for switchkey
         {
             RemovePosSync();
             return;
         }
         long sigpos = OnMP3Timer();
         if (sigpos <= 0)
         {
             return;
         }
         SetPosSync(sigpos);
     }
 }
示例#21
0
            internal clsEvPC(clsCFPC chordfile, clsMTime.clsBBT onbbt, bool[] chord, int root) //create from notemapCF
            {
                CF    = chordfile;
                OnBBT = onbbt;
                List <int>       notelist = ConvBoolArrayToListInt(root, chord, out Root);
                List <clsNotePC> listnpw  = new List <clsNotePC>();

                foreach (int n in notelist)
                {
                    listnpw.Add(new clsNotePC(n));
                }
                _Notes = listnpw.ToArray();
            }
示例#22
0
        //private clsMTime.clsBBT BarPaneBBTLo {
        //  get { return P.F.BarPaneBBTLo; }
        //}

        //private clsMTime.clsBBT BarPaneBBTHi {
        //  get { return P.F.BarPaneBBTHi; }
        //}

        protected long OnMP3Timer()
        {
            AudioSync.RefreshBBT();
            int?beat = Elapsed.GetNextActiveBeat(CurrentBBT.Beats);

            if (!beat.HasValue)
            {
                return(-1);
            }
            long nextpos = Elapsed.Play[beat.Value];

            CurrentBBT = new clsMTime.clsBBT(beat.Value, true); //refreshBBT on next OnMP3Timer call
            return(nextpos);
        }
示例#23
0
 protected void Copy(clsEv ev)
 {
     //CF = ev.CF;
     CopyCF(ev);
     //Notes = ev.Notes.ToArray();  //OnBBT or OFFBBT may be changed
     CopyNotes(ev.Notes.ToArray());
     Root           = ev.Root;
     ChordQualifier = ev.ChordQualifier;
     BassNote       = ev.BassNote;
     OnBBT          = ev.OnBBT.Copy();
     OffBBT         = ev.OffBBT.Copy();
     PlayChord      = ev.PlayChord;
     //AltEv = ev.AltEv;
 }
示例#24
0
        private void ReadStreamChord(out List <byte> bytes, out clsMTime.clsBBT bbtbeat)
        {
            //* read Strm until pitime changes
            clsFileStream.clsEvStrm ev = Strm[StrmPos];
            int ticks = ev.Ticks;

            bytes   = new List <byte>(36);
            bbtbeat = null;
            //Debug.WriteLine("clsQIPlay.ReadStrm: QIThis = " + QIThis);
            while (ev.Ticks == ticks)
            {
                if (!clsFileStream.clsPlay.BypassEv(FileStream, Mute, ev)) //muted evs etc.
                //* process evtempo/evshort msgs for current ticks/qi
                {
                    if (ev is clsFileStream.clsEvBeat)
                    {
                        bbtbeat = ((clsFileStream.clsEvBeat)ev).BBT;
                    }
                    else if (ev is clsFileStream.clsEvTempo)
                    {
                        MidiTempo   = ((clsFileStream.clsEvTempo)ev).MidiTempo;
                        TempoFactor = -1; //force tmepo recalc
                    }
                    else if (ev is clsFileStream.clsEvShort)
                    {
                        ev = ev.Transpose();
                        clsFileStream.clsEvShort evshort = (clsFileStream.clsEvShort)ev;
                        if (bytes == null)
                        {
                            bytes = new List <byte>(36);
                        }
                        bytes.Add(0); //deltatime - always zero (ignored by BASS_MIDI_StreamEvents)
                        bytes.Add(evshort.Status);
                        bytes.Add(evshort.Msg);
                        int statuspre = (evshort.Status & 0xf0);
                        if (statuspre != 0xc0 && statuspre != 0xd0)
                        {
                            bytes.Add(evshort.Data);
                        }
                    }
                }
                if (++StrmPos >= Strm.Length)
                {
                    return;                    //return false;
                }
                ev = Strm[StrmPos];
            }
            //return (ev.PITime <= P.F.MaxPITime);
        }
示例#25
0
 public void SwitchKey()
 {
     lock (P.F.AudioSync) {
         if (!clsAudioSync.StaticMP3Playing || clsAudioSync.Cmd == clsAudioSync.eCmd.Play)
         {
             return;
         }
         if (clsBASSOutDev.Disconnected)
         {
             return;
         }
         long posbytes = GetPosBytes();
         using (new clsPlay.clsMonitor()) {
             if (clsAudioSync.indFirstSwitchKey) //assumes CurrentBBT.BeatRemBars = 0
             {
                 RemovePosSync();
                 Elapsed.ResetRecord();
                 //AutoSync.SetCmdRecordActive();
                 clsMTime.clsBBT bbt = P.F.BarPaneBBTLo;
                 if (clsAudioSync.Cmd == clsAudioSync.eCmd.PlayAndRecord &&
                     P.F.BarPaneBBTHi.Bar > P.F.BarPaneBBTLo.Bar &&
                     CurrentBBT.Beats == P.F.BarPaneBBTLo.Beats)
                 {
                     for (int b = P.F.BarPaneBBTLo.Beats; b <= P.F.BarPaneBBTHi.Beats; b++)
                     {
                         Elapsed.SetRecord(b, -1); //jump
                     }
                     bbt = P.F.BarPaneBBTHi;       //jump to this
                 }
                 Elapsed.SetRecord(bbt.Beats, posbytes);
                 CurrentBBT = bbt.Copy();
             }
             else
             {
                 //AutoSync.SetCmdRecordInactive();
                 CurrentBBT.NextBeat();
                 Elapsed.SetRecord(CurrentBBT.Beats, GetPosBytes());
                 indSave = true;
             }
         }
         clsAudioSync.indFirstSwitchKey = false;
         AudioSync.RefreshBBT();
         if (P.F.frmAutoSync != null)
         {
             P.F.frmAutoSync.BeginInvoke(new clsAudioSync.delegUpdateCurrentPos(P.F.frmAutoSync.UpdateCurrentPos));
         }
     }
 }
示例#26
0
        //internal void StartRecord(Form playform, clsFileStream filestream, clsMute mute) {
        //  if (P.F.FileStreamMM != null) P.F.FileStreamMM.InitRec();
        //  StartPlayRecord(playform, filestream, mute);
        //}

        //internal void StartPlay(Form playform, clsFileStream filestream, clsMute mute) {
        //  StartPlayRecord(playform, filestream, mute);
        //}

        internal void StartPlay(Form playform, clsFileStream filestream, clsMute mute)
        {
            //* called from form thread
            //if (PlayCmdOn) DebugPlay();  //already playing?
            PlayableForms.CmdState_Stopped(); //before play starts - in case it fails
            RefreshBBTTimer.Stop();
            BBTQueue.Clear();

            //if (P.F.AutoSync != null && (!P.F.MidiFileLoaded || !P.frmStart.chkPlayMidiPriority.Checked)) {
            if (MidiPlay.OutMStream == null)
            {
                return;
            }
            P.F.Mute.StartPlay();
            //if (P.F.CurrentBBT.Bar >= new clsMTime.clsBBT(P.F.MaxTicks).Bar - 2) return;  //don't start too near the end
            if (P.F.CurrentBBT.Bar >= P.F.MaxBBT.Bar - 2)
            {
                return;                                      //don't start too near the end
            }
            if (/*clsPlay.PlayExists() &&*/ Forms.frmSC.MenuMonitor)
            {
                clsPlay.InitStopwatch();
            }
            Forms.frmSC.ShowfrmPCKBIn();
            if (P.frmSC.Play != null)
            {
                P.frmSC.Play.BBTSwitch = null;
                P.frmSC.Play.NewReset();
            }
            ShowGCCollectionCounts("Start Play");
            P.F.WaitPlay  = new clsWaitPlay(filestream, MidiPlay.OutMStream, mute);
            StreamStartBB = P.F.CurrentBBT.Copy();
            BeatCount     = StreamStartBB.Bar;
            try {
                //lock (TimerLock) {
                P.F.WaitPlay.Start();
                //}
            }
            catch {
                DebugPlay();
                return;
            }

            //if (P.frmStart.chkPlaySustain.Checked) clsPlay.clsSustain.PlayPedalStatic(true);
            //clsPlayKeyboard.PlayNearestChordNote = P.frmStart.chkPlayKBChord.Checked;
            P.frmStart.StreamPlayOnAll();      //enable/disable StartPlay/StopPlay etc.
            P.frmStart.FormsStreamOnOff(true); //enable/disable controls (not StartPlay/StopPlay etc.)
        }
示例#27
0
            internal clsEvPC(clsCFPC chordfile, clsMTime.clsBBT onbbt, int[] chord) //BIAB, ManChords
            {
                CF    = chordfile;
                OnBBT = onbbt;
                Root  = true;
                List <clsNotePC> listnpw = new List <clsNotePC>();

                for (int i = 0; i < chord.Length; i++)
                {
                    clsNotePC npw = new clsNotePC();
                    //npw.PC_NoKBTrans = chord[i].Mod12();
                    npw.Set_PC_NoKBTrans(chord[i]);
                    listnpw.Add(npw);
                }
                _Notes = listnpw.ToArray();
            }
示例#28
0
        internal void InitDGV(Forms.IFrmDGV frm)
        {
            //if (NumBars == 0) NumBars = new clsMTime.clsBBT(P.F.MaxTicks).Bar + 1;
            if (frm == null)
            {
                return;
            }
            int vmult = 6;

            if (frm == P.frmSC)
            {
                vmult = 4;            //use less space
            }
            DataGridView dgv = frm.Prop_dgvLyrics;

            dgv.DoubleBuffered(true);
            //clsMTime.clsBBT bbtmax = new clsMTime.clsBBT(P.F.MaxTicks);
            //NumBars = bbtmax.Bar + 1;
            //bbtmax = new clsMTime.clsBBT(NumBars, 0, 0);
            BarToBBT = new clsMTime.clsBBT[NumBars + 1];
            for (int bar = 0; bar <= NumBars; bar++) //end at one after numbars
            {
                BarToBBT[bar] = new clsMTime.clsBBT(bar, 0, 0);
            }
            while (dgv.Rows.Count > 0)
            {
                dgv.Rows.RemoveAt(0);
            }
            dgv.DefaultCellStyle.Font = new Font("Microsoft Sans Serif", 8.25F, FontStyle.Regular);
            //dgv.Width = frm.panNoteMap.Width;
            dgv.Height        = ((int)dgv.DefaultCellStyle.Font.GetHeight()) * vmult + 10; //lines
            dgv.SelectionMode = DataGridViewSelectionMode.CellSelect;                      //to avoid error on reinit
            dgv.ColumnCount   = NumBars;
            SetColumnWidth(frm);
            //dgv.SelectionMode = DataGridViewSelectionMode.FullColumnSelect;
            DataGridViewRow row = new DataGridViewRow();

            row.Height = dgv.Height;
            for (int bar = 0; bar < NumBars; bar++)
            {
                DataGridViewTextBoxCell cell = new DataGridViewTextBoxCell();
                row.Cells.Add(cell);
            }
            dgv.Rows.Add(row); //this will reset P.F.CurrentBBT
            ShowDGVCells(dgv);
        }
示例#29
0
            //internal void AddTicks(int ticks) {
            //  //* if indoff, set for off evs only (extend chord)
            //  //* this should only be used on all events from a point in time
            //  OnBBT = new clsMTime.clsBBT(OnTime + ticks);
            //  OffBBT = new clsMTime.clsBBT(OffTime + ticks);
            //  foreach (clsNote note in Notes) {
            //    note.OnBBT = new clsMTime.clsBBT(note.OnBBT.Ticks + ticks);
            //    note.OffBBT = new clsMTime.clsBBT(note.OffBBT.Ticks + ticks);
            //    if (note.OffBBT.Ticks >= P.F.MaxBBT.Ticks) {
            //      clsMTime.clsBBT bbt = new clsMTime.clsBBT(note.OffBBT.Ticks);
            //      P.F.MaxTicks = bbt.GetNextBar().Ticks;
            //    }
            //  }
            //}

            internal bool SubTicks(int ticks)
            {
                //* this should only be used on all events from a point in time
                //* called from frmChordMap.DeleteBar()
                if (OnTime < ticks)
                {
                    return(false);
                }
                OnBBT  = new clsMTime.clsBBT(OnTime - ticks);
                OffBBT = new clsMTime.clsBBT(OffTime - ticks);
                foreach (clsNote note in Notes)
                {
                    note.OnBBT  = new clsMTime.clsBBT(note.OnBBT.Ticks - ticks);
                    note.OffBBT = new clsMTime.clsBBT(note.OffBBT.Ticks - ticks);
                }
                return(true);
            }
示例#30
0
        private clsKeyTicks GetKey(int s, int keynote)
        {
            string scale = "major";

            if (keynote > 11)
            {
                scale    = "minor";
                keynote -= 12;
            }
            int midikey = NoteName.PitchToMidiKey(keynote, scale, null);
            int ticks   = new clsMTime.clsBBT(s, 0, 0).Ticks;
            //int ticks = mtime.TicksPerBeat * mtime.TSigNN * s;
            clsKeyTicks key = new clsKeyTicks(midikey, scale, ticks);

            //if (frmCalcKeys.optKeysText.Checked) return key.Transpose(-frmCalcKeys.CF.Transpose_File);
            return(key);
        }