Crates.io | data2sound |
lib.rs | data2sound |
version | 0.2.2 |
source | src |
created_at | 2023-02-24 16:52:36.124677 |
updated_at | 2023-03-01 09:38:46.433198 |
description | A library to convert data to sound, and vice versa, supports WASI (dependency-free) |
homepage | |
repository | https://github.com/TheAwiteb/data2sound |
max_upload_size | |
id | 793764 |
size | 18,065 |
A simple crate to convert data to sound, and sound to data. The sound file format is wave (.wav). You can use it as a library or as a command line tool, also supports WASI. (dependency-free)
The minimum supported Rust version is 1.59.0.
The sound frequency is 202860Hz (202.86kHz), and the sound is mono. The sound is encoded in 16 bits.
The sound file is a standard .wav file, so you can play it with any audio player.
The sound file will be the same size as the data file.
There are two ways to use this crate. As a library, or as a command line tool. The library is the core of the tool, so you can use the library to create your own tool. Also we support WASI, so you can use the cli in a WASI environment.
Add this to your Cargo.toml:
[dependencies]
data2sound = "0.2.0"
See the documentation for more information about the library.
Install the tool with cargo:
cargo install data2sound
Run the tool with:
data2sound --help
And to convert a file to sound:
data2sound encode input_file output_file.wav
And to convert a sound file to data:
data2sound decode input_file.wav output_file
You can use the CLI in a WASI environment. All you need to do is to install the wasm file from the releases page, and to run it with wasmtime or wasmer.
gh release download -R TheAwiteb/data2sound -p "*wasm32-wasi.zip"
unzip *wasm32-wasi.zip # The zip file contains the wasm
You need to get access to the directory where the input file is located, and to the directory where the output file will be created. You can do that with the --dir
flag.
Help message:
wasmtime data2sound.wasm -- --help
Encoding and decoding:
wasmtime data2sound.wasm --dir . -- encode input_file output_file.wav
wasmtime data2sound.wasm --dir . -- decode input_file.wav output_file
The same as with wasmtime Help message:
wasmer data2sound.wasm -- --help
Encoding and decoding:
wasmer data2sound.wasm --dir . -- encode input_file output_file.wav
wasmer data2sound.wasm --dir . -- decode input_file.wav output_file
This crate can be used to store data in a sound file, and to retrieve the data from the sound file. This can be useful for storing data in a sound file.
The following benchmarks were made on a 4.600GHz 12th Gen Intel i7-12700H CPU with 16GB of RAM.
File size | Audio file size | Audio length | Speed | Link |
---|---|---|---|---|
2687.94MB | 2687.94MB | 01:28:13 | 1.47s | Soundcloud-link |
35.3MB | 35.3MB | 00:01::27 | 39.07ms | Soundcloud-link |
File size | Audio file size | Audio length | Speed | Link |
---|---|---|---|---|
2687.94MB | 2687.94MB | 01:28:13 | 1.44s | Soundcloud-link |
35.3MB | 35.3MB | 00:01::27 | 38.97ms | Soundcloud-link |
This tool was designed for educational purposes as it explains how to save data in an audio file. It is not recommended to exploit this thing to use cloud audio storage services to store your data, as your account may be banned.
This project is licensed under the MIT license. See the LICENSE file for more information.