Skip to content

Commit 21a1ac6

Browse files
committed
sealed audio core and added slider for velocity multipler
1 parent 2c0f2cb commit 21a1ac6

File tree

4 files changed

+18
-17
lines changed

4 files changed

+18
-17
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
1-
# Unity Audio Visualizer
1+
# Unity Audio Visualizer Package
22

33
![Demo](./Pictures/SmartAssistantAudioDemoHD.png)
44

55
## What does this package contains??
66

7-
This is a package than handles all sorts of audio processing that is needed for the [Smart Assistant](https://github.com/voxell-tech/Voxell) project. Anyone can use this package in any way they want as long as they credit the author(s) and also respect the [license](LICENSE) agreement.
7+
This is a package than handles audio processing and visualization. Anyone can use this package in any way they want as long as they credit the author(s) and also respect the [license](LICENSE) agreement.
88

99

1010
### Audio Visualizer
1111

12-
The audio visualizer is made using custom VFX Graph and custom Shader Graph. It also utilizes Unity's Job System and Burst Compiler to manipulate the mesh of the audio visualizer.
12+
The audio visualizer is made using custom VFX Graph and custom Shader (Wireframe Shader). It also utilizes Unity's Job System and Burst Compiler to manipulate each triangles of the mesh of the audio visualizer.
1313

1414
## How to use?
1515

1616
This package only supports the Universal Render Pipeline. Unity's Job System and Burst Compiler must also be installed in order for this package to function.
1717

1818
1. Setup a project with URP as it's SRP.
1919
2. Install Unity's Job System and Burst Compiler from the Package Manager.
20-
3. Clone this repository and the [Core Repository](https://github.com/voxell-tech/smartassistant.core) into your project's Packages folder.
20+
3. Clone this repository and the [Unity Util](https://github.com/voxell-tech/UnityUtil) repository into your project's `Packages` folder.
2121
4. And you are ready to go!
2222

2323
## Support the project!
@@ -32,6 +32,6 @@ This package only supports the Universal Render Pipeline. Unity's Job System and
3232

3333
## License
3434

35-
Smart Assistant as a whole is licensed under the GNU Public License, Version 3. Individual files may have a different, but compatible license.
35+
This repository as a whole is licensed under the GNU Public License, Version 3. Individual files may have a different, but compatible license.
3636

3737
See [license file](./LICENSE) for details.

Runtime/AudioCore.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ namespace Voxell.Audio
2424
{
2525
[RequireComponent(typeof(VisualEffect))]
2626
[RequireComponent(typeof(AudioSource))]
27-
public partial class AudioCore : MonoBehaviour
27+
public sealed partial class AudioCore : MonoBehaviour
2828
{
2929
private const float EPSILON = 0.001f;
3030

Runtime/AudioInteraction.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,26 +40,26 @@ public partial class AudioCore
4040
[Tooltip("Multiplier of noise intensity before sending it to the VFX graph")]
4141
public float intensityCoefficient = 0.1f;
4242

43-
private Vector2 rotationVelocity;
43+
private Vector2 _rotationVelocity;
4444

45-
private void InitAgentInteraction() => rotationVelocity = Vector2.zero;
45+
private void InitAgentInteraction() => _rotationVelocity = Vector2.zero;
4646

4747
private void UpdateAgentInteraction()
4848
{
4949
if (Input.GetMouseButton(0)) OnMouseDrag();
5050

5151
if (Vector3.Dot(transform.up, Vector3.up) >= 0)
52-
transform.Rotate(Camera.main.transform.up, -Vector3.Dot(rotationVelocity, Camera.main.transform.right), Space.World);
52+
transform.Rotate(Camera.main.transform.up, -Vector3.Dot(_rotationVelocity, Camera.main.transform.right), Space.World);
5353
else
54-
transform.Rotate(Camera.main.transform.up, -Vector3.Dot(rotationVelocity, Camera.main.transform.right), Space.World);
54+
transform.Rotate(Camera.main.transform.up, -Vector3.Dot(_rotationVelocity, Camera.main.transform.right), Space.World);
5555

56-
transform.Rotate(Camera.main.transform.right, Vector3.Dot(rotationVelocity, Camera.main.transform.up), Space.World);
57-
rotationVelocity *= velocityDamping;
58-
rotationVelocity += idleVelocity*Time.deltaTime;
56+
transform.Rotate(Camera.main.transform.right, Vector3.Dot(_rotationVelocity, Camera.main.transform.up), Space.World);
57+
_rotationVelocity *= velocityDamping;
58+
_rotationVelocity += idleVelocity*Time.deltaTime;
5959

60-
if (rotationVelocity.magnitude <= EPSILON) rotationVelocity = Vector2.zero;
60+
if (_rotationVelocity.magnitude <= EPSILON) _rotationVelocity = Vector2.zero;
6161

62-
float intensity = Mathf.Clamp(rotationVelocity.magnitude * intensityCoefficient, idleNoiseIntensity, maxNoiseIntensity);
62+
float intensity = Mathf.Clamp(_rotationVelocity.magnitude * intensityCoefficient, idleNoiseIntensity, maxNoiseIntensity);
6363
audioVFX.SetFloat(VFXPropertyId.float_noiseIntensity, intensity);
6464
}
6565

@@ -71,7 +71,7 @@ private void OnMouseDrag()
7171
float rotationX = Input.GetAxis("Mouse X")*rotationMultiplier*Mathf.Deg2Rad;
7272
float rotationY = Input.GetAxis("Mouse Y")*rotationMultiplier*Mathf.Deg2Rad;
7373

74-
rotationVelocity = new Vector2(rotationX, rotationY);
74+
_rotationVelocity = new Vector2(rotationX, rotationY);
7575
}
7676
}
7777
}

Runtime/AudioVisualizer.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ public partial class AudioCore
4040
public MeshFilter meshFilter;
4141
public Mesh sampleMesh;
4242
[Tooltip("Damping value to multiply the velocity of each triangles each frame.")]
43-
public float velocityMultiplier = 2.5f;
43+
[Range(0, 1)]
44+
public float velocityMultiplier = 0.95f;
4445
public int batchSize = 100;
4546
[InspectOnly] public int totalTriangles;
4647

0 commit comments

Comments
 (0)