THIS IS WORK IN PROGRESS!!!
todo:
– make c tunes samples low mid hi + plick snd in Ableton!
– make each voice randomly change pitch in chord step
– control main mixer effects > lowpass / reverb / delay?
– reverb room in Unity
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.Audio; public class audio_controller : MonoBehaviour { public AudioSource as_low; public AudioSource as_mid; public AudioSource as_hi; public AudioSource as_plick; public AudioClip plick_ac; public AudioMixer mixer; /* note = 0; // C note = 1; // CIS note = 2; // D note = 3; // DIS note = 4; // E note = 5; // F note = 6; // FIS note = 7; // G note = 8; // GIS note = 9; // A note = 10; // AIS note = 11; // H */ public int[] halftone_steps = {0,5,7}; int stepped_pitch = 0; [Range(-.5f,.5f)] public float low_pitch_off = 0f; [Range(-.5f,.5f)] public float mid_pitch_off = 0f; [Range(-.5f,.5f)] public float hi_pitch_off = 0f; public float plick_pitch_off = 0f; [Range(0,1f)] public float pitch_offset = 0f; [Range(-7,7)] public int main_transpose = 0; // transpose in semitones [Range(100f,11000f)] public float main_cutoff = 1000f; // Start is called before the first frame update void Start() { Invoke("playPlick",1f); } // Update is called once per frame void Update() { mixer.SetFloat("sum_cutoff",main_cutoff); int arr_id = (int)(pitch_offset*(halftone_steps.Length -1)); stepped_pitch = halftone_steps[arr_id]; as_hi.pitch = Mathf.Pow(2, (stepped_pitch+main_transpose)/12.0f) + hi_pitch_off; as_mid.pitch = Mathf.Pow(2, (stepped_pitch+main_transpose)/12.0f) + mid_pitch_off; as_low.pitch = Mathf.Pow(2, (stepped_pitch+main_transpose)/12.0f) + low_pitch_off; } void playPlick(){ //audioSource.PlayOneShot(impact, 0.7F); int rhts = (int)Random.Range(0,halftone_steps.Length); as_plick.pitch = Mathf.Pow(2, ( halftone_steps[rhts]+main_transpose)/12.0f) + plick_pitch_off; as_plick.PlayOneShot(plick_ac,.9f); Invoke("playPlick",.33f); } }