Example #1
0
    // 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);
    }
Example #2
0
    // 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)]);
    }
Example #3
0
    // 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);
    }