mirror of
https://github.com/ghaisanghaisan/morse_rs.git
synced 2026-08-12 05:46:19 -05:00
readme update
This commit is contained in:
@@ -13,37 +13,41 @@ Add this to your `Cargo.toml`:
|
|||||||
|
|
||||||
```toml
|
```toml
|
||||||
[dependencies]
|
[dependencies]
|
||||||
morse_rs = "0.1.2"
|
morse_rs = "0.1.3"
|
||||||
```
|
```
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
Converts a string to morse then writes the encoded message into a wav file.
|
Converts a string to morse then writes the encoded message into a wav file, specifying the pause times.
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
use morse_rs::{to_morse, write_morse};
|
use morse_rs::{to_morse, write_morse_to_file};
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let my_message = "attack at noon";
|
let my_message = "attack at noon";
|
||||||
let morse = to_morse(my_message);
|
let morse = to_morse(my_message);
|
||||||
|
|
||||||
write_morse("my_message.wav", &morse);
|
write_morse_to_file("my_message.wav", &morse, 150.0, 200.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
We can also write the morse into a buffer in memory
|
We can also write the morse into a buffer in memory, doing so allows the use of transferring data with WebAssembly.
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
use morse_rs::{to_morse, write_morse};
|
use morse_rs::{to_morse, write_morse_in_memory};
|
||||||
|
|
||||||
fn main() {
|
#[wasm_bindgen]
|
||||||
let my_message = "attack at noon";
|
pub fn generate_morse_sound(s: String) -> Vec<u8> {
|
||||||
let morse = to_morse_inmemory(my_message);
|
let encoded = to_morse(&s);
|
||||||
|
let sound = write_morse_in_memory(encoded, 150.0, 200.0);
|
||||||
|
|
||||||
write_morse("my_message.wav", &morse);
|
sound
|
||||||
}
|
}
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## TODO
|
## TODO
|
||||||
- Decode morse from sound
|
- Decode morse from sound
|
||||||
- Add proper rust like error return types
|
- Solve the Riemann Hypothesis
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user