From 58cf13a564fd5e73aa7aeb14f8a0717aebc0f7ff Mon Sep 17 00:00:00 2001 From: Breval Ferrari Date: Mon, 10 Mar 2025 11:06:07 -0400 Subject: [PATCH] raw sound samples with rayon --- bingus/src/snd/raw.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bingus/src/snd/raw.rs b/bingus/src/snd/raw.rs index fa7a8c5..b4309d3 100644 --- a/bingus/src/snd/raw.rs +++ b/bingus/src/snd/raw.rs @@ -4,6 +4,7 @@ use num::{ traits::{FromBytes, ToBytes}, Zero, }; +use rayon::iter::{IntoParallelRefMutIterator, ParallelIterator}; use crate::{Bendable, IntoDataBytes, TryFromDataBytes}; @@ -65,12 +66,13 @@ where impl Bendable for RawSamples where - T: Sample + FromBytes + ToBytes + Zero, + T: Sample + FromBytes + ToBytes + Zero + Send, ::Bytes: Sized + for<'a> TryFrom<&'a [u8]>, + for<'a> Vec: IntoParallelRefMutIterator<'a, Item = &'a mut T>, { type Unit = T; fn map Self::Unit + Sync>(mut self, f: F) -> Self { - self.0.iter_mut().for_each(|e| *e = f(e)); + self.0.par_iter_mut().for_each(|e| *e = f(e)); self } fn format() -> crate::dynamic::Format {