| Crates.io | tinytones |
| lib.rs | tinytones |
| version | 0.1.0 |
| created_at | 2025-06-17 14:32:15.716603+00 |
| updated_at | 2025-06-17 14:32:15.716603+00 |
| description | A no_std crate for playing musical tones in embedded environments |
| homepage | |
| repository | https://github.com/implferris/tinytones |
| max_upload_size | |
| id | 1715817 |
| size | 16,651 |
tinytones is a #![no_std] Rust crate for defining and playing musical tones and melodies in embedded systems. It provides:
u32 or f64The crate includes a few predefined melodies for convenience:
use tinytones::{Tone, songs::happy_birthday};
let song = Tone::new(happy_birthday::TEMPO, happy_birthday::MELODY);
for (pitch, duration_ms) in song.iter() {
// Send `pitch.freq_u32()` to a PWM
// Wait for `duration_ms` using a delay
}
You can define your own melody using the provided Pitch and Duration enums:
use tinytones::{
note::{Duration::*, Pitch::*},
Tone, Melody,
};
let melody = Melody(&[
(C4, Quarter),
(D4, Quarter),
(E4, Half),
]);
let tempo = 120;
let tone = Tone::new(tempo, melody);
for (pitch, duration_ms) in tone.iter() {
// Send `pitch.freq_u32()` to a PWM
// Wait for `duration_ms` using a delay
}