示例#1
0
 public virtual void Activate(SingleAudioItem audioItem)
 {
     inactiveAudioItems.Remove(audioItem);
     activeAudioItems.Add(audioItem);
     activeAudioObjects.Remove(audioItem.gameObject);
     LimitVoices();
 }
示例#2
0
        public virtual void Initialize(SingleAudioItem audioItem, Magicolo.AudioTools.Player player)
        {
            this.audioItem = audioItem;
            this.player    = player;

            volume = audioItem.GetVolume() * player.audioSettings.masterVolume;
        }
示例#3
0
 public virtual void Deactivate(SingleAudioItem audioItem)
 {
     activeAudioItems.Remove(audioItem);
     activeAudioObjects.Remove(audioItem.gameObject);
     inactiveAudioObjects.Add(audioItem.gameObject);
     audioItem.gameObject.transform.parent = player.transform;
     audioItem.gameObject.SetActive(false);
 }
        public virtual SingleAudioItem GetPDSingleAudioItem(SamplerInstrument instrument, int note, float velocity, object source)
        {
            if (velocity > 0)
            {
                SamplerInstrumentLayer layer     = instrument.GetLayer(note, velocity);
                SingleAudioItem        audioItem = player.generalSettings.PdPlayer.itemManager.GetSingleAudioItem(layer.Name, source);
                audioItem.audioSource.clip = layer.GetClip();
                instrument.AddAudioItem(audioItem, note, velocity);
                return(audioItem);
            }

            instrument.Stop(note);
            return(null);
        }
        public AudioItem Play(string instrumentName, int note, float velocity, object source, params AudioOption[] audioOptions)
        {
            SamplerInstrument instrument = GetInstrument(instrumentName);

            SingleAudioItem audioItem = GetSingleAudioItem(instrument, note, velocity, source);

            if (audioItem == null)
            {
                return(instrument);
            }

            audioItem.Play(audioOptions);
            return(audioItem);
        }
        public AudioItem GetAudioItem(string soundName, GameObject source, params AudioOption[] audioOptions)
        {
            AudioInfo   audioInfo   = infoManager.GetAudioInfo(soundName);
            AudioSource audioSource = GetAudioSource(audioInfo, source, audioOptions);

            GameObject      gameObject      = audioSource.gameObject;
            CoroutineHolder coroutineHolder = gameObject.GetOrAddComponent <CoroutineHolder>();

            GainManager gainManager = gameObject.GetOrAddComponent <GainManager>();

            idCounter += 1;
            SingleAudioItem audioItem = new SingleAudioItem(soundName, idCounter, audioSource, audioInfo, gameObject, coroutineHolder, gainManager, this, audioPlayer);

            gainManager.Initialize(audioItem, audioPlayer);
            audioItem.Update();
            player.metronome.Subscribe(audioItem);
            inactiveAudioItems.Add(audioItem);

            return(audioItem);
        }
        public AudioItem Play(string moduleName, string instrumentName, int note, float velocity, object source, params AudioOption[] audioOptions)
        {
            PDModule          module     = player.generalSettings.PdPlayer.itemManager.GetModule(moduleName, source);
            SamplerInstrument instrument = GetInstrument(instrumentName);
            SingleAudioItem   audioItem  = GetPDSingleAudioItem(instrument, note, velocity, source);

            if (audioItem == null)
            {
                return(instrument);
            }

            if (module.State != AudioStates.Playing)
            {
                module.Initialize();
                module.Play();
            }

            audioItem.Play(audioOptions);
            module.AddAudioItem(audioItem);

            return(audioItem);
        }