Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scope-tui as library crate #7

Open
alemidev opened this issue Apr 4, 2024 · 1 comment
Open

scope-tui as library crate #7

alemidev opened this issue Apr 4, 2024 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@alemidev
Copy link
Owner

alemidev commented Apr 4, 2024

Discussed in https://github.com/alemidev/scope-tui/discussions/6

Originally posted by sbechet March 24, 2024

Hello, I am currently writing a small sound tracking player here. The usage example uses rodio. It might be fun to add scope-tui as a feature. is this a possibility? What do you think about that?


it may be cool to provide scope-tui as a dependency and not only a binary, so that other projects handling music and making TUIs can integrate these visualizers and not reinvent the wheel. idk if we can have a generic event type instead of crossterm's, and also if lib should include parsing/file sources

@alemidev alemidev self-assigned this Apr 4, 2024
@alemidev
Copy link
Owner Author

alemidev commented Apr 4, 2024

Originally posted by alemi April 4, 2024

hey, thanks for your interest! i believe it should be possible but it's probably still quite rough around the edges

i just pushed few commits separating the lib itself from the app code. you should be able to do

scope-tui = { git = "https://github.com/alemidev/scope-tui.git", rev = "b963aba7f93062acadf696efddab23ed93ecb7f2", default-features = false, features = ["tui"] }

and get access to scope lib:

use scope::{input::Matrix, display::{GraphConfig, DisplayMode, oscilloscope::Oscilloscope}};

let data : Matrix<f64> = vec![]; // Matrix<T> == Vec<Vec<T>>
let mut osc = Oscilloscope::default();
let cfg = GraphConfig::default();
let datasets = osc.process(&cfg, data); // these aren't ratatui's Dataset but implement Into<Dataset>

you should probably receive batches of samples from rodio and pass them to Oscilloscope/Vectorscope/Spectroscope. These will process your data and spit out a Vec<DataSet>. Note that DataSet is basically a ratatui's Dataset but with owned strings

let me know if this works for you!

@alemidev alemidev added the enhancement New feature or request label Apr 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant