1use std::sync::Arc;
2use crate::waveform::WaveformType;
3use crate::effects::EffectsChain;
4
5#[derive(Debug, Clone)]
6pub struct SampleData {
7 pub samples: Arc<Vec<f32>>,
8 pub sample_rate: u32,
9}
10
11#[derive(Debug, Clone)]
12pub enum InstrumentSource {
13 Synthesized(WaveformType),
14 Sample(SampleData),
15}
16
17#[derive(Debug, Clone)]
18pub struct Instrument {
19 pub name: String,
20 pub source: InstrumentSource,
21 pub attack: f32, pub decay: f32,
23 pub sustain: f32,
24 pub release: f32,
25 pub volume: f32,
26 pub pitch: f32,
27 pub pan: f32, pub detune: f32, pub effects: EffectsChain,
30}
31
32impl Default for Instrument {
33 fn default() -> Self {
34 Instrument {
35 name: "Boomie".to_string(),
36 source: InstrumentSource::Synthesized(WaveformType::Sine),
37 attack: 0.01,
38 decay: 0.1,
39 sustain: 0.8,
40 release: 0.2,
41 volume: 0.5,
42 pitch: 1.0,
43 pan: 0.0,
44 detune: 0.0,
45 effects: EffectsChain::default(),
46 }
47 }
48}
49
50#[derive(Debug, Clone)] pub struct Note {
52 pub pitch: f32,
53 pub duration: f32,
54 pub velocity: f32,
55 pub pan: Option<f32>,
56 pub slide_to: Option<f32>,
57}
58
59#[derive(Debug, Clone)]
61pub struct Chord {
62 pub pitches: Vec<f32>,
63 pub duration: f32,
64 pub velocity: f32,
65}
66
67#[derive(Debug, Clone)]
69pub enum SequenceElement {
70 Note(Note),
71 Chord(Chord),
72 Rest(f32),
73}