Convert some sound levels

This commit is contained in:
R Tyler Croy 2020-09-17 20:40:35 -07:00
parent e45fe39e1f
commit 60f5aa4f51
No known key found for this signature in database
GPG Key ID: E5C92681BEF6CEA2
1 changed files with 19 additions and 5 deletions

View File

@ -111,7 +111,16 @@ fn play_sound(sound: String) {
let device = rodio::default_output_device().unwrap();
let file = File::open(format!("sounds/{}.wav", sound)).unwrap();
let source = rodio::Decoder::new(BufReader::new(file)).unwrap();
rodio::play_raw(&device, source.convert_samples());
if sound == "factorywhistle" {
rodio::play_raw(&device, source.amplify(1.5).convert_samples());
}
else if sound == "cheer" {
rodio::play_raw(&device, source.amplify(0.7).convert_samples());
}
else {
rodio::play_raw(&device, source.convert_samples());
}
}
/**
@ -148,12 +157,17 @@ fn countdown(time_left: Duration, state: SafeState) {
}
async fn handle_websocket(state: SafeState, raw_stream: TcpStream, addr: SocketAddr) {
println!("Incoming TCP connection from: {}", addr);
info!("Incoming TCP connection from: {}", addr);
let ws_stream = async_tungstenite::accept_async(raw_stream)
.await
.expect("Error during the websocket handshake occurred");
println!("WebSocket connection established: {}", addr);
.await;
if ws_stream.is_err() {
error!("Failed to accept connection: {:?}", ws_stream);
return;
}
let ws_stream = ws_stream.unwrap();
info!("WebSocket connection established: {}", addr);
// Insert the write part of this peer to the peer map.
let (tx, rx) = unbounded();