1use core::ops;
2use euphony_buffer::{AsChannel, Buffer};
3
4macro_rules! g {
5 ($name:ident, $($hash:literal,)*) => {
6 pub static $name: &crate::Group = &crate::Group({
7 use crate::Buffer;
8 &[
9 $({
10 static B: Buffer = Buffer::new(concat!(
11 "https://raw.githubusercontent.com/camshaft/euphony-samples/main/",
12 $hash,
13 ".wav"
14 ));
15 &B
16 }),*
17 ]
18 });
19 };
20}
21
22pub struct Group(&'static [&'static Buffer]);
23
24impl ops::Deref for Group {
25 type Target = [&'static Buffer];
26
27 fn deref(&self) -> &Self::Target {
28 self.0
29 }
30}
31
32impl ops::Index<usize> for Group {
33 type Output = Buffer;
34
35 fn index(&self, index: usize) -> &Self::Output {
36 let index = index % self.0.len();
37 self.0[index]
38 }
39}
40
41impl AsChannel for Group {
42 fn buffer<F: FnOnce(&std::path::Path, &str) -> u64>(&self, init: F) -> u64 {
43 AsChannel::buffer(&self[0], init)
44 }
45
46 fn channel(&self) -> u64 {
47 AsChannel::channel(&self[0])
48 }
49
50 fn duration(&self) -> std::time::Duration {
51 AsChannel::duration(&self[0])
52 }
53}
54
55impl IntoIterator for &Group {
56 type Item = &'static Buffer;
57 type IntoIter = core::iter::Copied<core::slice::Iter<'static, Self::Item>>;
58
59 fn into_iter(self) -> Self::IntoIter {
60 self.0.iter().copied()
61 }
62}
63
64#[cfg(test)]
65mod generator;
66
67mod samples;
68pub use samples::*;
69
70mod waveforms;
71pub use waveforms::*;