cursed additions
This commit is contained in:
parent
c8d33b3c41
commit
ba25b7c89f
1 changed files with 9 additions and 5 deletions
14
src/dac.rs
14
src/dac.rs
|
|
@ -169,6 +169,10 @@ impl<'a> DpcmDecoder<'a> {
|
||||||
// output the next sample's amplitude
|
// output the next sample's amplitude
|
||||||
pub fn output_next(&mut self) -> usize {
|
pub fn output_next(&mut self) -> usize {
|
||||||
if let Some(data) = self.data {
|
if let Some(data) = self.data {
|
||||||
|
if (self.index >= data.len() * 2) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
let sub_index = 1 - self.index % 2;
|
let sub_index = 1 - self.index % 2;
|
||||||
|
|
||||||
let sample = DpcmSample::new(data[self.index / 2], sub_index);
|
let sample = DpcmSample::new(data[self.index / 2], sub_index);
|
||||||
|
|
@ -188,11 +192,11 @@ impl<'a> DpcmDecoder<'a> {
|
||||||
self.index = self.index + 1;
|
self.index = self.index + 1;
|
||||||
|
|
||||||
// reset the index to 0 if we roll over
|
// reset the index to 0 if we roll over
|
||||||
if (self.index >= data.len() * 2) {
|
// if (self.index >= data.len() * 2) {
|
||||||
self.index = 0;
|
// self.index = 0;
|
||||||
self.prev_amplitude = 0x74;
|
// self.prev_amplitude = 0x74;
|
||||||
samples_remaining = false;
|
// samples_remaining = false;
|
||||||
}
|
// }
|
||||||
|
|
||||||
// return the normalized amplitude
|
// return the normalized amplitude
|
||||||
return normalized_amplitude;
|
return normalized_amplitude;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue