I'm pretty new to c#, I want to make a program that alerts me if I prefixed window sound volume become too high, for example, I have Spotify running in the background suddenly a high pitch sound then i get an alert, is this possible to do for in a low-level way that I can understand?
I already tried, an open source code that uses cscore, I did make some advancement but its way to advance for me to even keep going with that, this is where the source code I use:
Getting individual windows application current volume output level as visualized in audio Mixer
I made it, so it sends a message box with the window name that went to high on sound, but it only worked 1 time after the first time I didn't get any more message boxes, if I could just make it so it keeps sending message boxes would be perfect for me
Edit
I downloaded the source code of the program linked here, it's at the bottom of the link
I changed
var value = audioMeterInformation.GetPeakValue();
to something like 0.9
and added a messagebox around here:
using (var audioMeterInformation = session.QueryInterface<AudioMeterInformation>()) {
var value = audioMeterInformation.GetPeakValue();
if (value != 0) {
if (process != null) {
seenPids.Add(sessionid);
List<double> samples;
if (!sessionIdToAudioSamples.TryGetValue(sessionid, out samples)) {
samples = new List<double>();
sessionIdToAudioSamples[sessionid] = samples;
if(process.MainWindowTitle == "NAME OF MY WINDOW")
{
MessageBox.Show("true");
}
}
var val = audioMeterInformation.GetPeakValue();
samples.Add(val);
truncateSamples(samples);
I'm getting the message box, but just 1 time, if the high volume sound happens again it won't show the message box again, it just happens once per window.