Exemplo n.º 1
0
        static long GetRiffValue(FileStream fs, string chunk, string offset)
        {
            long ret = DEFAULT_LOOP_VALUE;

            // riff values
            RiffCalculatingOffsetDescription riffCalculatingOffset = new RiffCalculatingOffsetDescription();

            riffCalculatingOffset.RelativeLocationToRiffChunkString = RiffCalculatingOffsetDescription.START_OF_STRING;
            riffCalculatingOffset.OffsetSize      = "4";
            riffCalculatingOffset.OffsetByteOrder = Constants.LittleEndianByteOrder;

            try
            {
                riffCalculatingOffset.RiffChunkString = chunk;
                riffCalculatingOffset.OffsetValue     = offset;

                ret = ParseFile.GetRiffCalculatedVaryingByteValueAtAbsoluteOffset(fs, riffCalculatingOffset, true);
            }
            catch (IndexOutOfRangeException iorEx)
            {
                // Console.WriteLine(String.Format("Error processing RIFF item for <{0}>: {1}", Path.GetFileName(fs.Name), iorEx.Message));
            }

            return(ret);
        }
        public new RiffCalculatingOffsetDescription GetOffsetValues()
        {
            RiffCalculatingOffsetDescription allValues = new RiffCalculatingOffsetDescription();

            allValues.OffsetValue       = this.tbOffset.Text;
            allValues.OffsetSize        = this.comboSize.Text;
            allValues.OffsetByteOrder   = this.comboByteOrder.Text;
            allValues.CalculationString = this.tbCalculation.Text;
            allValues.RelativeLocationToRiffChunkString = this.cbRiffRelativeLocation.Text;
            allValues.RiffChunkString = this.cbRiffChunkList.Text;

            return(allValues);
        }
Exemplo n.º 3
0
        public static long GetSampleCountForRiffHeaderedFile(string path)
        {
            long sampleCount = -1;

            ushort channelCount;
            uint   dataSize;

            RiffCalculatingOffsetDescription riffValue = new RiffCalculatingOffsetDescription();

            // get values from file
            using (FileStream fs = File.OpenRead(path))
            {
                // over kill, but i don't feel like recoding it
                riffValue.CalculationString = String.Empty;
                riffValue.OffsetByteOrder   = Constants.LittleEndianByteOrder;
                riffValue.OffsetSize        = "2";
                riffValue.OffsetValue       = "10";
                riffValue.RelativeLocationToRiffChunkString = RiffCalculatingOffsetDescription.START_OF_STRING;
                riffValue.RiffChunkString = "fmt ";

                channelCount = (ushort)ParseFile.GetRiffCalculatedVaryingByteValueAtAbsoluteOffset(fs, riffValue, true);

                riffValue.CalculationString = String.Empty;
                riffValue.OffsetByteOrder   = Constants.LittleEndianByteOrder;
                riffValue.OffsetSize        = "4";
                riffValue.OffsetValue       = "4";
                riffValue.RelativeLocationToRiffChunkString = RiffCalculatingOffsetDescription.START_OF_STRING;
                riffValue.RiffChunkString = "data";

                dataSize = (uint)ParseFile.GetRiffCalculatedVaryingByteValueAtAbsoluteOffset(fs, riffValue, true);

                sampleCount = (long)dataSize / 2 / (long)channelCount;
            } // using (FileStream fs = File.OpenRead(path))

            return(sampleCount);
        }