예제 #1
0
        /// <summary>
        /// </summary>
        /// <remarks>
        /// If argument is matrix, each element i#r of the result is evaluation
        /// of the column x[;i]. If (rho rho x) > 2, each element of the result is the
        /// evalution corresponding vector along the first axis of x.
        /// </remarks>
        /// <param name="argument"></param>
        /// <param name="decodeInfo"></param>
        /// <returns></returns>
        private static AType DecodeArray(AType argument, DecodeInformation decodeInfo)
        {
            List <AType> indexes = new List <AType>()
            {
                Utils.ANull()
            };
            AType index;

            if (argument.Rank > 1)
            {
                AType result = AArray.Create(ATypes.AFloat);

                for (int i = 0; i < argument.Shape[1]; i++)
                {
                    index = AInteger.Create(i);
                    indexes.Add(index);

                    result.AddWithNoUpdate(DecodeArray(argument[indexes], decodeInfo));

                    indexes.Remove(index);
                }

                result.Length = argument.Shape[1];
                result.Shape  = new List <int>();
                result.Shape.AddRange(argument.Shape.GetRange(1, argument.Rank - 1));
                result.Rank = argument.Rank - 1;

                return(result);
            }
            else
            {
                return(DecodeVector(argument, decodeInfo));
            }
        }
예제 #2
0
        public override AType Execute(AType right, AType left, Aplus environment = null)
        {
            DecodeInformation info   = ExtractDecodeInformation(left, right);
            AType             result = DecodeArray(right, info);

            if (info.RequiresConvert)
            {
                result = ConvertToInteger(result);
            }

            return(result);
        }
예제 #3
0
        /// <summary>
        /// Decode argument vector.
        /// </summary>
        /// <returns></returns>
        private static AType DecodeVector(AType argument, DecodeInformation decodeInfo)
        {
            double result = argument.Length > 0 ? argument[0].asFloat : 0;

            for (int i = 1; i < decodeInfo.DecodeValues.Length; i++)
            {
                result = result * decodeInfo.DecodeValues[i] + argument[i].asFloat;
            }

            if (decodeInfo.Type == ATypes.AInteger && !IsInteger(result))
            {
                decodeInfo.RequiresConvert = false;
            }

            return(AFloat.Create(result));
        }
예제 #4
0
    void DecodingUpdate()
    {
        if (s_decodedFrames.Count > 0)
        {
            //Take data from the queue to add to the audioclip.
            DecodeInformation decodedFrame    = s_decodedFrames.Dequeue();
            short[]           saDecodedFrames = decodedFrame.saDecodedData;
            int            numSamples         = decodedFrame.iNumSamples;
            int            frequency          = decodedFrame.iFrequency;
            CNetworkViewId senderViewID       = decodedFrame.cSenderViewID;

            float[] faDecodedAudioData = new float[numSamples];

            for (int i = 0; i < faDecodedAudioData.Length; ++i)
            {
                faDecodedAudioData[i] = (float)((float)saDecodedFrames[i] / 32767.0f);
            }

            // Play audio at location of sender
            GameObject  senderNetworkView = CNetworkView.FindUsingViewId(senderViewID).gameObject;
            AudioSource senderAudioSource = senderNetworkView.gameObject.GetComponent <AudioSource>();

            AudioClip newClip = AudioClip.Create("Test", faDecodedAudioData.Length, 1, frequency, true, false);
            newClip.SetData(faDecodedAudioData, 0);

            senderAudioSource.clip   = newClip;
            senderAudioSource.volume = 1.0f;

            //AudioSystem.GetInstance.Play(newClip, senderNetworkView.gameObject.transform.position, 1.0f, 1.0f, false, 0.0f, AudioSystem.SoundType.SOUND_EFFECTS, true);
            CAudioSystem.Play(senderAudioSource, 1.0f, 1.0f, false, 0.0f, CAudioSystem.SoundType.SOUND_EFFECTS, true);
        }

        if (s_framesToDecode.Count > 0)
        {
            for (int i = 0; i < m_kiNumDecodeThreads; i++)
            {
                if (m_DecodeThreads[i].IsAlive == false)
                {
                    m_DecodeThreads[i] = new Thread(new ParameterizedThreadStart(DecodeAudio));
                    m_DecodeThreads[i].Start((object)s_framesToDecode.Dequeue());
                    break;
                }
            }
        }
    }
예제 #5
0
        /// <summary>
        /// </summary>
        /// <remarks>
        /// If argument is matrix, each element i#r of the result is evaluation
        /// of the column x[;i]. If (rho rho x) > 2, each element of the result is the
        /// evalution corresponding vector along the first axis of x.
        /// </remarks>
        /// <param name="argument"></param>
        /// <param name="decodeInfo"></param>
        /// <returns></returns>
        private static AType DecodeArray(AType argument, DecodeInformation decodeInfo)
        {
            List<AType> indexes = new List<AType>() { Utils.ANull() };
            AType index;

            if (argument.Rank > 1)
            {
                AType result = AArray.Create(ATypes.AFloat);

                for (int i = 0; i < argument.Shape[1]; i++)
                {
                    index = AInteger.Create(i);
                    indexes.Add(index);

                    result.AddWithNoUpdate(DecodeArray(argument[indexes], decodeInfo));

                    indexes.Remove(index);
                }

                result.Length = argument.Shape[1];
                result.Shape = new List<int>();
                result.Shape.AddRange(argument.Shape.GetRange(1, argument.Rank - 1));
                result.Rank = argument.Rank - 1;

                return result;
            }
            else
            {
                return DecodeVector(argument, decodeInfo);
            }
        }
예제 #6
0
        /// <summary>
        /// Decode argument vector.
        /// </summary>
        /// <returns></returns>
        private static AType DecodeVector(AType argument, DecodeInformation decodeInfo)
        {
            double result = argument.Length > 0 ? argument[0].asFloat : 0;

            for (int i = 1; i < decodeInfo.DecodeValues.Length; i++)
            {
                result = result * decodeInfo.DecodeValues[i] + argument[i].asFloat;
            }

            if (decodeInfo.Type == ATypes.AInteger && !IsInteger(result))
            {
                decodeInfo.RequiresConvert = false;
            }

            return AFloat.Create(result);
        }