Ejemplo n.º 1
0
        // returns new time cursor
        public int Write(int timeCursor, MidiWriter mw)
        {
            if (letterName.Is(LN.NA))
            {
                return(timeCursor);
            }

            // pitch
            int p = GetMidiPitchValue();

            mw.WriteMidiNumber((ushort)(offset - timeCursor));
            mw.WriteByte(0x90);

            System.Diagnostics.Debug.Assert(p <= 0x7f);
            mw.WriteByte((byte)p);

            System.Diagnostics.Debug.Assert(volume <= 0x7f);
            mw.WriteByte((byte)volume);

            // stop note
            mw.WriteMidiNumber((ushort)(length));
            mw.WriteByte(0x90);
            mw.WriteByte((byte)p);
            mw.WriteByte((byte)0);

            return(offset + length);
        }
Ejemplo n.º 2
0
        public void Write(BinaryWriter a)
        {
            MidiWriter mw = new MidiWriter(a);

            int timeCursor = 0;

            foreach (Note n in noteList)
            {
                timeCursor = n.Write(timeCursor, mw);
            }
        }
Ejemplo n.º 3
0
        public void WriteTrackHeader(int partDataBytes, BinaryWriter a)
        {
            MidiWriter mw = new MidiWriter(a);

            mw.WriteByte((byte)'M');
            mw.WriteByte((byte)'T');
            mw.WriteByte((byte)'r');
            mw.WriteByte((byte)'k');

            // trackData = partData + trackFooter(4 bytes)
            mw.WriteBE4(partDataBytes + 4);
        }
Ejemplo n.º 4
0
        public void WriteMidiHeader(BinaryWriter a)
        {
            MidiWriter mw = new MidiWriter(a);

            mw.WriteByte((byte)'M');
            mw.WriteByte((byte)'T');
            mw.WriteByte((byte)'h');
            mw.WriteByte((byte)'d');

            mw.WriteBE4(6);
            mw.WriteBE2(1);
            mw.WriteBE2(nTrack);
            mw.WriteBE2(tempo);
        }
Ejemplo n.º 5
0
        public int CountMidiBytes(ref int timeCursorRW)
        {
            if (letterName.Is(LN.NA))
            {
                return(0);
            }

            int bytes =
                MidiWriter.CountMidiNumberBytes((ushort)(offset - timeCursorRW))
                + 3 +
                MidiWriter.CountMidiNumberBytes((ushort)(length))
                + 3;

            timeCursorRW = offset + length;
            return(bytes);
        }
Ejemplo n.º 6
0
        public void WriteTrackFooter(BinaryWriter a)
        {
            MidiWriter mw = new MidiWriter(a);

            mw.WriteBE4(0x00ff2f00);
        }