Skip to content

Commit

Permalink
Auto merge of #331 - khodzha:issue_300_2, r=Manishearth
Browse files Browse the repository at this point in the history
  • Loading branch information
bors-servo authored Jan 28, 2020
2 parents 2ea0e52 + b5f1516 commit bc8c7f7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
16 changes: 12 additions & 4 deletions audio/buffer_source_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -394,10 +394,18 @@ impl AudioBuffer {

let prev = pos.floor() as usize;
let offset = pos - pos.floor();
let next_sample = *self.buffers[chan as usize].get(prev + 1).unwrap_or(&0.0);

((1. - offset) * (self.buffers[chan as usize][prev] as f64) + offset * (next_sample as f64))
as f32
match self.buffers[chan as usize].get(prev + 1) {
Some(next_sample) => {
((1. - offset) * (self.buffers[chan as usize][prev] as f64)
+ offset * (*next_sample as f64)) as f32
}
_ => {
// linear extrapolation of two prev samples
((1. + offset) * (self.buffers[chan as usize][prev] as f64)
- offset * (self.buffers[chan as usize][prev - 1] as f64))
as f32
}
}
}

pub fn data_chan_mut(&mut self, chan: u8) -> &mut [f32] {
Expand Down
2 changes: 1 addition & 1 deletion audio/panner_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ impl AudioNodeEngine for PannerNode {
let x = if mono {
(azimuth + 90.) / 180.
} else if azimuth <= 0. {
(azimuth + 90. / 90.)
(azimuth + 90.) / 90.
} else {
azimuth / 90.
};
Expand Down

0 comments on commit bc8c7f7

Please sign in to comment.