Get info of currently playing song OSX - macos

I am currently trying to write a music visualizer of sorts, but I am running into a small issue.
I am familiar with the scripting bridge and being able to get various information from iTunes regarding the current track but I wanted to add support for other media players such as Spotify.
Since the Pause/Play, Next track, and Previous track buttons on the built in keyboard automatically direct the corresponding commands to the last used media player, I was assuming that there is a single library that I can call against to get this information, regardless of which music player is playing music.

Since the Pause/Play, Next track, and Previous track buttons on the built in keyboard automatically direct the corresponding commands to the last used media player, I was assuming that there is a single library that I can call against to get this information, regardless of which music player is playing music.
Unfortunately, this is a false assumption.
The media keys on the keyboard are weird. They are (unfortunately!) not part of any larger media API; the fact that they even work at all for programs other than iTunes has taken some significant effort by developers.
iTunes publishes some information on the current track through a distributed notification. You can also get the name of the current track through AppleScript. This isn't part of any larger standard, though; other audio player applications may or may not do anything similar.

Related

I want my android app to recognize finger snap sound, Is there any way?

I am creating a android application and I want my application to recognize sound and find whether it is finger snap sound or not, how to do it. Is there any API available help me with it.
To do this you would need to write an algorithm that compares hundreds of finger snaps to compare to the microphone input, you may be better off using a voice recognition api for voice commands instead as the finger snap is very akin to other sounds.
As far as I am aware there are no APIs for a finger snap however there is audio comparing software that could help.

Redirect microphone input to headphone output (soft playthru)

If I use my in-ear headphones with my macbook pro it takes me a few minutes until they are fitting perfectly (due to the foam bits on the headphones) :)
My idea is to use internal macbook pro microphone to be able talk to somebody coming to my desk without having to remove the headphones every time. So kind of an 'intercom' thing which can be enabled by hitting a hotkey.
First thought was to use applescript which could be easily used for pausing iTunes, but I could not find information about how I could forward the microphone output to my headphones.
Next try was to check Xcode for writing a Cocoa App. By starting with an example provided by Apple I think it would be achievable for me to extend it to fit my needs.
So my question is:
Do you have a better idea/approach to solve my problem?

Adobe AIR 3.1 Rendering/Input Issue with Steam Overlay (Windows)

I am in the process of porting a Flash Player-based game over to the Desktop (OSX and Windows) via Adobe AIR (3.1). The porting to AIR itself has gone rather smoothly. The one wrinkle I've been dealt is that the game will be distributed over the Steam network. In order to interact with the Steam Client, I've had to write a native extension to expose the Steam SDK APIs to AS3. The native extension support has been implemented for both platforms, and I have the application launching and communicating with Steam as desired.
The area I've run into trouble is dealing with Steam's Overlay, which renders overtop of games when it is activated. Essentially, when a game is launched, the Steam Client suspends the process in order to hook its Overlay library up to either D3D or OpenGL. Initially, the Overlay failed to appear at all as the AIR application descriptor had the default rendermode set to "auto." However, once I switched the rendermode to "gpu" the Overlay would appear as desired.
On the OSX side of things, everything works as expected. I can toggle in and out of the Overlay just fine. On the windows end of the spectrum, I've hit a bit of a problem when I activate the Overlay. Specifically, when the Overlay is enabled (it's rendering overtop of the game) and I either move the mouse or generate keyboard input, both the Overlay and the game both "freeze" (rendering stops) for 2-3 seconds. Additionally, I have noticed that when I open the Task Manager with the game running, the cpu usage is roughly 75-80%. The cpu usage remains the same when I first active the Overlay (which is desired). However, when I move the mouse cursor or press a key on the keyboard, the cpu usage drops to roughly 1%. This problem has occurred on 4 of 5 windows machines (2 XP, 3 Win 7) we've tested on. Naturally, I first contacted Valve about the issue since this only occurs when the Overlay is enabled. I've uploaded both the OSX and Windows builds for their devs to debug; however, my contact suggested I find out more about AIRs rendering/input as well.
Here is a snippet of a post with a Steam Dev detailing how the overlay works:
"The requirements for the overlay on Windows are as follows:
Game must use D3D7, D3D8, D3D9, D3D10, D3D11, or OpenGL
Game must call D3D Present() or OpenGL SwapBuffers() on a fast regular basis (these calls are hooked by the overlay and give it opportunity to do work). For instance 2D games that only call these functions when mouse movement occurs or graphics on screen actually change rather than every frame will not function well.
Game should use standard Win32 input messages, raw Win32 input messages, or DirectInput for input and the overlay will then detect hotkeys and hide/block input events from the game when active.
It sounds like your game may violate #2 and stops calling Present/SwapBuffers sometimes when the overlay is active. This may happen if you call these functions in response to user input which is now blocked due to the overlay being activated. You should guarantee you keep pumping frames and swapping at a regular interval even if input events aren't occurring."
After a little more prodding, the Valve devs profiled my application to determine if there was any specific problem occuring with the Game Overlay. Unfortunately, they were unable to find anything going on in the Overlay itself. This pretty much means that AIR on Windows doesn't like that the Overlay is blocking Win32 input messages. Here is the Valve dev's response:
"I got your depots and did some testing. Nothing unusual happens in the overlay. Profiling your app with xpref while the issue occurs and taking some minidumps to check callstacks it looks like the app just blocks up completely and uses zero CPU during the time it is blocked, when it happens it calls Present() only at roughly 1 second intervals until it recovers (maybe there is a 1 second timeout somewhere in the AIR code). It's hard to get much detail since I don't have any symbols for the AIR runtime libraries.
It does however look like this is somehow related to input state and AIR being unhappy with win32 input messages stopping. If I change our overlay to not block any input at all once activated (which obviously has some pretty big problems for usability, but just for testing purposes.) then the issue does not occur. It's possible that the AIR code has some weird logic where if it's seen some specific WM_WHATVER message it's expecting another right after and blocks on it waiting somehow.
Hopefully you can work out on your side or with Adobe as to why the application behaves badly in these situations and starts blocking and not presenting at regular intervals."
I've posted on the Adobe forums, but haven't had any such luck over there. Mainly, I'm hoping that someone has either dealt with this before or has an idea about how I could possibly get around the issue. Any suggestions, comments or thoughts would be greatly appreciated!
As it turns out, there is an bug deep in AIR core framework that is the root cause of this issue. Adobe has confirmed the bug, and they are working on a fix for the Cyril (AIR 3.3) release. The status of the bug (#3089755) can be viewed in the Adobe AIR bug list.
In the short-term, I was forced to detect Windows messages that were being consumed by the SteamOverlay, and pass on fake messages to prevent AIR from locking up. I accomplished this by using the Windows API SetWindowsHookEx along with the WH_DEBUG and WH_GETMESSAGE hooks. This is definitely not a desirable approach, but was needed in the short-term until Adobe releases a fix.

simple record and play application!

I am trying to make a simple application which will store the sound said by user , say on click of record button and will play it back to him/her , say on click of play button.
Can anyone suggest me some appropriate way to do this ??
Thanks,
Miraaj
You can use QuickTime Kit's capture APIs to record a movie of the audio, and QTMovie (from the same framework) to convert it to a more conventional format for audio files and to play back both the intermediate file and the converted file.
There used to be a QuickTime Kit Programming Guide, but it didn't cover capturing and is now gone from developer.apple.com. You should file a bug against the docs.
This answer will work in a Cocoa (Mac) app. If you meant to ask about the iPhone, you should re-tag your question, as the solution will be completely different for a Cocoa app vs. a Cocoa Touch (iPhone) app.
I used direct sound to create an entire internet phone application a few years ago. Your question is far simpler, you won't have to deal with the circular buffer as critically. Direct sound is pretty main stream and you can find a lot of help with it in forums, and it's free!

How do I change my Active Sound Card on the Fly?

I currently have speakers set up both in my office and in my living room, connected to my PC via two sound cards, and would like to switch the set of speakers I'm outputting to on the fly.
Anyone know an application or a windows API call that I can use to change the default sound output device? It is currently a bit of a pain to traverse the existing control panel system.
That topic is covered in depth here Easily Change or Switch the Default Audio Sound Output in Vista or XP. Note that sound management was changed in Vista significantly.
On a side note, I believe SnapStream is/was working on an application to allo multi-channel sound cards to output to different rooms (sets of speakers) simultaneously.

Resources