public void TestDecodeFrameNumFrames() { string dirName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); string path = Path.Combine(dirName, "bensound-scifi.mp3"); Mpg123 mpg123 = new Mpg123(); mpg123.Open(path); byte[] buffer = null; int num = 0; uint bytes = 0; int b = 0, c = 0; long a = 0; mpg123.GetFormat(ref a, ref b, ref c); Mpg123.Errors error = Mpg123.Errors.OK; while (error == Mpg123.Errors.OK) { error = mpg123.DecodeFrame(ref num, ref buffer, ref bytes); } Assert.That(num, Is.GreaterThan(0)); }
public void TestInstantiateWithDecoder() { string decoder = Mpg123.Decoders.ToArray()[0]; Mpg123 mpg123 = new Mpg123(decoder); Assert.That(mpg123.HasValidHandle, Is.True); }
public void TestSeekFrameInvalid() { string decoder = Mpg123.Decoders.ToArray().FirstOrDefault(); Mpg123 mpg123 = new Mpg123(); Assert.That(() => mpg123.SeekFrame(5, SeekOrigin.Begin), Throws.TypeOf <Mpg123.ErrorException>()); }
public void TestResetEqualizerRedLight() { Mpg123 mpg123 = new Mpg123(); mpg123.Dispose(); Assert.That(() => mpg123.ResetEq(), Throws.TypeOf <Mpg123.ErrorException>()); }
public void TestSetEqualizerRedLight() { Mpg123 mpg123 = new Mpg123(); int ErrorValue = 1000; Assert.That(() => mpg123.Eq(Mpg123.Channels.LEFT, ErrorValue, 20), Throws.TypeOf <Mpg123.ErrorException>()); }
public void TestOpenPathInvalid() { string path = "test.mp3"; Mpg123 mpg123 = new Mpg123(); Assert.That(() => mpg123.Open(path), Throws.TypeOf <Mpg123.ErrorException>()); }
public void TestFormatSupportedNoEx() { Mpg123 handle = new Mpg123(); //Mpg123.ChannelCount state = handle.IsFormatSupported(100, 20); Assert.That(() => handle.IsFormatSupported(100, 20), Throws.Nothing); }
public void TestDecodeFrameNeedMore() { string dirName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); string path = Path.Combine(dirName, "bensound-epic.mp3"); Mpg123 mpg123 = new Mpg123(); mpg123.OpenFeed(); byte[] fileBytes = File.ReadAllBytes(path); byte[] buffer = new byte[8]; Array.Copy(fileBytes, buffer, 8); int num = 0; uint bytes = 0; int b = 0, c = 0; long a = 0; mpg123.GetFormat(ref a, ref b, ref c); Mpg123.Errors error = Mpg123.Errors.OK; Assert.That(() => error = mpg123.DecodeFrame(ref num, ref buffer, ref bytes), Throws.Nothing); Assert.That(error, Is.EqualTo(Mpg123.Errors.NEED_MORE)); }
private SoundFile Decode(Stream s) { IAudioDecoder decoder = new Mpg123(); if (!decoder.IsAvailable) { decoder = new MP3AudioDecoder(); } if (!decoder.IsAvailable) { throw new Exception("No mp3 decoder available!"); } try { decoder.BeginDecode(s); using var data = new MemoryStream(); var packet = decoder.Decode(); IAudioConfiguration config = packet; while (packet != null) { data.Write(packet.Data, 0, packet.Length); packet = decoder.Decode(); } return(new SoundFile(config, data.ToArray())); } finally { decoder.Close(); } }
public void TestReadNoOpen() { Mpg123 mpg123 = new Mpg123(); uint done = 0; byte[] buffer = new byte[100]; Assert.That(() => mpg123.Read(buffer, ref done), Throws.TypeOf <Mpg123.ErrorException>()); }
public void TestGetFormatOK() //must fail because there isn't stream loaded { Mpg123 handle = new Mpg123(); long rate = 0; int channels = 0, encoding = 0; Assert.That(handle.GetFormat(ref rate, ref channels, ref encoding), Is.Not.EqualTo(Mpg123.Errors.OK)); }
public void TestTellStreamIsNegative() //without loaded stream { Mpg123 mpg123 = new Mpg123(Mpg123.Decoders.ToArray().FirstOrDefault()); long seekPositon = mpg123.TellStream(); Assert.That(seekPositon, Is.EqualTo(-1)); }
public void TestTellIsZero() //with no loaded stream { Mpg123 mpg123 = new Mpg123(Mpg123.Decoders.ToArray().FirstOrDefault()); long seekPositon = mpg123.Tell(); Assert.That(seekPositon, Is.Zero); }
public void TestOpenPathValid() { string dirName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); string path = dirName + "/bensound-epic.mp3"; Mpg123 mpg123 = new Mpg123(); Assert.That(() => mpg123.Open(path), Throws.Nothing); }
public void TestGetDecoder() { string decoder = Mpg123.Decoders.ToArray()[0]; Mpg123 mpg123 = new Mpg123(decoder); Assert.That(mpg123.Decoder, Is.EqualTo(decoder)); }
public void TestDecodeNoOpen() { Mpg123 mpg123 = new Mpg123(); uint done = 0; Assert.That(() => mpg123.Decode(null, 0, null, 0, ref done), Throws.TypeOf <Mpg123.ErrorException>()); }
public void TestTellFrameIsZero() { Mpg123 mpg123 = new Mpg123(Mpg123.Decoders.ToArray().FirstOrDefault()); long seekPositon = mpg123.TellFrame(); Assert.That(seekPositon, Is.Zero); }
public void TestGetDecoderFalse() { string decoder = Mpg123.Decoders.ToArray()[0]; string notDecoder = Mpg123.Decoders.ToArray()[1]; Mpg123 mpg123 = new Mpg123(decoder); Assert.That(mpg123.Decoder, Is.Not.EqualTo(notDecoder)); }
public void TestGetEqualizerRedLight() { Mpg123 mpg123 = new Mpg123(); mpg123.Eq(Mpg123.Channels.LR, 20, 30); double value = 20; Assert.That(mpg123.GetEq(Mpg123.Channels.LR, 20), Is.Not.EqualTo(value)); }
public void TestTellStreamIsNegative() { string decoder = Mpg123.Decoders.ToArray().FirstOrDefault(); Mpg123 mpg123 = new Mpg123(); long seekPositon = mpg123.TellStream(); Assert.That(seekPositon, Is.EqualTo(-1)); }
public void TestTellIsZero() { string decoder = Mpg123.Decoders.ToArray().FirstOrDefault(); Mpg123 mpg123 = new Mpg123(); long seekPositon = mpg123.Tell(); Assert.That(seekPositon, Is.Zero); }
public void TestGetEqualizer() { Mpg123 mpg123 = new Mpg123(); mpg123.Eq(Mpg123.Channels.LR, 20, 20); double aspectedValue = 20; Assert.That(mpg123.GetEq(Mpg123.Channels.LR, 20), Is.EqualTo(aspectedValue)); }
public void TestFeed() { Mpg123 mpg123 = new Mpg123(); mpg123.OpenFeed(); byte[] buffer = new byte[8]; Assert.That(() => mpg123.Feed(buffer), Throws.Nothing); }
public void TestSetDecoder() { Mpg123 mpg123 = new Mpg123(); string decoder = Mpg123.Decoders.ToArray()[0]; mpg123.Decoder = decoder; Assert.That(mpg123.Decoder, Is.EqualTo(decoder)); }
public void TestDecodeFrameNotOpen() { Mpg123 mpg123 = new Mpg123(); byte[] buffer = null; int num = 0; uint bytes = 0; Assert.That(() => mpg123.DecodeFrame(ref num, ref buffer, ref bytes), Throws.TypeOf <Mpg123.ErrorException>()); }
public void TestDecodeNullInputAndOutput() { Mpg123 mpg123 = new Mpg123(); mpg123.OpenFeed(); uint done = 0; Assert.That(() => mpg123.Decode(null, 0, null, 0, ref done), Throws.Nothing); }
public void TestOpenFeedOpen() { Mpg123 mpg123 = new Mpg123(); string dirName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); string path = Path.Combine(dirName, "bensound-epic.mp3"); mpg123.Open(path); Assert.That(() => mpg123.OpenFeed(), Throws.Nothing); }
public void TestDecodeInconsistentOutputSizeMinor() { Mpg123 mpg123 = new Mpg123(); mpg123.OpenFeed(); byte[] outBuffer = new byte[100]; uint done = 0; Assert.That(() => mpg123.Decode(null, 0, outBuffer, 50, ref done), Throws.Nothing); }
public void TestDecodeInconsistentOutputSizeMajor() { Mpg123 mpg123 = new Mpg123(); mpg123.OpenFeed(); byte[] outBuffer = new byte[100]; uint done = 0; Assert.That(() => mpg123.Decode(null, 0, outBuffer, 300, ref done), Throws.TypeOf <ArgumentOutOfRangeException>()); }
public void TestFeature() { string dirName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); string path = dirName + "/bensound-epic.mp3"; Mpg123 mpg123 = new Mpg123(); mpg123.Open(path); Assert.That(() => mpg123.Feature(Mpg123.Mpg123FeatureSet.MPG123_FEATURE_EQUALIZER), Throws.Nothing); }