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, Call, CallStats, Counters, Cut, DEFAULT_CACHE_BYTES, DEFAULT_MARK_EVERY,
31 DEFAULT_STORE_BYTES, EngineStats, FETCH_READS, Hash, INDEX_NAME, Kind, Lookup, Nothing,
32 Outcome, PayloadKind, Persisted, Phase, STORE_FORMAT, Store, Stored, Tally, Tier, Worked,
33};
34pub use cast::Cast;
35pub use error::{BindingFault, Diagnostic, EngineError, Located, REGISTRY};
36pub use meaning::{Meaning, meaning};
37pub use query::{
38 Answer, Arg, Ask, Atom, DEFAULT_BUFFER_SECS, DEFAULT_CELL_SECS, DEFAULT_FLOOR_DB,
39 DEFAULT_FRAME_SECS, DEFAULT_LEDGER_DEPTH, DEFAULT_MAX_PAIRS, DEFAULT_MAX_PEAKS,
40 DEFAULT_MODULATION_WINDOW_SECS, DEFAULT_NOVELTY_WINDOW_SECS, DEFAULT_OVERSAMPLE,
41 DEFAULT_PERIODICITY_WINDOW_SECS, DEFAULT_SMOOTH_SECS, Given, Harmonic, Output, READINGS,
42 Reading, Reads, Representation,
43};
44pub use refs::{identity, nodes_in, spectral_sum_of};
45pub use render::until::{Cmp, Term};
46pub use render::{
47 Abandon, Built, Change, Changed, Counts, Handle, Hear, LATEST, NOTES, Never, Out, Placed,
48 Range, Render, RenderConfig, STREAMED, Session, Stream, StreamConfig, Until, Work, answer,
49 answer_buffer, change, ends, fetch, plan, render, render_called, render_in, render_over,
50 sketch_atom,
51};
52pub use schedule::{Order, Schedule, schedule_from};
53pub use sva_formula::{C64, Codomain, Held, Line, NodeId, SpectralSum, Ty, Var};
54pub use sva_samples::measure::{harmony, modulation, periodicity, pitch, self_similarity, sliding};
55pub use sva_samples::{
56 Alias, AliasBand, BAND_COUNT, BandCrest, BandTrack, Bands, Buffer, Crest,
57 CuttingBelowSilenceThreshold, Detail, EnvelopeFrame, Extent, FormantFrame, Frames, Label,
58 LedgerEntry, Loudness, LoudnessFrame, MAX_PINNED_FRAME, Onsets, PSYCHOACOUSTIC_V1, PitchFrame,
59 Profile, Rule, SignalKind, Source, Spectrum, StereoFrame, StereoImage, measure_alias,
60 pinned_frame,
61};
62pub use threads::default_threads;
63pub use trace::{Traced, Up, trace};
64pub use typing::{Typing, Value, When};
65pub use vocabulary::{MAX_WIDTH, named_may_move, recognized_named, shape, shape_name};
66
67use sva_ast::Graph;
68
69pub const DEFAULT_SAMPLE_RATE: u32 = 44_100;
70
71pub fn check_structure(graph: &Graph, root: &str) -> Result<(), EngineError> {
73 types(graph, root).map(|_| ())
74}
75
76pub fn types(graph: &Graph, root: &str) -> Result<Typing, EngineError> {
78 types_at(graph, root, DEFAULT_SAMPLE_RATE)
79}
80
81pub fn types_at(graph: &Graph, root: &str, rate: u32) -> Result<Typing, EngineError> {
83 let instances = instantiate::instantiate(graph, root, rate)?;
84 let held = instances.instance_of(root)?;
86 let order = schedule::schedule_from(&instances, std::slice::from_ref(&held))?;
87 typing::infer_all(&instances, &order)
88}