Re: Monitoring input level
Re: Monitoring input level
- Subject: Re: Monitoring input level
- From: Neil Clayton <email@hidden>
- Date: Tue, 20 Jun 2006 21:59:17 +0100
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.
---
Neil Clayton
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