Esempio n. 1
0
        public virtual void Initialize(PDSingleAudioItem audioItem, PDPlayer pdPlayer)
        {
            base.Initialize(audioItem, pdPlayer);

            this.pdPlayer = pdPlayer;

            index = GetUnusedIndex();
            if (index == -1)
            {
                Debug.LogWarning(string.Format("No available voice for audio item {0} of id {1}.", audioItem.Name, audioItem.GetID()));
                audioItem.StopImmediate();
                return;
            }
            indexAudioItem[index] = audioItem;

            if (soundNameVoice.ContainsKey(audioItem.Name))
            {
                voice = soundNameVoice[audioItem.Name];
            }
            else
            {
                voice = voiceCounter;
                soundNameVoice[audioItem.Name] = voice;
                voiceCounter += 1;
                voiceCounter %= pdPlayer.audioSettings.maxVoices;
            }

            offset = index * pdPlayer.bridge.bufferSize * 2;
        }
Esempio n. 2
0
        public AudioItem GetAudioItem(string moduleName, 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>();

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

            idCounter += 1;
            PDSingleAudioItem audioItem = new PDSingleAudioItem(moduleName + "_" + soundName, idCounter, audioSource, audioInfo, gameObject, coroutineHolder, gainManager, this, pdPlayer);

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

            return(audioItem);
        }