From 1dec7aad5676a903ccf4af16fccb4b9d0127e028 Mon Sep 17 00:00:00 2001 From: p6nj Date: Sun, 7 Jul 2024 08:53:56 +0200 Subject: [PATCH] yay! macro! --- bingus/src/lib.rs | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/bingus/src/lib.rs b/bingus/src/lib.rs index 8c9509a..adb5159 100644 --- a/bingus/src/lib.rs +++ b/bingus/src/lib.rs @@ -3,7 +3,7 @@ use std::{ ops::{BitOr, Shl}, }; -use dasp_sample::{FromSample, Sample, U24}; +use dasp_sample::{FromSample, Sample, U24, U48}; use fundsp::Real; pub type Byte = u8; @@ -32,4 +32,20 @@ where } } -impl BytesToSample> for [Byte; 3] {} +macro_rules! impl_bts_for_array_of { + ($($N:expr, $Ir:ty);*) => + { + $( + impl BytesToSample<$Ir, Byte, array::IntoIter> for [Byte; $N] {} + )* + } +} + +impl_bts_for_array_of! { + 1, u8; + 2, u16; + 3, U24; + 4, u32; + 6, U48; + 8, u64 +}