mirror of
https://github.com/csd4ni3l/soundboard.git
synced 2026-04-17 16:07:22 +02:00
Compare commits
2 Commits
6480c80cb4
...
ff71f6f21a
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ff71f6f21a | ||
|
|
ca6fc96f99 |
24
src/main.rs
24
src/main.rs
@@ -81,6 +81,12 @@ fn create_virtual_mic() -> SoundSystem {
|
|||||||
.expect("Unable to open device")
|
.expect("Unable to open device")
|
||||||
.open_stream()
|
.open_stream()
|
||||||
.expect("Failed to open stream"),
|
.expect("Failed to open stream"),
|
||||||
|
// this is actually not needed here, since windows would exit by far. But, cargo doesnt like SoundSystem not getting the normal_output stream so...
|
||||||
|
#[cfg(target_os = "windows")]
|
||||||
|
normal_output_stream: OutputStreamBuilder::from_device(device)
|
||||||
|
.expect("Unable to open device")
|
||||||
|
.open_stream()
|
||||||
|
.expect("Failed to open stream"),
|
||||||
paused: false,
|
paused: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -227,24 +233,31 @@ fn play_sound(file_path: String, app_state: &mut AppState) {
|
|||||||
.total_duration()
|
.total_duration()
|
||||||
.expect("Could not get source duration")
|
.expect("Could not get source duration")
|
||||||
.as_secs_f32();
|
.as_secs_f32();
|
||||||
|
|
||||||
sink.append(src);
|
sink.append(src);
|
||||||
|
sink.play();
|
||||||
|
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
{
|
{
|
||||||
let file2 = File::open(&file_path).unwrap();
|
let file2 = File::open(&file_path).unwrap();
|
||||||
let src2 = Decoder::new(BufReader::new(file2)).unwrap();
|
let src2 = Decoder::new(BufReader::new(file2)).unwrap();
|
||||||
let normal_sink = Sink::connect_new(&app_state.sound_system.normal_output_stream.mixer());
|
let normal_sink = Sink::connect_new(&app_state.sound_system.normal_output_stream.mixer());
|
||||||
sink2.append(src2);
|
normal_sink.append(src2);
|
||||||
}
|
|
||||||
|
|
||||||
sink.play();
|
|
||||||
|
|
||||||
app_state.currently_playing.push(PlayingSound {
|
app_state.currently_playing.push(PlayingSound {
|
||||||
file_path: file_path.clone(),
|
file_path: file_path.clone(),
|
||||||
length,
|
length,
|
||||||
sink,
|
sink,
|
||||||
#[cfg(target_os = "windows")]
|
|
||||||
normal_sink
|
normal_sink
|
||||||
|
});
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
app_state.currently_playing.push(PlayingSound {
|
||||||
|
file_path: file_path.clone(),
|
||||||
|
length,
|
||||||
|
sink
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -264,6 +277,7 @@ fn ui_system(mut contexts: EguiContexts, mut app_state: ResMut<AppState>) -> Res
|
|||||||
let available_height = ui.available_height();
|
let available_height = ui.available_height();
|
||||||
let outputs = app_state.virt_outputs.clone();
|
let outputs = app_state.virt_outputs.clone();
|
||||||
|
|
||||||
|
#[allow(unused_mut)]
|
||||||
let mut mic_name = "Select inside apps".to_string();
|
let mut mic_name = "Select inside apps".to_string();
|
||||||
|
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ pub fn create_virtual_mic_windows() -> (OutputStream, OutputStream) {
|
|||||||
}).unwrap_or(false)
|
}).unwrap_or(false)
|
||||||
}).expect("Could not get default output device");
|
}).expect("Could not get default output device");
|
||||||
|
|
||||||
normal_output = host.default_output_device().expect("Could not get default output device");
|
let normal_output = host.default_output_device().expect("Could not get default output device");
|
||||||
|
|
||||||
return (OutputStreamBuilder::from_device(normal_output).expect("Unable to open default audio device").open_stream().expect("Failed to open stream"), OutputStreamBuilder::from_device(virtual_mic).expect("Unable to open default audio device").open_stream().expect("Failed to open stream"));
|
return (OutputStreamBuilder::from_device(normal_output).expect("Unable to open default audio device").open_stream().expect("Failed to open stream"), OutputStreamBuilder::from_device(virtual_mic).expect("Unable to open default audio device").open_stream().expect("Failed to open stream"));
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user