Skip to content

Commit

Permalink
fix a bug in web &ast
Browse files Browse the repository at this point in the history
  • Loading branch information
kaikalii committed Jun 17, 2024
1 parent c61a8dc commit daae8b2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
15 changes: 10 additions & 5 deletions site/src/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,19 +307,24 @@ impl SysBackend for WebBackend {
}
fn stream_audio(&self, mut f: uiua::AudioStreamFn) -> Result<(), String> {
let mut samples = Vec::new();
let mut t = 0.0;
const SAMPLE_RATE: u32 = 44100;
const SAMPLES_PER_FRAME: usize = 10000;
let mut times = Vec::with_capacity(SAMPLES_PER_FRAME);
let ast_time = get_ast_time();
while t <= ast_time {
let mut i = 0;
while (i as f64 / SAMPLE_RATE as f64) < ast_time {
times.clear();
for _ in 0..SAMPLES_PER_FRAME {
times.push(t);
t += 1.0 / SAMPLE_RATE as f64;
times.push(i as f64 / SAMPLE_RATE as f64);
i += 1;
}
match f(&times) {
Ok(s) => samples.extend(s),
Ok(s) => {
if s.len() > SAMPLES_PER_FRAME {
i += s.len() - SAMPLES_PER_FRAME;
}
samples.extend(s);
}
Err(err) => return Err(format!("{err}")),
}
}
Expand Down
1 change: 0 additions & 1 deletion todo.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Uiua Todo

- 0.12
- `orient` function
- Stack-source locality tutorial
- Rewrite .uasm format
- Fix pad cursor jumping with end-of-line comments
Expand Down

0 comments on commit daae8b2

Please sign in to comment.