This is the AudioComponent. All sound effects requests come through here. Requires StaticPool.cs so be sure to include that too
Inheritance: GameComponent
    public override UnitState HandleInput(Controller controller)
    {
        var swappedAbility = SwapActiveAbility(controller);

        if (swappedAbility != null)
        {
            BoardVisuals.RemoveTilesFromHighlightsByUnit(Owner);
            CleanIndicator();
            return(swappedAbility);
        }

        List <PathfindingData> tilesInRange = GetTilesInRange();

        // handling a special case where the targetting is programmatic.
        // will ecentually need to accomodate for this in a more robust way using OOP
        if (abilityComponent.CurrentAbility.AutoTargets)
        {
            PathfindingData autoTarget = tilesInRange.FirstOrDefault(
                element => element.tile.IsOccupied() && element.tile.OccupiedBy.GetComponent <Monster> ()
                );

            if (autoTarget == null)
            {
                AudioComponent.PlaySound(Sounds.ERROR);
                onAbilityCanceled();
                return(new PlayerIdleState(Owner));
            }

            if (Owner.EnergyComponent.AdjustEnergy(-abilityComponent.CurrentAbility.EnergyCost) &&
                abilityComponent.PrepAbility(tilesInRange, autoTarget))
            {
                onAbilityCommited(Owner, abilityComponent.IndexOfCurrentAbility());
                return(new PlayerActingState(Owner, tilesInRange, autoTarget));
            }
        }

        Point mousePosition = BoardUtility.mousePosFromScreenPoint();

        HighlightTiles(tilesInRange, mousePosition);

        // user clicks on a walkable tile which is in range....
        if (controller.DetectInputFor(ControlTypes.CONFIRM))
        {
            PathfindingData selectedTarget = tilesInRange.Find(
                element => element.tile.Position == mousePosition
                );

            // transition to acting state if it's a valid selection
            // and we successfully prep our ability for use
            bool targetIsValid = selectedTarget != null && selectedTarget.tile.isWalkable;
            if (targetIsValid && Owner.EnergyComponent.AdjustEnergy(-abilityComponent.CurrentAbility.EnergyCost) &&
                abilityComponent.PrepAbility(tilesInRange, selectedTarget))
            {
                onAbilityCommited(Owner, abilityComponent.IndexOfCurrentAbility());
                return(new PlayerActingState(Owner, tilesInRange, selectedTarget));
            }
        }

        return(null);
    }
        public void GetSetNullComponentList()
        {
            TestRuntime.AssertXcodeVersion(9, 0);
            var types = new List <AudioTypeOutput> {
                AudioTypeOutput.Generic, AudioTypeOutput.Remote, AudioTypeOutput.VoiceProcessingIO
            };

            foreach (var t in types)
            {
                var resources = new ResourceUsageInfo();
                resources.IOKitUserClient             = new string[] { "CustomUserClient1" };
                resources.MachLookUpGlobalName        = new string[] { "MachServiceName1" };
                resources.NetworkClient               = false;
                resources.TemporaryExceptionReadWrite = false;

                var componentInfo = new AudioComponentInfo();
                componentInfo.Type          = t.ToString();
                componentInfo.Subtype       = "XMPL";
                componentInfo.Name          = "XMPL";
                componentInfo.Version       = 1;
                componentInfo.ResourceUsage = resources;
                var component = AudioComponent.FindComponent(t);
                if (component == null)
                {
                    continue;
                }
                //monotouchtests does not have permissions to deal with the hwd.
                Assert.Throws <ArgumentNullException> (() => component.ComponentList = null);
            }
        }
Example #3
0
            /// <summary>
            /// constructor
            /// </summary>
            /// <param name="audioComponent">an audio component which houses the relevent audio elements</param>
            public AudioManager(AudioComponent audioComponent)
            {
                // assign references to all the relevant audio elements
                m_audioMixer = audioComponent.GetAudioMixer();
                m_BGM        = audioComponent.GetBGM();
                m_ambience   = audioComponent.GetAmbience();
                m_SFX        = audioComponent.GetSFX();
                m_voice      = audioComponent.GetVoice();

                // create a new object to house each different type of audio source
                m_bgmAudio     = new GameObject("BGM");
                m_ambientAudio = new GameObject("Ambience");
                m_sfxAudio     = new GameObject("SFX");
                m_voiceAudio   = new GameObject("Voice");

                // BGM, SFX and voice object all only need one AudioSource
                AudioSource bgmSource   = m_bgmAudio.AddComponent <AudioSource>();
                AudioSource sfxSource   = m_sfxAudio.AddComponent <AudioSource>();
                AudioSource voiceSource = m_voiceAudio.AddComponent <AudioSource>();

                bgmSource.outputAudioMixerGroup   = m_BGM;
                sfxSource.outputAudioMixerGroup   = m_SFX;
                voiceSource.outputAudioMixerGroup = m_voice;
                bgmSource.loop = true; // loop the BGM
            }
Example #4
0
    public void StopAll()
    {
        m_looping = false;
        StopAllCoroutines();
        IDictionaryEnumerator enumerator = m_childComponents.GetEnumerator();

        try
        {
            while (enumerator.MoveNext())
            {
                DictionaryEntry dictionaryEntry = (DictionaryEntry)enumerator.Current;
                if (dictionaryEntry.Value is AudioComponent)
                {
                    AudioComponent audioComponent = dictionaryEntry.Value as AudioComponent;
                    audioComponent.StopAll();
                }
                if (dictionaryEntry.Value is AudioRandomComponent)
                {
                    AudioRandomComponent audioRandomComponent = dictionaryEntry.Value as AudioRandomComponent;
                    audioRandomComponent.StopAll();
                }
            }
        }
        finally
        {
            IDisposable disposable;
            if ((disposable = (enumerator as IDisposable)) != null)
            {
                disposable.Dispose();
            }
        }
    }
Example #5
0
        private AudioComponent[] CollectNoInstanceAudioComponents()
        {
            List <AudioComponent> list = new List <AudioComponent>();
            int childCount             = base.transform.childCount;

            for (int i = 0; i < childCount; i++)
            {
                Component component = base.transform.GetChild(i).GetComponent <Component>();
                if (component != null && component.name != "Instances")
                {
                    AudioComponent[] componentsInChildren = component.gameObject.GetComponentsInChildren <AudioComponent>(includeInactive: true);
                    for (int j = 0; j < componentsInChildren.Length; j++)
                    {
                        list.Add(componentsInChildren[j]);
                    }
                }
            }
            AudioComponent component2 = base.gameObject.GetComponent <AudioComponent>();

            if (component2 != null)
            {
                list.Add(component2);
            }
            return(list.ToArray());
        }
Example #6
0
        protected override void SetInitialValues()
        {
            _animatorVariables = new PlayerAnimatorVariables();
            _cinemachine       = GameObject.FindObjectOfType <CinemachineVirtualCamera>();
            _uIManager         = GameObject.FindObjectOfType <UIManager>();
            _playerStateManage = GameObject.FindObjectOfType <PlayerStateManager>();
            _activePlayerUI    = GameObject.FindObjectOfType <ActivePlayersUIComponent>();
            _animator          = this.GetComponent <Animator>();
            _audioComponent    = this.GetComponent <AudioComponent>();

            _damageDealerComponent = this.GetComponent <DamageDealerComponent>();
            _damageTakerComponent  = this.GetComponent <DamageTakerComponent>();

            _miniMapComponent = GameObject.FindObjectOfType <MiniMapComponent>();


            if (_canMoveByClick)
            {
                _movementMouseComponent = this.GetComponent <MovementMouseComponent>();
            }
            if (_canInteract)
            {
                _interactableComponent = this.GetComponent <InteractableComponent>();
            }
            if (_canPoop)
            {
                _stomachComponent = this.GetComponent <StomachComponent>();
            }
        }
Example #7
0
    /// <summary>
    /// Init class method.
    /// </summary>
    private void Init()
    {
        // get items section component reference.
        if (_itemsSections == null)
        {
            _itemsSections = GetComponentInParent <ItemsSections>();
        }

        // get audio component.
        if (_audio == null)
        {
            _audio = GetComponent <AudioComponent>();
        }

        // get animator component.
        if (_anim == null)
        {
            _anim = GetComponent <Animator>();
        }

        if (_imageHandlerOriginalPosition == null)
        {
            _imageHandlerOriginalPosition = itemDragImage.gameObject.transform.position;
        }
    }
Example #8
0
    /// <summary>
    /// Init class method.
    /// </summary>
    private void Init()
    {
        // get animator component
        // _animator = GetComponent<Animator>();

        // get camera component from parent.
        _mainCamera = GetComponentInParent <Camera>();

        // get ray shooter component from camera.
        _rayShooter = GetComponentInParent <RayShooter>();

        // get audio component reference.
        _audio = GetComponent <AudioComponent>();

        // calculate heated threshold - this is used to check and update heated weapon status.
        if (plasmaGunData != null)
        {
            float temp = (float)plasmaGunData.heatedRechargeThreeshold / (float)plasmaGunData.maxPlasma;
            _heatedThreshold = temp * 100f;
        }

        // set next level data if not set ( usually when the game is initialised for the first time );
        if (plasmaGunData.nextLevel == null)
        {
            plasmaGunData.nextLevel = plasmaGunData.GetLevelDataObject(plasmaGunData.level + 1);
        }
    }
Example #9
0
    /// <summary>
    /// Init class method.
    /// </summary>
    private void Init()
    {
        // get animator component reference.
        if (_anim == null)
        {
            _anim = GetComponent <Animator>();
        }

        // get audio component reference.
        if (_audio == null)
        {
            _audio = GetComponent <AudioComponent>();
        }

        // debug.
        if (assignableData.resetAtInit)
        {
            assignableData.Reset();
        }

        // set up item assigned if required.
        if (assignableData.itemData != null)
        {
            SetUpCurrentAssignated();
        }
    }
Example #10
0
    public override void Activate()
    {
        var board    = Owner.Board;
        var ownerPos = Owner.Position;
        var from     = board.TileAt(ownerPos);

        Point targetDir = new Point((Mathf.Clamp(Target.tile.Position.x -
                                                 ownerPos.x, -1, 1)), (Mathf.Clamp(Target.tile.Position.y -
                                                                                   ownerPos.y, -1, 1)));

        var instance = Instantiate(Resources.Load <GameObject> ("Prefabs/Projectile"),
                                   new Vector3((targetDir.x + ownerPos.x),
                                               (targetDir.y + ownerPos.y), -2),
                                   Quaternion.identity);

        if (Owner.dir != targetDir.ToDirection())
        {
            var toTurn = from.GetDirection(Target.tile);
            Owner.AbilityComponent.TurnUnit(toTurn);
        }

        instance.AddComponent <ProjectileComponent> ().Initialize(targetDir, OnAbilityConnected);
        instance.AddComponent <DestinationComponent> ().Initialize(Target.tile.Position, OnAbilityConnected);

        AudioComponent.PlaySound(Sounds.BOMB_LAUNCHED);

        OnFinished(EnergyCost);
    }
Example #11
0
    public void Add(ActType actType)
    {
        if (actComponet.ContainsKey(actType))
        {
            return;
        }
        ActComponent act = null;

        switch (actType)
        {
        case ActType.Null:
            break;

        case ActType.Anim:
            act = new AnimComponent(this);
            break;

        case ActType.Audio:
            act = new AudioComponent(this);
            break;

        case ActType.Effect:
            act = new EffectComponent(this);
            break;

        default:
            break;
        }

        if (act != null)
        {
            actComponet.Add(actType, act);
        }
    }
Example #12
0
 private void Update()
 {
     m_realVolume = Mathf.Clamp(m_volume * m_parentVolume * m_setVolume, 0f, 1f);
     m_realPitch  = Mathf.Clamp(m_pitch * m_parentPitch * m_setPitch, -3f, 3f);
     for (int i = 0; i < m_hashKeys.Count; i++)
     {
         object obj = m_childComponents[m_hashKeys[i]];
         if (obj is AudioComponent)
         {
             AudioComponent audioComponent = obj as AudioComponent;
             audioComponent.m_parentVolume = m_realVolume;
             audioComponent.m_parentPitch  = m_realPitch;
         }
         if (obj is AudioRandomComponent)
         {
             AudioRandomComponent audioRandomComponent = obj as AudioRandomComponent;
             audioRandomComponent.m_parentVolume = m_realVolume;
             audioRandomComponent.m_parentPitch  = m_realPitch;
         }
         if (obj is AudioRandomSimpleComponent)
         {
             AudioRandomSimpleComponent audioRandomSimpleComponent = obj as AudioRandomSimpleComponent;
             audioRandomSimpleComponent.m_parentVolume = m_realVolume;
             audioRandomSimpleComponent.m_parentPitch  = m_realPitch;
         }
         if (obj is AudioGroupComponent)
         {
             AudioGroupComponent audioGroupComponent = obj as AudioGroupComponent;
             audioGroupComponent.m_parentVolume = m_realVolume;
             audioGroupComponent.m_parentPitch  = m_realPitch;
         }
     }
 }
Example #13
0
    public override void Activate()
    {
        if (Owner == null)
        {
            return;
        }

        if (Target == null)
        {
            Debug.Log(string.Format("No Target"));
            return;
        }

        var targetUnit = Target.tile.OccupiedBy;
        var from       = Owner.Board.TileAt(Owner.Position);

        var toTurn = from.GetDirection(Target.tile);

        Owner.AbilityComponent.TurnUnit(toTurn);

        if (targetUnit != null)
        {
            OnAbilityConnected(targetUnit.gameObject);
        }

        var vfx = Instantiate(Resources.Load <GameObject> ("Prefabs/Player Impact Visual"), new Vector3(Target.tile.Position.x, Target.tile.Position.y, Layers.Foreground), Quaternion.identity);

        AudioComponent.PlaySound(Sounds.BITE);
        Destroy(vfx, 0.2f);

        OnFinished(EnergyCost);
    }
Example #14
0
    /// <summary>
    /// Init class method.
    /// </summary>
    private void Init()
    {
        _audio    = GetComponent <AudioComponent>();
        _rePlayer = ReInput.players.GetPlayer(playerID);

        GetComponent <MeshRenderer>().enabled = false;
    }
Example #15
0
		public void DisposeMethodTest ()
		{
			// Test case from bxc #5410

			// Create instance of AudioUnit object
			AudioComponentDescription cd = new AudioComponentDescription () {
				ComponentType = AudioComponentType.Output,
#if MONOMAC
#if NET
				ComponentSubType = AudioUnitSubType.VoiceProcessingIO,
#else
				ComponentSubType = (int)AudioUnitSubType.VoiceProcessingIO,
#endif
#else
#if NET
				ComponentSubType = (AudioUnitSubType) AudioTypeOutput.Remote,
#else
				ComponentSubType = 0x72696f63, // Remote_IO
#endif
#endif
				ComponentManufacturer = AudioComponentManufacturerType.Apple
			};
			AudioComponent component = AudioComponent.FindComponent (ref cd);
			var audioUnit = component.CreateAudioUnit ();

			audioUnit.Dispose ();
		}
Example #16
0
		public void CopyIconTest ()
		{ 
			TestRuntime.AssertXcodeVersion (12, TestRuntime.MinorXcode12APIMismatch);
			AudioComponentDescription cd = new AudioComponentDescription () {
				ComponentType = AudioComponentType.Output,
#if MONOMAC
#if NET
				ComponentSubType = AudioUnitSubType.VoiceProcessingIO,
#else
				ComponentSubType = (int)AudioUnitSubType.VoiceProcessingIO,
#endif
#else
#if NET
				ComponentSubType = (AudioUnitSubType) AudioTypeOutput.Remote,
#else
				ComponentSubType = 0x72696f63, // Remote_IO
#endif
#endif
				ComponentManufacturer = AudioComponentManufacturerType.Apple
			};
			AudioComponent component = AudioComponent.FindComponent (ref cd);
			Assert.DoesNotThrow ( () => {
				var icon = component.CopyIcon (); // ensuring that the manual binding does not throw, we do not care about the result
			});
		}
Example #17
0
    public void CollectAudioComponents()
    {
        AudioComponent component = base.gameObject.GetComponent <AudioComponent>();

        if (component != null)
        {
            audioComponents    = new AudioComponent[1];
            audioComponents[0] = component;
            return;
        }
        List <AudioComponent> list = new List <AudioComponent>();

        AudioComponent[] componentsInChildren = base.gameObject.GetComponentsInChildren <AudioComponent>(includeInactive: true);
        for (int i = 0; i < componentsInChildren.Length; i++)
        {
            list.Add(componentsInChildren[i]);
        }
        GroupComponentProxy[] componentsInChildren2 = base.gameObject.GetComponentsInChildren <GroupComponentProxy>(includeInactive: true);
        for (int j = 0; j < componentsInChildren2.Length; j++)
        {
            AudioComponent[] componentsInChildren3 = componentsInChildren2[j]._groupComponent.GetComponentsInChildren <AudioComponent>();
            for (int k = 0; k < componentsInChildren3.Length; k++)
            {
                list.Add(componentsInChildren3[k]);
            }
        }
        audioComponents = list.ToArray();
    }
Example #18
0
        void prepareAudioUnit()
        {
            // creating an AudioComponentDescription of the RemoteIO AudioUnit
            AudioComponentDescription cd = new AudioComponentDescription()
            {
                componentType         = AudioComponentDescription.AudioComponentType.kAudioUnitType_Output,
                componentSubType      = AudioComponentDescription.AudioComponentSubType.kAudioUnitSubType_RemoteIO,
                componentManufacturer = AudioComponentDescription.AudioComponentManufacturerType.kAudioUnitManufacturer_Apple,
                componentFlags        = 0,
                componentFlagsMask    = 0
            };

            // Getting AudioComponent using the audio component description
            _audioComponent = AudioComponent.FindComponent(cd);

            // creating an audio unit instance
            _audioUnit = AudioUnit.CreateInstance(_audioComponent);

            // setting audio format
            _audioUnit.SetAudioFormat(_dstFormat,
                                      AudioUnit.AudioUnitScopeType.kAudioUnitScope_Input,
                                      0 // Remote Output
                                      );

            // setting callback method
            _audioUnit.RenderCallback += new EventHandler <AudioUnitEventArgs>(_audioUnit_RenderCallback);

            _audioUnit.Initialize();
        }
Example #19
0
        public override void Start()
        {
            m_params = Engine.AssetManager.GetAsset <MatchParameters>("Game/Match.lua::Match");
            m_params.OnAssetChanged += new OnChange(m_params_OnAssetChanged);

            m_params_OnAssetChanged();

            m_elapsedTime     = 0;
            m_matchBeginTimer = 3000;

            m_matchStateStep  = 0;
            m_timerMS         = m_params.Content.TimeS * 1000;
            m_timerMSPrevious = m_timerMS;

            //m_tutorialSprite = new SpriteComponent(Sprite.CreateFromTexture("Graphics/TutoPassAssist.png"), "ArenaUIOverlay0");
            //m_tutorialSprite.AttachedToOwner = false;
            //m_tutorialSprite.Visible = false;
            //Owner.Attach(m_tutorialSprite);

            m_audioCmpTimerPeriodLastSeconds = new AudioComponent("Audio/Sounds.lua::TimerPeriodLastSeconds");
            Owner.Attach(m_audioCmpTimerPeriodLastSeconds);
            m_audioCmpTimerPeriodEnd = new AudioComponent("Audio/Sounds.lua::TimerPeriodEnd");
            Owner.Attach(m_audioCmpTimerPeriodEnd);

            m_goTextTimerMS = new Timer(Engine.GameTime.Source, 1000);

            ChangeState(MatchState.Init);
        }
Example #20
0
 // for the case where there is more complex logic we have a place to put it
 public override void OnDestinationReached()
 {
     if (Owner is Hero)
     {
         AudioComponent.StopSound(Sounds.RUNNING);
     }
     OnFinished(EnergyCost);
 }
Example #21
0
 public void SetAudioComponentClip(string componentName, string resourceName, GameObject parentGameObject = null)
 {
     if (_audioComponents.ContainsKey(componentName))
     {
         AudioComponent audioComponent = _audioComponents[componentName];
         audioComponent.SetAudioClip(Resources.Load(resourceName) as AudioClip, parentGameObject);
     }
 }
Example #22
0
 public void SetAudioComponentClip(string componentName, AudioClip audioClip, GameObject parentGameObject = null)
 {
     if (!(audioClip == null) && _audioComponents.ContainsKey(componentName))
     {
         AudioComponent audioComponent = _audioComponents[componentName];
         audioComponent.SetAudioClip(audioClip, parentGameObject);
     }
 }
Example #23
0
    /// <summary>
    /// Init class method.
    /// </summary>
    private void Init()
    {
        // get audio component reference.
        _audio = GetComponent <AudioComponent>();

        // get button component reference.
        _button = GetComponent <Button>();
    }
Example #24
0
 public void removeComponent(AudioComponent audioComponent)
 {
     audioComponents.Remove(audioComponent);
     if (audioComponent is Speaker)
     {
         speakers.Remove(audioComponent as Speaker);
     }
 }
Example #25
0
    /// <summary>
    /// Init class method.
    /// </summary>
    private void Init()
    {
        // get animator component reference.
        _anim = GetComponent <Animator>();

        // get audio component reference.
        _audio = GetComponent <AudioComponent>();
    }
Example #26
0
 /// <summary>
 /// Init class method.
 /// </summary>
 protected virtual void Init()
 {
     // set audio component reference.
     if (_audio == null)
     {
         _audio = GetComponent <AudioComponent>();
     }
 }
Example #27
0
 public void addComponent(AudioComponent audioComponent)
 {
     audioComponents.Add(audioComponent);
     if (audioComponent is Speaker)
     {
         speakers.Add(audioComponent as Speaker);
     }
 }
Example #28
0
 protected override void SetInitialValues()
 {
     _playerStateManager   = GameObject.FindObjectOfType <PlayerStateManager>();
     _inputManager         = GameObject.FindObjectOfType <InputManager>();
     _cameraManager        = GameObject.FindObjectOfType <CameraManager>();
     _audioComponent       = this.GetComponent <AudioComponent>();
     HasItemUnderTheCursor = false;
 }
Example #29
0
 /// <summary>
 /// Init class method.
 /// </summary>
 private new void Init()
 {
     // set audio component reference.
     if (_audio == null)
     {
         _audio = GetComponent <AudioComponent>();
     }
 }
Example #30
0
    private void ShowAudioComponent(AudioComponent audioComponent)
    {
        AudioClip gameClip = EditorGUILayout.ObjectField(audioComponent.audioClip, typeof(AudioClip), false) as AudioClip;

        if (audioComponent.audioClip != gameClip)
        {
            audioComponent.SetAudioClip(gameClip);
        }
    }
Example #31
0
    public AudioComponent(Game game, string audioFile)
        : base(game)
    {
        Debug.Assert(s_theAudio == null, "You can only construct one AudioComponent");
        s_theAudio = this;
        m_filename = audioFile;
        m_cuePool = new StaticPool<AudioCue>(MAX_AUDIO_CUE);
        m_listener = new AudioListener();
#if AUDIO_DEBUG
        m_numPlaying = 0;
        m_numFailed = 0;
        m_numPlayed = 0;
        m_numStopped = 0;
#endif
    }
		public static AudioComponent FindNextComponent (AudioComponent cmp, AudioComponentDescription cd)
		{
			// Getting component hanlder
			IntPtr handle;
			if (cmp == null)
				handle = AudioComponentFindNext(IntPtr.Zero, cd);
			else
				handle = AudioComponentFindNext(cmp.Handle, cd);
			
			// creating an instance
			if (handle != IntPtr.Zero)
				return new AudioComponent (handle);
			else
				return null;
		}
		void PrepareAudioUnit()
		{
			// All iPhones and iPads have microphones, but early iPod touches did not
			if (!AudioSession.AudioInputAvailable) {
				var noInputAlert = new UIAlertView ("No audio input", "No audio input device is currently attached", null, "Ok");
				noInputAlert.Show ();
				return;
			}

			// Getting AudioComponent Remote output
			audioComponent = AudioComponent.FindComponent(AudioTypeOutput.Remote);
			CheckValue (audioComponent);

			// creating an audio unit instance
			audioUnit = new AudioUnit.AudioUnit(audioComponent);

			AudioUnitStatus status;
			status = audioUnit.SetEnableIO(true, AudioUnitScopeType.Input, 1);
			CheckStatus (status);
			status = audioUnit.SetEnableIO(true, AudioUnitScopeType.Output, 0);
			CheckStatus (status);

			dstFormat = new AudioStreamBasicDescription {
				SampleRate = AudioSession.CurrentHardwareSampleRate,
				Format = AudioFormatType.LinearPCM,
				FormatFlags = AudioFormatFlags.IsSignedInteger | AudioFormatFlags.IsNonInterleaved,
				BytesPerPacket = 4,
				FramesPerPacket = 1,
				BytesPerFrame = 4,
				ChannelsPerFrame = 2,
				BitsPerChannel = 16
			};

			audioUnit.SetAudioFormat(dstFormat, AudioUnitScopeType.Input, 0);
			audioUnit.SetAudioFormat(dstFormat, AudioUnitScopeType.Output, 1);

			status = audioUnit.SetRenderCallback(RenderCallback, AudioUnitScopeType.Input, 0);
			CheckStatus (status);
		}
Example #34
0
		public AudioUnit (AudioComponent component)
		{
			if (component == null)
				throw new ArgumentNullException ("component");
			if (component.Handle == IntPtr.Zero)
				throw new ObjectDisposedException ("component");
			
			int err = AudioComponentInstanceNew (component.handle, out handle);
			if (err != 0)
				throw new AudioUnitException (err);
			
			_isPlaying = false;
			
			gcHandle = GCHandle.Alloc(this);
			var callbackStruct = new AURenderCallbackStrct();
			callbackStruct.inputProc = renderCallback; // setting callback function            
			callbackStruct.inputProcRefCon = GCHandle.ToIntPtr(gcHandle); // a pointer that passed to the renderCallback (IntPtr inRefCon) 
			err = AudioUnitSetProperty(handle,
						   AudioUnitPropertyIDType.SetRenderCallback,
						   AudioUnitScopeType.Input,
						   0, // 0 == speaker                
						   callbackStruct,
						   (uint)Marshal.SizeOf(callbackStruct));
			if (err != 0)
				throw new AudioUnitException (err);
		}
 public static Entity PlayAudio(this Pool pool, AudioComponent source)
 {
     return pool.CreateEntity().AddAudio(source.clips, source.randomizePitch);
 }
Example #36
0
		public AudioUnit (AudioComponent component)
		{
			if (component == null)
				throw new ArgumentNullException ("component");
			if (component.Handle == IntPtr.Zero)
				throw new ObjectDisposedException ("component");
			
			int err = AudioComponentInstanceNew (component.handle, out handle);
			if (err != 0)
				throw new AudioUnitException (err);
			
			gcHandle = GCHandle.Alloc(this);

#pragma warning disable 612
			BrokenSetRender ();
#pragma warning restore 612
		}