it works!!
This commit is contained in:
parent
14c98f484b
commit
5c2607b574
9 changed files with 37 additions and 67 deletions
|
@ -14,5 +14,4 @@ keywords.workspace = true
|
|||
image = { workspace = true }
|
||||
fundsp = { workspace = true }
|
||||
anyhow = { workspace = true }
|
||||
dasp_sample = { workspace = true }
|
||||
bingus = { workspace = true }
|
||||
|
|
|
@ -1,7 +1,39 @@
|
|||
use std::array;
|
||||
|
||||
use anyhow::Result;
|
||||
use bingus::convert::samples::BytesToSample;
|
||||
use fundsp::{
|
||||
hacker::{bell_hz, pipei, U12},
|
||||
math::db_amp,
|
||||
};
|
||||
use image::io::Reader as ImageReader;
|
||||
|
||||
fn main() -> Result<()> {
|
||||
dbg!([1u8, 2, 3].to_sample::<f64>());
|
||||
let mut img = ImageReader::open("bmp/bigsample.bmp")?.decode()?.to_rgb8();
|
||||
let mut equalizer =
|
||||
pipei::<U12, _, _>(|i| bell_hz(1000.0 + 1000.0 * i as f32, 1.0, db_amp(0.0)));
|
||||
img.to_vec()
|
||||
.chunks_exact(3)
|
||||
.map(|px: &[u8]| f32::from_ne_bytes(array::from_fn(|i| px[i % px.len()])))
|
||||
.map(|x| equalizer.filter_mono(x))
|
||||
.flat_map(|px| -> [u8; 3] {
|
||||
let px = px.to_ne_bytes();
|
||||
array::from_fn(move |i| px[i])
|
||||
})
|
||||
.zip(img.as_mut())
|
||||
.for_each(|(filtered, original)| *original = filtered);
|
||||
img.save("bmp/out.bmp")?;
|
||||
|
||||
// let bytes: Vec<u8> = (1u8..7).into_iter().collect();
|
||||
// assert_eq!(
|
||||
// bytes,
|
||||
// bytes
|
||||
// .chunks_exact(3)
|
||||
// .map(|px: &[u8]| f64::from_ne_bytes(array::from_fn(|i| px[i % px.len()])))
|
||||
// .flat_map(|px: f64| -> [u8; 3] {
|
||||
// let px = px.to_ne_bytes();
|
||||
// array::from_fn(move |i| px[i])
|
||||
// })
|
||||
// .collect::<Vec<u8>>()
|
||||
// );
|
||||
Ok(())
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue