Can I send sound to the speakers when headphones are connected? - macos

I'm running a roleplaying game that involves demonic forces, so to make it a little more fun, I wrote a tiny program with EZAudio that takes the microphone input and plays it back with the pitch lowered by 400%. Overlayed with my actual voice, it sounds pretty evil (when I can focus enough to avoid the speech jamming effect).
The problem is that I don't have a dedicated microphone, and the feedback is pretty intense when I run it with the internal microphone and the internal speakers. I do, however, have earbuds with a microphone and a 4-ring jack, which my MacBook pro recognizes. Now, the problem is that when I use it, the sound goes to the earbuds, which defeats the whole purpose.
Mac OS X supports multiple audio output devices. However, as far as I can tell, my 2010 MacBook Pro exposes just one, which dynamically routes sound to either the internal speakers when no headphones are connected, or to the headphones when they are. EZAudioDevice's outputDevices returns just one entry in both cases.
Is there a way I can divert the sound to my computer's internal speakers even when headphones are connected?

In core audio for iOS, it is not possible as explained here. You are running Mac os and I would assume that the behavior would be the same.
The best option is to use a mic not associated with the headphones. Use a usb preamp with a mic.

Related

Audio for Windows in Assembly

I'm thinking of making a game in 8086 ASM using VGA for graphics, but before I proceed with anything I want to make sure that I can get audio into my project. I doubt PC Speaker will be sufficient.
I'm looking for a way to program music in 8086 for Windows. Is there some kind of standard in modern sound cards that I can access directly, or will I have to use the Windows API? I'm not really sure what to look for at this point, so any suggestions are welcome.
Unlike the displays, which ultimately converged to (S)VGA, soundcards never reached the same compatibility. There were different Sound Blasters, Gravis Ultrasound and others. These days the modern hardware is often incompatible with those and you cannot program them in DOS as the Sound Blaster without having a proper DOS driver or without knowing the supported memory regions, ports, formats and protocols.
I can only suggest writing such a program for a PC/DOS emulator like DosBox, which emulates Sound Blaster and (S)VGA. That should work.
Alternatively, you can just write a normal Windows program, using Win32 APIs for input, drawing and sound.

Best backwards compatible way to programmatically capture sound going to speakers

What would be the best approach to take in order to achieve a backwards compatible (Windows XP through Windows 7) way to capture sound that is being sent to the speakers on a machine, even if the audio driver doesn't expose the "Stereo Mix" recording device.
For extra points, it would be great if this approach allowed for capturing sound from a single application only (excluding sounds from other apps and Windows itself).
Is writing a loopback audio driver the only solution?
AFAIK there is no realiable way of doing this. Even if a card does have something like a stereo mix its a nightmare under XP and below due to a lack of coherent interfaces. CoreAudio under Vista and 7 massively improves matters but if you don't have stereo mix then you won't get far ...

Redirecting audio output

I need a method to redirect my Mac's audio output to a different computer on the same network as the Mac doesn't have audio output. I'm on Snow Leopard while the other computer which has speakers attached does not have any operating system at the moment.
Probably the simplest solution is to use Rogue Amoeba's Nicecast. It can hijack system audio and stream it locally so you can pick it up on another machine with any MP3 player that supports streams.
What's the software source of the audio? If the audio source is iTunes, there are a few things you can do specifically dealing with the support for Airport Express hardware. If you don't wish to spend more money on Team Apple, then the Enlightenment Sound Daemon runs on pretty much any hardware (Linux, OS/X, or Windows/Cygwin).
There's a quick tutorial here. It uses Rogue Audio's Hijack; looks like someone's recommended another Rogue Audio project as well. I'm a fan of Airfoil from them, as it lets me stream Pandora to the Airport Express in the main room.

Getting the speaker audio signal and then streaming it out

I am trying to build what I think is a basic app. Well, two apps one for windows and one for OS X. I would like to capture the audio signal that is playing (ie if the user is playing music out his/her speakers). Then take that signal and stream it out so another computer can "listen". The other computer would be Windows or OS X.
Any ideas on how to get the audio signal?
What's the most efficient way to stream out audio without a 3rd party plugin? If there is an open-source solution out there, I would be interested.
Thanks!
Chris
On Windows XP this isn't trivial at all because there's no way of intercepting the output signal without writing an audio filter driver (which is not somethign for the faint of heart).
On Windows Vista and above, you can capture the output of the audio engine by using the WASAPI APIs (built into Windows so they're free) and initializing an audio client with the AUDCLNT_STREAMFLAGS_LOOPBACK flag. This will give you a capture stream that's hooked to the output of the audio engine.
You can then package up that audio and send it to the other machine and render it with whatever audio rendering API you want.
I don't know how to do the equivilant on OSX though :(.

How do I capture the audio that is being played?

Does anyone know how to programmatically capture the sound that is being played (that is, everything that is coming from the sound card, not the input devices such as a microphone).
Assuming that you are talking about Windows, there are essentially three ways to do this.
The first is to open the audio device's main output as a recording source. This is only possible when the driver supports it, although most do these days. Common names for the virtual device are "What You Hear" or "Wave Out". You will need to use a suitable API (see WaveIn or DirectSound in MSDN) to do the capturing.
The second way is to write a filter driver that can intercept the audio stream before it reaches the physical device. Again, this technique will only work for devices that have a suitable driver topology and it's certainly not for the faint-hearted.
This means that neither of these options will be guaranteed to work on a PC with arbitrary hardware.
The last alternative is to use a virtual audio device, such as Virtual Audio Cable. If this device is set as the defualt playback device in Windows then all well-behaved apps will play through it. You can then record from the same device to capture the summed output. As long as you have control over the device that the application you want to record uses then this option will always work.
All of these techniques have their pros and cons - it's up to you to decide which would be the most suitable for your needs.
You can use the Waveform Audio Interface, there is an MSDN article on how to access it per PInvoke.
In order to capture the sound that is being played, you just need to open the playback device instead of the microphone. Open for input, of course, not for output ;-)
If you were using OSX, Audio Hijack Pro from Rogue Amoeba probably is the easiest way to go.
Anyway, why not just looping your audio back into your line in and recording that? This is a very simple solution. Just plug a cable in your audio output jack and your line in jack and start recordung.
You have to enable device stero mix. if you do this, direct sound find this device.

Resources