A CLI and library to convert data to sound, and vice versa (dependency-free)

Overview

Data to sound

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)

Minimum supported Rust version

The minimum supported Rust version is 1.59.0.

Note

The sound frequency is 202860Hz (202.86kHz), and the sound is mono. The sound is encoded in 16 bits.

Disadvantages

  • The wave file size limit is 4GB, so you can't store more than 4GB of data in a single file.

Advantages

  • 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.

Usage

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.

Library

Add this to your Cargo.toml:

[dependencies]
data2sound = "0.2.0"

See the documentation for more information about the library.

Command line Interface

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

WASI

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.

Install with GitHub CLI

gh release download -R TheAwiteb/data2sound -p "*wasm32-wasi.zip"
unzip *wasm32-wasi.zip # The zip file contains the wasm

Wasmtime

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

Wasmer

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

Use cases

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.

Benchmarks

The following benchmarks were made on a 4.600GHz 12th Gen Intel i7-12700H CPU with 16GB of RAM.

Encoding

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

Decoding

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

Disclaimer

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.

License

This project is licensed under the MIT license. See the LICENSE file for more information.

You might also like...
ears is a simple library to play Sounds and Musics in Rust

ears ears is a simple library to play Sounds and Musics in Rust. ears is build on the top of OpenAL and libsndfile. Provides an access to the OpenAL s

A low-overhead and adaptable audio playback library for Rust

Awedio   A low-overhead and adaptable audio playback library for Rust. Examples Play a single sound file: let (mut manager, backend) = awedio::start()

A rust binding for the FMOD library

rust-fmod This is a rust binding for FMOD, the library developped by FIRELIGHT TECHNOLOGIES. FMOD website : www.fmod.org You can also find it on crate

Cross-platform audio I/O library in pure Rust

CPAL - Cross-Platform Audio Library Low-level library for audio input and output in pure Rust. This library currently supports the following: Enumerat

Rust audio playback library

Audio playback library Rust playback library. Playback is handled by cpal. MP3 decoding is handled by minimp3. WAV decoding is handled by hound. Vorbi

Rust bindings for the soloud audio engine library

soloud-rs A crossplatform Rust bindings for the soloud audio engine library. Supported formats: wav, mp3, ogg, flac. The library also comes with a spe

A song analysis library for making playlists

bliss-rs is the Rust improvement of bliss, a library used to make playlists by analyzing songs, and computing distance between them.

Small music theory library with MIDI capabilities written in Rust
Small music theory library with MIDI capabilities written in Rust

mumuse Small music theory library with MIDI capabilities written in Rust (wip). Examples Creating notes and transpositions // Declare Note from &str l

A library for constructing Groth-Sahai proofs using pre-built wrappers

Groth-Sahai Wrappers A Rust library containing wrappers that facilitate the construction of non-interactive witness-indistinguishable and zero-knowled

Comments
  • Strip the header

    Strip the header

    Our wave file is two section, the first section is the wave header (44 bytes) and second section is the original file data. And the decoding process taking long than encoding (x2 benchmarks). I think is better to strip it and rewrite the data to the output file. @Amjad50 what do you think?

    My prototype of strip way with 2.7 GB

    Executed in 4.79 secs fish external usr time 3.17 secs 550.00 micros 3.17 secs sys time 1.54 secs 353.00 micros 1.54 secs

    Current way with 2.7 GB

    Executed in 12.62 secs fish external usr time 11.04 secs 472.00 micros 11.04 secs sys time 1.54 secs 279.00 micros 1.54 secs

    enhancement 
    opened by TheAwiteb 1
Releases(v0.2.2)
Owner
Awiteb
Some(Programmer { langs: vec!['πŸ¦€','🐍'] })
Awiteb
Rust Sound Synthesis Library

Oscen Oscen [β€œoh-sin”] is a library for building modular synthesizers in Rust. It contains a collection of components frequently used in sound synthes

Reed Rosenbluth 104 Nov 2, 2022
A Rust environment for sound synthesis and algorithmic composition.

Sorceress A Rust environment for sound synthesis and algorithmic composition, powered by SuperCollider. Overview Sorceress is a Rust crate that provid

Wesley Merkel 82 Dec 26, 2022
Program to check if stereo wav files have identical channels (faux-stereo) and convert them to mono.

zrtstr Command line application for checking WAV-files for identical channels, detecting faux-stereo files generated by some audio-editing software an

Kirill 22 Nov 6, 2022
Implements the free and open audio codec Opus in Rust.

opus-native Overview Implements the free and open audio codec Opus in Rust. Status This crate is under heavy development. Most functionality is not wo

Nils Hasenbanck 9 Nov 28, 2022
A free file hosting server that focuses on speed, reliability and security.

Triox Next Generation cloud storage server that is secure, fast, and reliable. Why Triox? ☘️ Open Source - We strongly believe in collaboration and tr

Triox 81 Nov 16, 2022
A library and application for lossless, format-preserving, two-pass optimization and repair of Vorbis data, reducing its size without altering any audio information.

OptiVorbis A library and application for lossless, format-preserving, two-pass optimization and repair of Vorbis data, reducing its size without alter

OptiVorbis 27 Jan 3, 2023
A simple CLI audio player with strange features.

legacylisten legacylisten is a simple CLI audio player I wrote because no existing one fulfilled my needs. The main feature is that you can change how

Matthias Kaak 3 Jun 8, 2022
CLI Rust Audio Visualizer

crav Console-based Rust Audio Visualizer It can run in the terminal but also has a 3D accelerated backend implemented in wgpu. demo compatibility The

null 20 Oct 16, 2022
Symphonia is a pure Rust audio decoding and media demuxing library supporting AAC, FLAC, MP3, MP4, OGG, Vorbis, and WAV.

Pure Rust multimedia format demuxing, tag reading, and audio decoding library

Philip Deljanov 1k Jan 2, 2023
A wav encoding and decoding library in Rust

Hound A wav encoding and decoding library in Rust. Hound can read and write the WAVE audio format, an ubiquitous format for raw, uncompressed audio. T

Ruud van Asseldonk 345 Dec 27, 2022