コード例 #1
0
    void CheckAndStopEmitterFromTimelinePosition()
    {
        bool shouldStop = false;
        int  position   = 0;

        emitter.GetTimelinePosition(out position);
        if (position >= (4 * 60000) + (21 * 1000) + 500)
        {
            shouldStop = true;
        }

        if (shouldStop)
        {
            StopMusicEmitter();
        }
    }
コード例 #2
0
    void UpdateMusicEmitter()
    {
        // Calculate overall valence (scaled 0-1)
        float currentValenceScaled = (currentValence + 100f) / 200f;

        overallValence = (overallValence * 0.7f) + (currentValenceScaled * 0.3f);

        // Initial valence, if necessary
        if (numImageResults <= numDataPointsForInitialValence)
        {
            initialValence = overallValence;
        }

        // Difference between overall and initial valence
        float overallInitialValenceDiff = overallValence - initialValence;

        // Kenny Loggins
        //Debug.Log ("overall valence: " + overallValence);
        //Debug.Log ("difference between overall and initial: " + overallInitialValenceDiff);

        // Set section
        //bool shouldGoToNextSection = false;
        int position = 0;

        emitter.GetTimelinePosition(out position);
        //Debug.Log ("position: " + position);

        if (!(shouldGoToNextSection || isSectionTransitionForced))
        {
            Debug.Log("a");

            if (position < (0 * 60000) + (3 * 1000) + 333)
            {
                //Debug.Log ("invok");
                //Invoke ("ForceSectionTransition", forceSectionTransitionTime);
                ForceSectionTransition();                 // immediately
            }

            shouldGoToNextSection = overallValence > 0.5f || overallInitialValenceDiff > 0.1f;             // Actually, this *is* basically looking for peaks
            if (shouldGoToNextSection)
            {
                Debug.Log("Peak detected! overall=" + overallValence + ", diff=" + overallInitialValenceDiff);
                WriteRowToCSV(true);

                CancelInvoke("ForceSectionTransition");
                SetNextSection();
            }

            // Set based on group
            int group = amaiManager.GetGroup();
            if (group == 2 && (sectionNum == 1 || sectionNum == 2))
            {
                sectionNum = 5;
            }


            if (shouldGoToNextSection || isSectionTransitionForced)
            {
                CancelInvoke("ForceSectionTransition");
                Invoke("ForceSectionTransition", forceSectionTransitionTime);

                //SetNextSection();
            }

            // REset
            //shouldGoToNextSection = false;
            //isSectionTransitionForced = false;
        }
        else
        {
            Debug.Log("b");

            int trueSectionNum = 0;
            if (position >= (4 * 60000) + (12 * 1000) + 982)
            {
                trueSectionNum = 7;
            }
            else if (position >= (3 * 60000) + (44 * 1000) + 561)
            {
                trueSectionNum = 6;
            }
            else if (position >= (3 * 60000) + (6 * 1000) + 667)
            {
                trueSectionNum = 5;
            }
            else if (position >= (2 * 60000) + (0 * 1000) + 0)
            {
                trueSectionNum = 4;
            }
            else if (position >= (0 * 60000) + (30 * 1000) + 0)
            {
                trueSectionNum = 2;
            }
            else if (position >= (0 * 60000) + (3 * 1000) + 333)
            {
                trueSectionNum = 1;
            }

            Debug.Log("pos=" + position + ", n=" + sectionNum + ", true=" + trueSectionNum);

            if (sectionNum == trueSectionNum)
            {
                // Clear/reset
                shouldGoToNextSection     = false;
                isSectionTransitionForced = false;
            }
        }

        // Update music emitter
        emitter.SetParameter("valence_overall", overallValence);
        emitter.SetParameter("arousal_overall", overallValence * 0.4f);          // just testing
        emitter.SetParameter("section_num", (float)sectionNum);
    }