Popularity
0.9
Growing
Activity
6.5
Declining
2
1
1

Description

A cross-platform audio playback library that targets .NET Standard 2.1. The main purpose of this project is to provide easy to use API for playing and streaming audio especially in desktop environment.

Behind the scene, it uses FFmpeg to decode audio frames (so it is possible to play video files by taking only audio stream). And PortAudio for sending buffer data or samples to output device using blocking calls mechanism.

Programming language: C#
License: MIT License
Tags: Cross-platform     Media     audio     sound     Codec    

Bufdio alternatives and similar packages

Based on the "Media" category.
Alternatively, view Bufdio alternatives based on common mentions on social networks and blogs.

  • NAudio

    Audio and MIDI library for .NET
  • CSCore

    An advanced audio library, written in C#. Provides tons of features. From playing/recording audio to decoding/encoding audio streams/files to processing audio data in realtime (e.g. applying custom effects during playback, create visualizations,...). The possibilities are nearly unlimited.
  • Scout APM allows you to find and fix performance issues with no hassle. Now with error monitoring and ´╗┐external services monitoring, Scout is a developer's best friend when it comes to application development.
    Promo
  • TagLib#

    Library for reading and writing metadata in media files
  • Xabe.FFmpeg

    .NET Standard wrapper for FFmpeg. It allows to process media without know how FFmpeg works, and can be used to pass customized arguments to FFmpeg from dotnet core application.
  • Audio Switcher

    .NET Library which facilitates interacting with Audio Devices on Windows
  • SeeShark

    Simple C# camera library.

Do you think we are missing an alternative of Bufdio or a related project?

Add another 'Media' Package

README

Bufdio

NuGet

A cross-platform audio playback library that targets .NET Standard 2.1. The main purpose of this project is to provides an easy to use API for playing and streaming audio file.

It uses FFmpeg to decode audio frames (so, it is possible to play audio stream from a video file). And PortAudio for writing audio stream to output device.

Example

Bufdio Sample

Getting Started

This repository include pre-compiled PortAudio binaries for Windows, Linux, macOS that can be found at the libs directory. However, we can construct PortAudio and FFmpeg by using system-wide libraries.

BufdioLib.InitializePortAudio("path/to/portaudio");
BufdioLib.InitializeFFmpeg("path/to/ffmpeg/libraries");

// Or just use system-wide libraries
BufdioLib.InitializePortAudio();
BufdioLib.InitializeFFmpeg();

With PortAudio initialized, now we can retrieve available output devices.

var defaultDevice = BufdioLib.DefaultOutputDevice;
Console.WriteLine(defaultDevice.Name);
Console.WriteLine(defaultDevice.MaxOutputChannels);
Console.WriteLine(defaultDevice.DefaultSampleRate);
Console.WriteLine(defaultDevice.DefaultHighOutputLatency);

// Retrieve all available output devices
foreach (var device in BufdioLib.OutputDevices)
{
    Console.WriteLine(device.Name);
}

Playing Audio Files

Bufdio provides high level interface for loading audio and control its playback state.

using IAudioPlayer player = new AudioPlayer();

// Methods
player.LoadAsync("audio-url-or-path");
player.LoadAsync(stream);
player.Play();
player.Pause();
player.Stop();
player.Seek(TimeSpan.FromSeconds(2));

// Properties
player.Volume;
player.CustomSampleProcessor;
player.Logger;

// Properties (read-only)
player.State;
player.IsSeeking;
player.IsLoaded;
player.Duration;
player.Position;

// Events
player.StateChanged += OnStateChanged;
player.PositionChanged += OnPositionChanged;

Generate Sine Wave

Bufdio also exposes low level IAudioEngine interface for sending or writing samples to an output device.

const int SampleRate = 8000;
const float Frequency = 350f;
const float Amplitude = 0.35f * short.MaxValue;

var samples = new float[SampleRate];
var options = new AudioEngineOptions(1, SampleRate);

using IAudioEngine engine = new PortAudioEngine(options);

for (var i = 0; i < samples.Length; i++)
{
    samples[i] = (float)(Amplitude * Math.Sin(2 * Math.PI * i * Frequency / SampleRate));
}

Console.WriteLine("Playing 10 times with 1 second delay..");

for (var i = 0; i < 10; i++)
{
    engine.Send(samples);
    Thread.Sleep(1000);
}

TODO

  • Still need more unit tests

Credits

Similar Projects

License

Bufdio is licenced under the MIT license.


*Note that all licence references and agreements mentioned in the Bufdio README section above are relevant to that project's source code only.