OS X: How to pipe audio output through a processing algorithm? - macos

What does one have to do to capture the output audio stream from an application (iTunes, QuckTime, VLC, whatever...) do some processing, maybe modify it and then send it back to the output? Any kind of help would be greatly appreciated because I don't even know where to look in the docs for this one...
Thanks

One approach you can try would be to use the SoundflowerBed source code as a basis for creating a virtual audio device. This can then be set as the default output device, in system preferences, so that all applications (other than those for which the output device has been set otherwise) will send audio to it.
Your processing program can capture the audio from a such a virtual audio device, process it, and pass it to an actual output device for playback in real-time.
It is possible to set/reset the default device programmatically, using the CoreAudio API, in order to provide a more integrated experience to your customers.

Related

How can I progammmatically determine which processes are actively using my webcam on OSX?

I'm writing a utility that addresses a Bluetooth status indicator light when my webcam is in use so that I'm not disturbed during meetings while working from home. Presently, I'm parsing the output of lsof to see which processes have a file descriptor open to VDC, but this approach is fraught for a number of reasons:
Not all processes with a FD to VDC are actually using the webcam (ex: avconfere, the Facetime daemon, and Chrome, which always holds a FD if it is open).
Most processes spin up a second process when the webcam is actually in use, and that child process doesn't always share a name in common with its parent, meaning I have to maintain a mapping to know which program is using the webcam.
Some applications (like Zoom) don't release the webcam FD when the webcam stops being used (only when Zoom is killed completely).
Is there any other/better interface for accurately determining which processes are using the webcam? Applications like Oversight lead me to believe that there should be a better method of doing this.

Multiple sound card output under Windows with Liquidsoap

Is it possible to output to multiple sound cards under Windows?
It seems that portaudio is the only way to play back through a sound card with Windows, but portaudio offers no mechanism for choosing which device to output to. Even if it did, it isn't clear that it would be possible to open multiple outputs.
Currently, I'm using a hack using VLC to output to the sound cards:
output.external(
%mp3(bitrate=320,stereo_mode="stereo"),
'"C:\\Program Files (x86)\\VideoLAN\\VLC\\vlc.exe" -vvv --config C:\vlc\vlcrc-remote1 -',
remote1
)
output.external(
%mp3(bitrate=320,stereo_mode="stereo"),
'"C:\\Program Files (x86)\\VideoLAN\\VLC\\vlc.exe" -vvv --config C:\vlc\vlcrc-remote2 -',
remote2
)
Each VLC profile has a different sound device set by default. Obviously this could be improved by switching to PCM, but if I can simply skip the whole external process issue completely, that would be great.
This is probably too late now...
Having been searching for this for a all night (several hours) and delving into the source code for PortAudio and Liquidsoap, I have established that LS utilises Pa_OpenDefaultStream() to open one stream only. It is not possible through LS' interface to pass a PA ID to input or output.portaudio. It will always default to device 0 which is the sound mapper (Windows default device).
However, all is not lost, in order to tell PortAudio which input/output to use, you can pass an environment variable before running LS:
set PA_RECOMMENDED_OUTPUT_DEVICE=x
set PA_RECOMMENDED_INPUT_DEVICE=x
Where x is a PA device reference. To find your device references you need a copy of pa_devs.exe (I found a copy here http://www.w1hkj.com/alpha/temp/pa_devs.exe) which when ran generates results.txt. This file contains the IDs you need. You can also get the IDs with Audacity by selecting Help>Audio Device Info.
So you could in theory do multiple outputs like this:
setenv("PA_RECOMMENDED_OUTPUT_DEVICE","13")
streamout1 = output.portaudio()
setenv("PA_RECOMMENDED_OUTPUT_DEVICE","14")
streamout2 = output.portaudio()
I don't know for definite if this will work but it's worth a go! If it doesn't work, you could always run two liquidsoap instances in different settings if this would work for your application.

Recording Audio Output from a Specific Program on Windows

Is there any way to record the sound output of a specific program on Windows? I already have a solution that uses WASAPI's loopback device to record all audio output to the speakers, but I would prefer to be able to record only the audio output of a specific program and ignore everything else. I assume this is possible using a virtual audio device, but I would like to avoid something so complicated if possible.
According to this post (which is very interesting in itself), there's a program called
Virtual Audio Cable which might do the trick for you....
Virtual Audio Cable will do what you already mentioned when you said it captures all audio sent to it.
You can a Virtual Line to be the default and then record that Virtual Line. You can Not select a specific program to do such a thing.
I have made a tutorial for using it.
https://www.youtube.com/watch?v=WUQmkgw8Pjg
I use it to play music from youtube through my "mic" while playing games.
On Windows 10, You may check here, which use ActivateAudioInterfaceAsync Win32 API ; "Note that this sample requires Windows 10 build 20348 or later."

how can i check the presence of sound in a video using a script

Hi
i am working for a broadcasting company, we have a PC with TV tuner Card (windows xp), this PC is recording channel TV 24h/24 no stop.
the output are video files "wmv" each one has a duration of an hour.
The video files are copied automatically to a NAS, then final users works on them.
the problem is sometimes, there is no signal in the antenna, or there is just video without sound, then the video files recorded are no more exploitables.
i am searching for a way to write a script that can check a file after being recorded before being transfered to the NAS, the script must check the presence of the sound (perhaps volume statistics) to be sure the sounds exists really, same thing of video.
(for video i am using a script checking the size of the file)
is there anyway to do so ?
is there any command line in vlc, mplayer, media player classic, ..... ?
Thanks
Perhaps you can use ffmpeg (http://linux.byexamples.com/archives/229/extract-audio-from-video-or-online-stream/) to dump the audio to a seperate file in a compressed state, and the filesize can give you some information about the amount of data?

HAL - how to monitor audio output on a mac

There is an application called wiretap available at
http://www.ambrosiasw.com/utilities/wiretap/
This application can record the system audio. I would like to be able to do the same in my program. Any insights on what I need to do this? I am familiar with Core Audio but havent found anything on how to do this.
would this help getting the answer? I entered the command line: ioreg -w0 -l | grep io |more
this is what I found aboud wiretap....there might be more related info close to where i found it:
+-o com_AmbrosiaSW_AudioSupport <class com_AmbrosiaSW_AudioSupport, registered, matched, active, busy 0, retain 4 >
"CFBundleIdentifier" = "com.AmbrosiaSW.AudioSupport"
"IOMatchCategory" = "com_AmbrosiaSW_AudioSupport"
"version" = 2
"IOClass" = "com_AmbrosiaSW_AudioSupport"
yan-bellavances-mac-mini:~ ybellavance$ ioreg -w0 -l | grep io |more
The short answer is no, unless you have connections and/or are really experienced/talented (i'm new to mac dev). Guess i'm gonna use the audioEngine example in the Darwin open source section.
Here is the answer I got from Jeff Moore at core-audio mailing list:
"There is no API for doing this, just various hacks/work-arounds that
folks have come up with. The most straight forward way would be to
write a fake driver to do what you want. Soundflower and JACK would be
good examples of this approach. Soundflower uses a kernel driver while
JACK uses a user-land driver.
Folks are clever and have come up with other ways to do it as well.
But I'll let them speak for themselves if they are inclined to share
their techniques. At any rate, you might want to start your education
on this by reading the list archives as this topic comes up on a
regular basis."
Another similar opensource tool is SoundFlower. This tool works by registering as an audio output device. Instead of being a physical device, it is just a virtual output device, that forwards to other devices, or back to the inputs.
This is one strategy for recording system audio output -- appear as an audio output device, and have the system play through this virtual device. In addition to recording the audio, you could also forward it on to the speakers to appear transparent. You could use SoundFlower as an example if you're interested in pursuing this route.

Resources