app: edit per-application volume in the audio tab
Each configured source gets a slider that sends updateAudioSource as it moves, so a change is heard while dragging. The demo data now includes two application sources and a microphone, which the screenshots use. Also look the game up by recording id in the review screen, so a refresh that adds a recording does not change what is open.
This commit is contained in:
1 parent
0377141e4f
commit
8883e93d2b
5 files changed
+85
-14
No files matched your search
+48
-2
@@ -10,7 +10,7 @@ use crate::history::{self, QueueCategory, Timeline};
|
||||
use crate::ipc::{self, Daemon};
|
||||
use crate::os;
|
||||
use crate::screens;
|
||||
use crate::settings::Settings;
|
||||
use crate::settings::{AudioSource, AudioSourceType, Settings};
|
||||
use crate::ui::{self, Paint, body, heading};
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
@@ -170,7 +170,53 @@ impl App {
|
||||
};
|
||||
self.games = history::sample();
|
||||
self.games_loaded = true;
|
||||
let settings = Settings::default();
|
||||
self.devices = AudioDevices {
|
||||
input_devices: vec![AudioDevice {
|
||||
id: "mic-1".into(),
|
||||
name: "Microphone (USB Audio)".into(),
|
||||
is_default: true,
|
||||
}],
|
||||
output_devices: vec![
|
||||
AudioDevice {
|
||||
id: "out-1".into(),
|
||||
name: "Speakers (Realtek)".into(),
|
||||
is_default: true,
|
||||
},
|
||||
AudioDevice {
|
||||
id: "out-2".into(),
|
||||
name: "Headphones (USB Audio)".into(),
|
||||
is_default: false,
|
||||
},
|
||||
],
|
||||
};
|
||||
self.encoders = Encoders {
|
||||
available: vec![EncoderInfo {
|
||||
id: "jim_nvenc".into(),
|
||||
name: "NVIDIA NVENC".into(),
|
||||
available: true,
|
||||
is_hardware: true,
|
||||
}],
|
||||
current: "jim_nvenc".into(),
|
||||
};
|
||||
let mut settings = Settings::default();
|
||||
settings.audio.capture_apps = vec![
|
||||
AudioSource {
|
||||
id: "discord".into(),
|
||||
name: "Discord".into(),
|
||||
source_type: AudioSourceType::Application,
|
||||
device: "Discord.exe".into(),
|
||||
volume: Some(80),
|
||||
enabled: true,
|
||||
},
|
||||
AudioSource {
|
||||
id: "spotify".into(),
|
||||
name: "Spotify".into(),
|
||||
source_type: AudioSourceType::Application,
|
||||
device: "Spotify.exe".into(),
|
||||
volume: Some(35),
|
||||
enabled: true,
|
||||
},
|
||||
];
|
||||
self.form.apply(&settings);
|
||||
self.settings = Some(settings);
|
||||
}
|
||||
|
||||
+1
-5
@@ -39,10 +39,7 @@ pub enum Command {
|
||||
GetEncoders,
|
||||
GetAudioDevices,
|
||||
AddAudioSource,
|
||||
RemoveAudioSource {
|
||||
id: String,
|
||||
},
|
||||
#[allow(dead_code)]
|
||||
RemoveAudioSource { id: String },
|
||||
UpdateAudioSource,
|
||||
StartRecording,
|
||||
StopRecording,
|
||||
@@ -376,7 +373,6 @@ impl Daemon {
|
||||
);
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn update_audio_source(&self, source: Value) {
|
||||
self.send(
|
||||
Request::UpdateAudioSource,
|
||||
|
||||
@@ -667,19 +667,22 @@ fn audio(app: &App, p: Paint, kit: &rune_kit::Kit, layer: &mut Vec<El>, content:
|
||||
.h(36.0),
|
||||
);
|
||||
}
|
||||
for source in &a.capture_apps {
|
||||
for (index, source) in a.capture_apps.iter().enumerate() {
|
||||
let id = source.id.clone();
|
||||
let volume = source.volume.unwrap_or(100);
|
||||
sources = sources.child(
|
||||
row()
|
||||
.key(format!("source-{}", source.id))
|
||||
.h(40.0)
|
||||
.h(48.0)
|
||||
.px(space::S3)
|
||||
.center_y()
|
||||
.gap(space::S3)
|
||||
.justify_between()
|
||||
.radius(radius::MD)
|
||||
.child(
|
||||
col()
|
||||
.key("source-labels")
|
||||
.grow(1.0)
|
||||
.gap(1.0)
|
||||
.child(
|
||||
text(source.name.clone())
|
||||
@@ -698,6 +701,33 @@ fn audio(app: &App, p: Paint, kit: &rune_kit::Kit, layer: &mut Vec<El>, content:
|
||||
.color(p.muted()),
|
||||
),
|
||||
)
|
||||
.child(
|
||||
row()
|
||||
.key("source-volume")
|
||||
.gap(space::S2)
|
||||
.center_y()
|
||||
.child(ui::slider(
|
||||
p,
|
||||
format!("volume-{}", source.id),
|
||||
"Application volume",
|
||||
volume,
|
||||
move |app: &mut App, value| {
|
||||
let payload = {
|
||||
let Some(source) =
|
||||
app.form.draft.audio.capture_apps.get_mut(index)
|
||||
else {
|
||||
return;
|
||||
};
|
||||
source.volume = Some(value);
|
||||
serde_json::to_value(&*source).ok()
|
||||
};
|
||||
app.form.dirty = true;
|
||||
if let Some(payload) = payload {
|
||||
app.daemon.update_audio_source(payload);
|
||||
}
|
||||
},
|
||||
)),
|
||||
)
|
||||
.child(ui::button(
|
||||
p,
|
||||
&format!("remove-{}", source.id),
|
||||
@@ -709,7 +739,6 @@ fn audio(app: &App, p: Paint, kit: &rune_kit::Kit, layer: &mut Vec<El>, content:
|
||||
)),
|
||||
);
|
||||
}
|
||||
|
||||
let source_type = app.form.source_type;
|
||||
content
|
||||
.child(ui::card(
|
||||
|
||||
+2
-1
@@ -180,11 +180,12 @@ pub fn toggle_row(
|
||||
/// A 0-100 slider with its value spelled out on the right.
|
||||
pub fn slider(
|
||||
p: Paint,
|
||||
key: &'static str,
|
||||
key: impl Into<String>,
|
||||
label: &'static str,
|
||||
value: u32,
|
||||
on_change: impl Fn(&mut App, u32) + Send + Sync + 'static,
|
||||
) -> El {
|
||||
let key = key.into();
|
||||
let (w, h, k, bar) = (180.0, 22.0, 18.0, 4.0);
|
||||
let travel = w - k;
|
||||
let v = (value.min(100) as f32 / 100.0).clamp(0.0, 1.0);
|
||||
|
||||
Reference in new issue
Block a user