#morse #wav #translator #write #text #generate #hound

morse_rs

A simple morse code translator, with the abilty to write to WAV files using Hound

4 releases

0.1.4 Oct 9, 2024
0.1.3 Oct 9, 2024
0.1.2 Oct 5, 2024
0.1.1 Oct 3, 2024
0.1.0 Oct 3, 2024

#237 in Audio

Download history 301/week @ 2024-09-30 263/week @ 2024-10-07

564 downloads per month

MIT license

10KB
224 lines

morse_rs

A simple Morse code translator written in Rust, with the ability to write Morse code to WAV files.

Features

  • Translate text to Morse code and vice versa
  • Generate WAV files from Morse code sequences

Installation

Add this to your Cargo.toml:

[dependencies]
morse_rs = "0.1.4"

Usage

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
}

TODO

  • Decode morse from sound
  • Solve the Riemann Hypothesis

Dependencies

~120KB