Move more stuff around.
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
03fd0b7641
commit
a67270e671
|
@ -4,67 +4,6 @@ use nom::error::{Error, ErrorKind};
|
|||
use nom::number::streaming::{le_u16, le_u24, le_u32, le_u8};
|
||||
use nom::{Err, IResult};
|
||||
|
||||
impl BlockType {
|
||||
pub fn info(&self) {
|
||||
match self {
|
||||
BlockType::Terminator => println!("Terminator"),
|
||||
BlockType::SoundData {
|
||||
sample_rate,
|
||||
codec,
|
||||
data,
|
||||
} => {
|
||||
println!(
|
||||
"Sound data: sample rate = {}, codec = {:?}, size = {}",
|
||||
sample_rate,
|
||||
codec,
|
||||
data.len()
|
||||
)
|
||||
}
|
||||
BlockType::SoundDataContinuation { data } => {
|
||||
println!("Sound data continuation: size = {}", data.len())
|
||||
}
|
||||
BlockType::Silence {
|
||||
length,
|
||||
sample_rate,
|
||||
} => {
|
||||
println!(
|
||||
"Silence: length = {}, sample rate = {}",
|
||||
length, sample_rate
|
||||
)
|
||||
}
|
||||
BlockType::Marker { value } => {
|
||||
println!("Marker: value = {}", value)
|
||||
}
|
||||
BlockType::Text { data } => {
|
||||
println!("Text: size = {}", data.len())
|
||||
}
|
||||
BlockType::RepeatStart { count } => {
|
||||
println!("Repeat: repetitions = {}", count)
|
||||
}
|
||||
BlockType::RepeatEnd => {
|
||||
println!("End repeat")
|
||||
}
|
||||
BlockType::ExtraInformation { sample_rate, codec, channels } => println!(
|
||||
"Extra information: sample rate = {}, channels = {}, codec = {:?}",
|
||||
sample_rate,
|
||||
channels,
|
||||
codec,
|
||||
),
|
||||
BlockType::SoundDataNew {
|
||||
sample_rate, bits, channels, codec, reserved, data
|
||||
} => println!(
|
||||
"Sound data (NEW): sample rate = {}, bits = {}, channels = {}, codec = {:?}, reserved: {}, size = {}",
|
||||
sample_rate,
|
||||
bits,
|
||||
channels,
|
||||
codec,
|
||||
reserved,
|
||||
data.len()
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn parse_sound_data(input: &[u8]) -> IResult<&[u8], BlockType> {
|
||||
let (input, block_size) = le_u24(input)?;
|
||||
let (input, frequency_divisor) = le_u8(input)?;
|
||||
|
|
95
src/types.rs
95
src/types.rs
|
@ -1,6 +1,25 @@
|
|||
pub const SIGNATURE1: &str = "Creative Voice File";
|
||||
pub const SIGNATURE2: [u8; 3] = [0x1A, 0x1A, 0x0];
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Voc {
|
||||
pub version: Version,
|
||||
pub checksum: Checksum,
|
||||
pub blocks: Vec<BlockType>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Version {
|
||||
pub major: u8,
|
||||
pub minor: u8,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Checksum {
|
||||
pub value: u16,
|
||||
pub valid: bool,
|
||||
}
|
||||
|
||||
#[derive(Eq, Debug, PartialEq)]
|
||||
pub enum Codec {
|
||||
Pcm8BitUnsigned,
|
||||
|
@ -53,21 +72,63 @@ pub enum BlockType {
|
|||
},
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Version {
|
||||
pub major: u8,
|
||||
pub minor: u8,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Checksum {
|
||||
pub value: u16,
|
||||
pub valid: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Voc {
|
||||
pub version: Version,
|
||||
pub checksum: Checksum,
|
||||
pub blocks: Vec<BlockType>,
|
||||
impl BlockType {
|
||||
pub fn info(&self) {
|
||||
match self {
|
||||
BlockType::Terminator => println!("Terminator"),
|
||||
BlockType::SoundData {
|
||||
sample_rate,
|
||||
codec,
|
||||
data,
|
||||
} => {
|
||||
println!(
|
||||
"Sound data: sample rate = {}, codec = {:?}, size = {}",
|
||||
sample_rate,
|
||||
codec,
|
||||
data.len()
|
||||
)
|
||||
}
|
||||
BlockType::SoundDataContinuation { data } => {
|
||||
println!("Sound data continuation: size = {}", data.len())
|
||||
}
|
||||
BlockType::Silence {
|
||||
length,
|
||||
sample_rate,
|
||||
} => {
|
||||
println!(
|
||||
"Silence: length = {}, sample rate = {}",
|
||||
length, sample_rate
|
||||
)
|
||||
}
|
||||
BlockType::Marker { value } => {
|
||||
println!("Marker: value = {}", value)
|
||||
}
|
||||
BlockType::Text { data } => {
|
||||
println!("Text: size = {}", data.len())
|
||||
}
|
||||
BlockType::RepeatStart { count } => {
|
||||
println!("Repeat: repetitions = {}", count)
|
||||
}
|
||||
BlockType::RepeatEnd => {
|
||||
println!("End repeat")
|
||||
}
|
||||
BlockType::ExtraInformation { sample_rate, codec, channels } => println!(
|
||||
"Extra information: sample rate = {}, channels = {}, codec = {:?}",
|
||||
sample_rate,
|
||||
channels,
|
||||
codec,
|
||||
),
|
||||
BlockType::SoundDataNew {
|
||||
sample_rate, bits, channels, codec, reserved, data
|
||||
} => println!(
|
||||
"Sound data (NEW): sample rate = {}, bits = {}, channels = {}, codec = {:?}, reserved: {}, size = {}",
|
||||
sample_rate,
|
||||
bits,
|
||||
channels,
|
||||
codec,
|
||||
reserved,
|
||||
data.len()
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue