Exemplo n.º 1
0
//		public static AudioClip DecompressAudioClip( byte[] data, int samples, int channels, bool threeD, BandMode mode, float gain )
        public static AudioClip DecompressAudioClip(byte[] data, int samples, int channels, bool threeD, float gain)
        {
            int frequency = 4000;

//			if( mode == BandMode.Narrow )
//			{
//				frequency = 8000;
//			}
//			else if( mode == BandMode.Wide )
//			{
//				frequency = 16000;
//			}

            byte[] d;
            d = unzip(data);

            short[] pcm = Codec.Decode(d);

            tmp.Clear();
            tmp.AddRange(pcm);

            //while( tmp.Count > 1 && Mathf.Abs( tmp[ tmp.Count - 1 ] ) <= 10 )
            //{
            //    tmp.RemoveAt( tmp.Count - 1 );
            //}

            //while( tmp.Count > 1 && Mathf.Abs( tmp[ 0 ] ) <= 10 )
            //{
            //    tmp.RemoveAt( 0 );
            //}

            return(USpeakAudioClipConverter.ShortsToAudioClip(tmp.ToArray(), channels, frequency, threeD, gain));
        }
Exemplo n.º 2
0
//      public static byte[] CompressAudioClip( AudioClip clip, out int samples, BandMode mode, float gain = 1.0f )
//      {
//          data.Clear();
//          samples = 0;
//          short[] b = USpeakAudioClipConverter.AudioClipToShorts( clip, gain );
//          byte[] mlaw = Codec.Encode( b, mode );
//          data.AddRange( mlaw );
//          return zip( data.ToArray() );
//      }

        public static AudioClip DecompressAudioClip(byte[] data, int samples, int channels, bool threeD, BandMode mode, float gain)
        {
//          byte[] d;
//          d = unzip( data );
            short[] pcm = Codec.Decode(data, mode);
            tmp.Clear();
            tmp.AddRange(pcm);
            return(USpeakAudioClipConverter.ShortsToAudioClip(tmp.ToArray(), channels, WSpeak.getFrequency(mode), threeD, gain));
        }