Inheritance: MonoBehaviour
示例#1
0
    // Use this for initialization
    void Start()
    {
        ServicePointManager.ServerCertificateValidationCallback = MyRemoteCertificateValidationCallback;

        ImplicitGrantAuth();

        context = _spotify.GetPlayback();

        Debug.Log("Device Id: " + context.Device.Id);

        shuffleState = context.ShuffleState;

        repeatState = context.RepeatState;

        privateProfile = _spotify.GetPrivateProfile();

        Debug.Log(privateProfile.Country);

        audioVisualizer = GameObject.Find("AudioVisualizer");

        audioVisualizerScript = audioVisualizer.GetComponent <AudioVisualizer>();

        featuredPlaylistTabScript = FeaturedPlaylistTab.GetComponent <FeaturedPlaylistTabScript>();

        searchResultsScript = searchResultsTab.GetComponent <SearchResultsScript>();

        currentSongScript = CurrentSongGameObject.GetComponent <CurrentSong>();

        recordPlayerScript = recordPlayer.GetComponent <RecordPlayer>();

        //Ignore collisions between character controller and vinyls
        Physics.IgnoreLayerCollision(8, 9);

        OnClicked += SendAudioAnaylisToParticleVisualizer;
    }
示例#2
0
 public RecorderBase(CaptureSource captureSource, AudioSinkAdapter audioSinkAdapter, AudioVisualizer audioVisualizer)
 {
     mCaptureSource    = captureSource;
     mAudioSinkAdapter = audioSinkAdapter;
     mAudioVisualizer  = audioVisualizer;
     VisualizationRate = 1;
 }
示例#3
0
 // Update is called once per frame
 protected override void FixedUpdate()
 {
     base.FixedUpdate();
     if (AudioVisualizer.audioIsPlaying())
     {
         UpdateColor();
     }
 }
示例#4
0
        public void AudioVisualizerConstructorGoodRefs()
        {
            ProgressBar progBar = new ProgressBar();
            PictureBox  picBox  = new PictureBox();
            Timer       timer   = new Timer();

            AudioVisualizer audioVisualizer = new AudioVisualizer(progBar, picBox, timer);
        }
示例#5
0
 public TestRunnerLive(EchoCancellerType echoCancellerType,
                       AudioVisualizer sourceAudioVisualizer,
                       AudioVisualizer speakersAudioVisualizer,
                       AudioVisualizer cancelledAudioVisualizer)
     : base(echoCancellerType, sourceAudioVisualizer, speakersAudioVisualizer, cancelledAudioVisualizer)
 {
     SpeakerFrames = new List <byte[]>();
 }
示例#6
0
 public PlayerBase(MediaElement mediaElement, AudioMediaStreamSource audioStreamSource, AudioVisualizer audioVisualizer)
 {
     mMediaElement      = mediaElement;
     mAudioStreamSource = audioStreamSource;
     Frames             = new List <byte[]>();
     mAudioVisualizer   = audioVisualizer;
     VisualizationRate  = 1;
 }
示例#7
0
    // Update is called once per frame
    void Update()
    {
        if (!audioVisualizer)
        {
            audioVisualizer = AudioVisualizer.instance;
        }

        if (useBuffer)
        {
            if (materialInstance != null)
            {
                materialInstance.SetColor("_EmissionColor", color * audioVisualizer.audioBandBuffer[audioBandMaterial] * emissionMultiplier);
            }
        }
        else
        {
            if (materialInstance != null)
            {
                materialInstance.SetColor("_EmissionColor", color * audioVisualizer.audioBand[audioBandMaterial] * emissionMultiplier);
            }
        }


        if (_generationCount != 0)
        {
            int count = 0;
            for (int i = 0; i < _initiatorPointAmount; i++)
            {
                if (useBuffer)
                {
                    lerpAudio[i] = audioVisualizer.audioBandBuffer[audioBand[i]];
                }
                else
                {
                    lerpAudio[i] = audioVisualizer.audioBand[audioBand[i]];
                }

                for (int j = 0; j < (_positions.Length - 1) / _initiatorPointAmount; j++)
                {
                    lerpPositions[count] = Vector3.Lerp(_positions[count], _targetPositions[count], lerpAudio[i]);
                    count++;
                }
            }
            lerpPositions[count] = Vector3.Lerp(_positions[count], _targetPositions[count], lerpAudio[_initiatorPointAmount - 1]);

            if (_useBezierCurve)
            {
                _bezierPosition            = BezierCurve(lerpPositions, _bezierVertexCount);
                lineRenderer.positionCount = _bezierPosition.Length;
                lineRenderer.SetPositions(_bezierPosition);
            }
            else
            {
                lineRenderer.positionCount = lerpPositions.Length;
                lineRenderer.SetPositions(lerpPositions);
            }
        }
    }
示例#8
0
 public TestRunnerFast(EchoCancellerType echoCancellerType,
                       AudioVisualizer sourceAudioVisualizer,
                       AudioVisualizer speakersAudioVisualizer,
                       AudioVisualizer cancelledAudioVisualizer,
                       List <byte[]> speakerFrames)
     : base(echoCancellerType, sourceAudioVisualizer, speakersAudioVisualizer, cancelledAudioVisualizer)
 {
     SpeakerFrames = speakerFrames;
 }
 private void RenderVisualization(short[] frame, AudioVisualizer audioVisualizer)
 {
     if (audioVisualizer != null)
     {
         var samples = new short[frame.Length / sizeof(short)];
         Buffer.BlockCopy(frame, 0, samples, 0, frame.Length);
         audioVisualizer.RenderVisualization(samples);
     }
 }
示例#10
0
    void OnDestroy()
    {
        AudioVisualizer av = GameObject.FindObjectOfType <AudioVisualizer>();

        if (av != null)
        {
            av.expandableAudioListeners.Remove(this);
        }
    }
示例#11
0
    protected virtual void UpdateColor()
    {
        float r, g, b, a;

        //Interpolate between initial color and end color based on current audio data, making sure not to go passed the end color
        //If buffer is applied
        if (bufferDecreaseSpeed > 0 || bufferIncreaseSpeed > 0)
        {
            r = initialColor.r + (endColor.r - initialColor.r) * valueBuffer * colorChangeSpeed;
            if ((r > endColor.r && endColor.r > initialColor.r) || (r < endColor.r && endColor.r < initialColor.r))
            {
                r = endColor.r;
            }
            g = initialColor.g + (endColor.g - initialColor.g) * valueBuffer * colorChangeSpeed;
            if ((g > endColor.g && endColor.g > initialColor.g) || (g < endColor.g && endColor.g < initialColor.g))
            {
                g = endColor.g;
            }
            b = initialColor.b + (endColor.b - initialColor.b) * valueBuffer * colorChangeSpeed;
            if ((b > endColor.b && endColor.b > initialColor.b) || (b < endColor.b && endColor.b < initialColor.b))
            {
                b = endColor.b;
            }
            a = initialColor.a + (endColor.a - initialColor.a) * valueBuffer * colorChangeSpeed;
            if ((a > endColor.a && endColor.a > initialColor.a) || (a < endColor.a && endColor.a < initialColor.a))
            {
                a = endColor.a;
            }
        }
        //no buffer
        else
        {
            float raw = AudioVisualizer.getRawAudioRange(range);
            r = (endColor.r - initialColor.r) * raw * colorChangeSpeed;
            if ((r > endColor.r && endColor.r > initialColor.r) || (r < endColor.r && endColor.r < initialColor.r))
            {
                r = endColor.r;
            }
            g = (endColor.g - initialColor.g) * raw * colorChangeSpeed;
            if ((g > endColor.g && endColor.g > initialColor.g) || (g < endColor.g && endColor.g < initialColor.g))
            {
                g = endColor.g;
            }
            b = (endColor.b - initialColor.b) * raw * colorChangeSpeed;
            if ((b > endColor.b && endColor.b > initialColor.b) || (b < endColor.b && endColor.b < initialColor.b))
            {
                b = endColor.b;
            }
            a = (endColor.a - initialColor.a) * raw * colorChangeSpeed;
            if ((a > endColor.a && endColor.a > initialColor.a) || (a < endColor.a && endColor.a < initialColor.a))
            {
                a = endColor.a;
            }
        }
        rend.material.color = new Color(r, g, b, a);
    }
示例#12
0
    void Initialize()
    {
        if (!audioVisualizer)
        {
            audioVisualizer = AudioVisualizer.instance;
        }

        startColor = new Color(0, 0, 0, 0);
        endColor   = new Color(0, 0, 0, 1);

        trails = new List <TrailObject>();

        for (int i = 0; i < _initiatorPointAmount; i++)
        {
            GameObject  trailInstance       = Instantiate(trailPrefab, transform.position, Quaternion.identity, this.transform);
            TrailObject trailObjectInstance = new TrailObject();
            trailObjectInstance.GO                   = trailInstance;
            trailObjectInstance.Trail                = trailInstance.GetComponent <TrailRenderer>();
            trailObjectInstance.Trail.material       = new Material(trailMaterial);
            trailObjectInstance.EmissionColor        = trailColor.Evaluate(i * (1.0f / _initiatorPointAmount));
            trailObjectInstance.Trail.numCapVertices = trailEndCapVertices;
            trailObjectInstance.Trail.widthCurve     = trailWidthCurve;

            Vector3 instantiatePosition;

            if (_generationCount > 0)
            {
                int step;
                if (_useBezierCurve)
                {
                    step = _bezierPosition.Length / _initiatorPointAmount;
                    instantiatePosition = _bezierPosition[i * step];
                    trailObjectInstance.CurrentTargetNum = (i * step) + 1;
                    trailObjectInstance.TargetPosition   = _bezierPosition[trailObjectInstance.CurrentTargetNum];
                }
                else
                {
                    step = _positions.Length / _initiatorPointAmount;
                    instantiatePosition = _positions[i * step];
                    trailObjectInstance.CurrentTargetNum = (i * step) + 1;
                    trailObjectInstance.TargetPosition   = _positions[trailObjectInstance.CurrentTargetNum];
                }
            }
            else
            {
                instantiatePosition = _positions[i];
                trailObjectInstance.CurrentTargetNum = i + 1;
                trailObjectInstance.TargetPosition   = _positions[trailObjectInstance.CurrentTargetNum];
            }

            trailObjectInstance.GO.transform.localPosition = instantiatePosition;
            trails.Add(trailObjectInstance);
        }
    }
示例#13
0
 protected virtual void FixedUpdate()
 {
     if (AudioVisualizer.audioIsPlaying())
     {
         //Check if buffer is being used
         if (bufferIncreaseSpeed > 0 || bufferDecreaseSpeed > 0)
         {
             UpdateBuffer();
         }
     }
 }
示例#14
0
        public void SetSongBadReference()
        {
            AudioFile   audioFile = new AudioFile(".//TestResources//test2.mp3");
            ProgressBar progBar   = new ProgressBar();
            PictureBox  picBox    = new PictureBox();
            Timer       timer     = new Timer();

            AudioVisualizer audioVisualizer = new AudioVisualizer(progBar, picBox, timer);

            audioVisualizer.SetSong(null);
        }
示例#15
0
        public void checkPlay()
        {
            ProgressBar progBar = new ProgressBar();
            PictureBox  picBox  = new PictureBox();
            Timer       timer   = new Timer();

            AudioVisualizer audioVisualizer = new AudioVisualizer(progBar, picBox, timer);

            audioVisualizer.OnPauseEvent(null, null); // event args aren't relevant here
            Assert.IsTrue(timer.Enabled, "Timer should be enabled by onPlay() events");
        }
 // Use this for initialization
 void Start()
 {
     meshRenderer                 = GetComponent <MeshRenderer>();
     spotifyManager               = GameObject.Find("SpotifyManager");
     script                       = spotifyManager.GetComponent <Spotify>();
     recordPlayerScript           = recordPlayer.GetComponent <RecordPlayer>();
     audioVisualizer              = GameObject.Find("AudioVisualizer");
     particleVisualizerGameObject = GameObject.Find("Visualizer Room/ParticleVisualizer");
     particleVisualizer           = particleVisualizerGameObject.GetComponent <ParticleVisualizer>();
     audioVisualizerScript        = audioVisualizer.GetComponent <AudioVisualizer>();
     raycast                      = GameObject.Find("/OVRPlayerController/OVRCameraRig/TrackingSpace/LocalAvatar/controller_right").GetComponent <Raycast>();
 }
示例#17
0
        public void SetSongGoodReference()
        {
            AudioFile   audioFile = new AudioFile(".//TestResources//test2.mp3");
            ProgressBar progBar   = new ProgressBar();
            PictureBox  picBox    = new PictureBox();
            Timer       timer     = new Timer();

            AudioVisualizer audioVisualizer = new AudioVisualizer(progBar, picBox, timer);

            audioVisualizer.SetSong(audioFile);
            Assert.IsTrue(timer.Enabled, "Timer should be enabled when a good audio file is sent.");
        }
示例#18
0
        public void SetSongGeneratedBitmap()
        {
            AudioFile   audioFile = new AudioFile(".//TestResources//test2.mp3");
            ProgressBar progBar   = new ProgressBar();
            PictureBox  picBox    = new PictureBox();
            Timer       timer     = new Timer();

            AudioVisualizer audioVisualizer = new AudioVisualizer(progBar, picBox, timer);

            audioVisualizer.SetSong(audioFile);
            Assert.IsNotNull(picBox.Image, "Image should be generated and applied to picture box.");
        }
示例#19
0
		public RecorderAec(
			CaptureSource captureSource,
			AudioSinkAdapter audioSinkAdapter,
			AudioVisualizer speakerAudioVisualizer,
			AudioVisualizer cancelledAudioVisualizer,
			EchoCancelFilter echoCancelFilter,
			List<byte[]> cancelledFrames) :
			base(captureSource, audioSinkAdapter, speakerAudioVisualizer)
		{
			mEchoCancelFilter = echoCancelFilter;
			mCancelledAudioVisualizer = cancelledAudioVisualizer;
			CancelledFrames = cancelledFrames;
		}
示例#20
0
        protected override void OnShown(EventArgs e)
        {
            base.OnShown(e);

            numRepeatLength.Value   = (decimal)AudioVisualizer.RepeatLength;
            numRepeatBack.Value     = (decimal)AudioVisualizer.RepeatBackwards;
            numRepeatPause.Value    = (decimal)AudioVisualizer.RepeatPause;
            numTypingPause.Value    = MainForm.TypingPauseLength / 1000m;
            numFrequencyRange.Value = AudioVisualizer.GetFrequencyRange();
            numTempo.Value          = (decimal)AudioVisualizer.GetTempo();
            numSmallStep.Value      = (decimal)AudioVisualizer.SmallStep;
            numLargeStep.Value      = (decimal)AudioVisualizer.LargeStep;
            numZoomSeconds.Value    = (decimal)AudioVisualizer.ZoomSeconds;
        }
    //Create a singleton that doesn't destroy itself inbetween scenes
    void Awake()
    {
        if (instance == null)
        {
            instance = this;
        }

        else if (instance != this)
        {
            Destroy(gameObject);
        }

        DontDestroyOnLoad(gameObject);
    }
示例#22
0
 void Start()
 {
     if (!instance)
     {
         instance = this;
         DontDestroyOnLoad(instance);
     }
     else
     {
         Destroy(gameObject);
     }
     spectrum = new float[256];
     music    = GetComponent <AudioSource>();
 }
 /// <summary>
 /// Rotate x, y, and/or z based on input settings
 /// </summary>
 protected virtual void UpdateRotation()
 {
     //Check if any scaling occurs
     if (rotX || rotY || rotZ)
     {
         Vector3 currentRotation = intialRotation;
         if (rotX)
         {
             //If buffer is applied
             if (bufferDecreaseSpeed > 0 || bufferIncreaseSpeed > 0)
             {
                 currentRotation.x += valueBuffer * rotFactor.x;
             }
             //no buffer
             else
             {
                 currentRotation.x += AudioVisualizer.getRawAudioRange(range) * rotFactor.x;
             }
         }
         if (rotY)
         {
             //If buffer is applied
             if (bufferDecreaseSpeed > 0 || bufferIncreaseSpeed > 0)
             {
                 currentRotation.y += valueBuffer * rotFactor.y;
             }
             //no buffer
             else
             {
                 currentRotation.y += AudioVisualizer.getRawAudioRange(range) * rotFactor.y;
             }
         }
         if (rotZ)
         {
             //If buffer is applied
             if (bufferDecreaseSpeed > 0 || bufferIncreaseSpeed > 0)
             {
                 currentRotation.z += valueBuffer * rotFactor.z;
             }
             //no buffer
             else
             {
                 currentRotation.z += AudioVisualizer.getRawAudioRange(range) * rotFactor.z;
             }
         }
         transform.localRotation = Quaternion.Euler(currentRotation);
     }
 }
示例#24
0
 /// <summary>
 /// Scale x, y, and/or z based on input settings
 /// </summary>
 protected virtual void UpdateScale()
 {
     //Check if any scaling occurs
     if (scaleX || scaleY || scaleZ)
     {
         Vector3 currentScale = initialScale;
         if (scaleX)
         {
             //If buffer is applied
             if (bufferDecreaseSpeed > 0 || bufferIncreaseSpeed > 0)
             {
                 currentScale.x += valueBuffer * scaleFactor.x;
             }
             //no buffer
             else
             {
                 currentScale.x += AudioVisualizer.getRawAudioRange(range) * scaleFactor.x;
             }
         }
         if (scaleY)
         {
             //If buffer is applied
             if (bufferDecreaseSpeed > 0 || bufferIncreaseSpeed > 0)
             {
                 currentScale.y += valueBuffer * scaleFactor.y;
             }
             //no buffer
             else
             {
                 currentScale.y += AudioVisualizer.getRawAudioRange(range) * scaleFactor.y;
             }
         }
         if (scaleZ)
         {
             //If buffer is applied
             if (bufferDecreaseSpeed > 0 || bufferIncreaseSpeed > 0)
             {
                 currentScale.z += valueBuffer * scaleFactor.z;
             }
             //no buffer
             else
             {
                 currentScale.z += AudioVisualizer.getRawAudioRange(range) * scaleFactor.z;
             }
         }
         transform.localScale = currentScale;
     }
 }
示例#25
0
 /// <summary>
 /// Move x, y, and/or z based on input settings
 /// </summary>
 protected virtual void UpdatePosition()
 {
     //Check if any scaling occurs
     if (moveX || moveY || moveZ)
     {
         Vector3 currentPosition = intialPosition;
         if (moveX)
         {
             //If buffer is applied
             if (bufferDecreaseSpeed > 0 || bufferIncreaseSpeed > 0)
             {
                 currentPosition.x += valueBuffer * moveFactor.x;
             }
             //no buffer
             else
             {
                 currentPosition.x += AudioVisualizer.getRawAudioRange(range) * moveFactor.x;
             }
         }
         if (moveY)
         {
             //If buffer is applied
             if (bufferDecreaseSpeed > 0 || bufferIncreaseSpeed > 0)
             {
                 currentPosition.y += valueBuffer * moveFactor.y;
             }
             //no buffer
             else
             {
                 currentPosition.y += AudioVisualizer.getRawAudioRange(range) * moveFactor.y;
             }
         }
         if (moveZ)
         {
             //If buffer is applied
             if (bufferDecreaseSpeed > 0 || bufferIncreaseSpeed > 0)
             {
                 currentPosition.z += valueBuffer * moveFactor.z;
             }
             //no buffer
             else
             {
                 currentPosition.z += AudioVisualizer.getRawAudioRange(range) * moveFactor.z;
             }
         }
         transform.position = currentPosition;
     }
 }
 void Start()
 {
     if (!instance)
     {
         instance = this;
         DontDestroyOnLoad(instance);
     }
     else
     {
         Destroy(gameObject);
     }
     spectrum = new float[256];
     music    = GetComponent <AudioSource>();
     InvokeRepeating("ChangePitch", 2.0f, 3.0f);
     InvokeRepeating("CheckPitch", 0.5f, 0.5f);
 }
示例#27
0
    // Use this for initialization
    void Start()
    {
        matris = new Transform[resolution, resolution];
        av     = GetComponent <AudioVisualizer> ();
        for (int x = 0; x < resolution; x++)
        {
            GameObject go = Instantiate(visualBarPrefab, transform.position + new Vector3((barDistance * x), 0.1f, 0), Quaternion.identity) as GameObject;
            av.visualBars.Add(go.transform);

            for (int y = 0; y < resolution; y++)
            {
                GameObject go2 = Instantiate(visualBarPrefab, transform.position + new Vector3((barDistance * y), 0.1f, barDistance * x), Quaternion.identity) as GameObject;
                matris [y, x] = go2.transform;
            }
        }
        StartCoroutine(UpdateDelayedAudioVisuals());
    }
示例#28
0
 protected TestRunnerBase(EchoCancellerType echoCancellerType,
                          AudioVisualizer sourceAudioVisualizer,
                          AudioVisualizer speakersAudioVisualizer,
                          AudioVisualizer cancelledAudioVisualizer)
 {
     mEchoCancellerType        = echoCancellerType;
     mSourceAudioVisualizer    = sourceAudioVisualizer;
     mSpeakersAudioVisualizer  = speakersAudioVisualizer;
     mCancelledAudioVisualizer = cancelledAudioVisualizer;
     Results     = new ObservableCollection <PlaybackResults>();
     mediaConfig = new MediaConfig
     {
         EnableAec     = true,
         EnableAgc     = true,
         EnableDenoise = true
     };
     audioFormat = AudioFormat.Default;
 }
示例#29
0
    // Start is called before the first frame update
    void Start()
    {
        if (!audioVisualizer)
        {
            audioVisualizer = AudioVisualizer.instance;
        }

        lerpAudio                  = new float[_initiatorPointAmount];
        lineRenderer               = GetComponent <LineRenderer>();
        lineRenderer.enabled       = true;
        lineRenderer.useWorldSpace = false;
        lineRenderer.loop          = true;
        lineRenderer.positionCount = _positions.Length;
        lineRenderer.SetPositions(_positions);
        lerpPositions = new Vector3[_positions.Length];

        //Apply material
        materialInstance      = new Material(material);
        lineRenderer.material = materialInstance;
    }
示例#30
0
    private void Awake()
    {
        if (Instance == null)
        {
            Instance = this;
        }
        else
        {
            Destroy(this);
        }

        audioSource             = GetComponent <AudioSource>();
        samples                 = new float[SampleSize];
        sampleAverages          = new float[SampleSize];
        bandStates              = new BandState[FrequencyBands.Length];
        cubeEmissionStartColors = new Color[FrequencyBands.Length];
        for (int b = 0; b < FrequencyBands.Length; b++)
        {
            bandStates[b] = new BandState();
            cubeEmissionStartColors[b] = new Color();
        }
    }
    public virtual void OnAudioEvent(AudioVisualizer.AudioEvent audioEvent)
    {
        // Allow the listener to be disabled without being removed from the visualizer controller
        if (!this.enabled)
        {
            Debug.Log(this.GetType().Name + " is disabled.");
            return;
        }

        // Calulate the current db sample. This will be different for different listeners because they may have
        // different rates of increase/decrease
        CalculateAverageDb(audioEvent.averageDbSample);

        // This is the default order of processing. Override OnAudioEvent to override this order
        // If there's no spectrum color, don't change color from the last thing.
        if (audioEvent.spectrumColorRepresetation.a != 0)
        {
            ProcessRepresentationalColor(audioEvent.spectrumColorRepresetation);
        }
        ProcessAverageDBSample (currentDbAverage);
        ProcessSpectrumSamples (audioEvent.spectrumData);
        ProcessDBSamples (audioEvent.dbData);
    }
    public override void OnAudioEvent(AudioVisualizer.AudioEvent audioEvent)
    {
        /*
         * Transform sine amplitude multiplier towards target
         * Multiplier is based on the first frequency datapoint as well as the averageDbVolume
         	 */

        // Compare the current target with the new data point
        mMax = Mathf.Max (mMax, audioEvent.averageDbSample * 0.5f + audioEvent.spectrumData [0] * 0.5f);
        // Get the direction of difference between the target and current
        float diff = Mathf.Sign (mMax - mCur);
        // Transform towards target
        mCur = Mathf.Clamp (mCur + diff * Time.deltaTime * 5, minSin, mMax);

        // If we're above the target, then lower the current
        if (mCur >= mMax) {
            mMax -= Time.deltaTime;
        }

        // Set the multiplier (a sine to add to the pulsing effect)
        float sc = Mathf.Sin (Time.time * speedOffset) * mCur * scaleOffset;

        // Iterate through each sample and linerenderer point
        for (int i = 0; i < AudioVisualizer.sSampleCount; i++) {
            // Set distance along x axis based on scale
            float x = xScale * i;

            // Calculate y based on scale, volume, and current frequency data
            float y = audioEvent.spectrumData[i] * audioEvent.averageDbSample * 2 * yScale;

            // Transform the y value towards the target. We want the highest point, based on current data and last data.
            fMax[i] = Mathf.Max(fMax[i], y);

            // Transform towards the target. This will clamp between fMax[i] and fCur[i]
            if(fCur[i] > fMax[i]) {
                fCur[i] = Mathf.Clamp(fCur[i] - Time.deltaTime * 60 * audioEvent.averageDbSample * 5, fMax[i], fCur[i]);
            } else {
                fCur[i] = Mathf.Clamp(fCur[i] + Time.deltaTime * 100 * audioEvent.averageDbSample * 5, fCur[i], fMax[i]);
            }

            // Lower the max over time since the last time fMax was set
            fMax[i] -= Time.deltaTime * 60;

            y = fCur[i];

            /*
             * Apply the sine wave
             */
            float segval = (sineFade - i) / sineFade;
            // Minimum value
            segval = Mathf.Max(segval, .15f);

            // Get sine based on multiplier
            float y2 = Mathf.Sin(x + Time.time * speedOffset) * (segval * sc);
            y += y2;

            // Apply the calculated position to the current point in LineRenderer
            foreach(LineRenderer l in lineRenderers) {
                l.SetPosition(i, new Vector3(x, y, 0));
            }
        }
        // Cycle material over time
        foreach (LineRenderer l in lineRenderers) {
            Vector2 mainTextureOffset = l.gameObject.renderer.material.mainTextureOffset;
            mainTextureOffset.x -= Time.deltaTime * 20 * mCur;
            l.gameObject.renderer.material.mainTextureOffset = mainTextureOffset;
        }
    }
示例#33
0
    void Start()
    {
        manager = GameObject.FindGameObjectWithTag ( "Manager" );
        startupManager = manager.GetComponent<StartupManager> ();
        socketsManager = manager.GetComponent<SocketsManager> ();
        onlineMusicBrowser = GameObject.FindGameObjectWithTag ( "OnlineMusicBrowser" ).GetComponent <OnlineMusicBrowser>();
        paneManager = manager.GetComponent <PaneManager> ();
        loadingImage = GameObject.FindGameObjectWithTag ( "LoadingImage" ).GetComponent<LoadingImage>();
        currentSlideshowImage = GameObject.FindGameObjectWithTag ( "SlideshowImage" ).GetComponent<GUITexture>();
        currentSong = GameObject.FindGameObjectWithTag ( "CurrentSong" ).GetComponent<GUIText>();

        musicViewerPosition.width = Screen.width;
        musicViewerPosition.height = Screen.height;

        bottomBarPosition = new Rect (( musicViewerPosition.width - 240 ) / 2 , musicViewerPosition.height - 18, 240, 54 );

        optionsWindowRect.x = musicViewerPosition.width/2 - optionsWindowRect.width/2;
        optionsWindowRect.y = musicViewerPosition.height/2 - optionsWindowRect.height/2;

        audioVisualizer = GameObject.FindGameObjectWithTag ("AudioVisualizer").GetComponent<AudioVisualizer> ();

        timemark = GameObject.FindGameObjectWithTag ( "Timemark" ).GetComponent<GUIText> ();
        GameObject.FindGameObjectWithTag ( "TimebarImage" ).guiTexture.pixelInset = new Rect ( -musicViewerPosition.width/2, musicViewerPosition.height/2 - 3, musicViewerPosition.width, 6 );

        LoadSettings ( false );

        centerStyle = new GUIStyle ();
        centerStyle.alignment = TextAnchor.MiddleCenter;

        labelStyle = new GUIStyle ();
        labelStyle.alignment = TextAnchor.MiddleCenter;
        labelStyle.wordWrap = true;

        folderStyle = new GUIStyle ();
        folderStyle.alignment = TextAnchor.MiddleLeft;
        folderStyle.border = new RectOffset ( 6, 6, 4, 4 );
        folderStyle.hover.background = guiSkin.button.hover.background;
        folderStyle.active.background = guiSkin.button.active.background;
        folderStyle.fontSize = 22;

        fileStyle = new GUIStyle ();
        fileStyle.alignment = TextAnchor.MiddleLeft;
        fileStyle.border = new RectOffset ( 6, 6, 6, 4 );
        fileStyle.padding = new RectOffset ( 6, 6, 3, 3 );
        fileStyle.margin = new RectOffset ( 4, 4, 4, 4 );
        fileStyle.hover.background = guiSkin.button.hover.background;
        fileStyle.active.background = guiSkin.button.active.background;
        fileStyle.fontSize = 22;

        fileBrowserFileStyle = new GUIStyle ();
        fileBrowserFileStyle.alignment = TextAnchor.MiddleLeft;

        currentSongStyle = new GUIStyle ();
        currentSongStyle.font = secretCode;
        currentSongStyle.fontSize = 31;

        songStyle = new GUIStyle ();
        songStyle.alignment = TextAnchor.MiddleLeft;
        songStyle.fontSize = 16;

        buttonStyle = new GUIStyle ();
        buttonStyle.fontSize = 22;
        buttonStyle.alignment = TextAnchor.MiddleCenter;
        buttonStyle.border = new RectOffset ( 6, 6, 6, 4 );
        buttonStyle.padding = new RectOffset ( 6, 6, 3, 3 );
        buttonStyle.margin = new RectOffset ( 4, 4, 4, 4 );
        buttonStyle.hover.background = guiSkin.button.hover.background;

        hideGUIStyle = new GUIStyle ();
        hideGUIStyle.normal.background = hideGUINormal;
        hideGUIStyle.hover.background = hideGUIHover;
        hideGUIStyle.onNormal.background = hideGUIOnNormal;
        hideGUIStyle.onHover.background = hideGUIOnHover;

        showVisualizerStyle = new GUIStyle ();
        showVisualizerStyle.normal.background = showAudioVisualizerNormal;
        showVisualizerStyle.hover.background = showAudioVisualizerHover;
        showVisualizerStyle.onNormal.background = showAudioVisualizerOnNormal;
        showVisualizerStyle.onHover.background = showAudioVisualizerOnHover;

        doubleSpeedStyle = new GUIStyle ();
        doubleSpeedStyle.normal.background = audioSpeedDoubleNormal;
        doubleSpeedStyle.hover.background = audioSpeedDoubleHover;
        doubleSpeedStyle.onNormal.background = audioSpeedNormalNormal;
        doubleSpeedStyle.onHover.background = audioSpeedNormalHover;

        halfSpeedStyle = new GUIStyle ();
        halfSpeedStyle.normal.background = audioSpeedHalfNormal;
        halfSpeedStyle.hover.background = audioSpeedHalfHover;
        halfSpeedStyle.onNormal.background = audioSpeedNormalNormal;
        halfSpeedStyle.onHover.background = audioSpeedNormalHover;

        echoStyle = new GUIStyle ();
        echoStyle.normal.background = echoNormal;
        echoStyle.hover.background = echoHover;
        echoStyle.onNormal.background = echoOnNormal;
        echoStyle.onHover.background = echoOnHover;

        InvokeRepeating ( "Refresh", 0, 2 );
        StartCoroutine ( SetArtwork ());
    }
 public override void OnAudioEvent(AudioVisualizer.AudioEvent audioEvent)
 {
     ProcessFrequencyDb(audioEvent.frequencySplitData[frequencySpace], audioEvent.averageDbSample);
 }