Ejemplo n.º 1
0
        public void CanCalculateAlbum(int number, int position, int count)
        {
            var info        = new ReplayGainBatchInfo();
            var expectation = Expectations[number];
            var handles     = new List <int>();

            try
            {
                for (var a = position; a < count; a++)
                {
                    var handle = Bass.CreateStream(Expectations[a].FileName, Flags: BassFlags.Decode | BassFlags.Float);
                    handles.Add(handle);
                }
                Assert.IsTrue(BassReplayGain.ProcessBatch(handles.ToArray(), out info));
                for (var a = position; a < count; a++)
                {
                    Assert.AreEqual(Math.Round(Expectations[a].Peak, 2), Math.Round(info.items[a].peak, 2));
                    Assert.AreEqual(Math.Round(Expectations[a].Gain, 2), Math.Round(info.items[a].gain, 2));
                }
            }
            finally
            {
                foreach (var handle in handles)
                {
                    Bass.StreamFree(handle);
                }
            }
            Assert.AreEqual(Math.Round(expectation.Peak, 2), Math.Round(info.peak, 2));
            Assert.AreEqual(Math.Round(expectation.Gain, 2), Math.Round(info.gain, 2));
        }
Ejemplo n.º 2
0
        protected virtual bool ScanGroup(IDictionary <ScannerItem, IBassStream> group)
        {
            if (group.Count == 0)
            {
                //Nothing to do.
                return(true);
            }
            var channelHandles = group.Values
                                 .Select(stream => stream.ChannelHandle)
                                 .ToArray();
            var info = default(ReplayGainBatchInfo);

            if (!BassReplayGain.ProcessBatch(channelHandles, out info))
            {
                return(false);
            }
            foreach (var scannerItem in group.Keys)
            {
                var stream = group[scannerItem];
                foreach (var item in info.items)
                {
                    if (item.handle == stream.ChannelHandle)
                    {
                        scannerItem.ItemPeak  = item.peak;
                        scannerItem.ItemGain  = item.gain;
                        scannerItem.GroupPeak = info.peak;
                        scannerItem.GroupGain = info.gain;
                        break;
                    }
                }
            }
            return(true);
        }