Ejemplo n.º 1
0
        // Creates a user AudioClip with a name and with the given length in samples, channels and frequency.
        public static AudioClip Create(string name, int lengthSamples, int channels, int frequency, bool stream, PCMReaderCallback pcmreadercallback, PCMSetPositionCallback pcmsetpositioncallback)
        {
            if (name == null)
            {
                throw new NullReferenceException();
            }
            if (lengthSamples <= 0)
            {
                throw new ArgumentException("Length of created clip must be larger than 0");
            }
            if (channels <= 0)
            {
                throw new ArgumentException("Number of channels in created clip must be greater than 0");
            }
            if (frequency <= 0)
            {
                throw new ArgumentException("Frequency in created clip must be greater than 0");
            }

            AudioClip clip = Construct_Internal();

            if (pcmreadercallback != null)
            {
                clip.m_PCMReaderCallback += pcmreadercallback;
            }
            if (pcmsetpositioncallback != null)
            {
                clip.m_PCMSetPositionCallback += pcmsetpositioncallback;
            }

            clip.CreateUserSound(name, lengthSamples, channels, frequency, stream);

            return(clip);
        }
Ejemplo n.º 2
0
        public static AudioClip Create(string name, int lengthSamples, int channels, int frequency, bool stream, AudioClip.PCMReaderCallback pcmreadercallback, AudioClip.PCMSetPositionCallback pcmsetpositioncallback)
        {
            bool flag = name == null;

            if (flag)
            {
                throw new NullReferenceException();
            }
            bool flag2 = lengthSamples <= 0;

            if (flag2)
            {
                throw new ArgumentException("Length of created clip must be larger than 0");
            }
            bool flag3 = channels <= 0;

            if (flag3)
            {
                throw new ArgumentException("Number of channels in created clip must be greater than 0");
            }
            bool flag4 = frequency <= 0;

            if (flag4)
            {
                throw new ArgumentException("Frequency in created clip must be greater than 0");
            }
            AudioClip audioClip = AudioClip.Construct_Internal();
            bool      flag5     = pcmreadercallback != null;

            if (flag5)
            {
                audioClip.m_PCMReaderCallback += pcmreadercallback;
            }
            bool flag6 = pcmsetpositioncallback != null;

            if (flag6)
            {
                audioClip.m_PCMSetPositionCallback += pcmsetpositioncallback;
            }
            audioClip.CreateUserSound(name, lengthSamples, channels, frequency, stream);
            return(audioClip);
        }