#beep #sound

actually_beep

A cross platform library to provides easy to use beep functions that actually beep

2 releases

0.1.1 Jun 5, 2024
0.1.0 Jun 3, 2024

#213 in Audio

26 downloads per month

Apache-2.0

15KB
139 lines

actually_beep

A library to actually beep.

crates.io docs.rs MSRV License

Overview

This is a cross-platform library to provides easy to use beep functions that actually beep. It provides very basic audio tones (beeps) for whatever use you may have for that. It’s built on the AMAZING CPAL crate, which provides the low level audio support, & also provides excellent examples from which this crate stole heavily.

Install

Are we really doing this?

# Add this to your [dependencies] section in Cargo.toml
actually_beep = "0.1.0"

Usage

use actually_beep::beep_with_hz_and_millis;

fn main() {
  let middle_e_hz = 329;
  let a_bit_more_than_a_second_and_a_half_ms = 1600;

  beep_with_hz_and_millis(middle_e_hz, a_bit_more_than_a_second_and_a_half_ms).unwrap();
}

Crate features

  • jack - Use the "jack" feature of cpal. Only useful on Linux & the BSDs.

Motivation

I was writing one of my 1970s retro-game re-writes, & I needed to be able to generate a beep (for period verisimilitude). I had needed this before, & I found the beep crate, which I used, but had to stop using because it wasn't cross-platform.

Then I was writing a new 1970s retro game & needed a beep, so I looked further. There are a variety of platform dependent crates that have a similar function, including:

None of these are cross-platform, & they are all different. This crate fixes that by providing a general beeping interface that works on all platforms.

There are also some cool libraries that are AWESOME, but way more than I needed. One of these was CPAL, which was not what I needed, but with which I could build what I needed.

Futures

Currently, there is one call that blocks. There is no “beep indefinitely” call as the beep crate provides, & it doesn't provide any way to adjust things like the audio device, host audio system, or anything else.

These things are potentially, possibly, something that may be worked on.

License

Licensed under:

Thanks

Thanks to the authors of beep, beep_evdev, & win-beep for inspiration.

Unimaginable, ridiculous thanks to the author(s) of CPAL.

Dependencies

~0.7–29MB
~438K SLoC