Working
This commit is contained in:
parent
23bf6da142
commit
9eab9dd9a3
|
@ -1,6 +1,6 @@
|
|||
use std::fmt;
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub enum Codec {
|
||||
Pcm8BitUnsigned,
|
||||
Adpcm4to8,
|
||||
|
@ -12,7 +12,6 @@
|
|||
Adpcm4to16,
|
||||
}
|
||||
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
pub enum BlockType {
|
||||
Terminator,
|
||||
|
@ -44,7 +43,7 @@
|
|||
impl Block for SoundData {
|
||||
fn to_bytes(&self) -> Vec<u8> {
|
||||
let size_bytes : [u8; 4] = self.size.to_le_bytes();
|
||||
let frequency_divisor: u8 = (1844416f32 / self.sample_rate as f32).ceil() as u8;
|
||||
let frequency_divisor: u8 = (256i32 - 1000000i32 / self.sample_rate as i32) as u8;
|
||||
|
||||
let mut result: Vec<u8> = vec![
|
||||
self.block_type as u8,
|
||||
|
@ -52,6 +51,7 @@
|
|||
size_bytes[1],
|
||||
size_bytes[2],
|
||||
frequency_divisor,
|
||||
self.codec as u8
|
||||
];
|
||||
|
||||
result.extend_from_slice(&self.data);
|
||||
|
|
Loading…
Reference in New Issue