Esempio n. 1
0
 public void ReadBitDepthTest(FixtureModel model)
 {
     if (model.Process.ContainsKey(FixtureModel.FlacHeaderExtractor))
     {
         Fin <byte> bitDepth = Flac.ReadBitDepth(model.ToTargetInformation(this.RealFileSystem).FileStream);
         Assert.True(bitDepth.IsSucc);
         ((byte)bitDepth).Should().Be(model.Record.BitDepth);
     }
 }
Esempio n. 2
0
        public ValueTask <Recording> ProcessFileAsync(TargetInformation information, Recording recording)
        {
            var samples    = Flac.ReadTotalSamples(information.FileStream);
            var sampleRate = Flac.ReadSampleRate(information.FileStream);
            var channels   = Flac.ReadNumChannels(information.FileStream);
            var bitDepth   = Flac.ReadBitDepth(information.FileStream);

            Rational?duration = samples.IsFail || sampleRate.IsFail || (uint)sampleRate == 0 ? null : (new Rational((ulong)samples) / new Rational((uint)sampleRate));
            uint?    bitRate  = sampleRate.IsFail || bitDepth.IsFail || channels.IsFail ? null : (uint)sampleRate * (uint)bitDepth * (uint)channels;

            recording = recording with
            {
                DurationSeconds = recording.DurationSeconds ?? duration,
                SampleRateHertz = recording.SampleRateHertz ?? (sampleRate.IsFail ? null : (uint)sampleRate),
                TotalSamples    = recording.TotalSamples ?? (samples.IsFail ? null : (ulong)samples),
                Channels        = recording.Channels ?? (channels.IsFail ? null : (byte)channels),
                BitDepth        = recording.BitDepth ?? (bitDepth.IsFail ? null : (byte)bitDepth),
                BitsPerSecond   = recording.BitsPerSecond ?? bitRate,
            };

            return(ValueTask.FromResult(recording));
        }