This commit is contained in:
Pedro de Oliveira 2022-11-13 03:12:51 +00:00
parent d55935c54b
commit 8e7c90a770
1 changed files with 324 additions and 326 deletions

View File

@ -29,7 +29,7 @@
#[derive(Debug)]
pub struct VocFile {
pub version: (u8, u8),
pub blocks: Vec<BlockT>
pub blocks: Vec<BlockT>,
}
impl VocFile {
@ -128,14 +128,14 @@
let block = SoundData::new(block_size, sample_rate, codec, data);
voc.blocks.push(Box::new(block));
},
}
BlockType::SoundDataContinuation => {
let mut data: Vec<u8> = vec![0; (next - address) as usize];
drop(fp.read(&mut data));
let block = SoundDataContinuation::new(block_size, data);
voc.blocks.push(Box::new(block));
},
}
BlockType::Silence => {
let mut length_buffer: [u8; 2] = [0; 2];
drop(fp.read(&mut length_buffer));
@ -154,11 +154,9 @@
let block = Text { block_type, size: block_size, data };
voc.blocks.push(Box::new(block));
},
}
_ => panic!("block Type {:?} not implemented", block_type),
}
}
voc
}
@ -185,7 +183,7 @@
size_bytes[1],
size_bytes[2],
frequency_divisor,
self.codec as u8
self.codec as u8,
];
result.extend_from_slice(&self.data);
@ -291,7 +289,7 @@
size,
sample_rate,
codec,
data
data,
}
}
}
@ -315,7 +313,7 @@
Self {
block_type: BlockType::SoundDataContinuation,
size,
data
data,
}
}
}