actually_beep

Crates.ioactually_beep
lib.rsactually_beep
version0.1.1
sourcesrc
created_at2024-06-03 23:44:47.462996
updated_at2024-06-05 03:39:36.780266
descriptionA cross platform library to provides easy to use beep functions that actually beep
homepage
repositoryhttps://github.com/evanjpw/actually_beep
max_upload_size
id1260565
size43,903
Evan Williams (evanjpw)

documentation

README

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.

Commit count: 5

cargo fmt