コード例 #1
0
ファイル: ID3v2Frame.cs プロジェクト: felixwatts/PodPuppy
        /// <summary>
        /// Writes the header for this frame to a stream.
        /// </summary>
        /// <param name="stream">The stream to write to.</param>
        /// <param name="version">The ID3v2 version to use in writing the frame.</param>
        protected void WriteHeaderToStream(Stream stream, ID3Versions version)
        {
            if (stream == null)
            {
                throw new ArgumentNullException("stream");
            }

            if ((version & ID3Versions.V2) == ID3Versions.V2)
            {
                string frameIDString = FrameRegistry.GetFrameId(this.frameType, version);
                if (frameIDString == null)
                {
                    throw new UnsupportedVersionException(version);
                }

                EncodedString frameID = new EncodedString(TextEncodingType.ISO_8859_1, frameIDString);
                frameID.IsTerminated             = false;
                frameID.HasEncodingTypePrepended = false;
                frameID.WriteToStream(stream);
                WriteFrameSize(stream, version);
                WriteFlags(stream, version);
                stream.Flush();
            }
            else
            {
                throw new UnsupportedVersionException(version);
            }
        }
コード例 #2
0
        public HomogeneousTransformation[] IntermediateHomogeneousTransformations()
        {
            HomogeneousTransformation[] retval = new HomogeneousTransformation[Rows];
            SillyParser p = (SillyParser)SillyParser.GetInstance();

            Matrix[] matrices = new Matrix[Rows];

            for (int i = 0; i < Rows; i++)
            {
                string matrixStr =
                    $"cos(_th{i}),  -sin(_th{i}) * cos(_al{i}),  sin(_th{i}) * sin(_al{i}),   _a{i} * cos(_th{i});" +
                    $"sin(_th{i}),  cos(_th{i}) * cos(_al{i}),   -cos(_th{i}) * sin(_al{i}),  _a{i} * sin(_th{i});" +
                    $"0,            sin(_al{i}),                 cos(_al{i}),                 _d{i};" +
                    $"0,            0,                           0,                           1";
                matrixStr   = matrixStr.Replace($"_a{i}", this[i, 0].ToString());
                matrixStr   = matrixStr.Replace($"_al{i}", this[i, 1].ToString());
                matrixStr   = matrixStr.Replace($"_d{i}", this[i, 2].ToString());
                matrixStr   = matrixStr.Replace($"_th{i}", this[i, 3].ToString());
                matrices[i] = p.InterpretMatrix(matrixStr);
            }

            for (int i = 0; i < Rows; i++)
            {
                Frame baseFrame = FrameRegistry.GetFrame($"{i}");
                Frame toFrame   = FrameRegistry.GetFrame($"{i + 1}");
                retval[i] = new HomogeneousTransformation(matrices[i], baseFrame, toFrame);
            }

            return(retval);
        }
コード例 #3
0
ファイル: ID3v2Frame.cs プロジェクト: felixwatts/PodPuppy
        /// <summary>
        /// Reads and returns a frame from a stream.
        /// </summary>
        /// <param name="stream">The stream to read from.</param>
        /// <param name="version">The ID3v2 version of the tag being parsed.</param>
        /// <returns>The frame read from the stream.</returns>
        public static ID3v2Frame ReadFrame(Stream stream, ID3Versions version)
        {
            if (stream == null)
            {
                throw new ArgumentNullException("stream");
            }

            ID3v2Frame      frame      = null;
            FrameParameters parameters = new FrameParameters(version);

            byte[] header    = new byte[parameters.HeaderLength];
            char[] idChars   = new char[parameters.IDLength];
            byte[] sizeBytes = new byte[parameters.SizeLength];
            byte[] flags     = new byte[parameters.FlagsLength];
            byte[] frameData;
            string frameID;
            int    size;

            stream.Read(header, 0, header.Length);

            Array.Copy(header, 0, idChars, 0, idChars.Length);
            Array.Copy(header, parameters.IDLength, sizeBytes, 0, sizeBytes.Length);
            Array.Copy(header, parameters.IDLength + parameters.SizeLength, flags, 0, flags.Length);

            if (idChars[0] != 0x0)
            {
                frameID = new String(idChars);
                if (parameters.SizeIsSynchSafe)
                {
                    size = SynchsafeInteger.UnSynchsafe(sizeBytes);
                }
                else
                {
                    size = EncodedInteger.ToInt(sizeBytes);
                }

                frameData = new byte[size];
                stream.Read(frameData, 0, frameData.Length);

                FrameType frameType = FrameRegistry.GetFrameType(frameID, version);
                frame = FrameRegistry.GetNewFrame(frameType);

                frame.Initialize(flags, frameData, version);
            }
            else
            {
                frame = null;
            }

            return(frame);
        }
コード例 #4
0
ファイル: ID3v2Tag.cs プロジェクト: felixwatts/PodPuppy
        /// <summary>
        /// Sets the value of a text frame. If the frame is a composite, the
        /// first frame is used; if no frames exist for the given FrameType,
        /// a new frame is added; if null is passed as the value, any frames
        /// of the specified type are removed.
        /// </summary>
        /// <param name="frameType">The type of frame to set the value of.</param>
        /// <param name="textValue">The value to assign to the frame.</param>
        private void SetFrameTextValue(FrameType frameType, string textValue)
        {
            if (textValue == null)
            {
                this.RemoveFrame(frameType);
            }
            else
            {
                TextInformationFrame textFrame = GetFirstFrame(frameType) as TextInformationFrame;

                if (textFrame == null)
                {
                    textFrame = (TextInformationFrame)FrameRegistry.GetNewFrame(frameType);
                    this.AddFrame(textFrame);
                }
                textFrame.Text = textValue;
            }
        }
コード例 #5
0
ファイル: ID3v2Frame.cs プロジェクト: felixwatts/PodPuppy
 /// <summary>
 /// Returns a new frame of the given type.
 /// </summary>
 /// <param name="frameType">The type of frame to return.</param>
 /// <returns>A new frame of the given type.</returns>
 public static ID3v2Frame GetNewFrame(FrameType frameType)
 {
     return(FrameRegistry.GetNewFrame(frameType));
 }
コード例 #6
0
ファイル: ID3v2Frame.cs プロジェクト: felixwatts/PodPuppy
 /// <summary>
 /// Returns the FrameType for the given frame ID and version.
 /// </summary>
 /// <param name="frameId">The frame ID string to look up.</param>
 /// <param name="version">The ID3v2 version to use.</param>
 /// <returns>The frame ID for the given FrameType and version.</returns>
 public static FrameType GetFrameType(string frameId, ID3Versions version)
 {
     return(FrameRegistry.GetFrameType(frameId, version));
 }
コード例 #7
0
ファイル: ID3v2Frame.cs プロジェクト: felixwatts/PodPuppy
 /// <summary>
 /// Returns the frame ID for the given FrameType and version.
 /// </summary>
 /// <param name="frameType">The FrameType to look up.</param>
 /// <param name="version">The ID3v2 version to use.</param>
 /// <returns>The frame ID for the given FrameType and version.</returns>
 public static string GetFrameId(FrameType frameType, ID3Versions version)
 {
     return(FrameRegistry.GetFrameId(frameType, version));
 }