-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMuzakTrack.cs
55 lines (49 loc) · 1.46 KB
/
MuzakTrack.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEngine.Audio;
namespace Muzak
{
[Serializable]
public class MuzakChannel
{
[Range(0, 1)]
public float Volume;
public AudioClip Clip;
public List<MuzakSequence> Sequences = new List<MuzakSequence>();
public MuzakSequence GetSequenceAtTime(double time) => Sequences.OrderBy(s => s.StartTime).FirstOrDefault(s => s.StartTime <= time);
}
[Serializable]
public class MuzakSequence
{
public double Duration;
public AnimationCurve VolumeCurve;
public AnimationCurve StrengthCurve;
public double StartTime;
public double Offset;
public float Probability;
public MuzakSequence Clone()
{
return new MuzakSequence
{
Duration = this.Duration,
Offset = this.Offset,
StrengthCurve = this.StrengthCurve,
VolumeCurve = this.VolumeCurve,
Probability = this.Probability,
StartTime = this.StartTime
};
}
}
[CreateAssetMenu(menuName = "Muzak/Track")]
public class MuzakTrack : ScriptableObject
{
public AudioMixerGroup Mixer;
public List<MuzakChannel> Channels = new List<MuzakChannel>();
public float Duration;
public bool Loop;
public int BPM = 90;
}
}