Replies: 2 comments 1 reply
-
More info... I'm using a Mac Mini which does not have a built-in microphone. Also, I get this message in the Xcode console when my app first starts: AddInstanceForFactory: No factory registered for id <CFUUID 0x600000970380> F8BB1C28-BAE8-11D6-9C31-00039315CD46 Google doesn't turn up anything suggesting this is causing the issue I'm seeing though. Seems to be related to Xcode. |
Beta Was this translation helpful? Give feedback.
-
To try another tack, I've downloaded and compiled the Apple sample recording program from here: Here is one of the recordings (zipped): Here is the Xcode console output for one 30 second recording:
Am I doing something wrong? Keen to contribute to the Black Hole project if I can get it to work. Thanks in advance, |
Beta Was this translation helpful? Give feedback.
-
Hi Devin,
I am developing a digital signal processing application using BlackHole and Apple AudioToolbox. The idea is to pass audio from a player (Jriver Media Center and Quicktime) to my application through BlackHole
Environment:
MacOS Sonoma 14.4.1
Xcode 15.4
Quicktime 10.5 and JRiver Media Center 32
BlackHole 2ch and 16ch
Problem: All audio samples received are zero.
Steps to recreate:
Set Mac Settings Sound audio output to BlackHole 2ch.
Set Mac Settings Sound audio input to BlackHole 2ch.
Authorise Xcode to access Microphone.
In Audio MIDI set "Use this device for sound input" and "Use this device for sound output". Set volume of both to 1.0 .
Play a 44.1 16-bit stereo FLAC file using Quicktime.
Start C++ application - key details of my code below...
AudioStreamBasicDescription asbd = { 0 };
asbd.mFormatID = kAudioFormatLinearPCM;
asbd.mFormatFlags = kLinearPCMFormatFlagIsFloat | kLinearPCMFormatFlagIsPacked;
asbd.mSampleRate = 48000;
asbd.mBitsPerChannel = 32;
asbd.mBytesPerFrame = 8;
asbd.mChannelsPerFrame = 2;
asbd.mBytesPerPacket = asbd.mBytesPerFrame;
asbd.mFramesPerPacket = 1;
status = AudioQueueNewInput(&asbd,
read_audio_callback,
&userdata,
NULL,
NULL,
0,
&queue_ref);
for (uint8_t b = 0; b < num_buffers; b++) {
AudioQueueBufferRef buf_ref;
status = AudioQueueAllocateBuffer(queue_ref, audio_buf_size, &buf_ref);
printf("Allocate buffer status: %d length %d\n", status, buf_ref->mAudioDataByteSize);
status = AudioQueueEnqueueBuffer (queue_ref, buf_ref, 0, NULL);
printf ("Initial Enqueue Buffer status: %d\n", status);
}
status = AudioQueueStart(queue_ref, NULL);
Here is my callback:
void read_audio_callback(void * ptr, AudioQueueRef queue_ref, AudioQueueBufferRef buf_ref, const AudioTimeStamp * ts_not_used, uint32_t num_packets, const AudioStreamPacketDescription * aspd_not_used) {
if (num_packets > 0) {
uint32_t bytesize = buf_ref -> mAudioDataByteSize;
float * sample_buf_float = (float *)buf_ref -> mAudioData;
float data[bytesize / 4];
memcpy(data, sample_buf_float, bytesize);
OSStatus status = AudioQueueEnqueueBuffer(queue_ref, buf_ref, 0, NULL);
printf ("Enqueue buffer status: %d\n", status);
printf("Buffer length %d Packets received %d\n", bytesize, num_packets);
for (int j = 0; j < bytesize / 4; j++) {
printf("%f",data[j]);
}
}
printf("read_audio_callback called!\n");
}
All calls to Apple Audio functions return status of 0.
The samples in the buffer are all 0.0 . Why would this be the case?
Also, my callback is called even when playback is stopped. num_packets is always > 0 .
Appreciate any help.
Thanks in advance,
Geoff.
Beta Was this translation helpful? Give feedback.
All reactions