protected override void Parse() { BinaryReader br = new BinaryReader(this._dataStream); BitStream bits = new BitStream(this._dataStream); ushort _reserved = (ushort)bits.GetBits(4); this._playbacksoundrate = DefineSound.getSoundRate(bits.GetBits(2)); this._playbacksoundsize = (bits.GetBits(1) == 0) ? SoundSize.snd_8bit : SoundSize.snd_16bit; this._playbacksoundtype = (bits.GetBits(1) == 0) ? SoundType.mono : SoundType.stereo; this._streamsoundcompression = DefineSound.getFormat(bits.GetBits(4)); this._streamsoundrate = DefineSound.getSoundRate(bits.GetBits(2)); this._streamsoundsize = (bits.GetBits(1) == 0) ? SoundSize.snd_8bit : SoundSize.snd_16bit; this._streamsoundtype = (bits.GetBits(1) == 0) ? SoundType.mono : SoundType.stereo; this._streamsoundsamplecount = br.ReadUInt16(); if (_streamsoundcompression == SoundEncoding.MP3) this._latencyseek = br.ReadInt16(); if (_reserved != 0) { Exception e = new SwfFormatException("Reserved bits are set"); Log.Warn(this, e); } String s1 = String.Format("0x{0:X08}: reading soundstreamhead. Avarage samples {1}", this.Tag.OffsetData, this.AvarageCount); Log.Debug(this, s1); String s2 = String.Format("0x{0:X08}:\tPlayback: {1} {2} {3}", this.Tag.OffsetData, this.PlaybackRate, this.PlaybackSize, this.PlaybackType); Log.Debug(this, s2); String s3 = String.Format("0x{0:X08}:\tStream: {1} {2} {3} {4}", this.Tag.OffsetData, this.StreamCompression, this.StreamRate, this.StreamSize, this.StreamType); Log.Debug(this, s3); }
/// <summary> /// Initializes a new instance of the <see cref="SoundAnnotation" /> class. /// </summary> /// <param name="Links">Link to the document.</param> /// <param name="Color">Color of the annotation.</param> /// <param name="Contents">Get the annotation content.</param> /// <param name="Modified">The date and time when the annotation was last modified.</param> /// <param name="Id">Gets ID of the annotation.</param> /// <param name="Flags">Gets Flags of the annotation.</param> /// <param name="Name">Gets Name of the annotation.</param> /// <param name="Rect">Gets Rect of the annotation. (required)</param> /// <param name="PageIndex">Gets PageIndex of the annotation.</param> /// <param name="ZIndex">Gets ZIndex of the annotation.</param> /// <param name="HorizontalAlignment">Gets HorizontalAlignment of the annotation.</param> /// <param name="VerticalAlignment">Gets VerticalAlignment of the annotation.</param> /// <param name="CreationDate">The date and time when the annotation was created.</param> /// <param name="Subject">Get the annotation subject.</param> /// <param name="Title">Get the annotation title.</param> /// <param name="RichText">Get the annotation RichText.</param> /// <param name="FilePath">A sound file path defining the sound to be played when the annotation is activated. (required)</param> /// <param name="Icon">Gets or sets an icon to be used in displaying the annotation.</param> /// <param name="Rate">Gets or sets the sampling rate, in samples per second.</param> /// <param name="Channels">Gets or sets the number of sound channels.</param> /// <param name="Bits">Gets or sets the number of bits per sample value per channel.</param> /// <param name="Encoding">Gets or sets the encoding format for the sample data.</param> public SoundAnnotation(List <Link> Links = default(List <Link>), Color Color = default(Color), string Contents = default(string), string Modified = default(string), string Id = default(string), List <AnnotationFlags> Flags = default(List <AnnotationFlags>), string Name = default(string), Rectangle Rect = default(Rectangle), int?PageIndex = default(int?), int?ZIndex = default(int?), HorizontalAlignment HorizontalAlignment = default(HorizontalAlignment), VerticalAlignment VerticalAlignment = default(VerticalAlignment), string CreationDate = default(string), string Subject = default(string), string Title = default(string), string RichText = default(string), string FilePath = default(string), SoundIcon Icon = default(SoundIcon), int?Rate = default(int?), int?Channels = default(int?), int?Bits = default(int?), SoundEncoding Encoding = default(SoundEncoding)) { // to ensure "Rect" is required (not null) if (Rect == null) { throw new InvalidDataException("Rect is a required property for SoundAnnotation and cannot be null"); } else { this.Rect = Rect; } // to ensure "FilePath" is required (not null) if (FilePath == null) { throw new InvalidDataException("FilePath is a required property for SoundAnnotation and cannot be null"); } else { this.FilePath = FilePath; } this.Links = Links; this.Color = Color; this.Contents = Contents; this.Modified = Modified; this.Id = Id; this.Flags = Flags; this.Name = Name; this.PageIndex = PageIndex; this.ZIndex = ZIndex; this.HorizontalAlignment = HorizontalAlignment; this.VerticalAlignment = VerticalAlignment; this.CreationDate = CreationDate; this.Subject = Subject; this.Title = Title; this.RichText = RichText; this.Icon = Icon; this.Rate = Rate; this.Channels = Channels; this.Bits = Bits; this.Encoding = Encoding; }
/// <summary> /// Initializes a new instance of the <see cref="SoundAnnotation" /> class. /// </summary> /// <param name="Links">Link to the document..</param> /// <param name="Color">Color of the annotation..</param> /// <param name="Contents">Get the annotation content..</param> /// <param name="Modified">The date and time when the annotation was last modified..</param> /// <param name="Id">Gets ID of the annotation..</param> /// <param name="Flags">Gets Flags of the annotation..</param> /// <param name="Name">Gets Name of the annotation..</param> /// <param name="Rect">Gets Rect of the annotation..</param> /// <param name="PageIndex">Gets PageIndex of the annotation..</param> /// <param name="ZIndex">Gets ZIndex of the annotation..</param> /// <param name="HorizontalAlignment">Gets HorizontalAlignment of the annotation..</param> /// <param name="VerticalAlignment">Gets VerticalAlignment of the annotation..</param> /// <param name="CreationDate">The date and time when the annotation was created..</param> /// <param name="Subject">Get the annotation subject..</param> /// <param name="Title">Get the annotation title..</param> /// <param name="RichText">Get the annotation RichText..</param> /// <param name="FilePath">A sound file path defining the sound to be played when the annotation is activated..</param> /// <param name="Icon">Gets or sets an icon to be used in displaying the annotation..</param> /// <param name="Rate">Gets or sets the sampling rate, in samples per second..</param> /// <param name="Channels">Gets or sets the number of sound channels..</param> /// <param name="Bits">Gets or sets the number of bits per sample value per channel..</param> /// <param name="Encoding">Gets or sets the encoding format for the sample data..</param> public SoundAnnotation(List <Link> Links = default(List <Link>), Color Color = default(Color), string Contents = default(string), string Modified = default(string), string Id = default(string), List <AnnotationFlags> Flags = default(List <AnnotationFlags>), string Name = default(string), Rectangle Rect = default(Rectangle), int?PageIndex = default(int?), int?ZIndex = default(int?), HorizontalAlignment HorizontalAlignment = default(HorizontalAlignment), VerticalAlignment VerticalAlignment = default(VerticalAlignment), string CreationDate = default(string), string Subject = default(string), string Title = default(string), string RichText = default(string), string FilePath = default(string), SoundIcon Icon = default(SoundIcon), int?Rate = default(int?), int?Channels = default(int?), int?Bits = default(int?), SoundEncoding Encoding = default(SoundEncoding)) { this.Links = Links; this.Color = Color; this.Contents = Contents; this.Modified = Modified; this.Id = Id; this.Flags = Flags; this.Name = Name; this.Rect = Rect; this.PageIndex = PageIndex; this.ZIndex = ZIndex; this.HorizontalAlignment = HorizontalAlignment; this.VerticalAlignment = VerticalAlignment; this.CreationDate = CreationDate; this.Subject = Subject; this.Title = Title; this.RichText = RichText; this.FilePath = FilePath; this.Icon = Icon; this.Rate = Rate; this.Channels = Channels; this.Bits = Bits; this.Encoding = Encoding; }
/// <summary> /// /// </summary> protected override void Parse() { BinaryReader br = new BinaryReader(this._dataStream); BitStream bits = new BitStream(this._dataStream); this._soundID = br.ReadUInt16(); this._soundFormat = getFormat(bits.GetBits(4)); this._soundRate = getSoundRate(bits.GetBits(2)); this._soundSize = (bits.GetBits(1) == 0) ? SoundSize.snd_8bit : SoundSize.snd_16bit; this._soundType = (bits.GetBits(1) == 0) ? SoundType.mono : SoundType.stereo; this._soundSampleCount = br.ReadUInt32(); this._requiredVersion = getRequiredVersion(this._soundFormat); // TODO: check buffersize // Casting from UInt32 to int !!!! this._soundData = br.ReadBytes((int)Tag.Length - 7); String s = String.Format("\t{0} {1}", Tag.Length, Length); //Log.Debug(this, s); }
/// <summary> /// /// </summary> /// <param name="format"></param> /// <returns></returns> public static byte getRequiredVersion(SoundEncoding format) { if (format == SoundEncoding.uncompressed_native || format == SoundEncoding.ADPCM) return 1; else if (format == SoundEncoding.Uncompressed_little_endian || format == SoundEncoding.MP3) return 4; else if (format == SoundEncoding.Nellymoser16kHz || format == SoundEncoding.Nellymoser8kHz || format == SoundEncoding.Speex) return 10; else if (format == SoundEncoding.Nellymoser) return 6; else return 255; // Unknown format }
/// <summary> /// /// </summary> /// <param name="format"></param> /// <returns></returns> public static uint getFormatID(SoundEncoding format) { if (format == SoundEncoding.uncompressed_native) return 0; else if (format == SoundEncoding.ADPCM) return 1; else if (format == SoundEncoding.MP3) return 2; else if (format == SoundEncoding.Uncompressed_little_endian) return 3; else if (format == SoundEncoding.Nellymoser8kHz) return 4; else if (format == SoundEncoding.Nellymoser16kHz) return 5; else if (format == SoundEncoding.Nellymoser) return 6; else if (format == SoundEncoding.Speex) return 11; else return 255; // Invalid Value }