Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Samuel111

macrumors newbie
Original poster
Jan 16, 2017
1
0
Does anyone know what language I'd have learn in order to make a volume limiter for my headphones so I won't accidently blast out my ears?
(I took a look around on the net for like an hour but I couldn't really find any apps like this for mac so I'd like to make one. Preferably it'd work similarly to Audio Hijack where I'd run all the system audio into my app which will then forcefully lower the volume of audio above 50db.)
Screen Shot 2017-01-17 at 9.06.19 pm.png
 

Toutou

macrumors 65816
Jan 6, 2015
1,082
1,575
Prague, Czech Republic
Doesn't sound like a project for a programming newbie. Messing around with audio is non-trivial, so there are more things to consider than just which language to use.
 

Mark FX

macrumors regular
Nov 18, 2011
159
17
West Sussex, UK
Like Toutou stated.

Making an App like Audio Hijack is not an easy one for a beginner.
But don't let that discourage you, sometimes working on a project your really keen on encourages you to fight harder to learn what you have too.
Most novice programming books and tutorials can be a bit boring, as the projects tend to be simple and lack any excitement in the finished project.
I found in my younger days learning programming, that adapting tutorials to my own App ideas more interesting.

There was a time when creating serious Audio App's on the Mac involved knowing the C or C++ programming languages, and using the Core Audio Framework, but knowdays you can achieve all that Audio Hyjack achieves with the AVFoundation framework.

https://developer.apple.com/av-foundation/

As for learning a programming language, there are so many choices out there, but if your going to use the AVFoundation framework, and only make your App for Mac, then Swift or Objective-C are the obvious choices, but do have a steep learning curve, while also using Apple's Xcode developer tool has some learning time attached too.
If you want to keep a simpler learning curve, then you could even use the AppleScriptObjC language in an Xcode project, which might then encourage you to learn the aforementioned more advanced programming languages.

Regards Mark
 

mfram

Contributor
Jan 23, 2010
1,341
380
San Diego, CA USA
I would like to point out that the computer doesn't really know how much power is hitting your ears. Once the audio signal leaves the computer it could be run through any number of amplifiers, speakers, headphones, etc. For an initial programming project, it might be easier to see if you can limit how high the volume level slider is allowed to go on your Mac. Like 80% or something like that. Such a project wouldn't involve you having to deal with sound samples or adjustment at all. Watch the volume level and set it back down to your maximum if it goes too high.

This assumes there is an API to get notified when the volume level on the primary sound device changes. I would assume there's such an API, but I haven't looked for it myself. There's certainly an API to adjust the volume level.

I know there are C APIs to some of the audio systems because I've messed with some of them before. But there might be higher level APIs as well. Realistically, that means your choices of languages on the Mac are C, Objective-C, and Swift. In other words, the standard languages supported by Xcode.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.