Beispiel #1
0
    void Start()
    {
        seed = new Seed();
        bpm  = Meta_MusicGenerator.GetBPM(seed);
        secondsPerQuarter = Meta_MusicGenerator.GetDurationOfOneBeat(bpm);

        patternDistributed = true;

        rhythmObject = Instantiate(instrumentPrefab, transform.position, Quaternion.identity);
        rhythm       = rhythmObject.GetComponent <Instrument>();
        rhythm.InitInstrument(Meta_MusicGenerator.EInstrument.bassDrum, Meta_MusicGenerator.EInstrumenType.ePercussion, Meta_MusicGenerator.EKey.A, Meta_MusicGenerator.EMode.minor, bpm);
    }
    public void InitInstrument(Meta_MusicGenerator.EInstrument _instrument, Meta_MusicGenerator.EInstrumenType _type, Meta_MusicGenerator.EKey _key, Meta_MusicGenerator.EMode _mode, int _bpm)
    {
        play = false;

        audioClips = Meta_MusicGenerator.GetScaleAudio(_key, _mode, _instrument);
        instrument = _instrument;
        type       = _type;
        key        = _key;
        mode       = _mode;
        bpm        = _bpm;

        secondsPerQuarter = Meta_MusicGenerator.GetDurationOfOneBeat(bpm);
        audioSources      = new AudioSource[5]; //5 should be enough; there will rarely be more notes playing on top of each other
        for (int i = 0; i < audioSources.Length; i++)
        {
            audioSources[i] = gameObject.AddComponent <AudioSource>();
        }
    }