public void ReadSampleRateTest(FixtureModel model) { if (model.Process.ContainsKey(FixtureModel.FlacHeaderExtractor)) { Fin <uint> sampleRate = Flac.ReadSampleRate(model.ToTargetInformation(this.RealFileSystem).FileStream); Assert.True(sampleRate.IsSucc); ((uint)sampleRate).Should().Be(model.Record.SampleRateHertz); } }
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)); }