Feat: documentation, UI/UX
This commit is contained in:
@@ -176,7 +176,7 @@ impl SpectrumAnalyzer {
|
||||
let avg = sum / (hi - lo) as f32;
|
||||
let amplitude = avg / (FFT_SIZE as f32 / 4.0);
|
||||
let db = 20.0 * amplitude.max(1e-10).log10();
|
||||
*mag = ((db + 60.0) / 60.0).clamp(0.0, 1.0);
|
||||
*mag = ((db + 80.0) / 80.0).clamp(0.0, 1.0);
|
||||
}
|
||||
|
||||
output.write(&bands);
|
||||
|
||||
@@ -171,6 +171,7 @@ pub struct SharedSequencerState {
|
||||
pub tempo: f64,
|
||||
pub beat: f64,
|
||||
pub script_trace: Option<ExecutionTrace>,
|
||||
pub print_output: Option<String>,
|
||||
}
|
||||
|
||||
pub struct SequencerSnapshot {
|
||||
@@ -180,6 +181,7 @@ pub struct SequencerSnapshot {
|
||||
pub tempo: f64,
|
||||
pub beat: f64,
|
||||
script_trace: Option<ExecutionTrace>,
|
||||
pub print_output: Option<String>,
|
||||
}
|
||||
|
||||
impl From<&SharedSequencerState> for SequencerSnapshot {
|
||||
@@ -191,6 +193,7 @@ impl From<&SharedSequencerState> for SequencerSnapshot {
|
||||
tempo: s.tempo,
|
||||
beat: s.beat,
|
||||
script_trace: s.script_trace.clone(),
|
||||
print_output: s.print_output.clone(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -205,6 +208,7 @@ impl SequencerSnapshot {
|
||||
tempo: 0.0,
|
||||
beat: 0.0,
|
||||
script_trace: None,
|
||||
print_output: None,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -573,6 +577,7 @@ pub struct SequencerState {
|
||||
script_frontier: f64,
|
||||
script_step: usize,
|
||||
script_trace: Option<ExecutionTrace>,
|
||||
print_output: Option<String>,
|
||||
}
|
||||
|
||||
impl SequencerState {
|
||||
@@ -610,6 +615,7 @@ impl SequencerState {
|
||||
script_frontier: -1.0,
|
||||
script_step: 0,
|
||||
script_trace: None,
|
||||
print_output: None,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -817,6 +823,7 @@ impl SequencerState {
|
||||
self.script_frontier = -1.0;
|
||||
self.script_step = 0;
|
||||
self.script_trace = None;
|
||||
self.print_output = None;
|
||||
self.buf_audio_commands.clear();
|
||||
let flush = std::mem::take(&mut self.audio_state.flush_midi_notes);
|
||||
TickOutput {
|
||||
@@ -922,6 +929,7 @@ impl SequencerState {
|
||||
) -> StepResult {
|
||||
self.buf_audio_commands.clear();
|
||||
self.buf_completed_iterations.clear();
|
||||
let mut print_cleared = false;
|
||||
let mut result = StepResult {
|
||||
any_step_fired: false,
|
||||
};
|
||||
@@ -1012,12 +1020,26 @@ impl SequencerState {
|
||||
std::mem::take(&mut trace),
|
||||
);
|
||||
|
||||
if !print_cleared {
|
||||
self.print_output = None;
|
||||
print_cleared = true;
|
||||
}
|
||||
for cmd in cmds {
|
||||
self.event_count += 1;
|
||||
self.buf_audio_commands.push(TimestampedCommand {
|
||||
cmd,
|
||||
time: event_time,
|
||||
});
|
||||
if let Some(text) = cmd.strip_prefix("print:") {
|
||||
match &mut self.print_output {
|
||||
Some(existing) => {
|
||||
existing.push(' ');
|
||||
existing.push_str(text);
|
||||
}
|
||||
None => self.print_output = Some(text.to_string()),
|
||||
}
|
||||
} else {
|
||||
self.event_count += 1;
|
||||
self.buf_audio_commands.push(TimestampedCommand {
|
||||
cmd,
|
||||
time: event_time,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1113,12 +1135,23 @@ impl SequencerState {
|
||||
self.script_engine
|
||||
.evaluate_with_trace(&self.script_text, &ctx, &mut trace)
|
||||
{
|
||||
self.print_output = None;
|
||||
for cmd in cmds {
|
||||
self.event_count += 1;
|
||||
self.buf_audio_commands.push(TimestampedCommand {
|
||||
cmd,
|
||||
time: event_time,
|
||||
});
|
||||
if let Some(text) = cmd.strip_prefix("print:") {
|
||||
match &mut self.print_output {
|
||||
Some(existing) => {
|
||||
existing.push(' ');
|
||||
existing.push_str(text);
|
||||
}
|
||||
None => self.print_output = Some(text.to_string()),
|
||||
}
|
||||
} else {
|
||||
self.event_count += 1;
|
||||
self.buf_audio_commands.push(TimestampedCommand {
|
||||
cmd,
|
||||
time: event_time,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
self.script_trace = Some(trace);
|
||||
@@ -1201,6 +1234,7 @@ impl SequencerState {
|
||||
tempo: self.last_tempo,
|
||||
beat: self.last_beat,
|
||||
script_trace: self.script_trace.clone(),
|
||||
print_output: self.print_output.clone(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user