1use audio_code::prelude::*;
6
7struct Hello;
8
9impl Scene for Hello {
10 fn start(&mut self, ctx: &mut Context) {
11 ctx.speech.speak("Hello! Press space to beep, F1 to repeat, escape to quit.");
12 }
13
14 fn update(&mut self, ctx: &mut Context) {
15 if ctx.input.pressed(Key::Space) {
16 let pitch = 300.0 + (ctx.time.elapsed() as f32 * 50.0) % 900.0;
18 ctx.audio.play_tone(pitch.round(), 0.15);
19 }
20 if ctx.input.pressed(Key::F1) {
21 ctx.speech.repeat_last();
22 }
23 if ctx.input.pressed(Key::Escape) {
24 ctx.quit();
25 }
26 }
27}
28
29fn main() -> audio_code::Result<()> {
30 Engine::new("Hello audio-code").echo_speech(true).run(Hello)
31}