コード例 #1
0
        public void SaveLastRecordedAudioClip(string path)
        {
            if (LastRecordedClip != null)
            {
                try
                {
#if UNITY_EDITOR || UNITY_STANDALONE || UNITY_ANDROID || UNITY_IPHONE
                    File.WriteAllBytes(path, AudioClip2PCMConverter.AudioClip2PCM(LastRecordedClip));
#endif
                }
                catch (Exception e)
                {
                    Debug.LogException(e);
                }
            }
        }
        public static string Convert(AudioClip clip, Enumerators.AudioEncoding encoding, bool increaseVolume = false, float volume = 1f)
        {
            byte[] audioArray;

            switch (encoding)
            {
            case Enumerators.AudioEncoding.LINEAR16:
            {
                if (increaseVolume)
                {
                    clip.SetData(AudioClip2ByteConverter.ByteToFloat(
                                     AudioClip2ByteConverter.AudioClipToByte(clip, increaseVolume, volume)), 0);
                }

                audioArray = AudioClip2PCMConverter.AudioClip2PCM(clip);
            }
            break;

            default:
                throw new System.NotSupportedException(encoding + " doesn't supported for converting!");
            }

            return(System.Convert.ToBase64String(audioArray));
        }