🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Sign inDemoInstall
Socket

oldbit.beep

Package Overview
Dependencies
Maintainers
0
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package was removed
Sorry, it seems this package was removed from the registry

oldbit.beep

0.9.3-pre.111
NuGet
Version published
Maintainers
0
Created
Source

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:

FormatDescriptionSize
Unsigned8BitLittleEndian8-bit unsigned PCM1 byte (0..255)
Signed16BitLittleEndian16-bit signed PCM2 bytes (-32768..32767)
Float32BitLittleEndian32-bit float PCM4 bytes (-1.0..1.0)

Keywords

audio

FAQs

Package last updated on 24 Feb 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts