// Get all the tone names from scale public List <string> GetToneNames(MusicTone baseTone, ToneRange toneRange) { List <string> toneNames = GetToneNames(baseTone, toneRange.MinOctave, toneRange.ToneCount); for (int i = 0; i < toneNames.Count; i++) { if (!toneRange.IsToneInRange(toneNames[i])) { toneNames.RemoveAt(i); i--; } } return(toneNames); }
// returns merged tone name and octave public string GetRandomTone(ToneRange toneRange, MusicTone baseTone) { List <string> toneNames = GetToneNames(baseTone, toneRange); return(toneNames[Random.Range(0, toneNames.Count)]); }
// play random tone from given variables - scale and range public void PlayTone(string instrument, ToneDuration duration, MusicTone baseTone, ToneRange toneRange, string scale) { string toneString = MusicScale.MusicScales[scale].GetRandomTone(toneRange, baseTone); MusicTone tone; int octave; MusicUtilities.StringToToneOctave(toneString, out tone, out octave); PlayTone(instrument, duration, tone, octave); }