1mod arguments;
4mod bindings;
5mod cache;
6mod cast;
7mod error;
8mod index;
9pub mod instantiate;
10mod loops;
11mod lower;
12mod meaning;
13pub mod overload;
14pub mod query;
15mod recent;
16mod refs;
17pub mod render;
18mod schedule;
19mod steps;
20mod threads;
21mod time;
22mod trace;
23mod typing;
24mod vocabulary;
25
26pub use arguments::{Argument, Arguments, Called, Chosen};
27pub use bindings::Binding;
28pub use cache::log::cache_log;
29pub use cache::{
30 Backend, CacheStats, Counters, DEFAULT_CACHE_BYTES, DEFAULT_MARK_EVERY, DEFAULT_STORE_BYTES,
31 FETCH_READS, Hash, INDEX_NAME, Lookup, Nothing, Outcome, PayloadKind, Persisted, STORE_FORMAT,
32 Store, Stored, Tier,
33};
34pub use cast::Cast;
35pub use error::{BindingFault, Diagnostic, EngineError, Located, REGISTRY};
36pub use meaning::{Meaning, meaning};
37pub use query::{Answer, Ask, DEFAULT_FRAME_SECS, Output, Representation};
38pub use refs::{identity, nodes_in, spectral_sum_of};
39pub use render::until::{Cmp, Term};
40pub use render::{
41 Abandon, Built, Change, Changed, Counts, Handle, LATEST, NOTES, Never, Out, Placed, Range,
42 Render, RenderConfig, STREAMED, Session, Stream, StreamConfig, Until, Work, answer,
43 answer_buffer, change, ends, fetch, plan, render, render_in, render_over, sketch_atom,
44};
45pub use schedule::{Order, Schedule, schedule_from};
46pub use sva_formula::{C64, Codomain, Held, Line, NodeId, SpectralSum, Ty, Var};
47pub use sva_samples::{
48 Alias, AliasBand, BAND_COUNT, BandCrest, BandTrack, Bands, Buffer, Crest,
49 CuttingBelowSilenceThreshold, Detail, EnvelopeFrame, Extent, FormantFrame, Frames, Label,
50 LedgerEntry, Loudness, LoudnessFrame, MAX_PINNED_FRAME, Onsets, PSYCHOACOUSTIC_V1, PitchFrame,
51 Profile, Rule, SignalKind, Source, Spectrum, StereoFrame, StereoImage, measure_alias,
52 pinned_frame,
53};
54pub use threads::default_threads;
55pub use trace::{Traced, Up, trace};
56pub use typing::{Typing, Value, When};
57pub use vocabulary::{MAX_WIDTH, named_may_move, recognized_named, shape, shape_name};
58
59use sva_ast::Graph;
60
61pub const DEFAULT_SAMPLE_RATE: u32 = 44_100;
62
63pub fn check_structure(graph: &Graph, root: &str) -> Result<(), EngineError> {
65 types(graph, root).map(|_| ())
66}
67
68pub fn types(graph: &Graph, root: &str) -> Result<Typing, EngineError> {
70 types_at(graph, root, DEFAULT_SAMPLE_RATE)
71}
72
73pub fn types_at(graph: &Graph, root: &str, rate: u32) -> Result<Typing, EngineError> {
75 let instances = instantiate::instantiate(graph, root, rate)?;
76 let held = instances.instance_of(root)?;
78 let order = schedule::schedule_from(&instances, std::slice::from_ref(&held))?;
79 typing::infer_all(&instances, &order)
80}