Ejemplo n.º 1
0
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;
}
/** 
 * 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 );
		}
	}
}
Ejemplo n.º 3
0
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 );
}
Ejemplo n.º 4
0
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;
}
Ejemplo n.º 5
0
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;
}
Ejemplo n.º 6
0
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;
  }
}
Ejemplo n.º 7
0
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
	}
}
Ejemplo n.º 8
0
void CoreAudioOutput::setVolume(float vol)
{
	this->_volume = vol;
	
	OSSpinLockLock(this->_spinlockAU);
	AudioUnitSetParameter(this->_au, kHALOutputParam_Volume, kAudioUnitScope_Global, 0, vol, 0);
	OSSpinLockUnlock(this->_spinlockAU);
}
Ejemplo n.º 9
0
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;
	}

}
Ejemplo n.º 10
0
	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);
	}
Ejemplo n.º 11
0
/** 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);
}
// ----------------------------------------------------------
void ofxAudioUnitSampler::setVolume(float volume)
// ----------------------------------------------------------
{
    AudioUnitSetParameter(*_unit,
                          kMusicDeviceParam_Volume,
                          kAudioUnitScope_Global,
                          0,
                          volume,
                          0);
}
/*
 * 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
}
// ----------------------------------------------------------
void ofxAudioUnitMixer::setInputVolume(float volume, int bus)
// ----------------------------------------------------------
{
  ERR_CHK(AudioUnitSetParameter(*_unit, 
                                kMultiChannelMixerParam_Volume, 
                                kAudioUnitScope_Input, 
                                bus, 
                                volume,
                                0), 
          "setting mixer input gain");
}
// ----------------------------------------------------------
void ofxAudioUnitMixer::setOutputVolume(float volume)
// ----------------------------------------------------------
{
  ERR_CHK(AudioUnitSetParameter(*_unit, 
                                kMultiChannelMixerParam_Volume, 
                                kAudioUnitScope_Output, 
                                0, 
                                volume,
                                0), 
          "setting mixer output gain");
}
Ejemplo n.º 16
0
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;
}
Ejemplo n.º 17
0
 int AudioDataMixerCallback(uint busIndex, int totalNbOfFrameToWrite,  AudioBufferList* data)
 {
     char* outPtr = (char*)data->mBuffers[0].mData;
     
     int remainingFramesToWrite = totalNbOfFrameToWrite;
     while (remainingFramesToWrite > 0)
     {
         int nbOfFrameToWrite = std::min(remainingFramesToWrite, (ShouldBeLooped() ? LoopEndPoint : TotalNumberOfFrames) - CurrentFrame);
             
         CopyDataToBuffer(outPtr, nbOfFrameToWrite, NumberOfChannels);
         
         remainingFramesToWrite -= nbOfFrameToWrite;
             
         // Check if the track have to be re-looped
         if (ShouldBeLooped() && CurrentFrame >= LoopEndPoint)
         {
             --NumberOfLoops;
             CurrentFrame = LoopStartPoint;
         }
         
         // Check if we reached the end of the track.
         if (CurrentFrame >= TotalNumberOfFrames)
         {
             AudioUnitSetParameter((AudioUnit)HandleChannelMixer, kMultiChannelMixerParam_Enable, kAudioUnitScope_Input, busIndex, 0, 0);
             AudioUnitSetParameter((AudioUnit)Handle3DMixer, k3DMixerParam_Enable, kAudioUnitScope_Input, busIndex, 0, 0);
         
             IsEnabled2D = false;
             IsEnabled3D = false;
         
             PlaybackEnded = true;
         
             // Fill the rest of the buffer with blank
             int sizeToBlank = sizeof(short) * NumberOfChannels * remainingFramesToWrite;
             memset(outPtr, 0, sizeToBlank);
         
             return 0;
         }
     }
     
     return 0;
 }
Ejemplo n.º 18
0
void CoreAudioSound::SetVolume(int volume)
{
	OSStatus err;
    m_volume = volume;

	err = AudioUnitSetParameter(audioUnit,
					kHALOutputParam_Volume,
					kAudioUnitParameterFlag_Output, 0,
					volume / 100., 0);
	if (err != noErr)
		ERROR_LOG(AUDIO, "error setting volume");
}
Ejemplo n.º 19
0
void native_midi_setvolume(int volume)
{
    if (latched_volume == volume)
        return;

    latched_volume = volume;
    if ((currentsong) && (currentsong->audiounit)) {
        const float floatvol = ((float) volume) / ((float) MIX_MAX_VOLUME);
        AudioUnitSetParameter(currentsong->audiounit, kHALOutputParam_Volume,
                              kAudioUnitScope_Global, 0, floatvol, 0);
    }
}
Ejemplo n.º 20
0
void FCoreAudioDevice::SetMatrixMixerInputVolume( int32 Input, float Volume )
{
	check( Input < MAX_MULTICHANNEL_AUDIOCHANNELS );
	
	uint32 InputOffset = Input * MatrixMixerInputFormat.mChannelsPerFrame;
	
	// Set Input channel 0 volume
	uint32 element = CalculateMatrixElement( InputOffset + 0, -1 );
	AudioUnitSetParameter( MatrixMixerUnit, kMatrixMixerParam_Volume, kAudioUnitScope_Global, element, Volume, 0 );
	
	// Set Input channel 1 volume
	element = CalculateMatrixElement( InputOffset + 1, -1 );
	AudioUnitSetParameter( MatrixMixerUnit, kMatrixMixerParam_Volume, kAudioUnitScope_Global, element, Volume, 0 );
	
	// Set Input channel 2 volume
	element = CalculateMatrixElement( InputOffset + 2, -1 );
	AudioUnitSetParameter( MatrixMixerUnit, kMatrixMixerParam_Volume, kAudioUnitScope_Global, element, Volume, 0 );
	
	// Set Input channel 3 volume
	element = CalculateMatrixElement( InputOffset + 3, -1 );
	AudioUnitSetParameter( MatrixMixerUnit, kMatrixMixerParam_Volume, kAudioUnitScope_Global, element, Volume, 0 );
	
	// Set Input channel 4 volume
	element = CalculateMatrixElement( InputOffset + 4, -1 );
	AudioUnitSetParameter( MatrixMixerUnit, kMatrixMixerParam_Volume, kAudioUnitScope_Global, element, Volume, 0 );
	
	// Set Input channel 5 volume
	element = CalculateMatrixElement( InputOffset + 5, -1 );
	AudioUnitSetParameter( MatrixMixerUnit, kMatrixMixerParam_Volume, kAudioUnitScope_Global, element, Volume, 0 );
}
Ejemplo n.º 21
0
bool CCoreAudioUnit::SetCurrentVolume(Float32 vol)
{
  if (!m_Component)
    return false;
  
  OSStatus ret = AudioUnitSetParameter(m_Component, kHALOutputParam_Volume, kAudioUnitScope_Global, 0, vol, 0);
  if (ret)
  {
    CLog::Log(LOGERROR, "CCoreAudioUnit::SetCurrentVolume: Unable to set AudioUnit volume. Error = 0x%08x (%4.4s)", ret, CONVERT_OSSTATUS(ret));
    return false;
  }
  return true;
}
Ejemplo n.º 22
0
void macosx_audio_set_ogain(audio_desc_t ad,int vol)
{
	UNUSED(ad);
	OSStatus err = noErr;
	// Remember the playback gain.
	//devices[ad].pgain_ = level;
	devices[ad].outputGain_ = vol; /// outputGainDivisor_;
	//float og_scaled = devices[ad].outputGain_ / 16;

	// Set the volume.
	err = AudioUnitSetParameter(devices[ad].outputUnit_, kAudioUnitParameterUnit_LinearGain, kAudioUnitScope_Global, 0, devices[ad].outputGain_, 0);
	if (err != noErr) fprintf(stderr, "Input device error: set_ogain");
};
Ejemplo n.º 23
0
int
sa_stream_set_volume_abs(sa_stream_t *s, float vol) {

  if (s == NULL || s->output_unit == NULL) {
    return SA_ERROR_NO_INIT;
  }

  pthread_mutex_lock(&s->mutex);
  AudioUnitSetParameter(s->output_unit, kHALOutputParam_Volume,
      kAudioUnitParameterFlag_Output, 0, vol, 0);
  pthread_mutex_unlock(&s->mutex);
  return SA_SUCCESS;
}
Ejemplo n.º 24
0
void OutputImplAudioUnit::Track::play() 
{
	AURenderCallbackStruct renderCallback;
	renderCallback.inputProc = &OutputImplAudioUnit::Track::renderCallback;
	renderCallback.inputProcRefCon = (void *)this;
	
	OSStatus err;
	
	err = AudioUnitSetProperty( mOutput->mMixerUnit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Input, mInputBus, mOutput->mPlayerDescription, sizeof( AudioStreamBasicDescription ) );
	if( err ) {
		//throw
		std::cout << "Error setting track input bus format on mixer" << std::endl;
	}
	
	err = AudioUnitSetParameter( mOutput->mMixerUnit, kMultiChannelMixerParam_Enable, kAudioUnitScope_Input, mInputBus, 1, 0 );
	if( err ) {
		std::cout << "error enabling input bus" << std::endl;
	}
	
	err = AudioUnitSetParameter( mOutput->mMixerUnit, kMultiChannelMixerParam_Volume, kAudioUnitScope_Input, mInputBus, CINDER_DEFAULT_VOLUME, 0 );
	if( err ) {
		std::cout << "error setting default volume" << std::endl;
	}
	
	mIsPlaying = true;
	
	err = AudioUnitAddRenderNotify( mOutput->mMixerUnit, OutputImplAudioUnit::Track::renderNotifyCallback, (void *)this );
	if( err ) {
		//throw
		std::cout << "Error setting track redner notify callback on mixer" << std::endl;
	}
	
	err = AudioUnitSetProperty( mOutput->mMixerUnit, kAudioUnitProperty_SetRenderCallback, kAudioUnitScope_Input, mInputBus, &renderCallback, sizeof(renderCallback) );
	if( err ) {
		//throw
		std::cout << "Error setting track redner callback on mixer" << std::endl;
	}
}
Ejemplo n.º 25
0
/*----------------------------------------------------------------------
|    OsxAudioUnitsOutput_SetVolume
+---------------------------------------------------------------------*/
BLT_METHOD
OsxAudioUnitsOutput_SetVolume(BLT_VolumeControl* _self, float volume)
{
    OsxAudioUnitsOutput* self = ATX_SELF(OsxAudioUnitsOutput, BLT_VolumeControl);
    ComponentResult      result;
    Float32              au_volume = volume;
    
    result = AudioUnitSetParameter(self->audio_unit, kHALOutputParam_Volume, kAudioUnitScope_Global, 0, au_volume, 0);
    if (result == noErr) {
        return BLT_SUCCESS;
    } else {
        return BLT_FAILURE;
    }    
}
Ejemplo n.º 26
0
bool CAUMatrixMixer::SetInputBusFormat(UInt32 busCount, AudioStreamBasicDescription *pFormat)
{
  if (!m_audioUnit)
    return false;

  UInt32 enable = 1;
  for (UInt32 i = 0; i < busCount; i++)
  {
    AudioUnitSetParameter(m_audioUnit, kMatrixMixerParam_Enable, kAudioUnitScope_Input, i, enable, 0);
    if (!SetFormat(pFormat, kAudioUnitScope_Input, i))
      return false;
  }

  return true;
}
Ejemplo n.º 27
0
bool CAUMatrixMixer::SetOutputVolume(UInt32 element, Float32 vol)
{
  if (!m_audioUnit)
    return false;

  OSStatus ret = AudioUnitSetParameter(m_audioUnit,
    kMatrixMixerParam_Volume, kAudioUnitScope_Output, element, vol, 0);
  if (ret)
  {
    CLog::Log(LOGERROR, "CAUMatrixMixer::SetOutputVolume: "
      "Unable to set output volume. Error = %s", GetError(ret).c_str());
    return false;
  }
  return true;
}
Ejemplo n.º 28
0
bool CAUMultiChannelMixer::SetCurrentVolume(Float32 vol)
{

  if (!m_audioUnit)
    return false;

  OSStatus ret = AudioUnitSetParameter(m_audioUnit, kMultiChannelMixerParam_Volume, kAudioUnitScope_Input, kInputBus, vol, 0);
  if (ret)
  {
    CLog::Log(LOGERROR, "CAUMultiChannelMixer::SetCurrentVolume: Unable to set Mixer volume. Error = %s", GetError(ret).c_str());
    return false;
  }

  return true;
}
Ejemplo n.º 29
0
bool CAUMatrixMixer::SetGlobalVolume(Float32 vol)
{
  if (!m_audioUnit)
    return false;

  OSStatus ret = AudioUnitSetParameter(m_audioUnit,
    kMatrixMixerParam_Volume, kAudioUnitScope_Global, 0xFFFFFFFF, vol, 0);
  if (ret)
  {
    CLog::Log(LOGERROR, "CAUMatrixMixer::SetGlobalVolume: "
      "Unable to set global volume. Error = %s", GetError(ret).c_str());
    return false;
  }
  return true;
}
Ejemplo n.º 30
0
bool CAUOutputDevice::SetCurrentVolume(Float32 vol)
{
  if (!m_audioUnit)
    return false;

  OSStatus ret = AudioUnitSetParameter(m_audioUnit, kHALOutputParam_Volume,
    kAudioUnitScope_Global, 0, vol, 0);
  if (ret)
  {
    CLog::Log(LOGERROR, "CCoreAudioUnit::SetCurrentVolume: "
      "Unable to set AudioUnit volume. Error = %s", GetError(ret).c_str());
    return false;
  }
  return true;
}