-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #64 from instaclustr/wavbrro
Wavbrro format
- Loading branch information
Showing
11 changed files
with
421 additions
and
1 deletion.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ members = [ | |
"optimizer", | ||
"prometheus-remote", | ||
"tools", | ||
"wavbrro", | ||
] | ||
resolver = "2" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
use wavbrro::wavbrro::WavBrro; | ||
use log::debug; | ||
//use clap::{arg, command, Parser}; | ||
|
||
fn main() { | ||
env_logger::init(); | ||
//let arguments = Args::parse(); | ||
//debug!("{:?}", arguments); | ||
debug!("Test, 1,23"); | ||
let mut wb = WavBrro::new(); | ||
wb.add_sample(34.1); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
[package] | ||
name = "wavbrro" | ||
version = "0.1.0" | ||
authors = ["Carlos Rolo <[email protected]>"] | ||
edition = "2021" | ||
license = "Apache-2.0" | ||
description = "An adaptation of the WAV format for use by the BRRO compressor" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
[dependencies] | ||
env_logger = "0.10.0" | ||
log = "0.4.0" | ||
rkyv = { version = "0.7.42", features = ["validation"] } | ||
|
||
[dev-dependencies] | ||
env_logger = "0.10.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# WAVBRRO | ||
|
||
**NOTE:** This needs some serious work! | ||
|
||
WAVBRRO is a based on the WAV format to be used to store raw timeseries data. | ||
|
||
## SPEC | ||
|
||
The spec for WAVBRRO is the following: | ||
|
||
Extension: .wbro | ||
|
||
- Header, 12 Bytes | ||
- 0..3 "WBRO" | ||
- 4..7 Sample number (u32) | ||
- 8..12 "WBRO" | ||
- Internal Structure | ||
- Sample number: u32 | ||
- Bitdepth: u8 [0 -> u8, 1 -> i16, 2 -> i32, 3 -> i64, 4 -> f32, 5 -> f64] | ||
- Samples | ||
- Blocks of 2048 samples | ||
|
||
### Reading/Writting WAVBRRO | ||
|
||
Check the tests in the `wavbrro.rs` | ||
|
||
### What it doesn't support | ||
|
||
WAVBRRO doesn't support the following bitdepths | ||
|
||
- Windows OS | ||
- Timestamps (VSRI will land here eventually) | ||
- Anything other than f64 | ||
- Anything bigger than 64bit bitdepth | ||
|
||
### Next steps | ||
|
||
- Implement streaming read and write | ||
- Seeking for a specific block | ||
- Support other bitdepth |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
pub mod wavbrro; | ||
pub mod read; | ||
pub mod write; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
use std::io::{self, Read, Seek, SeekFrom}; | ||
use std::fs; | ||
use std::fs::File; | ||
use std::path::Path; | ||
|
||
// Function to check if a file is a WAV file | ||
pub fn is_wavbrro_file(file_path: &Path) -> bool { | ||
// Open the file for reading and read the first 12 bytes (header) of the file | ||
let mut file = fs::File::open(file_path).expect("Can't open file!"); | ||
let mut header = [0u8; 12]; | ||
file.read_exact(&mut header).expect("File is too small!"); | ||
&header[0..4] == b"WBRO" && &header[8..12] == b"WBRO" | ||
} | ||
|
||
pub fn read_wavbrro_file(file_path: &Path) -> io::Result<Vec<u8>> { | ||
let mut file = File::open(file_path)?; | ||
let mut contents = Vec::new(); | ||
file.seek(SeekFrom::Start(12))?; | ||
file.read_to_end(&mut contents)?; | ||
Ok(contents) | ||
} |
Oops, something went wrong.