GAudio.AGATAudioFile.ReadNextChunk C# (CSharp) Méthode

ReadNextChunk() public abstract méthode

Reads the next chunk into the target array at offset. Multichannel data is always interleaved.
public abstract ReadNextChunk ( float target, int offset, int numFrames ) : int
target float
offset int
numFrames int
Résultat int
        public abstract int ReadNextChunk( float[] target, int offset, int numFrames );

Usage Example

Exemple #1
0
        /// <summary>
        /// Blocking load of wav and ogg files.
        /// </summary>
        public GATData[] LoadSync(AGATAudioFile file, GATDataAllocationMode allocationMode)
        {
            GATData[] loadedChannels;
            int       i;
            bool      didFail = false;

            loadedChannels = new GATData[file.Channels];

            for (i = 0; i < file.Channels; i++)
            {
                if (allocationMode == GATDataAllocationMode.Fixed)                  //GZComment: allocation fail leaks
                {
                    try{ loadedChannels[i] = GATManager.GetFixedDataContainer(file.NumFrames, file.FileName); }
                    catch (System.Exception ex)
                    {
                        didFail = true;
                                                #if UNITY_EDITOR
                        Debug.LogException(ex);
                                                #endif
                    }
                }
                else if (allocationMode == GATDataAllocationMode.Managed)                  //GZComment: allocation fail leaks
                {
                    try
                    {
                        loadedChannels[i] = GATManager.GetDataContainer(file.NumFrames);
                    }
                    catch (System.Exception ex)
                    {
                        didFail = true;
                                                #if UNITY_EDITOR
                        Debug.LogException(ex);
                                                #endif
                    }
                }
                else
                {
                    loadedChannels[i] = new GATData(new float[file.NumFrames]);
                }
            }

            if (didFail)
            {
                for (i = 0; i < loadedChannels.Length; i++)
                {
                    if (loadedChannels[i] != null)
                    {
                        loadedChannels[i].Release();
                    }
                }

                return(null);
            }

            if (file.Channels == 1)
            {
                file.ReadNextChunk(loadedChannels[0].ParentArray, loadedChannels[0].MemOffset, file.NumFrames);
                return(loadedChannels);
            }

            int framesPerRead;
            int framesRead;
            int totalFramesRead = 0;

            framesPerRead = _buffer.Length / file.Channels;

            while (true)
            {
                framesRead = file.ReadNextChunk(_buffer, 0, framesPerRead);

                for (i = 0; i < file.Channels; i++)
                {
                    loadedChannels[i].CopyFromInterlaced(_buffer, framesRead, totalFramesRead, i, file.Channels);
                }

                totalFramesRead += framesRead;

                if (framesRead < framesPerRead)
                {
                    break;
                }
            }

            return(loadedChannels);
        }
All Usage Examples Of GAudio.AGATAudioFile::ReadNextChunk