/// <summary> /// The splitter will begin broadcasting it's /// sub streams immediately. /// </summary> public GATAudioThreadStreamSplitter(IGATAudioThreadStream stream, GATDataAllocationMode bufferAllocationMode) { int i; _sourceStreamChannels = stream.NbOfChannels; if (_sourceStreamChannels < 2) { Debug.LogWarning("source stream is mono: " + stream.StreamName); } IntPtr outputBufferPointer = IntPtr.Zero; _sharedBufferSize = stream.BufferSizePerChannel; if (bufferAllocationMode == GATDataAllocationMode.Unmanaged) { _sharedBufferArray = new float[_sharedBufferSize]; _sharedBuffer = new GATData(_sharedBufferArray); } else { if (bufferAllocationMode == GATDataAllocationMode.Fixed) { _sharedBuffer = GATManager.GetFixedDataContainer(_sharedBufferSize, "StreamSplitter buffer"); } else { _sharedBuffer = GATManager.GetDataContainer(_sharedBufferSize); } _sharedBufferArray = _sharedBuffer.ParentArray; outputBufferPointer = _sharedBuffer.GetPointer(); } _memOffset = _sharedBuffer.MemOffset; _streamProxies = new GATAudioThreadStreamProxy[_sourceStreamChannels]; for (i = 0; i < _sourceStreamChannels; i++) { _streamProxies[i] = new GATAudioThreadStreamProxy(_sharedBufferSize, 1, outputBufferPointer, _sharedBuffer.MemOffset, (stream.StreamName + " split " + i)); } stream.AddAudioThreadStreamClient(this); _sourceStream = stream; }
protected virtual void OnEnable() { if( GATInfo.NbOfChannels == 0 ) return; if( _player != null ) //Object has just been deserialized, only setup transient objects { _panInfo = new GATDynamicPanInfo( _player, true ); _panInfo.SetGains( _gains ); _trackBuffer = GATManager.GetFixedDataContainer( GATInfo.AudioBufferSizePerChannel, "track"+TrackNb+" buffer" ); _audioThreadStreamProxy = new GATAudioThreadStreamProxy( GATInfo.AudioBufferSizePerChannel, 1, _trackBuffer.GetPointer(), _trackBuffer.MemOffset, ( "Track " + _trackNb + " stream" ) ); _player.onPlayerWillMix += PlayerWillBeginMixing; _mute = _nextMute; //only _nextMute is serialized _active = true; } }
protected virtual void OnEnable() { if (GATInfo.NbOfChannels == 0) { return; } if (_player != null) //Object has just been deserialized, only setup transient objects { _panInfo = new GATDynamicPanInfo(_player, true); _panInfo.SetGains(_gains); _trackBuffer = GATManager.GetFixedDataContainer(GATInfo.AudioBufferSizePerChannel, "track" + TrackNb + " buffer"); _audioThreadStreamProxy = new GATAudioThreadStreamProxy(GATInfo.AudioBufferSizePerChannel, 1, _trackBuffer.GetPointer(), _trackBuffer.MemOffset, ("Track " + _trackNb + " stream")); _player.onPlayerWillMix += PlayerWillBeginMixing; _mute = _nextMute; //only _nextMute is serialized _active = true; } }