From 0e447ca05ff0c0fe91ec9a9a9091940680f967ba Mon Sep 17 00:00:00 2001 From: Tom Barrett Date: Wed, 11 Mar 2020 07:15:16 -0500 Subject: waveform is now accurately shown --- src/tom.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/tom.rs') diff --git a/src/tom.rs b/src/tom.rs index a8fd4a4..8a55f44 100644 --- a/src/tom.rs +++ b/src/tom.rs @@ -58,14 +58,14 @@ pub struct Tom { border: Vec>, wave: Vec, last_x: usize, - samples: Vec, + waveform: Vec, tessalations: Vec, } impl Tom { - pub fn new(samples: Vec) -> Tom { + pub fn new(waveform: Vec) -> Tom { Tom { - samples, + waveform, border: gen_border(), wave: Vec::new(), last_x: 0, @@ -127,20 +127,20 @@ impl Tom { self.wave.clear(); let start = self.last_x; - let end = start + 10; + let end = start + 3000; - let max_y = 200.0; - let min_y = -200.0; + let max_y = *self.waveform.iter().max().unwrap() as f32; + let min_y = *self.waveform.iter().min().unwrap() as f32; for x in start..end { self.wave.push(Vertex { position: VertexPosition::new([ relative(x as f32, start as f32, end as f32, -0.9, 0.9), - relative(self.samples[x] as f32, min_y, max_y, -0.9, 0.9), + relative(self.waveform[x] as f32, min_y, max_y, -0.9, 0.9), ]), color: VertexRGB::new(constants::C64_GREEN), }); } - self.last_x += 1; + self.last_x += constants::SAMPLE_RATE / 60; } } -- cgit v1.2.3