本文整理汇总了C++中AudioUnitSetParameter函数的典型用法代码示例。如果您正苦于以下问题:C++ AudioUnitSetParameter函数的具体用法?C++ AudioUnitSetParameter怎么用?C++ AudioUnitSetParameter使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了AudioUnitSetParameter函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sizeof
bool CCoreAudioMixMap::SetMixingMatrix(CAUMatrixMixer *mixerUnit,
CCoreAudioMixMap *mixMap, AudioStreamBasicDescription *inputFormat,
AudioStreamBasicDescription *fmt, int channelOffset)
{
if (!mixerUnit || !inputFormat || !fmt)
return false;
// Fetch the mixing unit size
UInt32 dims[2];
UInt32 size = sizeof(dims);
AudioUnitGetProperty(mixerUnit->GetUnit(),
kAudioUnitProperty_MatrixDimensions, kAudioUnitScope_Global, 0, dims, &size);
if(inputFormat->mChannelsPerFrame + channelOffset > dims[0])
{
CLog::Log(LOGERROR, "CCoreAudioMixMap::SetMixingMatrix - input format doesn't fit mixer size %u+%u > %u"
, inputFormat->mChannelsPerFrame, channelOffset, dims[0]);
return false;
}
if(fmt->mChannelsPerFrame > dims[1])
{
CLog::Log(LOGERROR, "CCoreAudioMixMap::SetMixingMatrix - ouput format doesn't fit mixer size %u > %u"
, fmt->mChannelsPerFrame, dims[1]);
return false;
}
if(fmt->mChannelsPerFrame < dims[1])
{
CLog::Log(LOGWARNING, "CCoreAudioMixMap::SetMixingMatrix - ouput format doesn't specify all outputs %u < %u"
, fmt->mChannelsPerFrame, dims[1]);
}
// Configure the mixing matrix
Float32* val = (Float32*)*mixMap;
for (UInt32 i = 0; i < inputFormat->mChannelsPerFrame; ++i)
{
UInt32 j = 0;
for (; j < fmt->mChannelsPerFrame; ++j)
{
AudioUnitSetParameter(mixerUnit->GetUnit(),
kMatrixMixerParam_Volume, kAudioUnitScope_Global, ( (i + channelOffset) << 16 ) | j, *val++, 0);
}
// zero out additional outputs from this input
for (; j < dims[1]; ++j)
{
AudioUnitSetParameter(mixerUnit->GetUnit(),
kMatrixMixerParam_Volume, kAudioUnitScope_Global, ( (i + channelOffset) << 16 ) | j, 0.0f, 0);
}
}
CLog::Log(LOGDEBUG, "CCoreAudioGraph::Open: "
"Mixer Output Format: %d channels, %0.1f kHz, %d bits, %d bytes per frame",
(int)fmt->mChannelsPerFrame, fmt->mSampleRate / 1000.0f, (int)fmt->mBitsPerChannel, (int)fmt->mBytesPerFrame);
if (!mixerUnit->InitMatrixMixerVolumes())
return false;
return true;
}
示例2: AudioUnitSetParameter
/**
* Calls the platform specific code to set the parameters that define a radio effect.
*
* @param RadioEffectParameters The new parameters for the radio distortion effect.
*/
void FCoreAudioEffectsManager::SetRadioEffectParameters( const FAudioRadioEffect& RadioEffectParameters )
{
enum ERadioEffectParams
{
RadioParam_ChebyshevPowerMultiplier,
RadioParam_ChebyshevPower,
RadioParam_ChebyshevMultiplier,
RadioParam_ChebyshevCubedMultiplier
};
const float ChebyshevPowerMultiplier = Radio_ChebyshevPowerMultiplier->GetValueOnGameThread();
const float ChebyshevPower = Radio_ChebyshevPower->GetValueOnGameThread();
const float ChebyshevMultiplier = Radio_ChebyshevMultiplier->GetValueOnGameThread();
const float ChebyshevCubedMultiplier = Radio_ChebyshevCubedMultiplier->GetValueOnGameThread();
for( uint32 Index = 1; Index < CORE_AUDIO_MAX_CHANNELS; Index++ )
{
FCoreAudioSoundSource *Source = ((FCoreAudioDevice*)AudioDevice)->AudioChannels[Index];
if( Source && Source->RadioUnit )
{
AudioUnitSetParameter( Source->RadioUnit, RadioParam_ChebyshevPowerMultiplier, kAudioUnitScope_Global, 0, ChebyshevPowerMultiplier, 0 );
AudioUnitSetParameter( Source->RadioUnit, RadioParam_ChebyshevPower, kAudioUnitScope_Global, 0, ChebyshevPower, 0 );
AudioUnitSetParameter( Source->RadioUnit, RadioParam_ChebyshevMultiplier, kAudioUnitScope_Global, 0, ChebyshevMultiplier, 0 );
AudioUnitSetParameter( Source->RadioUnit, RadioParam_ChebyshevCubedMultiplier, kAudioUnitScope_Global, 0, ChebyshevCubedMultiplier, 0 );
}
}
}
示例3: check
void FCoreAudioDevice::SetupMatrixMixerInput( int32 Input, bool bIs6ChannelOGG )
{
check( Input < MAX_MULTICHANNEL_AUDIOCHANNELS );
uint32 InputOffset = Input * MatrixMixerInputFormat.mChannelsPerFrame;
uint32 FLInputOffset = 0;
uint32 FRInputOffset = 1;
uint32 FCInputOffset = 2;
uint32 LFEInputOffset = 3;
uint32 SLInputOffset = 4;
uint32 SRInputOffset = 5;
// Channel ordering is different for 6 channel OGG files
if (bIs6ChannelOGG)
{
FLInputOffset = 0;
FCInputOffset = 1;
FRInputOffset = 2;
SLInputOffset = 3;
SRInputOffset = 4;
LFEInputOffset = 5;
}
// Enable input 0
AudioUnitSetParameter( MatrixMixerUnit, kMatrixMixerParam_Enable, kAudioUnitScope_Input, Input, 1.0, 0 );
// Set Matrix Input volume
SetMatrixMixerInputVolume( Input, 1.0 );
// FL channel to left output
uint32 element = CalculateMatrixElement( InputOffset + FLInputOffset, 0 );
AudioUnitSetParameter( MatrixMixerUnit, kMatrixMixerParam_Volume, kAudioUnitScope_Global, element, 1.0, 0 );
// FR channel to right output
element = CalculateMatrixElement( InputOffset + FRInputOffset, 1 );
AudioUnitSetParameter( MatrixMixerUnit, kMatrixMixerParam_Volume, kAudioUnitScope_Global, element, 1.0, 0 );
// FC channel to left & right output
element = CalculateMatrixElement( InputOffset + FCInputOffset, 0 );
AudioUnitSetParameter( MatrixMixerUnit, kMatrixMixerParam_Volume, kAudioUnitScope_Global, element, 0.5, 0 );
element = CalculateMatrixElement( InputOffset + FCInputOffset, 1 );
AudioUnitSetParameter( MatrixMixerUnit, kMatrixMixerParam_Volume, kAudioUnitScope_Global, element, 0.5, 0 );
// LFE channel to left & right output
element = CalculateMatrixElement( InputOffset + LFEInputOffset, 0 );
AudioUnitSetParameter( MatrixMixerUnit, kMatrixMixerParam_Volume, kAudioUnitScope_Global, element, 0.5, 0 );
element = CalculateMatrixElement( InputOffset + LFEInputOffset, 1 );
AudioUnitSetParameter( MatrixMixerUnit, kMatrixMixerParam_Volume, kAudioUnitScope_Global, element, 0.5, 0 );
// SL channel to left output
element = CalculateMatrixElement( InputOffset + SLInputOffset, 0 );
AudioUnitSetParameter( MatrixMixerUnit, kMatrixMixerParam_Volume, kAudioUnitScope_Global, element, 1.0, 0 );
// SR channel to right output
element = CalculateMatrixElement( InputOffset + SRInputOffset, 1 );
AudioUnitSetParameter( MatrixMixerUnit, kMatrixMixerParam_Volume, kAudioUnitScope_Global, element, 1.0, 0 );
}
示例4: writeRenderProc
OSStatus writeRenderProc(void *inRefCon,
AudioUnitRenderActionFlags *inActionFlags,
const AudioTimeStamp *inTimeStamp,
UInt32 inBusNumber,
UInt32 inNumFrames,
AudioBufferList *ioData)
{
OSStatus err= noErr;
void *inInputDataProcUserData=NULL;
CAData *d=(CAData*)inRefCon;
if (gain_changed_out == true)
{
err = AudioUnitSetParameter(d->caOutAudioUnit, kAudioUnitParameterUnit_LinearGain,
kAudioUnitScope_Global, 0, (Float32)gain_volume_out, 0);
if(err != noErr)
{
ms_error("failed to set output volume %i", err);
}
gain_changed_out = false;
err= noErr;
}
if(d->write_started != FALSE) {
AudioStreamPacketDescription* outPacketDescription = NULL;
err = AudioConverterFillComplexBuffer(d->caOutConverter, writeACInputProc, inRefCon,
&inNumFrames, ioData, outPacketDescription);
if(err != noErr)
ms_error("writeRenderProc:AudioConverterFillComplexBuffer err %08x %d", err, ioData->mNumberBuffers);
}
return err;
}
示例5: AudioUnitSetParameter
bool CCoreAudioMixMap::SetMixingMatrix(CAUMatrixMixer *mixerUnit,
CCoreAudioMixMap *mixMap, AudioStreamBasicDescription *inputFormat,
AudioStreamBasicDescription *fmt, int channelOffset)
{
if (!mixerUnit || !inputFormat || !fmt)
return false;
// Configure the mixing matrix
Float32* val = (Float32*)*mixMap;
CLog::Log(LOGDEBUG, "CCoreAudioGraph::Open: Loading matrix mixer configuration");
for (UInt32 i = 0; i < inputFormat->mChannelsPerFrame; ++i)
{
val = (Float32*)*mixMap + i*m_deviceChannels;
for (UInt32 j = 0; j < fmt->mChannelsPerFrame; ++j)
{
OSStatus ret = AudioUnitSetParameter(mixerUnit->GetUnit(),
kMatrixMixerParam_Volume, kAudioUnitScope_Global, ( (i + channelOffset) << 16 ) | j, *val++, 0);
if (!ret)
{
CLog::Log(LOGINFO, "CCoreAudioGraph::Open: \t[%d][%d][%0.1f]",
(int)i + channelOffset, (int)j, *(val-1));
}
}
}
CLog::Log(LOGINFO, "CCoreAudioGraph::Open: "
"Mixer Output Format: %d channels, %0.1f kHz, %d bits, %d bytes per frame",
(int)fmt->mChannelsPerFrame, fmt->mSampleRate / 1000.0f, (int)fmt->mBitsPerChannel, (int)fmt->mBytesPerFrame);
if (!mixerUnit->InitMatrixMixerVolumes())
return false;
return true;
}
示例6: setParameter
bool auLoader::setParameter(int index, float value, long frames) {
if(AudioUnitSetParameter(m_plugin, index, kAudioUnitScope_Global, 0, value, frames) == noErr) {
return true;
}
else {
return false;
}
}
示例7: AudioUnitSetParameter
void OutputImplAudioUnit::setVolume( float aVolume )
{
aVolume = math<float>::clamp( aVolume, 0.0, 1.0 );
OSStatus err = AudioUnitSetParameter( mMixerUnit, kMultiChannelMixerParam_Volume, kAudioUnitScope_Output, 0, aVolume, 0 );
if( err ) {
//throw
}
}
示例8: OSSpinLockLock
void CoreAudioOutput::setVolume(float vol)
{
this->_volume = vol;
OSSpinLockLock(this->_spinlockAU);
AudioUnitSetParameter(this->_au, kHALOutputParam_Volume, kAudioUnitScope_Global, 0, vol, 0);
OSSpinLockUnlock(this->_spinlockAU);
}
示例9: control
static int control(int cmd,void *arg){
ao_control_vol_t *control_vol;
OSStatus err;
Float32 vol;
switch (cmd) {
case AOCONTROL_GET_VOLUME:
control_vol = (ao_control_vol_t*)arg;
if (ao->b_digital) {
// Digital output has no volume adjust.
return CONTROL_FALSE;
}
err = AudioUnitGetParameter(ao->theOutputUnit, kHALOutputParam_Volume, kAudioUnitScope_Global, 0, &vol);
if(err==0) {
// printf("GET VOL=%f\n", vol);
control_vol->left=control_vol->right=vol*100.0/4.0;
return CONTROL_TRUE;
}
else {
ao_msg(MSGT_AO, MSGL_WARN, "could not get HAL output volume: [%4.4s]\n", (char *)&err);
return CONTROL_FALSE;
}
case AOCONTROL_SET_VOLUME:
control_vol = (ao_control_vol_t*)arg;
if (ao->b_digital) {
// Digital output can not set volume. Here we have to return true
// to make mixer forget it. Else mixer will add a soft filter,
// that's not we expected and the filter not support ac3 stream
// will cause mplayer die.
// Although not support set volume, but at least we support mute.
// MPlayer set mute by set volume to zero, we handle it.
if (control_vol->left == 0 && control_vol->right == 0)
ao->b_muted = 1;
else
ao->b_muted = 0;
return CONTROL_TRUE;
}
vol=(control_vol->left+control_vol->right)*4.0/200.0;
err = AudioUnitSetParameter(ao->theOutputUnit, kHALOutputParam_Volume, kAudioUnitScope_Global, 0, vol, 0);
if(err==0) {
// printf("SET VOL=%f\n", vol);
return CONTROL_TRUE;
}
else {
ao_msg(MSGT_AO, MSGL_WARN, "could not set HAL output volume: [%4.4s]\n", (char *)&err);
return CONTROL_FALSE;
}
/* Everything is currently unimplemented */
default:
return CONTROL_FALSE;
}
}
示例10: SetParameter
OSStatus SetParameter(AudioUnitParameterID inID, AudioUnitScope scope, AudioUnitElement element,
Float32 value, UInt32 bufferOffsetFrames)
{
if (mSetParamProc != NULL) {
return reinterpret_cast<AudioUnitSetParameterProc>(mSetParamProc) (mConnInstanceStorage,
inID, scope, element, value, bufferOffsetFrames);
}
return AudioUnitSetParameter(mUnit, inID, scope, element, value, bufferOffsetFrames);
}
示例11: DoSetVolume
/** Set the volume of the current sequence. */
static void DoSetVolume()
{
if (_sequence == NULL) return;
AUGraph graph;
MusicSequenceGetAUGraph(_sequence, &graph);
AudioUnit output_unit = NULL;
/* Get output audio unit */
UInt32 node_count = 0;
AUGraphGetNodeCount(graph, &node_count);
for (UInt32 i = 0; i < node_count; i++) {
AUNode node;
AUGraphGetIndNode(graph, i, &node);
AudioUnit unit;
OSType comp_type = 0;
#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5)
if (MacOSVersionIsAtLeast(10, 5, 0)) {
/* The 10.6 SDK has changed the function prototype of
* AUGraphNodeInfo. This is a binary compatible change,
* but we need to get the type declaration right or
* risk compilation errors. The header AudioComponent.h
* was introduced in 10.6 so use it to decide which
* type definition to use. */
#ifdef __AUDIOCOMPONENT_H__
AudioComponentDescription desc;
#else
ComponentDescription desc;
#endif
AUGraphNodeInfo(graph, node, &desc, &unit);
comp_type = desc.componentType;
} else
#endif
{
#if (MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5)
ComponentDescription desc;
AUGraphGetNodeInfo(graph, node, &desc, NULL, NULL, &unit);
comp_type = desc.componentType;
#endif
}
if (comp_type == kAudioUnitType_Output) {
output_unit = unit;
break;
}
}
if (output_unit == NULL) {
DEBUG(driver, 1, "cocoa_m: Failed to get output node to set volume");
return;
}
Float32 vol = _volume / 127.0f; // 0 - +127 -> 0.0 - 1.0
AudioUnitSetParameter(output_unit, kHALOutputParam_Volume, kAudioUnitScope_Global, 0, vol, 0);
}
示例12: AudioUnitSetParameter
// ----------------------------------------------------------
void ofxAudioUnitSampler::setVolume(float volume)
// ----------------------------------------------------------
{
AudioUnitSetParameter(*_unit,
kMusicDeviceParam_Volume,
kAudioUnitScope_Global,
0,
volume,
0);
}
示例13: AudioUnitSetParameter
/*
* FOR SETTING VOLUME ON iOS, AudioQueue SHOULD BE USED INSTEAD OF AudioUnit
*/
void AudioLoopImplCocoa::setVolume(float volume)
{
#if !TARGET_OS_IPHONE
if (initialized)
{
OSStatus err = AudioUnitSetParameter(audioUnit, kHALOutputParam_Volume, kAudioUnitScope_Output, 0, volume, 0);
if (err) printf("AudioUnitSetParameter ERROR: %d\n", (int)err);
}
#endif
}
示例14: ERR_CHK
// ----------------------------------------------------------
void ofxAudioUnitMixer::setInputVolume(float volume, int bus)
// ----------------------------------------------------------
{
ERR_CHK(AudioUnitSetParameter(*_unit,
kMultiChannelMixerParam_Volume,
kAudioUnitScope_Input,
bus,
volume,
0),
"setting mixer input gain");
}
示例15: set_volume
static int set_volume(struct ao *ao, struct ao_control_vol *vol) {
struct priv *p = ao->priv;
float auvol = (vol->left + vol->right) / 200.0;
OSStatus err =
AudioUnitSetParameter(p->audio_unit, kHALOutputParam_Volume,
kAudioUnitScope_Global, 0, auvol, 0);
CHECK_CA_ERROR("could not set HAL output volume");
return CONTROL_TRUE;
coreaudio_error:
return CONTROL_ERROR;
}