Exemplo n.º 1
0
        public static Fin <bool> IsPcmWaveFile(Stream stream)
        {
            var riffChunk = FindRiffChunk(stream);

            var waveChunk = riffChunk.Bind(r => FindWaveChunk(stream, r));

            var formatChunk = waveChunk.Bind(w => Wave.FindFormatChunk(stream, w));

            if (formatChunk.IsFail)
            {
                return((Error)formatChunk);
            }

            var formatSpan = RangeHelper.ReadRange(stream, (RangeHelper.Range)formatChunk);

            var format = Wave.GetAudioFormat(formatSpan);

            return(format == Format.Pcm);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Check if file has version 1 wamd chunk.
        /// Wamd chunk contains metadata for wildlife acoustics sensors.
        /// </summary>
        /// <param name="stream">The file stream.</param>
        /// <returns>Boolean indicating weather the wamd chunk is present.</returns>
        public static Fin <bool> HasVersion1WamdChunk(Stream stream)
        {
            var wamdChunk = GetWamdChunk(stream);

            if (wamdChunk.IsFail)
            {
                return((Error)wamdChunk);
            }

            var wamdSpan = RangeHelper.ReadRange(stream, (RangeHelper.Range)wamdChunk);

            var version = GetVersion(wamdSpan);

            if (version.IsFail)
            {
                return((Error)version);
            }

            return(version == 1);
        }