Pre-allocates a large float[] to use as virtual memory and avoid any garbage collection. All calls to GATActiveSampleBank and GATReamplingSampleBank GetProcessedSample methods result in a virtual allocation from GATManager's default GATDataAllocator instance.
Inheritance: IDisposable
コード例 #1
0
    /*public void SetAllocator( GATDataAllocator allocator )
    {
        _allocator 				 = allocator;

        _largestAllocatableChunk = allocator.BinWidth * _allocator.NbOfBins;
        _binWidth 				 = allocator.BinWidth;
        _nbOfBins 			     = allocator.NbOfBins;
        _totalSize 				 = allocator.TotalSize;
        _totalDuration 			 = ( float )_totalSize / GATInfo.OutputSampleRate;
        _humanReadableTotalSize  = ( _totalSize * 4 ).HumanReadableBytes();
        _largestRequestedChunk   = ( float )_largestAllocatableChunk / GATInfo.OutputSampleRate;
    }*/
    public void SetAllocatorInfo( GATDataAllocator.InitializationSettings settings )
    {
        _largestAllocatableChunk = settings.binWidth * settings.nbOfBins;
        _binWidth 				 = settings.binWidth;
        _nbOfBins 			     = settings.nbOfBins;
        _totalSize 				 = ( int )( settings.preAllocatedAudioDuration * GATInfo.OutputSampleRate );
        _totalDuration 			 = settings.preAllocatedAudioDuration;
        _humanReadableTotalSize  = ( _totalSize * 4 ).HumanReadableBytes();
        _largestRequestedChunk   = ( float )_largestAllocatableChunk / GATInfo.OutputSampleRate;
    }
コード例 #2
0
        void OnDestroy()
        {
            if (__uniqueInstance != this)              //Destroying an illegal duplicate
            {
                return;
            }
            //Call static cleaners first
            GATPlayer.CleanUpStatics();

            if (__allocator != null)
            {
                __allocator.Dispose();
                __allocator = null;
            }

            DefaultPlayer = null;

            __uniqueInstance = null;

            onMainThreadResumed = null;

            //System.GC.Collect();
        }
コード例 #3
0
ファイル: GATDataAllocator.cs プロジェクト: gregzo/G-Audio
 public GATManagedData( GATDataAllocator manager )
     : base(manager._mainBuffer)
 {
     _manager = manager;
 }
コード例 #4
0
ファイル: GATDataAllocator.cs プロジェクト: gregzo/G-Audio
 public GATFixedData( GATDataAllocator manager, string description )
     : base(manager)
 {
     Description = description;
 }
コード例 #5
0
ファイル: GATDataAllocator.cs プロジェクト: uniphonic/G-Audio
 public GATFixedData(GATDataAllocator manager, string description) : base(manager)
 {
     Description = description;
 }
コード例 #6
0
ファイル: GATDataAllocator.cs プロジェクト: uniphonic/G-Audio
 public GATManagedData(GATDataAllocator manager) : base(manager._mainBuffer)
 {
     _manager = manager;
 }
コード例 #7
0
ファイル: GATMemoryWindow.cs プロジェクト: gregzo/G-Audio
    void RefreshMemInfo()
    {
        int			binWidth;
        List<Color> colors;
        int			i;
        int 		segments;
        Color 		color;
        bool 		free;

        GATMemDebugInfo info;

        _allocator = GATManager.DefaultDataAllocator;

        if( _allocator == null )
            return;

        binWidth 		= _allocator.BinWidth;
        _memInfo 		= _allocator.GetDebugInfo();
        _fixedMemInfo 	= _allocator.GetFixedDebugInfo();
        colors 			= new List< Color >( 1000 );

        _nbOfFragmentedChunks = 0;
        _totalFragmentedSize  = 0;
        _nbOfAllocatedChunks  = 0;
        _totalAllocatedSize   = 0;
        _totalUnusedAllocated = 0;

        for( i = 0; i < _memInfo.Count; i++ )
        {
            info 	 = _memInfo[ i ];

            segments = info.MaxSize / binWidth;
            free  	 = info.AllocatedSize == 0;
            color 	 = free ? FREE_COLOR : USED_COLOR;

            if( free )
            {
                _nbOfFragmentedChunks++;
                _totalFragmentedSize += info.MaxSize;
            }
            else
            {
                _nbOfAllocatedChunks++;
                _totalAllocatedSize 	+= info.MaxSize;
                _totalUnusedAllocated 	+= info.MaxSize - info.AllocatedSize;
            }

            for( int j = 0; j < segments; j++ )
            {
                colors.Add ( color );
            }

            colors.Add ( SEPERATOR_COLOR );
        }

        segments = _allocator.UnfragmentedSize / binWidth;

        for( i = 0; i < segments; i++ )
        {
            colors.Add ( FREE_COLOR );
        }

        int totalFixed = 0;
        foreach( GATFixedMemDebugInfo fInfo in _fixedMemInfo )
        {
            totalFixed += fInfo.AllocatedSize;
        }

        segments = totalFixed / binWidth;

        if( segments == 0 && totalFixed > 0 )
        {
            segments = 2;
        }

        for( i = 0; i < segments; i++ )
        {
            colors.Add ( FIXED_COLOR );
        }

        if( _memTexture != null )
        {
            DestroyImmediate( _memTexture );
        }

        _memTexture = new Texture2D( colors.Count, TEXTURE_HEIGHT, TextureFormat.RGB24, false );

        Color[] colorArray = colors.ToArray();

        for( i = 0; i < TEXTURE_HEIGHT; i++ )
        {
            _memTexture.SetPixels( 0, i, colorArray.Length, 1, colorArray );
        }

        _memTexture.Apply( false, false );

        _maxAllocStop   = new Vector3( _maxAllocStart.x + _allocator.NbOfBins, _maxAllocStart.y );
        _maxAllocString = string.Format( "Largest Allocatable Chunk( {0} samples )", ( _allocator.BinWidth * _allocator.NbOfBins ).ToString( "N0")  );
        _maxAllocRect   = new Rect( _maxAllocStop.x + 5f, _maxAllocStop.y - 8f, 300f, 20f );
    }
コード例 #8
0
ファイル: GATManager.cs プロジェクト: gregzo/G-Audio
        void OnDestroy()
        {
            if( __uniqueInstance != this ) //Destroying an illegal duplicate
            {
                return;
            }
            //Call static cleaners first
            GATPlayer.CleanUpStatics();

            if( __allocator != null )
            {
                __allocator.Dispose();
                __allocator = null;
            }

            DefaultPlayer = null;

            __uniqueInstance = null;

            onMainThreadResumed = null;

            //System.GC.Collect();
        }
コード例 #9
0
ファイル: GATManager.cs プロジェクト: gregzo/G-Audio
        void InitManager()
        {
            __uniqueInstance = this;

            #if !UNITY_5
            if( _speakerModeInit == SpeakerModeBehaviour.Stereo )
            {
                AudioSettings.speakerMode = AudioSpeakerMode.Stereo;
            }
            else
            {
                AudioSettings.speakerMode = AudioSettings.driverCaps;
            }
            #endif

            if( GATInfo.UniqueInstance == null )
            {
                GATInfo.Init();
            }

            GATInfo.UniqueInstance.SetSyncDspTime( AudioSettings.dspTime );
            GATInfo.UniqueInstance.SetPulseLatency( _PulseLatency );
            GATInfo.UniqueInstance.SetMaxIOChannels( _MaxIOChannels );

            if( __allocator == null )
            {
            #if UNITY_EDITOR
                if( Application.isPlaying )
            #endif
                {
                    __allocator = new GATDataAllocator( _AllocatorInitSettings );
                }
            }

            //Static initializers
            GATPlayer.InitStatics();

            if( _defaultPlayer == null )
            {
                GameObject go = new GameObject( "DefaultPlayer" );
                go.transform.parent = transform;
                go.AddComponent< AudioSource >();
                _defaultPlayer = go.AddComponent< GATPlayer >();
                _defaultPlayer.AddTrack< GATTrack >();
            }

            DefaultPlayer = _defaultPlayer;

            #if GAT_IOS && !UNITY_EDITOR
            GATiOS.InitializeNativeGAudio( GATInfo.OutputSampleRate, GATInfo.AudioBufferSizePerChannel, ( byte )GATInfo.NbOfChannels );
            #endif
        }