Skip to content

aldrinabastillas/Audio-Visualizer

 
 

Repository files navigation

Lorenz System Audio Visualizer in Unity3D

Overview

This is my first project in Unity3D and first experience in game development and CGI. It is an audio visualizer in the pattern of a Lorenz System, which is a system of 3 ordinary differential equations that form the shape of a butterfly or figure-eight. The objects at each point change size and color with the song's audio frequency.

Changes

This project was modified from Hypnotoad09's original project (see Videos and References sections below), which was then converted from UnityScript to C# by Dommii.

Code Refactoring

  • The pattern that is created can now be changed in the IDE, by making an enum value for the pattern type a public field. This enum is passed into a Factory Method that creates a List of vector points. The List of points is a property on an abstract base class, Pattern. The classes Lorenz and Circle inherit from Pattern and add to this List according to their own variables like radius for Circle and sigma, rho and beta for Lorenz.
  • Fields that were duplicated between scripts like maxHeight for the object, were made public in AudioManager.cs and internal elsewhere.
    This creates one central access point for editing parameters, rather than having to know which script to open, and eliminates ambiguity of which value from the two scripts will actually be used.
  • Objects expand depending on the type of prefab mesh is used. For example, if the mesh is a sphere, it expands in all dimensions, but only expands in the y-dimension for cubes.
  • Added an accessor method into the AudioManager's internal array of frequency samples rather than indexing into the array directly.
  • Commented code, sectioned off regions for Fields, Parameters, Event Functions, and Methods.

Visual Updates

  • Added a skybox background.
  • Added a silver reflective object material for each prefab object.
  • Prefab objects expand downwards as well as up.

Assets

Scripts

  • Visualizer.cs: Creates a prefab object at each location for the specified pattern. Currenctly either Lorenz or Circle patterns can be chosen from the Unity IDE.

  • AudioManager.cs: Saves the song's audio frequency data to an array with a size of the given sampling rate. Samples are taken using a Hamming Window.

  • PrefabBehaviour.cs: Updates each prefab's size and color according to the current audio spectrum value and its position in the Hamming Window.

  • CameraRotation.cs: Rotates the camera's position on a specified axis and at a specified rotation rate.

Patterns

  • Pattern.cs: Abstract base class that others below derive from. Has a List of points that the derived classes add to using its specific implementation of the AddPoints method.

  • Lorenz.cs: Implements a Lorenz system.

  • Circle.cs: The points that were generated in Hypnotoad09's original project.

Materials

Executables

Files to download that allow you to change the visualization's resolution and frame rate.

Videos

References

Future Enhancements

  • Create a UI with sliders that changes the visualizer's parameters, like number and max size of objects, as seen in this project.
  • Add the ability to select your own audio file.
  • Listen to any audio coming out of speakers. This is much harder to implement, as it would require writing a plugin to get the audio directly from the hardware device.

About

An audio visualizer based on the Lorenz System equations, created in Unity3D

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 100.0%