#dac #emulator #laser #protocols #etherdream

ether-dream-dac-emulator

A crate for building and running custom Ether Dream DAC emulators

4 releases (2 breaking)

0.3.0 May 19, 2020
0.2.1 Apr 1, 2020
0.2.0 May 20, 2018
0.1.0 May 19, 2018

#13 in #dac

37 downloads per month

MIT/Apache

110KB
2K SLoC

ether-dream-dac-emulator Crates.io Crates.io docs.rs

This contains an ether-dream-dac-emulator crate. This crate may be used to build and run custom, virtual Ether Dream DACs which may be useful for testing and visualisation.

Emulation includes all networking (UDP broadcasting, TCP listening, TCP streaming) and the full set of state machines within the DAC (light engine, playback and source).

Seeing as the virtual DAC does not have a means of emitting physical light, it instead yields "frame"s of points via an Output queue. The rate at which frames are pushed to this queue may be controlled by specifying the frame_rate field within the DAC Description.

The ./dac-emulator/examples demonstrate how the crate may be used for both simple command-line testing and for full visualisation of the DAC emulator output.

extern crate ether_dream_dac_emulator;

fn main() {
    let dac_description = Default::default();
    println!("Creating an emulator for the following Ether Dream DAC:\n{:#?}", dac_description);
    let (broadcaster, mut listener) = ether_dream_dac_emulator::new(dac_description).unwrap();
    println!("Broadcasting DAC once per second...");
    let broadcaster_handle = broadcaster.spawn().unwrap();
    broadcaster_handle.spawn_once_per_second_timer().unwrap();
    println!("Listening for stream connection requests...");
    while let Ok((stream, addr)) = listener.accept() {
        println!("Connected to {}!", addr);
        let output = stream.output();
        loop {
            match output.next_frame() {
                Ok(frame) => println!("\tReceived frame with {} points", frame.len()),
                Err(_) => break,
            }
        }
        println!("Stream connection shutdown. Awaiting new requests...");
    }
}

Acknowledgements

This crate is based upon the work of Jacob Potter, the creator of the Ether Dream DAC. Many of the documentation comments are transcribed directly from their writings in the protocol, while many others are adaptations based on my understanding of the original writings and the source code itself.

License

Licensed under either of

at your option.

Contributions

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~3MB
~45K SLoC