Example #1
0
        private int generateBuffer()
        {
            _errors.HasErrors();

            int  buffer   = _backend.GenBuffer();
            Type dataType = _soundData.Data.GetType();

            if (dataType == typeof(byte[]))
            {
                byte[] bytes = (byte[])_soundData.Data;
                _backend.BufferData(buffer, getSoundFormat(_soundData.Channels, _soundData.BitsPerSample),
                                    bytes, _soundData.DataLength, _soundData.SampleRate);
            }
            else if (dataType == typeof(short[]))
            {
                short[] shorts = (short[])_soundData.Data;
                _backend.BufferData(buffer, getSoundFormat(_soundData.Channels, _soundData.BitsPerSample),
                                    shorts, _soundData.DataLength, _soundData.SampleRate);
            }
            else
            {
                throw new NotSupportedException("ALSound: Data type not supported: " + dataType.Name);
            }

            _errors.HasErrors();
            return(buffer);
        }