示例#1
0
        // returns TRUE if has more to read
        public async Task <bool> ReadNext(Stream output)
        {
            var header = reader.Header;
            var writer = new WavWriter(output, header);

            long size = WavHeader.Size + WavChunkHeader.Size;

            bool hasMore = true;

            do
            {
                var count = await reader.ReadDataChunk(buffer).ConfigureAwait(false);

                size += count;

                await writer.Write(buffer, 0, count).ConfigureAwait(false);

                bytesToReadFromDataChunk -= count;

                hasMore = reader.HasMore;

                if (bytesToReadFromDataChunk == 0 && hasMore)
                {
                    currentDataChunkHeader   = reader.ReadChunkHeader();
                    bytesToReadFromDataChunk = currentDataChunkHeader.ChunkLength;
                }
            } while (size < fileSizeLimit && hasMore);

            writer.Flush();

            return(hasMore);
        }
示例#2
0
        public Splitter(Stream input, int fileSizeLimit)
        {
            this.reader        = new WavReader(input);
            this.fileSizeLimit = fileSizeLimit;

            buffer = new byte[fileSizeLimit];

            currentDataChunkHeader   = reader.ReadChunkHeader();
            bytesToReadFromDataChunk = currentDataChunkHeader.ChunkLength;

            //position = reader.Header.HeaderSize;
        }
示例#3
0
        public WavChunkHeader ReadChunkHeader(bool skipFllr = true)
        {
            currentDataChunkHeader = new WavChunkHeader();
            currentDataChunkHeader.Read(reader);

            if (skipFllr)
            {
                while (currentDataChunkHeader.ShouldSkip)
                {
                    reader.BaseStream.Seek(currentDataChunkHeader.ChunkLength, SeekOrigin.Current);
                    currentDataChunkHeader = new WavChunkHeader();
                    currentDataChunkHeader.Read(reader);
                }
            }

            currentDataChunkPosition = 0;

            return(currentDataChunkHeader);
        }