Browse Source

Audio Update ScriptableObj

main
cailean 9 months ago
parent
commit
c8a00fbed8
  1. BIN
      Assets/4_Audio/458366__dwoboyle__footsteps-tile-run-13.wav
  2. BIN
      Assets/4_Audio/617053__fmaudio__tapping-wood-4.wav
  3. BIN
      Assets/4_Audio/617055__fmaudio__tapping-wood-2.wav
  4. BIN
      Assets/4_Audio/617056__fmaudio__tapping-wood-1.wav
  5. 8
      Assets/4_Audio/Audio Clips.meta
  6. BIN
      Assets/4_Audio/Audio Clips/458366__dwoboyle__footsteps-tile-run-13.wav
  7. 0
      Assets/4_Audio/Audio Clips/458366__dwoboyle__footsteps-tile-run-13.wav.meta
  8. BIN
      Assets/4_Audio/Audio Clips/617053__fmaudio__tapping-wood-4.wav
  9. 0
      Assets/4_Audio/Audio Clips/617053__fmaudio__tapping-wood-4.wav.meta
  10. BIN
      Assets/4_Audio/Audio Clips/617055__fmaudio__tapping-wood-2.wav
  11. 0
      Assets/4_Audio/Audio Clips/617055__fmaudio__tapping-wood-2.wav.meta
  12. BIN
      Assets/4_Audio/Audio Clips/617056__fmaudio__tapping-wood-1.wav
  13. 0
      Assets/4_Audio/Audio Clips/617056__fmaudio__tapping-wood-1.wav.meta
  14. BIN
      Assets/4_Audio/Audio Clips/Chair Wood 3.wav
  15. 0
      Assets/4_Audio/Audio Clips/Chair Wood 3.wav.meta
  16. 0
      Assets/4_Audio/Audio Clips/chair-01.mp3
  17. 0
      Assets/4_Audio/Audio Clips/chair-01.mp3.meta
  18. 8
      Assets/4_Audio/Audio Objects.meta
  19. 22
      Assets/4_Audio/Audio Objects/Ground.asset
  20. 4
      Assets/4_Audio/Audio Objects/Ground.asset.meta
  21. 8
      Assets/4_Audio/Audio Script.meta
  22. 40
      Assets/4_Audio/Audio Script/AudioManager.cs
  23. 0
      Assets/4_Audio/Audio Script/AudioManager.cs.meta
  24. 16
      Assets/4_Audio/Audio Script/AudioObject.cs
  25. 2
      Assets/4_Audio/Audio Script/AudioObject.cs.meta
  26. BIN
      Assets/4_Audio/Chair Wood 3.wav
  27. 71
      Assets/4_Audio/New Audio Random Container.asset
  28. 16
      Assets/6_Scenes/Beep.unity
  29. 6
      Assets/9_ML-Agents/Shared Assets MLA/SharedAssets/Scripts/GroundContact.cs
  30. 2
      Assets/ML-Agents/Timers/Beep_timers.json

BIN
Assets/4_Audio/458366__dwoboyle__footsteps-tile-run-13.wav

Binary file not shown.

BIN
Assets/4_Audio/617053__fmaudio__tapping-wood-4.wav

Binary file not shown.

BIN
Assets/4_Audio/617055__fmaudio__tapping-wood-2.wav

Binary file not shown.

BIN
Assets/4_Audio/617056__fmaudio__tapping-wood-1.wav

Binary file not shown.

8
Assets/4_Audio/Audio Clips.meta

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 072e5ae9fd3d91046af14acaf6b118c2
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

BIN
Assets/4_Audio/Audio Clips/458366__dwoboyle__footsteps-tile-run-13.wav (Stored with Git LFS)

Binary file not shown.

0
Assets/4_Audio/458366__dwoboyle__footsteps-tile-run-13.wav.meta → Assets/4_Audio/Audio Clips/458366__dwoboyle__footsteps-tile-run-13.wav.meta

BIN
Assets/4_Audio/Audio Clips/617053__fmaudio__tapping-wood-4.wav (Stored with Git LFS)

Binary file not shown.

0
Assets/4_Audio/617053__fmaudio__tapping-wood-4.wav.meta → Assets/4_Audio/Audio Clips/617053__fmaudio__tapping-wood-4.wav.meta

BIN
Assets/4_Audio/Audio Clips/617055__fmaudio__tapping-wood-2.wav (Stored with Git LFS)

Binary file not shown.

0
Assets/4_Audio/617055__fmaudio__tapping-wood-2.wav.meta → Assets/4_Audio/Audio Clips/617055__fmaudio__tapping-wood-2.wav.meta

BIN
Assets/4_Audio/Audio Clips/617056__fmaudio__tapping-wood-1.wav (Stored with Git LFS)

Binary file not shown.

0
Assets/4_Audio/617056__fmaudio__tapping-wood-1.wav.meta → Assets/4_Audio/Audio Clips/617056__fmaudio__tapping-wood-1.wav.meta

BIN
Assets/4_Audio/Audio Clips/Chair Wood 3.wav (Stored with Git LFS)

Binary file not shown.

0
Assets/4_Audio/Chair Wood 3.wav.meta → Assets/4_Audio/Audio Clips/Chair Wood 3.wav.meta

0
Assets/4_Audio/chair-01.mp3 → Assets/4_Audio/Audio Clips/chair-01.mp3

0
Assets/4_Audio/chair-01.mp3.meta → Assets/4_Audio/Audio Clips/chair-01.mp3.meta

8
Assets/4_Audio/Audio Objects.meta

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 2d63fc558990e4c4abd9e64e4ef02a0b
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

22
Assets/4_Audio/Audio Objects/Ground.asset

@ -0,0 +1,22 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 512202d9599b0c045b13ffb47d9ebe9e, type: 3}
m_Name: Ground
m_EditorClassIdentifier:
m_GroundType: {fileID: 13400000, guid: 52a249eaa894e35488a1519221a56769, type: 2}
m_AudioClip:
- {fileID: 8300000, guid: ad5741084eec3493c87e72baec553b5c, type: 3}
m_PitchMax: 0.7
m_PitchMin: 1.3
m_Volume: 1
m_VelcoityMax: 40
m_VelcoityMin: 5

4
Assets/4_Audio/New Audio Random Container.asset.meta → Assets/4_Audio/Audio Objects/Ground.asset.meta

@ -1,8 +1,8 @@
fileFormatVersion: 2
guid: 1efe78fa29d2bcf4ba21383447074078
guid: a3d7e9d3971e72946921864c3574b1bb
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 6418180475301049370
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

8
Assets/4_Audio/Audio Script.meta

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: fa6c04b00dd26394cbfa4b531f9982a5
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

40
Assets/4_Audio/AudioManager.cs → Assets/4_Audio/Audio Script/AudioManager.cs

@ -10,11 +10,7 @@ public class AudioManager : MonoBehaviour
{
public static AudioManager instance { get; private set; }
public float m_FootStepMinVelocity = 5;
public float m_FootStepMaxVelocity = 40;
public AudioClip m_FootStep;
public List<AudioObject> m_AudioObjects = new List<AudioObject>();
private void Awake()
{
@ -27,21 +23,37 @@ public class AudioManager : MonoBehaviour
}
}
public void FootStepAudio( Vector3 bp_Position, float magnitude, string groundType )
public void FootStepAudio( Vector3 bp_Position, float magnitude, PhysicMaterial groundType)
{
AudioObject match = FindAudioObjectByType(groundType);
if (magnitude > m_FootStepMinVelocity)
if (magnitude > match.m_VelcoityMin && match != null)
{
AudioClip randomPick = match.m_AudioClip[Random.Range(0, m_AudioObjects.Count - 1)];
// Play sound
if (m_FootStep != null)
if (randomPick != null)
{
float volume = Mathf.Lerp(0f, 1f, ( magnitude - m_FootStepMinVelocity) / (m_FootStepMaxVelocity - m_FootStepMinVelocity) );
//Debug.Log($"{magnitude}, {groundType}, {volume}");
CustomAudioOneShot(bp_Position, m_FootStep, volume);
float volume = Mathf.Lerp(0f, match.m_Volume, ( magnitude - match.m_VelcoityMin) / (match.m_VelcoityMax - match.m_VelcoityMin) );
CustomAudioOneShot(bp_Position, randomPick, volume, match.m_PitchMin, match.m_PitchMax);
}
}
}
void CustomAudioOneShot(Vector3 position, AudioClip clip, float volume)
private AudioObject FindAudioObjectByType(PhysicMaterial groundType)
{
// Check for PM match
foreach(AudioObject obj in m_AudioObjects)
{
if(obj.m_GroundType.name == groundType.name)
{
return obj;
}
}
return null;
}
void CustomAudioOneShot(Vector3 position, AudioClip clip, float volume, float pitchMin, float pitchMax)
{
GameObject audioObject = new GameObject("FootstepAudio");
@ -55,13 +67,13 @@ public class AudioManager : MonoBehaviour
// Adjust sound properties
audioSource.volume = Mathf.Pow((volume), 2); // Adjust the volume (0.0f to 1.0f)
audioSource.pitch = Random.Range(0.7f, 1.3f); // Randomize the pitch within a range (e.g., 0.9 to 1.1)
audioSource.pitch = Random.Range(pitchMin, pitchMax); // Randomize the pitch within a range (e.g., 0.9 to 1.1)
// You can adjust other properties here such as spatial blend, loop, etc.
// Play the sound
audioSource.Play();
// Clean up the GameObject after the sound finishes playing
Destroy(audioObject, m_FootStep.length);
Destroy(audioObject, clip.length);
}
}

0
Assets/4_Audio/AudioManager.cs.meta → Assets/4_Audio/Audio Script/AudioManager.cs.meta

16
Assets/4_Audio/Audio Script/AudioObject.cs

@ -0,0 +1,16 @@
using NUnit.Framework;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[CreateAssetMenu]
public class AudioObject : ScriptableObject
{
public PhysicMaterial m_GroundType;
public List<AudioClip> m_AudioClip = new List<AudioClip>();
public float m_PitchMax;
public float m_PitchMin;
public float m_Volume;
public float m_VelcoityMax;
public float m_VelcoityMin;
}

2
Assets/4_Audio/Audio Script/AudioObject.cs.meta

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 512202d9599b0c045b13ffb47d9ebe9e

BIN
Assets/4_Audio/Chair Wood 3.wav

Binary file not shown.

71
Assets/4_Audio/New Audio Random Container.asset

@ -1,71 +0,0 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1233149941 &-5975054407277783851
AudioContainerElement:
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: 617056__fmaudio__tapping-wood-1_{-5975054407277783851}
m_AudioClip: {fileID: 8300000, guid: 591c24ce5596adf4e9d1e7a0cabe0d25, type: 3}
m_Volume: 0
m_Enabled: 1
--- !u!1233149941 &-5368430530676617884
AudioContainerElement:
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: 617055__fmaudio__tapping-wood-2_{-5368430530676617884}
m_AudioClip: {fileID: 8300000, guid: 6ac67932331adca41ae832e195a72b91, type: 3}
m_Volume: 0
m_Enabled: 1
--- !u!1307931743 &6418180475301049370
AudioRandomContainer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: New Audio Random Container
m_Volume: 0
m_Pitch: 0
m_AutomaticTriggerTime: 0
m_LoopCount: 1
m_VolumeRandomizationRange: {x: -20.014149, y: 3.455143}
m_PitchRandomizationRange: {x: -223.94107, y: 228.36092}
m_AutomaticTriggerTimeRandomizationRange: {x: 0, y: 0}
m_LoopCountRandomizationRange: {x: 0, y: 0}
m_Elements:
- {fileID: 8741578137423200642}
- {fileID: -5368430530676617884}
- {fileID: -5975054407277783851}
- {fileID: 7406355764817372577}
m_AvoidRepeatingLast: 0
m_PlaybackMode: 0
m_TriggerMode: 0
m_AutomaticTriggerMode: 1
m_LoopMode: 2
m_VolumeRandomizationEnabled: 1
m_PitchRandomizationEnabled: 1
m_AutomaticTriggerTimeRandomizationEnabled: 0
m_LoopCountRandomizationEnabled: 0
--- !u!1233149941 &7406355764817372577
AudioContainerElement:
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: 617053__fmaudio__tapping-wood-4_{7406355764817372577}
m_AudioClip: {fileID: 8300000, guid: 4504e7a182be36a40ab60949991502fd, type: 3}
m_Volume: 0
m_Enabled: 1
--- !u!1233149941 &8741578137423200642
AudioContainerElement:
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: 458366__dwoboyle__footsteps-tile-run-13_{8741578137423200642}
m_AudioClip: {fileID: 8300000, guid: 77d1257663150ef4099ba5cfc873f0f8, type: 3}
m_Volume: 0
m_Enabled: 0

16
Assets/6_Scenes/Beep.unity

@ -320,7 +320,7 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 155411616}
serializedVersion: 2
m_LocalRotation: {x: 0.032237254, y: 0.9667706, z: -0.15566996, w: 0.20020582}
m_LocalRotation: {x: 0.032237247, y: 0.9667706, z: -0.15566997, w: 0.20020577}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
@ -897,7 +897,7 @@ PrefabInstance:
- target: {fileID: 3364236482078802793, guid: 263d8cea838224448bdfd0e71bc2dce4,
type: 3}
propertyPath: m_LocalPosition.x
value: -247.36
value: -267.59
objectReference: {fileID: 0}
- target: {fileID: 3364236482078802793, guid: 263d8cea838224448bdfd0e71bc2dce4,
type: 3}
@ -1377,7 +1377,7 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 513050371}
serializedVersion: 2
m_LocalRotation: {x: 0.17829932, y: -0.22369513, z: 0.04166349, w: 0.9573056}
m_LocalRotation: {x: 0.17829932, y: -0.22369513, z: 0.041663494, w: 0.9573056}
m_LocalPosition: {x: 9.355881, y: -3.2973547, z: -5.6164856}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
@ -1625,9 +1625,8 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 953a08eddf4c70249933c26b006dbb7b, type: 3}
m_Name:
m_EditorClassIdentifier:
m_FootStepMinVelocity: 1
m_FootStepMaxVelocity: 20
m_FootStep: {fileID: 8300000, guid: ad5741084eec3493c87e72baec553b5c, type: 3}
m_AudioObjects:
- {fileID: 11400000, guid: a3d7e9d3971e72946921864c3574b1bb, type: 2}
--- !u!1 &701091196
GameObject:
m_ObjectHideFlags: 3
@ -3680,6 +3679,11 @@ PrefabInstance:
serializedVersion: 3
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 841324076368356447, guid: 796c0c7bfd2e89547bd866eedcc6d386,
type: 3}
propertyPath: m_LocalPosition.x
value: -34.69
objectReference: {fileID: 0}
- target: {fileID: 841324076368356447, guid: 796c0c7bfd2e89547bd866eedcc6d386,
type: 3}
propertyPath: m_LocalPosition.y

6
Assets/9_ML-Agents/Shared Assets MLA/SharedAssets/Scripts/GroundContact.cs

@ -50,8 +50,8 @@ namespace Unity.MLAgentsExamples
agent.EndEpisode();
}
if(isFoot)
AudioManager.instance.FootStepAudio(col.transform.position, col.relativeVelocity.magnitude, k_Ground);
if (isFoot)
AudioManager.instance.FootStepAudio(col.transform.position, col.relativeVelocity.magnitude, col.collider.sharedMaterial);
}
if (col.transform.CompareTag(k_Stairs))
@ -60,7 +60,7 @@ namespace Unity.MLAgentsExamples
if(isFoot)
{
agent.AddReward(0.002f);
AudioManager.instance.FootStepAudio(col.transform.position, col.relativeVelocity.magnitude, k_Stairs);
AudioManager.instance.FootStepAudio(col.transform.position, col.relativeVelocity.magnitude, col.collider.material);
}
if (isBody)
{

2
Assets/ML-Agents/Timers/Beep_timers.json

@ -1 +1 @@
{"count":1,"self":8.0935408,"total":8.2257777,"children":{"InitializeActuators":{"count":1,"self":0.0015025,"total":0.0015025,"children":null},"InitializeSensors":{"count":1,"self":0.0015030999999999998,"total":0.0015030999999999998,"children":null},"AgentSendState":{"count":100,"self":0.0045179999999999994,"total":0.0237175,"children":{"CollectObservations":{"count":20,"self":0.0035126999999999997,"total":0.0035126999999999997,"children":null},"WriteActionMask":{"count":20,"self":0,"total":0,"children":null},"RequestDecision":{"count":20,"self":0.0156868,"total":0.0156868,"children":null}}},"DecideAction":{"count":100,"self":0.098491399999999993,"total":0.09999509999999999,"children":{"RayPerceptionSensor.Perceive":{"count":20,"self":0.0015037,"total":0.0015037,"children":null}}},"AgentAct":{"count":100,"self":0.0045157999999999995,"total":0.0045157999999999995,"children":null}},"gauges":{},"metadata":{"timer_format_version":"0.1.0","start_time_seconds":"1710434073","unity_version":"2023.2.8f1","command_line_arguments":"C:\\Program Files\\Unity\\Hub\\Editor\\2023.2.8f1\\Editor\\Unity.exe -projectpath C:\\Users\\caile\\Desktop\\Projects\\24_02-Beep\\4_Unity\\Beep Final Git\\beep-final -useHub -hubIPC -cloudEnvironment production","communication_protocol_version":"1.5.0","com.unity.ml-agents_version":"2.3.0-exp.3","scene_name":"Beep","end_time_seconds":"1710434082"}}
{"count":1,"self":21.986438399999997,"total":22.2462934,"children":{"InitializeActuators":{"count":1,"self":0.0010111999999999999,"total":0.0010111999999999999,"children":null},"InitializeSensors":{"count":1,"self":0.0025353999999999997,"total":0.0025353999999999997,"children":null},"AgentSendState":{"count":815,"self":0.0125647,"total":0.032178,"children":{"CollectObservations":{"count":163,"self":0.0035077,"total":0.0035077,"children":null},"WriteActionMask":{"count":163,"self":0,"total":0,"children":null},"RequestDecision":{"count":163,"self":0.016105599999999998,"total":0.016105599999999998,"children":null}}},"DecideAction":{"count":815,"self":0.21458539999999998,"total":0.2181073,"children":{"RayPerceptionSensor.Perceive":{"count":163,"self":0.0035218999999999997,"total":0.0035218999999999997,"children":null}}},"AgentAct":{"count":815,"self":0.0050181,"total":0.0050181,"children":null}},"gauges":{},"metadata":{"timer_format_version":"0.1.0","start_time_seconds":"1710504874","unity_version":"2023.2.8f1","command_line_arguments":"C:\\Program Files\\Unity\\Hub\\Editor\\2023.2.8f1\\Editor\\Unity.exe -projectpath C:\\Users\\caile\\Desktop\\Projects\\24_02-Beep\\4_Unity\\Beep Final Git\\beep-final -useHub -hubIPC -cloudEnvironment production","communication_protocol_version":"1.5.0","com.unity.ml-agents_version":"2.3.0-exp.3","scene_name":"Beep","end_time_seconds":"1710504896"}}
Loading…
Cancel
Save