Example #1
0
 public void ConvertToBinary(System.IO.BinaryWriter writer)
 {
     UtilBinary.WriteValue(writer, this.ChunkID);
     UtilBinary.WriteValue(writer, this.GetSizeInBytes());
     UtilBinary.WriteValue(writer, (ushort)this.FormatType);
     UtilBinary.WriteValue(writer, this.NumberOfTracks);
     UtilBinary.WriteValue(writer, this.PulsesPerQuarterNote);
 }
Example #2
0
 public override void ConvertToBinary(System.IO.BinaryWriter writer)
 {
     if (this.DataLength > 0)
     {
         base.ConvertToBinary(writer);
         UtilBinary.WriteValue(writer, this.Text.ToCharArray());
     }
 }
Example #3
0
 public override void ConvertToBinary(System.IO.BinaryWriter writer)
 {
     if (this.DataLength > 0)
     {
         base.ConvertToBinary(writer);
         UtilBinary.WriteValue(writer, this.MicroSecondsPerQuarterNote, 3);
     }
 }
 public override void ConvertToBinary(System.IO.BinaryWriter writer)
 {
     if (this.DataLength > 0)
     {
         base.ConvertToBinary(writer);
         UtilBinary.WriteValue(writer, this.Numerator);
         UtilBinary.WriteValue(writer, this.CalculateRawDenominator());
         UtilBinary.WriteValue(writer, this.MetronomePulse);
         UtilBinary.WriteValue(writer, this.ThirtySecondNotes);
     }
 }
Example #5
0
        //public static ChannelMidiEvent CreateNoteAfterTouchChannelMidiEvent(byte channel, byte noteNumber, byte aftertouchValue, uint deltaTime)
        //{
        //    return new ChannelMidiEvent(ChannelEventType.NoteAfterTouch, channel, noteNumber, aftertouchValue, deltaTime);
        //}

        //public static ChannelMidiEvent CreateControllerChannelMidiEvent(byte channel, byte controllerNumber, byte controllerValue, uint deltaTime)
        //{
        //    return new ChannelMidiEvent(ChannelEventType.Controller, channel, controllerNumber, controllerValue, deltaTime);
        //}

        //public static ChannelMidiEvent CreateProgramChangehannelMidiEvent(byte channel, byte programNumber, uint deltaTime)
        //{
        //    return new ChannelMidiEvent(ChannelEventType.ProgramChange, channel, programNumber, 0, deltaTime);
        //}

        //public static ChannelMidiEvent CreateChannelAftertouchChannelMidiEvent(byte channel, byte value, uint deltaTime)
        //{
        //    return new ChannelMidiEvent(ChannelEventType.ChannelAfterTouch, channel, value, 0, deltaTime);
        //}

        //public static ChannelMidiEvent CreatePitchBendChannelMidiEvent(byte channel, byte pitchValueLSB, byte pitchValueMSB, uint deltaTime)
        //{
        //    return new ChannelMidiEvent(ChannelEventType.PitchBend, channel, pitchValueLSB, pitchValueMSB, deltaTime);
        //}

        public override void ConvertToBinary(System.IO.BinaryWriter writer)
        {
            base.ConvertToBinary(writer);

            //if (this.Parameter2 == 0 && this.Type == ChannelEventType.NoteOn)
            //    UtilBinary.WriteValue(writer, UtilBinary.CombineBytes((byte)ChannelEventType.NoteOff, this.Channel));
            //else
            UtilBinary.WriteValue(writer, UtilBinary.CombineBytes((byte)this.Type, this.Channel));

            UtilBinary.WriteValue(writer, this.Parameter1);
            UtilBinary.WriteValue(writer, this.Parameter2);
        }
Example #6
0
        public KeySignatureEvent KeySignature;       // = new KeySignatureEvent();               // = 0x59

        public void ConvertToBinary(System.IO.BinaryWriter writer)
        {
            UtilBinary.WriteValue(writer, this.ChunkID);
            UtilBinary.WriteValue(writer, this.GetSizeInBytes());

            ///these will only get written only if there is actually data to write.

            if (this.SequenceNumber != null)
            {
                this.SequenceNumber.ConvertToBinary(writer);
            }

            if (this.Comments != null)
            {
                this.Comments.ConvertToBinary(writer);
            }

            if (this.CopyrightNotice != null)
            {
                this.CopyrightNotice.ConvertToBinary(writer);
            }

            if (this.TrackName != null)
            {
                this.TrackName.ConvertToBinary(writer);
            }

            if (this.InstrumentName != null)
            {
                this.InstrumentName.ConvertToBinary(writer);
            }

            if (this.Lyrics != null)
            {
                this.Lyrics.ConvertToBinary(writer);
            }

            if (this.Marker != null)
            {
                this.Marker.ConvertToBinary(writer);
            }

            if (this.CuePoint != null)
            {
                this.CuePoint.ConvertToBinary(writer);
            }

            if (this.DeviceName != null)
            {
                this.DeviceName.ConvertToBinary(writer);
            }

            if (this.Channel != null)
            {
                this.Channel.ConvertToBinary(writer);
            }

            if (this.Port != null)
            {
                this.Port.ConvertToBinary(writer);
            }

            if (this.Tempo != null)
            {
                this.Tempo.ConvertToBinary(writer);
            }

            if (this.SMPTEOffSet != null)
            {
                this.SMPTEOffSet.ConvertToBinary(writer);
            }

            if (this.TimeSignature != null)
            {
                this.TimeSignature.ConvertToBinary(writer);
            }

            if (this.KeySignature != null)
            {
                this.KeySignature.ConvertToBinary(writer);
            }

            foreach (ChannelMidiEvent chan in this.ChannelEvents)
            {
                chan.ConvertToBinary(writer);
                //Debug.Write(chan.ToString());
            }

            this.EndOfTrack.ConvertToBinary(writer);    //mandatory and must be at end
        }
 public virtual void ConvertToBinary(System.IO.BinaryWriter writer)
 {
     UtilBinary.WriteVariableLengthValue(writer, this.DeltaTime); //use variable length binary
     UtilBinary.WriteValue(writer, UtilBinary.CombineBytes((byte)this.Type, this.Channel));
 }