3

for some background of the question I am looking to make another program for my personal windows desktop which runs in the background, that when a certain level of sound is detected through a headset, it will automatically log the user out.

Its a Windows 10 PC. I have a decent amount of experience in plain C, but I lack the knowledge to create a program like this. The program must Auto start when logged in, and Run in the background to avoid detection.

I'm really stumped, I've looked around and asked my Comp Sci friends and they didn't know either.

[The reason I'm trying to make this program is I have a younger brother who games on my computer with his friends online (Skype, Discord, Hangouts, etc), and he becomes very very loud, often yelling and screaming, and intense laughing. This has become a big problem in the household for my family as he can be heard from multiple floors and rooms away, especially at night. Telling him to be quiet, and restricting his privileges isn't working anymore, as he doesn't believe he is too loud.]

KevinDTimm
  • 14,226
  • 3
  • 42
  • 60
Strivous
  • 41
  • 3
  • Writing this in C would b a pain. Pick something higher-level with a good Windows-specific support. – Eugene Sh. Jan 20 '17 at 21:04
  • 2
    Find a 'Clapper' - rig it to trigger at an appropriate volume – KevinDTimm Jan 20 '17 at 21:07
  • It doesn't have to be C, I just mentioned it because that and Python are the only two programming languages I know. Less so for Python. – Strivous Jan 20 '17 at 21:28
  • @Strivous Here's a similar question with a solution in Python: http://stackoverflow.com/q/1936828/2415524 – mbomb007 Jan 20 '17 at 21:33
  • You want to write a *"program for [your] personal windows desktop"*, and one of the requirements is, that you want to *"avoid detection"*. I'm stumped. – IInspectable Jan 20 '17 at 21:55
  • 1
    What happened to _talking_ to him? Anyway as stated this is too broad. Stack Overflow is to help with specific programming problems where you already have code, and you have none. – CodeCaster Jan 20 '17 at 22:05
  • @CodeCaster Or banning him from using the computer. – mbomb007 Jan 20 '17 at 22:05
  • 1
    @mbomb007: The whole point about having a personal desktop is, so that others cannot access it. – IInspectable Jan 20 '17 at 22:08
  • @IInspectable It is my computer, that I let my brother use. I want it to be undetectable because my brother is smart enough to look in the active windows bar at the bottom and minimized applications as well as within the task manager as well, I thinking to disguise it as another background program (e.x. renaming it Cortana with an icon, or file explorer, etc) I would've posted code, but as I said, my comp sci friends and I don't know where to begin. – Strivous Jan 20 '17 at 22:13
  • 1
    If it's really a problem for the *family*, not just him, then shouldn't the parents be the ones taking action? Otherwise, just don't let him use your computer until he can maintain a proper volume, or don't let him game with a microphone. – mbomb007 Jan 20 '17 at 22:13
  • Maybe this [answer](http://stackoverflow.com/a/21056089) from [this question](http://stackoverflow.com/q/4640106) could help you out for the sound level part. The [`shutdown`](http://ss64.com/nt/shutdown.html) command will help you for the "log out" part – J.Baoby Jan 20 '17 at 22:42
  • @J.Baoby that controls the volume of the output, not measures the volume of the ambient sound. – Remus Rusanu Jan 20 '17 at 23:25

2 Answers2

1

Looks like ffmpeg volumedetect can do the heavy lifting of actually detecting the sound level. For example, trying out on my MBP (you'll have to change the input device for your Windows machine):

$>ffmpeg -hide_banner -f avfoundation -i "none:0" -af "volumedetect" -t 2 -f null /dev/null

Input #0, avfoundation, from 'none:0':
  Duration: N/A, start: 316943.850567, bitrate: 2822 kb/s
    Stream #0:0: Audio: pcm_f32le, 44100 Hz, stereo, flt, 2822 kb/s
Output #0, null, to '/dev/null':
  Metadata:
    encoder         : Lavf57.62.100
    Stream #0:0: Audio: pcm_s16le, 44100 Hz, stereo, s16, 1411 kb/s
    Metadata:
      encoder         : Lavc57.75.100 pcm_s16le
Stream mapping:
  Stream #0:0 -> #0:0 (pcm_f32le (native) -> pcm_s16le (native))
Press [q] to stop, [?] for help
size=N/A time=00:00:02.00 bitrate=N/A speed=0.996x
video:0kB audio:345kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
[Parsed_volumedetect_0 @ 0x7f8ba8726860] n_samples: 178176
[Parsed_volumedetect_0 @ 0x7f8ba8726860] mean_volume: -60.3 dB
[Parsed_volumedetect_0 @ 0x7f8ba8726860] max_volume: -29.9 dB
[Parsed_volumedetect_0 @ 0x7f8ba8726860] histogram_29db: 4
[Parsed_volumedetect_0 @ 0x7f8ba8726860] histogram_30db: 0
[Parsed_volumedetect_0 @ 0x7f8ba8726860] histogram_31db: 6
[Parsed_volumedetect_0 @ 0x7f8ba8726860] histogram_32db: 10
[Parsed_volumedetect_0 @ 0x7f8ba8726860] histogram_33db: 18
[Parsed_volumedetect_0 @ 0x7f8ba8726860] histogram_34db: 10
[Parsed_volumedetect_0 @ 0x7f8ba8726860] histogram_35db: 12
[Parsed_volumedetect_0 @ 0x7f8ba8726860] histogram_36db: 36
[Parsed_volumedetect_0 @ 0x7f8ba8726860] histogram_37db: 42
[Parsed_volumedetect_0 @ 0x7f8ba8726860] histogram_38db: 48

This runs ffmpeg on the microphone input source for 2 seconds and produces a histogram of the audio volumes (decibels), as well as the mean and max volume levels (which is what you want).

You can probably do the equivalent using ffmpeg as a library and embed it into your application of choice.

Remus Rusanu
  • 288,378
  • 40
  • 442
  • 569
-2

Though this doesn't trigger automatically due to volume levels, you can use another device on your network to do a remote shutdown of the computer he's on. The steps may be slightly different for Windows 10, but you should be able to figure it out. Note that if you still want to trigger it via volume, this guide below will still be useful, as it shows how to do the shutdown part.

http://www.online-tech-tips.com/computer-tips/remote-shutdown-command/

Simply put, the steps are as follows (read the guide, as it's more specific, with pictures):

1. Enable remote shutdown on the target computer

  • Control Panel, Network and Sharing Center, Change Advanced Sharing settings "Private" enable "Turn on File and Printer sharing" [more info]
  • Modify the registry (save a registry backup first) HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System
  • add new DWORD LocalAccountTokenFilterPolicy with the value 1

2. Create a batch file that will shutdown/restart the computer

  • This can be on the target computer if you intend to trigger it via audio, otherwise use a remote shutdown command:
  • shutdown /m \\computername /r /f
    • /r - restart the computer
    • /f - force programs to close immediately

If you try these steps and still get "access denied", you can try this solution:

net use \\<computer>
shutdown -r -m \\<computer name>
mbomb007
  • 3,788
  • 3
  • 39
  • 68