raw sound samples with rayon
This commit is contained in:
parent
76ced9bb9d
commit
58cf13a564
1 changed files with 4 additions and 2 deletions
|
@ -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<T> Bendable for RawSamples<T>
|
||||
where
|
||||
T: Sample + FromBytes + ToBytes + Zero,
|
||||
T: Sample + FromBytes + ToBytes + Zero + Send,
|
||||
<T as FromBytes>::Bytes: Sized + for<'a> TryFrom<&'a [u8]>,
|
||||
for<'a> Vec<T>: IntoParallelRefMutIterator<'a, Item = &'a mut T>,
|
||||
{
|
||||
type Unit = T;
|
||||
fn map<F: Fn(&Self::Unit) -> 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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue