OldBit.Beep 0.9.2-rc.2

This is a prerelease version of OldBit.Beep.
dotnet add package OldBit.Beep --version 0.9.2-rc.2                
NuGet\Install-Package OldBit.Beep -Version 0.9.2-rc.2                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="OldBit.Beep" Version="0.9.2-rc.2" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add OldBit.Beep --version 0.9.2-rc.2                
#r "nuget: OldBit.Beep, 0.9.2-rc.2"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install OldBit.Beep as a Cake Addin
#addin nuget:?package=OldBit.Beep&version=0.9.2-rc.2&prerelease

// Install OldBit.Beep as a Cake Tool
#tool nuget:?package=OldBit.Beep&version=0.9.2-rc.2&prerelease                

Beep Audio Player

Beep is a simple cross-platform low level dotnet library for playing PCM audio.

It was inspired by oto golang library that I used before. However, it is not a direct port of it. It has been created to be used by my ZX Spectrum emulator, hence the name Beep. I needed a simple way of playing audio and couldn't find anything that would suit my needs.

I don't plan to add any advanced features to this library. It is quite challenging to implement a good audio library that would work on all platforms. Each platform has its own way of handling audio and good examples are hard to find.

I've tested it on MacOS, Windows and Linux. But I can't guarantee that it will work on all systems.

Features

  • written in C# and .NET 8
  • no external dependencies other than native OS frameworks
  • cross-platform, currently supports MacOS, Windows and Linux
  • supports 8-bit unsigned, 16-bit signed and 32-bit float PCM data formats
  • simple volume control

Internally it uses 32-bit float PCM audio format (little endian).

Platforms:

MacOS

Audio playback is implemented using AudioToolbox.framework. The framework is available on MacOS by default.

Windows

Audio playback is implemented using WASAPI. The framework is available on Windows by default.

Linux

Audio playback is implemented using ALSA. The library may need to be installed on some Linux distributions.

Additionally, you might need ALSA development library. Installation method may differ depending on the Linux distribution.

On Debian based Linux distributions run:

apt install libasound2-dev

On RedHat based Linux distributions run:

dnf install alsa-lib-devel

Usage

Demo app

Please check the Demo project for an example how to use Beep.

Code

using OldBit.Beep;

using var audioPlayer = new AudioPlayer(AudioFormat.Float32BitLittleEndian, 44100, 2);
audioPlayer.Volume = 50;

audioPlayer.Start();
await audioPlayer.EnqueueAsync(new byte[] { 0.5f, 0.5f, 0.5f, 0.5f });
audioPlayer.Stop();

EnqueueAsync method takes an array of audio bytes. The format is one of the following:

Format Description Size
Unsigned8BitLittleEndian 8-bit unsigned PCM 1 byte (0..255)
Signed16BitLittleEndian 16-bit signed PCM 2 bytes (-32768..32767)
Float32BitLittleEndian 32-bit float PCM 4 bytes (-1.0..1.0)
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.9.2-rc.2 59 1/2/2025
0.9.2-rc.1 60 10/17/2024