Add simpler sound

This commit is contained in:
Nigel Breslaw 2025-06-05 13:35:50 +03:00
parent 9022308c54
commit 7abe65ea1c
5 changed files with 7 additions and 6 deletions

View file

@ -3,11 +3,10 @@
use chrono::{Datelike, Local, Timelike};
use kira::{
AudioManager, AudioManagerSettings, DefaultBackend,
sound::static_sound::StaticSoundData,
sound::static_sound::StaticSoundData, AudioManager, AudioManagerSettings, DefaultBackend,
};
use std::io::Cursor;
use slint::{Timer, TimerMode};
use std::io::Cursor;
#[cfg(target_arch = "wasm32")]
use wasm_bindgen::prelude::*;
@ -30,7 +29,7 @@ pub fn main() {
let app = AppWindow::new().expect("AppWindow::new() failed");
let app_weak = app.as_weak();
let mut manager = AudioManager::<DefaultBackend>::new(AudioManagerSettings::default()).unwrap();
let mut manager = AudioManager::<DefaultBackend>::new(AudioManagerSettings::default()).unwrap();
let api = app.global::<Api>();
api.on_play_sound(move |sound| {
@ -41,7 +40,7 @@ pub fn main() {
let sound_data = StaticSoundData::from_cursor(cursor).unwrap();
let _sound_handle = manager.play(sound_data).unwrap();
});
let timer = Timer::default();
timer.start(TimerMode::Repeated, std::time::Duration::from_millis(1000), move || {
if let Some(app) = app_weak.upgrade() {

View file

@ -20,7 +20,7 @@ export component Dial {
property <bool> moving: ta.firstTouch;
in-out property <angle> dialAngle: DialState.startAngle;
out property <int> volume: ((dialAngle - DialState.startAngle) / DialState.degreesFilledWithLights) * DialState.totalLights;
changed volume => {
changed volume => {
Api.play-sound(SoundEffect.dial-tick);
}

Binary file not shown.

View file

@ -0,0 +1,2 @@
SPDX-FileCopyrightText: BubblePopping by Sess8it -- https://freesound.org/s/762781/ -- License: Creative Commons 0
SPDX-License-Identifier: CC0-1.0