#robot36 #sstv

robot36-encoder

Library to convert images into audio using the robot 36 encoding

4 releases

Uses new Rust 2021

0.2.1 Aug 5, 2022
0.2.0 Aug 5, 2022
0.1.1 May 13, 2019
0.1.0 May 13, 2019

#380 in Encoding

Download history 6/week @ 2022-04-24 10/week @ 2022-05-01 12/week @ 2022-05-08 35/week @ 2022-05-15 10/week @ 2022-05-22 15/week @ 2022-05-29 11/week @ 2022-06-05 2/week @ 2022-06-19 2/week @ 2022-07-03 2/week @ 2022-07-10 4/week @ 2022-07-17 4/week @ 2022-07-24 34/week @ 2022-07-31 17/week @ 2022-08-07

59 downloads per month

MIT license

19KB
291 lines

Robot36-encoder

This is a simple encoder of images into audio samples by using the Robot 36 encoding. It is based on the C implementation of Ahmet. You can use his decoder to decode this image.

It works as a library so you can use in your rust project. You encode a Robot36Image into an iterator of i16 representing each sample of the audio. You can then use this sample to write to an audio file or directly into the audio output. There is an optinal feature image, that can be enabled to add a conversion function from DynamicImage into the Robot36Image.

Bear in mind that breaking changes may and probably will happen in next versions!

Example using Hound

use robot36_encoder::{Encoder, Robot36Image};
use std::env;

/** Simple exmaple.
 * encode-image /path/to/image-input.png /path/to/audio-output.wav
*/
fn main() {
    let args: Vec<String> = env::args().collect();
    let image = image::open(args[1].to_string()).unwrap();
    let encoder = Encoder::new(
        Robot36Image::from_image(image.resize(320, 240, image::imageops::FilterType::Lanczos3))
            .unwrap(),
        48000,
    );
    let samples = encoder.encode();
    let spec = hound::WavSpec {
        channels: 1,
        sample_rate: 48000,
        bits_per_sample: 16,
        sample_format: hound::SampleFormat::Int,
    };
    let mut writer = hound::WavWriter::create(args[2].to_string(), spec).unwrap();
    for sample in samples {
        writer.write_sample(sample).unwrap();
    }
}

Dependencies

~0.5–1.9MB
~33K SLoC