Example #1
0
        internal bool Bypass(clsFileStream.clsEvShort ev)
        {
            //* used by play stream to determine if ev should be bypassed
            int status = ev.Status & 0xf0;

            if (status != 0xb0 && status != 0xc0)
            {
                return(false);                             //retain
            }
            int chan = ev.Status & 0x0f;
            int ctlr;

            if (status == 0xc0)
            {
                ctlr = PatchCtlrNum;
            }
            else
            {
                ctlr = ev.Msg;
            }
            if (status == 0xb0 && ctlr == 0 && P.frmStart.chkFilterMidiBank.Checked)
            {
                return(true);
            }
            if (ctlr != PatchCtlrNum && ctlr >= 120)
            {
                return(true);                                //bypass realtime msgs
            }
            if (Override[ctlr] != null && Override[ctlr][chan] >= 0)
            {
                return(true);
            }
            return(false);
        }
Example #2
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);
        }
Example #3
0
 private void WriteChord(ref int prevticks, clsCF.clsEv evcf, int status, int ticks, byte vel)
 {
     foreach (clsCF.clsEv.clsNote note in evcf.Notes) //write ON evs
     {
         int pc = note.PC[eKBTrans.None] + 60;        //octave above middle C
         if (P.frmSaveMidiFileAs.chkChordRoot.Checked &&
             evcf.Root && evcf.Notes.Length > 1 &&
             pc < evcf.Notes[0].PC[eKBTrans.None] + 60)
         {
             pc += 12;
         }
         clsFileStream.clsEvStrm evstrm = new clsFileStream.clsEvShort(0, ticks, -1, (byte)status, (byte)pc, vel);
         WriteStrmMsg(ref prevticks, evstrm);
     }
 }
Example #4
0
        private void WriteTrack(clsTrks.T trk)
        {
            int prevticks = 0;

            using (stTrk = new MemoryStream()) {
                BinaryWriter br = new BinaryWriter(stTrk);
                MWriterTrk = new clsMWriter(br);
                string strtitle = (P.F.frmTrackMap == null || P.F.frmTrackMap.txtTitles[trk] == null) ?
                                  FS.Title[trk] : P.F.frmTrackMap.txtTitles[trk].Text;
                byte[] bytestitle = Encoding.ASCII.GetBytes(strtitle);
                clsFileStream.clsEvTitle evtitle = new clsFileStream.clsEvTitle(0, 0, -1, bytestitle); //trk param not used
                evtitle.WriteTitle(this, 0);

                //* write overriding controllers (vol, pan, patch)
                clsFileStream.clsEvShort evshort;
                bool indvol = false, indpan = false, indpatch = false;
                if (P.F.Chan[trk] >= 0)
                {
                    int  chan = P.F.Chan[trk];
                    byte vol  = (byte)P.F.Vol[chan];
                    if (vol <= 127)
                    {
                        indvol  = true;
                        evshort = new clsFileStream.clsEvShort(0, trk.TrkNum, (byte)(0xb0 | chan), 7, vol);
                        WriteStrmMsg(ref prevticks, evshort);
                    }
                    byte pan = (byte)P.F.Pan[chan];
                    if (pan <= 127)
                    {
                        indpan  = true;
                        evshort = new clsFileStream.clsEvShort(0, trk.TrkNum, (byte)(0xb0 | chan), 10, pan);
                        WriteStrmMsg(ref prevticks, evshort);
                    }
                    byte patch = (byte)P.F.Patch[chan];
                    if (patch <= 127)
                    {
                        indpatch = true;
                        evshort  = new clsFileStream.clsEvShort(0, 0, trk.TrkNum, (byte)(0xc0 | chan), patch);
                        WriteStrmMsg(ref prevticks, evshort);
                    }
                }

                foreach (clsFileStream.clsEvStrm ev in FS.Strm)
                {
                    if (ev.Trk != trk)
                    {
                        continue;
                    }
                    if (ev is clsFileStream.clsEvBeat)
                    {
                        continue;
                    }
                    if (ev is clsFileStream.clsEvShort)
                    {
                        clsFileStream.clsEvShort evsh = (clsFileStream.clsEvShort)ev;
                        int status = evsh.Status & 0xf0;
                        if (indvol && status == 0xb0 && evsh.Msg == 7)
                        {
                            continue;                                 //vol overriden
                        }
                        if (indpan && status == 0xb0 && evsh.Msg == 10)
                        {
                            continue;                                  //pan overriden
                        }
                        if (indpatch && status == 0xc0)
                        {
                            continue;                  //patch overriden
                        }
                    }
                    WriteStrmMsg(ref prevticks, ev);
                }
                WriteToFileStream(prevticks);
            }
        }
Example #5
0
        internal void PropagatePW(clsFileStream filestream, int len, clsTrks.T trk)
        {
            //* null trk = all trks
            //* initialize PB
            if (trk == null)
            {
                PB = new clsTrks.Array <short[]>(delegate() {
                    short[] pw = new short[len];
                    for (int i = 0; i < len; i++)
                    {
                        pw[i] = -1;
                    }
                    return(pw);
                });
            }
            else
            {
                PB[trk] = new short[len];
                for (int i = 0; i < len; i++)
                {
                    PB[trk][i] = -1;
                }
            }

            //* read stream
            clsFileStream.clsEvStrm[] strm = filestream.Strm;
            for (int i = 0; i < strm.Length; i++)
            {
                if (strm[i] is clsFileStream.clsEvShort)
                {
                    clsFileStream.clsEvShort ev = ((clsFileStream.clsEvShort)strm[i]);
                    if (trk != null && trk != ev.Trk)
                    {
                        continue;
                    }
                    if ((ev.Status & 0xe0) != 0xe0)
                    {
                        continue;                    //not pitchbend
                    }
                    int val = ev.Msg + (ev.Data << 7);
                    PB[ev.Trk][ev.QTime] = (short)val; //channel not used - only track
                }
            }

            //* propagate PB
            foreach (clsTrks.T t in PB.Next)
            {
                if (trk != null && trk != t)
                {
                    continue;
                }
                short pw = 8192; //centre (default)
                for (int qi = 0; qi < len; qi++)
                {
                    if (PB[t][qi] >= 0)
                    {
                        pw = PB[t][qi];        //set current value
                    }
                    PB[t][qi] = pw;
                }
            }
        }