コード例 #1
0
        public static AudioClip DncodeAdpcmData(byte[] adpcmData)
        {
            if (adpcmData == null || adpcmData.Length < 8)
            {
                return(null);
            }

            try {
                //channels
                byte[] bytes = new byte[4];
                Buffer.BlockCopy(adpcmData, 0, bytes, 0, bytes.Length);
                int channels = (int)BitConverter.ToUInt32(bytes, 0);
                //frequency
                bytes = new byte[4];
                Buffer.BlockCopy(adpcmData, 4, bytes, 0, bytes.Length);
                int frequency = (int)BitConverter.ToUInt32(bytes, 0);
                //adpcmData
                bytes = new byte[adpcmData.Length - 8];
                Buffer.BlockCopy(adpcmData, 8, bytes, 0, bytes.Length);
                short[] data = adpcm.Decode(bytes);
                return(RTMAudioManager.ShortsToAudioClip(data, channels, frequency, false, 1.0f));
            } catch (Exception ex) {
                Debug.LogWarning(ex);
            }
            return(null);
        }
コード例 #2
0
        private AudioClip GetAudioClip()
        {
            lock (self_locker) {
                if (this._clipRecord == null)
                {
                    return(null);
                }

                short[] data = RTMAudioManager.AudioClipToShorts(this._clipRecord, 1.0f);
                return(RTMAudioManager.ShortsToAudioClip(data, this._clipRecord.channels, this._clipRecord.frequency, false, 1.0f));
            }
        }