Crates.io | morse_rs |
lib.rs | morse_rs |
version | 0.1.41 |
source | src |
created_at | 2024-10-03 16:58:34.566696 |
updated_at | 2024-12-11 06:03:15.654372 |
description | A simple morse code translator, with the abilty to write to WAV files using Hound. |
homepage | |
repository | |
max_upload_size | |
id | 1395415 |
size | 11,283 |
A simple Morse code translator written in Rust, with the ability to write Morse code to WAV files.
Converts a string to morse then writes the encoded message into a wav file, specifying the pause times.
use morse_rs::{to_morse, write_morse_to_file};
fn main() {
let my_message = "attack at noon";
let morse = to_morse(my_message);
write_morse_to_file("my_message.wav", &morse, 150.0, 200.0);
}
We can also write the morse into a buffer in memory, doing so allows the use of transferring data with WebAssembly.
use morse_rs::{to_morse, write_morse_in_memory};
#[wasm_bindgen]
pub fn generate_morse_sound(s: String) -> Vec<u8> {
let encoded = to_morse(&s);
let sound = write_morse_in_memory(encoded, 150.0, 200.0);
sound
}