/// <summary> /// Generates the "<paramref name="tone"/>"th note of a 3-octave C Scale /// </summary> public FeedbackChords( bool major, int tone, NoteProgression progression = NoteProgression.Scale, int octaveOffset = 0, int octaveSpan = 3) { this.major = major; IReadOnlyList <FrequencySet> scale = GetSequence(progression); //Note spans 3 octaves of CMajor scale. int notes = scale.Count * octaveSpan + 1; int note = GeneralMath.Clamp(tone, 0, notes - 1); int octaves = octaveOffset + note / scale.Count; int noteIndex = note % scale.Count; fundamentalFreq = BaseFreqLB * Math.Pow(2, octaves) * scale[noteIndex].freqRatio; Duration = major ? 0.2 : 0.4; //Place sound Forward angle = 0.0; BuildStream(); }
/// <summary> /// Collapses the tone to the nearest chromatic note /// </summary> public FeedbackChords( bool major, double lateralization, double tone, NoteProgression progression = NoteProgression.Scale, int octaveOffset = 0, int octaveSpan = 3) { this.major = major; IReadOnlyList <FrequencySet> scale = GetSequence(progression); int notes = scale.Count * octaveSpan + 1; int note = (int)Math.Floor(notes * tone); note = GeneralMath.Clamp(note, 0, notes - 1); int octaves = octaveOffset + note / scale.Count; int noteIndex = note % scale.Count; fundamentalFreq = BaseFreqLB * Math.Pow(2, octaves) * scale[noteIndex].freqRatio; Duration = major ? 0.2 : 0.4; //Angle is between -Range/2 and +Range/2 angle = Range * (lateralization - 0.5); BuildStream(); }
protected static IReadOnlyList <FrequencySet> GetSequence(NoteProgression progression) { switch (progression) { case NoteProgression.Chromatic: return(Chromatic); case NoteProgression.Scale: return(Scale); case NoteProgression.Arpeggio: return(Arpeggio); default: UnityEngine.Debug.LogError($"Unexpected NoteProgression: {progression}"); return(Scale); } }
public HarmonicComplex( int toneNum, NoteProgression progression = NoteProgression.Scale, int octaveOffset = 0, int octaveSpan = 3, double duration = 0.2) { IReadOnlyList <FrequencySet> scale = GetSequence(progression); int notes = scale.Count * octaveSpan + 1; int note = GeneralMath.Clamp(toneNum, 0, notes - 1); int octaves = octaveOffset + note / scale.Count; int noteIndex = note % scale.Count; fundamentalFreq = BaseFreqLB * Math.Pow(2, octaves) * scale[noteIndex].freqRatio; Duration = duration; angle = 0.0; BuildStream(); }