1#![allow(dead_code)]
2#![allow(clippy::module_inception)]
3
4pub mod engine;
5pub mod language;
6pub mod shared;
7pub mod utils;
8
9#[cfg(feature = "plugin")]
11pub mod plugin {
12 pub use crate::engine::plugin::bindings::*;
18
19 pub use crate::{export_plugin, export_plugin_with_state, simple_oscillator_plugin};
21}
22
23#[cfg(all(feature = "cli", not(target_arch = "wasm32")))]
25pub mod platform;
26
27#[cfg(all(feature = "cli", not(target_arch = "wasm32")))]
28pub mod services;
29
30#[cfg(all(feature = "cli", not(target_arch = "wasm32")))]
31pub mod tools;
32
33#[cfg(all(feature = "cli", not(target_arch = "wasm32")))]
34pub mod workspace;
35
36#[cfg(all(target_arch = "wasm32", feature = "wasm"))]
38pub mod web;
39
40#[cfg(all(target_arch = "wasm32", not(feature = "wasm")))]
41pub mod web {
42 pub mod registry {
45 pub mod samples {
46 pub fn get_sample(_name: &str) -> Option<Vec<f32>> {
47 None
48 }
49 }
50 pub mod debug {
51 pub fn log(_msg: &str) {}
52 pub fn is_debug_errors_enabled() -> bool {
53 false
54 }
55 pub fn push_parse_error_from_parts(
56 _source: String,
57 _line: usize,
58 _column: usize,
59 _length: usize,
60 _message: String,
61 _severity: String,
62 ) {
63 }
64 }
65 pub mod banks {
66 use std::collections::HashMap;
67 pub static REGISTERED_BANKS: once_cell::sync::Lazy<
68 std::sync::Mutex<HashMap<String, String>>,
69 > = once_cell::sync::Lazy::new(|| std::sync::Mutex::new(HashMap::new()));
70 }
71 pub mod playhead {
72 #[derive(Default)]
73 pub struct PlayheadEvent {
74 pub kind: String,
75 pub event_type: String,
76 pub midi: Vec<u8>,
77 pub time: f32,
78 pub velocity: f32,
79 pub synth_id: String,
80 pub pitch: u8,
81 pub sample: Option<String>,
82 }
83 pub fn push_event(_event: PlayheadEvent) {}
84 }
85 }
86}
87
88#[cfg(all(target_arch = "wasm32", not(feature = "wasm")))]
89pub mod web_sys {
90 pub mod console {
92 pub fn log_1(_msg: &str) {}
93 pub fn warn_1(_msg: &str) {}
94 }
95}
96
97#[cfg(not(target_arch = "wasm32"))]
98pub mod web {
99 pub mod registry {
100 pub mod samples {
101 pub fn get_sample(_name: &str) -> Option<Vec<f32>> {
102 None
103 }
104 }
105 pub mod debug {
106 pub fn log(_msg: &str) {}
107 pub fn is_debug_errors_enabled() -> bool {
108 false
109 }
110 pub fn push_parse_error_from_parts(
111 _source: String,
112 _line: usize,
113 _column: usize,
114 _length: usize,
115 _message: String,
116 _severity: String,
117 ) {
118 }
119 }
120 pub mod banks {
121 pub struct BankEntry {
122 pub full_name: String,
123 pub alias: String,
124 }
125 use std::cell::RefCell;
126 thread_local! {
127 pub static REGISTERED_BANKS: RefCell<Vec<BankEntry>> = RefCell::new(Vec::new());
128 }
129 }
130 pub mod playhead {
131 pub fn push_event<T>(_event: T) {}
132 }
133 }
134}
135
136#[cfg(all(target_arch = "wasm32", not(any(feature = "wasm", feature = "cli"))))]
137pub mod midly {
138 pub struct Header;
140 pub enum Format {
141 SingleTrack,
142 }
143 pub enum Timing {
144 Metrical(u16),
145 }
146
147 #[derive(Debug, Clone)]
148 pub struct TrackEvent {
149 pub delta: u28,
150 pub kind: TrackEventKind,
151 }
152
153 #[derive(Debug, Clone)]
154 pub struct u28(pub u32);
155 impl From<u32> for u28 {
156 fn from(v: u32) -> Self {
157 u28(v)
158 }
159 }
160
161 #[derive(Debug, Clone)]
162 pub struct u24(pub u32);
163 impl From<u32> for u24 {
164 fn from(v: u32) -> Self {
165 u24(v)
166 }
167 }
168
169 #[derive(Debug, Clone)]
170 pub struct u7(pub u8);
171 impl From<u8> for u7 {
172 fn from(v: u8) -> Self {
173 u7(v)
174 }
175 }
176
177 #[derive(Debug, Clone)]
178 pub struct u4(pub u8);
179 impl From<u8> for u4 {
180 fn from(v: u8) -> Self {
181 u4(v)
182 }
183 }
184
185 #[derive(Debug, Clone)]
186 pub enum MetaMessage {
187 Tempo(u24),
188 EndOfTrack,
189 }
190
191 #[derive(Debug, Clone)]
192 pub enum TrackEventKind {
193 Meta(MetaMessage),
194 Midi { channel: u4, message: MidiMessage },
195 }
196
197 #[derive(Debug, Clone)]
198 pub enum MidiMessage {
199 NoteOn { key: u7, vel: u7 },
200 NoteOff { key: u7, vel: u7 },
201 }
202
203 pub struct Track(Vec<TrackEvent>);
204 impl From<Vec<TrackEvent>> for Track {
205 fn from(events: Vec<TrackEvent>) -> Self {
206 Track(events)
207 }
208 }
209
210 pub struct Smf {
211 pub tracks: Vec<Track>,
212 }
213
214 impl Header {
215 pub fn new(_format: Format, _timing: Timing) -> Self {
216 Header
217 }
218 }
219
220 impl Smf {
221 pub fn new(_header: Header) -> Self {
222 Smf { tracks: Vec::new() }
223 }
224 pub fn write<W: std::io::Write>(&self, _writer: &mut W) -> std::io::Result<()> {
225 Ok(())
226 }
227 }
228}