Large diffs are not rendered by default.

Large diffs are not rendered by default.

@@ -0,0 +1,62 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: da86896963196479e85326b2fc70af49, type: 3}
m_Name: SoundSet_A
m_EditorClassIdentifier:
m_audioCategories:
- m_name: Rhythm
m_audioChannelGroups:
- m_name: Kick
m_stack: 0
m_audioChannels:
- m_name: Variation_1
m_audioClip: {fileID: 8300000, guid: 6f8a4937d3c034d27b6258e4bb20dea0, type: 3}
- m_name: Variation_2
m_audioClip: {fileID: 8300000, guid: 0e0b88bdf79d249c5b3ea69be124de08, type: 3}
- m_name: Variation_3
m_audioClip: {fileID: 8300000, guid: a6677ddbf4e4b4ad8a5a0072ee4aceba, type: 3}
- m_name: Snare
m_stack: 0
m_audioChannels:
- m_name: Variation_1
m_audioClip: {fileID: 8300000, guid: e1a09df9ff38c46238016ad6131d7dc0, type: 3}
- m_name: Variation_2
m_audioClip: {fileID: 8300000, guid: f003beb4f2ce24c3ab8b96dbca8598da, type: 3}
- m_name: Variation_3
m_audioClip: {fileID: 8300000, guid: d6b624839d6b24e0394a03b4d2da87d9, type: 3}
- m_name: Variation_4
m_audioClip: {fileID: 8300000, guid: 2c2ae4515c5ee4d7aba86db7b6807437, type: 3}
- m_name: Hi-Hat
m_stack: 1
m_audioChannels:
- m_name: Variation_1
m_audioClip: {fileID: 8300000, guid: 8a7bf39837de74321a1b4d9fc43b6733, type: 3}
- m_name: Variation_2
m_audioClip: {fileID: 8300000, guid: aa0b4fecf754b462b837e331428bbf4b, type: 3}
- m_name: Variation_3
m_audioClip: {fileID: 8300000, guid: 9676320bf14de433898819c54d8930e0, type: 3}
- m_name: Variation_4
m_audioClip: {fileID: 8300000, guid: 364b74ca907db4cf9bc1d23951d8b01e, type: 3}
- m_name: Percussion
m_stack: 1
m_audioChannels:
- m_name: Variation_1
m_audioClip: {fileID: 8300000, guid: c3fc7cda40bc94d92b103587e4b79831, type: 3}
- m_name: Variation_2
m_audioClip: {fileID: 8300000, guid: ff8fb49e0d38245948ac371765dc5a9d, type: 3}
- m_name: Variation_3
m_audioClip: {fileID: 8300000, guid: c712207edc6534e69968d292a2901121, type: 3}
- m_name: Variation_4
m_audioClip: {fileID: 8300000, guid: 5f1d69ed71ec84447965647578fdd541, type: 3}
- m_name: Harmony
m_audioChannelGroups: []
- m_name: Melody
m_audioChannelGroups: []

Large diffs are not rendered by default.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

Large diffs are not rendered by default.

@@ -15,29 +15,21 @@ public enum SyncType {Bar, Beat, SubBeat};
* Each value represents one AudioMixerGroup
*/
public enum AudioMixerExposedParams {
volume_rhythm_0,
volume_rhythm_1,
volume_rhythm_2,
volume_rhythm_3,
volume_rhythm_4,
volume_rhythm_5,
volume_rhythm_6,
volume_rhythm_7,
volume_harmony_0,
volume_harmony_1,
volume_harmony_2,
volume_harmony_3,
volume_harmony_4,
volume_harmony_5,
volume_harmony_6,
volume_harmony_7,
volume_melody_0,
volume_melody_1,
volume_melody_2,
volume_melody_3,
volume_melody_4,
volume_melody_5,
volume_melody_6,
volume_melody_7,
Kick_Variation_1,
Kick_Variation_2,
Kick_Variation_3,
Kick_Variation_4,
Snare_Variation_1,
Snare_Variation_2,
Snare_Variation_3,
Snare_Variation_4,
HiHat_Variation_1,
HiHat_Variation_2,
HiHat_Variation_3,
HiHat_Variation_4,
Percussion_Variation_1,
Percussion_Variation_2,
Percussion_Variation_3,
Percussion_Variation_4,
};
}
@@ -8,6 +8,8 @@ public class AudioManager : MonoBehaviour {

public AudioMixer m_audioMixer;

public SoundSet m_soundSet;

public AudioClip m_masterAudioClip;
public int m_bpm = 120;
[Range(1,16)]
@@ -42,12 +44,14 @@ public class AudioManager : MonoBehaviour {
private float m_subBeatTimer = 0;
private float m_prevSubBeatTimer = 1.0f;

private float m_masterTimer = 0;

// Use this for initialization
void Awake () {
// log error if there is no masteraudioclip
if (m_masterAudioClip == null){
Debug.LogError("Set MasterAudioClip in AudioManager object!");
Destroy(this);
//Destroy(this);
} else {
if (m_audioMixer == null){
Debug.LogError("No AudioMixer attached");
@@ -64,6 +68,8 @@ public class AudioManager : MonoBehaviour {
// Debug.Log(GetTimePerBar());
// Debug.Log(GetTimeAtBar(1));
// Debug.Log(GetSamplesPerBar());

Init();
}
}

@@ -96,7 +102,7 @@ public class AudioManager : MonoBehaviour {
m_prevSubBeatTimer = m_subBeatTimer;

//SyncToAudioSource(m_audioSource, m_audioSources);
//SyncToAudioSource();
SyncToAudioSource();

// Debug.Log("timeSamples: " + m_audioSource.timeSamples);
} else {
@@ -108,6 +114,45 @@ public class AudioManager : MonoBehaviour {
}
}


#region init

private void Init(){
if (m_soundSet == null){
Debug.LogError("no soundset selected");
} else {
// load audio clips from soundset
//Debug.Log(transform.childCount + " == " + m_soundSet.m_audioCategories.Length + " ?");
//if (transform.childCount == m_soundSet.m_audioCategories.Length){
for (int i = 0; i < m_soundSet.m_audioCategories.Length; i++){
SoundSet.AudioCategory category = m_soundSet.m_audioCategories[i];

GameObject gameObjectCategory = transform.GetChild(i).gameObject;

//if (gameObjectCategory.transform.childCount == category.m_audioChannelGroups.Length){
for (int j = 0; j < category.m_audioChannelGroups.Length; j++){
SoundSet.AudioChannelGroup channelGroup = category.m_audioChannelGroups[j];

GameObject gameObjectChannelGroup = gameObjectCategory.transform.GetChild(j).gameObject;

//if (gameObjectChannelGroup.transform.childCount == channelGroup.m_audioChannels.Length){
for (int k = 0; k < channelGroup.m_audioChannels.Length; k++){
SoundSet.AudioChannel channel = channelGroup.m_audioChannels[k];

GameObject gameObjectChannel = gameObjectChannelGroup.transform.GetChild(k).gameObject;

gameObjectChannel.GetComponent<AudioSource>().clip = channel.m_audioClip;
}

}

}
}
}

#endregion


#region private functions

void PlayAll(){
@@ -149,7 +194,7 @@ public class AudioManager : MonoBehaviour {

// gets called on every subbeat / movement unit
void SubBeat(){
SyncToAudioSource();
//SyncToAudioSource();

m_currentSubBeat = GetCurrentSubBeat();

@@ -42,22 +42,24 @@ public class AudioSourceSync : MonoBehaviour {
}

public void SyncToMaster(AudioManager _reference){
if (m_isLoop){

if (m_manualLoopArea){
// manual loop area
SetTimeSamples((_reference.GetCurrentTimeSamples() % (m_loopLength * _reference.GetSamplesPerBar())) +
m_loopOffset * _reference.GetSamplesPerBar());
} else {
// automatically loop through entire track
SetTimeSamples(_reference.GetCurrentTimeSamples() % m_audioSource.clip.samples);
}
if (m_audioSource.clip != null){
if (m_isLoop){

if (m_manualLoopArea){
// manual loop area
SetTimeSamples((_reference.GetCurrentTimeSamples() % (m_loopLength * _reference.GetSamplesPerBar())) +
m_loopOffset * _reference.GetSamplesPerBar());
} else {
// automatically loop through entire track
SetTimeSamples(Mathf.Clamp((_reference.GetCurrentTimeSamples() % m_audioSource.clip.samples), 0, m_audioSource.clip.samples));
}

} else {

// simple sync
SetTimeSamples(_reference.GetCurrentTimeSamples());
} else {
// simple sync
SetTimeSamples(_reference.GetCurrentTimeSamples());

}
}
}

@@ -59,6 +59,7 @@ public class Trigger : MonoBehaviour {
* This will send a trigger event to every target this trigger is attached to
*/
protected virtual void BroadcastTrigger(){
//Debug.Log("Trigger");
if (OnTrigger != null) {
OnTrigger(this);
}
@@ -28,7 +28,7 @@ public class TriggerTarget : MonoBehaviour {
* Is called every time a trigger in m_triggers is triggered.
*/
protected virtual void Action(Trigger _reference){

//Debug.Log("Triggered!");
}

protected virtual void OnDrawGizmos(){
@@ -16,8 +16,12 @@ public class TriggerGroup : Trigger {

m_lineRenderer = GetComponent<LineRenderer>();

if (m_lookForTriggersInChildren){
UpdateTriggers();
}

// subscribe to trigger events
if (Application.isPlaying){
if (m_triggers.Length > 0){
foreach (Trigger trigger in m_triggers){
trigger.OnTrigger += OnReceiveTrigger;
}
@@ -2,32 +2,93 @@
using UnityEngine.Audio;
using System.Collections;

[CreateAssetMenu (menuName = "Data/SoundSet", fileName = "SoundSet", order = 100)]
[CreateAssetMenu (menuName = "SoundSet", fileName = "SoundSet", order = 100)]
public class SoundSet : ScriptableObject {

public AudioChannelGroup[] m_audioChannelGroups;
const int VARIATIONS = 4;

public class AudioChannelGroup{
public AudioCategory[] m_audioCategories;

public SoundSet(){
m_audioCategories = new AudioCategory[3]{
new AudioCategory("Rhythm",
"Kick", "Snare", "Hi-Hat", "Percussion"),
new AudioCategory("Harmony"),
new AudioCategory("Melody"),
};
}


#region public functions

public string GetChannelName(){
return "";
}

public string[] GetChannelNames(){
return new string[1]{""};
}

#endregion


#region structs

[System.Serializable]
public struct AudioCategory{
public string m_name;
public AudioChannelGroup[] m_audioChannelGroups;

public AudioChannel[] m_audioChannels;
public AudioCategory(string categoryName, params string[] channelGroupNames){
m_name = categoryName;
m_audioChannelGroups = new AudioChannelGroup[channelGroupNames.Length];

public AudioChannelGroup(){

for (int i = 0; i < channelGroupNames.Length; i++){

string[] channelNames = new string[VARIATIONS];
for (int n = 0; n < VARIATIONS; n++){
channelNames[n] = "Variation_" + (n+1);
}

m_audioChannelGroups[i] = new AudioChannelGroup(channelGroupNames[i], false, channelNames);
}
}
}

public AudioChannelGroup(string name){
m_name = name;
[System.Serializable]
public struct AudioChannelGroup{
public string m_name;

public bool m_stack;

public AudioChannel[] m_audioChannels;

public AudioChannelGroup(string groupName, bool stack, params string[] channelNames){
m_name = groupName;

m_stack = stack;

m_audioChannels = new AudioChannel[channelNames.Length];

for (int i = 0; i < channelNames.Length; i++){
m_audioChannels[i] = new AudioChannel(channelNames[i]);
}
}

}

[System.Serializable]
public struct AudioChannel{
public string m_name;

public AudioClip m_audioClip;

public AudioChannel(string name){
m_name = name;
m_audioClip = null;
}
}

#endregion

}