add: add mp3, removed guild register slash commands

This commit is contained in:
2026-08-02 20:10:37 -04:00
parent bca88c7a70
commit 302fe56ff9
3 changed files with 15 additions and 28 deletions
+4 -28
View File
@@ -1,13 +1,11 @@
use std::collections::HashSet;
use std::f32::consts::TAU;
use std::io::Cursor;
use std::sync::Arc;
use serenity::all::{
ButtonStyle, ChannelId, CreateActionRow, CreateButton, GuildId, MessageId, UserId,
};
use serenity::prelude::TypeMapKey;
use songbird::input::{Input, RawAdapter};
use songbird::input::Input;
use tokio::sync::Mutex;
pub const BUZZER_CUSTOM_ID: &str = "buzzer:press";
@@ -87,33 +85,11 @@ fn control_components(is_open: bool, session_ended: bool) -> Vec<CreateActionRow
vec![CreateActionRow::Buttons(vec![buzzer, reset, lock, unlock])]
}
/// Produces a short, self-contained buzzer tone as stereo f32 PCM.
/// Returns the bundled buzzer sound.
pub fn buzzer_sound() -> Input {
const SAMPLE_RATE: u32 = 48_000;
const DURATION_SECONDS: f32 = 0.4;
const FREQUENCY_HZ: f32 = 180.0;
const BUZZ_MP3: &[u8] = include_bytes!("../../assets/buzz.mp3");
let sample_count = (SAMPLE_RATE as f32 * DURATION_SECONDS) as usize;
let mut pcm = Vec::with_capacity(sample_count * 2 * size_of::<f32>());
for sample_index in 0..sample_count {
let time = sample_index as f32 / SAMPLE_RATE as f32;
let progress = sample_index as f32 / sample_count as f32;
let attack = (time / 0.01).min(1.0);
let release = ((1.0 - progress) / 0.08).min(1.0);
let envelope = attack * release;
// Odd harmonics give the tone the rasp of a physical game-show buzzer.
let phase = TAU * FREQUENCY_HZ * time;
let value =
envelope * (phase.sin() + (3.0 * phase).sin() / 3.0 + (5.0 * phase).sin() / 5.0) * 0.32;
for _ in 0..2 {
pcm.extend_from_slice(&value.to_le_bytes());
}
}
RawAdapter::new(Cursor::new(pcm), SAMPLE_RATE, 2).into()
BUZZ_MP3.into()
}
/// The application's single active buzzer session.