• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Monitoring input level
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Monitoring input level


  • Subject: Re: Monitoring input level
  • From: Jeff Moore <email@hidden>
  • Date: Tue, 20 Jun 2006 14:26:39 -0700


On Jun 20, 2006, at 2:09 PM, Neil Clayton wrote:

Actually, you might be leading me somewhere useful anyway. I'm wanting to do this so that people can use whatever device they have. Obviously, people may well be using USB microphones and wot not (it's actually for a screen capturing app, with voiceover support).

If it's not going to work for USB devices, then .... I'll have to use some other approach anyway.

Indeed.

Would this other approach happen to be something like the ComplexPlayThru example? Where an Input AUHAL is used to capture data to a ring buffer, and that data is pumped into an AUGraph?

That is one way to do it. In it's plainest, simplest form, it's even easy to code up. However, you have the issue of synchronization to deal with. With two clocks in the picture, you have to compensate for the differences in how fast they are running relative to each other or risk over/underflowing your ring buffer if you run long enough.


Or something completely different?

Aggregate devices are the more complete solution to the problem as you don't have to worry about the synchronization as the HAL will do that work for you. To use aggregate devices, you either have to rely on the user constructing one for you to use using AMS or you can build them programatically.


For building them programatically, there was a fairly thorough discussion of how to do it on this list back a few months. You should be able to find the thread in the list archives.


---
Neil Clayton



On 20 Jun 2006, at 22:02, Jeff Moore wrote:

Nope. This device is a full duplex device apparently. That should allow you to use the the techniques Bill and Doug are describing just fine.

I was worried that this was not a full duplex device (like most USB devices and even the built-in hardware on our Intel boxes). In which case, you were going to have to use some other techniques.

Sorry for the confusion. Back to the AU discussions.

On Jun 20, 2006, at 1:59 PM, Neil Clayton wrote:

In HALLab, the EDIROL appears as a single device. 2 in's and 2 outs.

Does this mean however; that the approach outlined below (using a AUHAL) to monitor the input level, will not work on some devices? (e.g: USB devices). In reality, I don't actually NEED to hear anything, so if monitoring is still possible, but I'd not hear anything - that's fine. I only need the level readings to drive a control on screen.

On 20 Jun 2006, at 21:05, Jeff Moore wrote:

Generally, USB Audio devices have to be represented as two devices, one for the input section and one for the output section. As such, my guess is that this is the reason why you aren't hearing anything. Full duplex support in the device is required to make this mechanism work.

However, the UA-25 has it's own driver, so it may support full duplex. The way to figure this out is to build the HALLab sample app in our SDK and look to see if it shows two devices for the UA-25. (Note that AMS will fake it out to show the device as a single device, even if it is two.)

On Jun 20, 2006, at 12:44 PM, Neil Clayton wrote:


So, you have a signal flow that is input->mixer->output (where input and output are the same node).
You should be able to hear the audio as with this connection you are passing input data to an output. Is this the case?
- this will also confirm that you've set up the AUHAL input unit correctly.
You also have to enable metering (the reason being that it adds cost, so we have it disabled by default). The property is:
kAudioUnitProperty_MeteringMode
and there are some comments on this in AudioUnitProperties.h


Bill

No. I cannot hear any audio being played through. For my testing, I'm choosing my Edirol UA25 as the device. I've connected some headphones to it's monitor, to hear any output sent back.


I'll try to explain exactly what I'm doing code wise, in the hope that I, or someone reading this, uncovers a silly mistake on my part.

Note: The part I'm unsure about is settings the formats. So far, I've taken the code from http://developer.apple.com/ technotes/tn2002/tn2091.html and assumed that this is correct. It talks about cases whereby you are either outputting data, or obtaining data, but not both. Since I'm feeding the input, to the ouput (via a mixer), I'm assuming I'm doing both (so my stream format setup may be incomplete, dunno). I could be entirely wrong there.

1) Start a new graph
	NewAUGraph(&auGraph);

2) Create the AUHAL
	ComponentDescription desc;
	desc.componentType = kAudioUnitType_Output;
	desc.componentSubType = kAudioUnitSubType_HALOutput;
	desc.componentManufacturer = kAudioUnitManufacturer_Apple;
	desc.componentFlags = 0;
	desc.componentFlagsMask = 0;

	AUGraphNewNode(auGraph, &desc, 0, NULL, &inputNode);

3) Create the mixer
	ComponentDescription mixer;
	mixer.componentType = kAudioUnitType_Mixer;
	mixer.componentSubType = kAudioUnitSubType_MatrixMixer;
	mixer.componentManufacturer = kAudioUnitManufacturer_Apple;
	mixer.componentFlags = 0;
	mixer.componentFlagsMask = 0;

	AUGraphNewNode(auGraph, &mixer, 0, NULL, &mixerNode);

4) Connect the output of element 1 (the input bus) to the mixer, and also the output of the mixer to the input scope of element 0 (the output bus)
AUGraphConnectNodeInput(auGraph, inputNode, 1, mixerNode, 0);
AUGraphConnectNodeInput(auGraph, mixerNode, 0, inputNode, 0);


5) Open the AU Graph
	AUGraphOpen(auGraph);

6) Get references to the AU Units. Only two required (the input/ output unit, and the mixer itself)
AUGraphGetNodeInfo(auGraph, inputNode, NULL, NULL, NULL, &inputUnit);
AUGraphGetNodeInfo(auGraph, mixerNode, NULL, NULL, NULL, &mixerUnit);


7) Enable IO on the input scope of the AUHAL, and disable the output scope of the AUHAL
UInt32 enableIO = 1;
AudioUnitSetProperty(inputUnit, kAudioOutputUnitProperty_EnableIO, kAudioUnitScope_Input, 1, &enableIO, sizeof(enableIO));
enableIO = 0;
AudioUnitSetProperty(inputUnit, kAudioOutputUnitProperty_EnableIO, kAudioUnitScope_Output, 0, &enableIO, sizeof(enableIO));


8) Enable metering, on the mixer
UInt32 meteringMode = 1;
AudioUnitSetProperty(mixerUnit, kAudioUnitProperty_MeteringMode, kAudioUnitScope_Global, 0, &meteringMode, sizeof(meteringMode) );


9) Setup the input device, on the AUHAL (element 1, the source)
UInt32 size;
size = sizeof(AudioDeviceID);
AudioUnitSetProperty(inputUnit, kAudioOutputUnitProperty_CurrentDevice, kAudioUnitScope_Global, 0, &deviceId, sizeof(deviceId));

10) Set the stream format of the input device, to be the same as the output (using code from http://developer.apple.com/ technotes/tn2002/tn2091.html)
CAStreamBasicDescription DeviceFormat;
CAStreamBasicDescription DesiredFormat;
size = sizeof(CAStreamBasicDescription);
//Get the input device format
AudioUnitGetProperty (inputUnit,
kAudioUnitProperty_StreamFormat,
kAudioUnitScope_Input,
1,
&DeviceFormat,
&size);


    DesiredFormat.mSampleRate =  DeviceFormat.mSampleRate;

	//set format to output scope
     AudioUnitSetProperty(
						 inputUnit,
						 kAudioUnitProperty_StreamFormat,
						 kAudioUnitScope_Output,
						 1,
						 &DesiredFormat,
						 sizeof(CAStreamBasicDescription));

11) Initialize and start the graph
	AUGraphInitialize(auGraph);
	AUGraphStart(auGraph);


--

Jeff Moore
Core Audio
Apple


_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40cloudnine.net.nz


This email sent to email@hidden

_______________________________________________ Do not post admin requests to the list. They will be ignored. Coreaudio-api mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden


--

Jeff Moore
Core Audio
Apple


_______________________________________________ Do not post admin requests to the list. They will be ignored. Coreaudio-api mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Follow-Ups:
    • Re: Monitoring input level
      • From: Neil Clayton <email@hidden>
References: 
 >Monitoring input level (From: Neil Clayton <email@hidden>)
 >Re: Monitoring input level (From: Neil Clayton <email@hidden>)
 >Re: Monitoring input level (From: Jeff Moore <email@hidden>)
 >Re: Monitoring input level (From: Neil Clayton <email@hidden>)
 >Re: Monitoring input level (From: Doug Wyatt <email@hidden>)
 >Re: Monitoring input level (From: Neil Clayton <email@hidden>)
 >Re: Monitoring input level (From: William Stewart <email@hidden>)
 >Re: Monitoring input level (From: Neil Clayton <email@hidden>)
 >Re: Monitoring input level (From: Jeff Moore <email@hidden>)
 >Re: Monitoring input level (From: Neil Clayton <email@hidden>)
 >Re: Monitoring input level (From: Jeff Moore <email@hidden>)
 >Re: Monitoring input level (From: Neil Clayton <email@hidden>)

  • Prev by Date: Re: Monitoring input level
  • Next by Date: Re: Don't exchange pointers, was Re: Objective-C++/C++ with CocoaUI Issue...
  • Previous by thread: Re: Monitoring input level
  • Next by thread: Re: Monitoring input level
  • Index(es):
    • Date
    • Thread