mirror of
https://github.com/exoticorn/microw8.git
synced 2026-01-20 19:26:43 +01:00
Compare commits
1 Commits
v0.2.1-che
...
v0.2.1-sou
| Author | SHA1 | Date | |
|---|---|---|---|
| fa089100be |
1861
Cargo.lock
generated
1861
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -62,7 +62,6 @@ export fn sndGes(t: i32) -> f32 {
|
||||
let phase = channelState!GesChannelState.Phase;
|
||||
|
||||
let inline pulseWidth = channelReg?1;
|
||||
let phaseShift = (pulseWidth - 128) * 255;
|
||||
let invPhaseInc = 1 as f32 / phaseInc as f32;
|
||||
|
||||
i = 0;
|
||||
@@ -131,7 +130,7 @@ export fn sndGes(t: i32) -> f32 {
|
||||
let phaseInc = (freq * (65536.0 / 44100.0)) as i32;
|
||||
|
||||
let phase = channelState!GesChannelState.Phase;
|
||||
if modSrc > ch {
|
||||
if modSrc < ch {
|
||||
phase = phase - (phaseInc << 6);
|
||||
}
|
||||
|
||||
|
||||
@@ -419,6 +419,14 @@ fn init_sound(
|
||||
mem[64..68].copy_from_slice(¤t_time.to_le_bytes());
|
||||
}
|
||||
|
||||
fn clamp_sample(s: f32) -> f32 {
|
||||
if s.is_nan() {
|
||||
0.0
|
||||
} else {
|
||||
s.max(-1.0).min(1.0)
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(ref mut resampler) = resampler {
|
||||
while !buffer.is_empty() {
|
||||
let copy_size = resampler.output_buffers[0]
|
||||
@@ -429,10 +437,12 @@ fn init_sound(
|
||||
resampler.input_buffers[0].clear();
|
||||
resampler.input_buffers[1].clear();
|
||||
for _ in 0..resampler.resampler.input_frames_next() {
|
||||
resampler.input_buffers[0]
|
||||
.push(snd.call(&mut store, (sample_index,)).unwrap_or(0.0));
|
||||
resampler.input_buffers[1]
|
||||
.push(snd.call(&mut store, (sample_index + 1,)).unwrap_or(0.0));
|
||||
resampler.input_buffers[0].push(clamp_sample(
|
||||
snd.call(&mut store, (sample_index,)).unwrap_or(0.0),
|
||||
));
|
||||
resampler.input_buffers[1].push(clamp_sample(
|
||||
snd.call(&mut store, (sample_index + 1,)).unwrap_or(0.0),
|
||||
));
|
||||
sample_index = sample_index.wrapping_add(2);
|
||||
}
|
||||
|
||||
@@ -458,7 +468,7 @@ fn init_sound(
|
||||
}
|
||||
} else {
|
||||
for v in buffer {
|
||||
*v = snd.call(&mut store, (sample_index,)).unwrap_or(0.0);
|
||||
*v = clamp_sample(snd.call(&mut store, (sample_index,)).unwrap_or(0.0));
|
||||
sample_index = sample_index.wrapping_add(1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,4 +15,4 @@ pollster = "0.2"
|
||||
bytemuck = { version = "1.4", features = [ "derive" ] }
|
||||
anyhow = "1"
|
||||
minifb = { version = "0.23.0", default-features = false, features = ["x11"] }
|
||||
winapi = "0.3.9"
|
||||
winapi = { version = "0.3.9", features = ["std"] }
|
||||
|
||||
Reference in New Issue
Block a user