Esempio n. 1
0
        /// <summary>
        /// Check if the channel is one the local player is listening to
        /// </summary>
        /// <param name="channel"></param>
        /// <param name="recipient"></param>
        /// <returns></returns>
        private RemoteChannel?IsChannelToLocalPlayer(ChannelBitField channel, ushort recipient)
        {
            var options = new PlaybackOptions(channel.IsPositional, channel.AmplitudeMultiplier, channel.Priority);

            if (channel.Type == ChannelType.Player)
            {
                //If the channel is not to the local player we don't care about it
                if (recipient != _localId)
                {
                    return(null);
                }

                return(new RemoteChannel(_localName, ChannelType.Player, options));
            }
            else if (channel.Type == ChannelType.Room)
            {
                //This only returns the name for rooms we're currently listening to
                var roomName = _localListeningRooms.Name(recipient);
                if (roomName == null)
                {
                    return(null);
                }

                return(new RemoteChannel(roomName, ChannelType.Room, options));
            }
            else
            {
                //ncrunch: no coverage start (Justification: Impossible branch)
                throw Log.CreatePossibleBugException(string.Format("Unknown ChannelType variant '{0}'", channel.Type), "1884B2CF-35AA-46BD-93C7-80F14D8D25D8");
                //ncrunch: no coverage end
            }
        }
Esempio n. 2
0
        public SpriteBase( SpriteBase o )
        {
            this.m_vecPos = o.Position;
            this.m_vecOrigin = o.m_vecOrigin;
            this.m_playbackOptions = o.AnimationOptions;

            this.m_texBase = o.m_texBase;

            this.m_fScale = o.m_fScale;
            this.m_fRotation = o.m_fRotation;

            this.m_iCurrFrame = o.m_iCurrFrame;
            this.m_iMaxFrames = o.m_iMaxFrames;
            this.m_iFrameWidth = o.m_iFrameWidth;

            this.m_fFrameTime = o.m_fFrameTime;
            this.m_fTimeAccumulator = o.m_fTimeAccumulator;

            this.m_frameRect = o.m_frameRect;

            this.m_AABBs = o.m_AABBs;

            this.basicEffect = o.basicEffect;
            this.vertices = o.vertices;

            this.m_bDisplayAABBs = o.m_bDisplayAABBs;
        }
Esempio n. 3
0
        public Task AdjustPlaybackAsync(IPreparedEffect prepared, PlaybackOptions options)
        {
            PreparedSource preparedSource = (PreparedSource)prepared;

            AdjustEmitter(preparedSource.Emitter, options);
            return(Task.CompletedTask);
        }
Esempio n. 4
0
 /// <summary>
 /// Free up memory from announcements
 /// </summary>
 private void UnloadAnnouncements()
 {
     while (announcementItems.Count > 0)
     {
         UserControl announcement = announcementItems.ElementAt(0);
         if (announcement is Welcome)
         {
             Welcome welcome = announcement as Welcome;
             announcementItems.Remove(welcome);
             welcome.UserControl_Unloaded(null, null);
             welcome.Unloaded -= welcome.UserControl_Unloaded;
         }
         else if (announcement is PlaybackMode)
         {
             PlaybackMode playbackMode = announcement as PlaybackMode;
             announcementItems.Remove(playbackMode);
             playbackMode.UserControl_Unloaded(null, null);
             playbackMode.Unloaded -= playbackMode.UserControl_Unloaded;
         }
         else if (announcement is ThemeMode)
         {
             ThemeMode themeMode = announcement as ThemeMode;
             announcementItems.Remove(themeMode);
             themeMode.UserControl_Unloaded(null, null);
             themeMode.Unloaded -= themeMode.UserControl_Unloaded;
         }
         else if (announcement is TvMode)
         {
             TvMode tvMode = announcement as TvMode;
             announcementItems.Remove(tvMode);
             tvMode.UserControl_Unloaded(null, null);
             tvMode.Unloaded -= tvMode.UserControl_Unloaded;
         }
         else if (announcement is PlaybackOptions)
         {
             PlaybackOptions playbackOptions = announcement as PlaybackOptions;
             announcementItems.Remove(playbackOptions);
             playbackOptions.UserControl_Unloaded(null, null);
             playbackOptions.Unloaded -= playbackOptions.UserControl_Unloaded;
         }
         else if (announcement is Shuffle)
         {
             Shuffle shuffle = announcement as Shuffle;
             announcementItems.Remove(shuffle);
             shuffle.UserControl_Unloaded(null, null);
             shuffle.Unloaded -= shuffle.UserControl_Unloaded;
         }
         else if (announcement is NewReleases)
         {
             NewReleases newReleases = announcement as NewReleases;
             announcementItems.Remove(newReleases);
             newReleases.UserControl_Unloaded(null, null);
             newReleases.Unloaded -= newReleases.UserControl_Unloaded;
         }
     }
 }
Esempio n. 5
0
        /// <summary>
        /// Create a new voice packet
        /// </summary>
        /// <param name="senderPlayerId"></param>
        /// <param name="priority"></param>
        /// <param name="ampMul"></param>
        /// <param name="positional"></param>
        /// <param name="encodedAudioFrame">The encoded audio data. The data will be copied out of this array as soon as it is passed to the decoder
        /// pipeline (i.e. you can re-use this array right away)</param>
        /// <param name="sequence"></param>
        /// <param name="channels">List of all channels this voice packet is being spoken on. Data will be copied out of the list as soon as it is
        /// passed to the decoder pipeline (i.e. you can re-use this array right away)</param>
        public VoicePacket(string senderPlayerId, ChannelPriority priority, float ampMul, bool positional, ArraySegment <byte> encodedAudioFrame, uint sequence, [CanBeNull] List <RemoteChannel> channels = null)
        {
            _options = new PlaybackOptions(positional, ampMul, priority);

            SenderPlayerId    = senderPlayerId;
            EncodedAudioFrame = encodedAudioFrame;
            SequenceNumber    = sequence;

            Channels = channels;
        }
Esempio n. 6
0
        internal RemoteChannel([NotNull] string targetName, ChannelType type, PlaybackOptions options)
        {
            if (targetName == null)
            {
                throw new ArgumentNullException("targetName");
            }

            _target  = targetName;
            _type    = type;
            _options = options;
        }
Esempio n. 7
0
 private void worker_DoWork(object sender, DoWorkEventArgs e)
 {
     foreach (TaskInfo taskInfo in this.tasks)
     {
         TapeFile tapeFile = new TapeFile(taskInfo.File.FullName);
         this.currentTask = taskInfo;
         this.currentTape = tapeFile;
         PlaybackOptions playbackOptions = new PlaybackOptions();
         playbackOptions.Symbols   = new List <string>((IEnumerable <string>) this.instruments.Keys).ToArray();
         playbackOptions.Trades    = this.settings.Trades;
         playbackOptions.Quotes    = this.settings.Quotes;
         playbackOptions.BeginTime = this.settings.From;
         playbackOptions.EndTime   = this.settings.To;
         this.OnCurrentTaskBegin();
         if (this.worker.CancellationPending)
         {
             e.Cancel = true;
             this.OnCurrentTaskDone((Exception)null);
         }
         else
         {
             Exception error = (Exception)null;
             try
             {
                 this.currentSkipped = false;
                 this.currentWriter  = !this.settings.Advanced.WriteDataAsync ? (DataWriter) new SyncDataWriter() : (DataWriter) new AsyncDataWriter(this.settings.Advanced.MaxBufferSize);
                 this.currentWriter.BeginWrite();
                 tapeFile.Play((IMessageReceiver)this, playbackOptions);
             }
             catch (Exception ex)
             {
                 error = ex;
             }
             finally
             {
                 try
                 {
                     this.currentWriter.EndWrite();
                 }
                 catch (Exception ex)
                 {
                     error = ex;
                 }
                 this.OnCurrentTaskDone(error);
             }
         }
     }
 }
Esempio n. 8
0
        private AudioNodeEmitter GetEmitter(PlaybackOptions options)
        {
            if (options.Position == null)
            {
                return(null);
            }

            var shape = AudioNodeEmitterShape.CreateOmnidirectional();
            var decay = AudioNodeEmitterDecayModel.CreateNatural(0.1, 1.0, 10, 100);

            var emitter = new AudioNodeEmitter(shape, decay, AudioNodeEmitterSettings.None);

            emitter.SpatialAudioModel = SpatialAudioModel.ObjectBased;
            AdjustEmitter(emitter, options);
            return(emitter);
        }
Esempio n. 9
0
 // Sets PlaybackOptions for currently selected animation
 public void SetPlaybackOptions( PlaybackOptions playbackOptions )
 {
     if (m_SpriteAnims.ContainsKey(m_strCurrAnim))
     {
         m_SpriteAnims[m_strCurrAnim].AnimationOptions = playbackOptions;
     }
 }
Esempio n. 10
0
        public SpriteBase(Vector2 pos, int frameWidth, float frameRate, GraphicsDevice pDevice )
        {
            m_playbackOptions = PlaybackOptions.None;

            m_vecPos = pos;
            m_fScale = 1.0f;
            m_fRotation = 0.0f;

            m_iCurrFrame = 0;
            m_iFrameWidth = frameWidth;

            m_fFrameTime = (1.0f / frameRate);

            m_AABBs = new List<Rectangle>();

            m_bDisplayAABBs = false;

            // Set rendering of debug BBs
            vertices = new VertexPositionColor[4];
            basicEffect = new BasicEffect(pDevice);
            basicEffect.VertexColorEnabled = true;
            basicEffect.Projection = Matrix.CreateOrthographicOffCenter(0, pDevice.Viewport.Width, pDevice.Viewport.Height, 0, 0, 1);
        }
Esempio n. 11
0
        public Task <IPreparedEffect> PrepareEffectAsync(EnvironmentElement element, string descriptor, PlaybackOptions options)
        {
            if (element is null)
            {
                throw new ArgumentNullException(nameof(element));
            }

            LightingComponent lighting = element.Lighting;

            if (lighting == null)
            {
                return(Task.FromResult <IPreparedEffect> (null));
            }

            return(Task.FromResult <IPreparedEffect> (null));
        }
Esempio n. 12
0
        } //END onGetAudioClipFailed



        //---------------------------------//
        private void SetupEventTriggers()
        //---------------------------------//
        {
            if( showDebug ) { Debug.Log( "SetupEventTriggers() playbackOptions = " + playbackOptions ); }

            //If there isn't a collider attached, and if we can't find the component attached to this gameObject, then try to use the BlockButton,
            //and if we can't find the BlockButton, change the playbackOptions to "Play Entire Clip"
            if( playbackOptions == PlaybackOptions.EndWhenGazeExitsCollider )
            {
                if( showDebug ) { Debug.Log( "BlockAudio.cs SetupOnExitEventTrigger() inside playBackOptions = 'End When Gaze Exits Collider'" ); }

                foundEventTrigger = false;
                foundEventTriggerOnBlockButtonCollider = false;
                List<Block> blockButtons = blockGroup.GetBlocks( BlockType.Button );

                if( ( eventTriggers == null || ( eventTriggers != null && eventTriggers.Count == 0 ) ) &&
                    blockGroup != null && blockButtons != null && blockButtons.Count > 0 )
                {
                    foreach( Block blockButton in blockButtons )
                    {
                        if( (blockButton as BlockButton).collider3D != null &&
                            (blockButton as BlockButton).collider3D.GetComponent<EventTrigger>() != null )
                        {
                            eventTriggers.Add( ( blockButton as BlockButton ).collider3D.GetComponent<EventTrigger>() );
                            foundEventTrigger = true;
                            foundEventTriggerOnBlockButtonCollider = true;
                        }
                    }
                }
                else if( eventTriggers != null )
                {
                    foundEventTrigger = true;
                }

                //If we didn't find the collider, change the playbackOptions to "Play Entire Clip"
                if( !foundEventTrigger )
                {
                    if( showDebug ) { Debug.Log( "BlockAudio.cs SetupOnExitEventTrigger() unable to find EventTrigger, settings playbackOptions = 'Play Entire Clip'" ); }
                    playbackOptions = PlaybackOptions.PlayEntireClip;
                }
                else
                {
                    if( showDebug ) { Debug.Log( "BlockAudio.cs SetupOnExitEventTrigger() found the EventTrigger we'll be attaching the PointerExit event to" ); }
                }

                //Setup the EventTrigger OnExit event to call Stop() or FadeOut() on PointerExit, and optionally Play or FadeIn() on PointerEnter
                if( eventTriggers != null )
                {
                    foreach( EventTrigger eventTrigger in eventTriggers )
                    {
                        EventTriggerHelper.AddEventTriggerListener( eventTrigger, EventTriggerType.PointerExit, BlockAudio_OnPointerExit );
                    }

                    if( fadeInOnReEnterTrigger )
                    {
                        foreach( EventTrigger eventTrigger in eventTriggers )
                        {
                            EventTriggerHelper.AddEventTriggerListener( eventTrigger, EventTriggerType.PointerEnter, BlockAudio_OnPointerEnter );
                        }
                    }
                }
            }
            
            else if( playbackOptions == PlaybackOptions.PlayEntireClip )
            {
                foundEventTrigger = false;
                foundEventTriggerOnBlockButtonCollider = false;
                List<Block> blockButtons = blockGroup.GetBlocks( BlockType.Button );

                if( showDebug ) { Debug.Log( "BlockAudio.cs SetupOnExitEventTrigger() 'Play Entire Clip' set, about to look through BlockButtons for this block and attach to their collider events... blockButtons = " + blockButtons + ", blockButtonss.Count = " + blockButtons.Count ); }

                if( ( eventTriggers == null || ( eventTriggers != null && eventTriggers.Count == 0 ) ) &&
                    blockGroup != null && blockButtons != null && blockButtons.Count > 0 )
                {
                    foreach( Block blockButton in blockButtons )
                    {
                        if( ( blockButton as BlockButton ).collider3D != null &&
                            ( blockButton as BlockButton ).collider3D.GetComponent<EventTrigger>() != null )
                        {
                            eventTriggers.Add( ( blockButton as BlockButton ).collider3D.GetComponent<EventTrigger>() );
                            foundEventTrigger = true;
                            foundEventTriggerOnBlockButtonCollider = true;
                        }
                    }
                }
                else if( eventTriggers != null )
                {
                    foundEventTrigger = true;
                }
            }
            
        } //END SetupEventTriggers
Esempio n. 13
0
        private void AdjustEmitter(AudioNodeEmitter emitter, PlaybackOptions options)
        {
            var position = options.Position;

            emitter.Position = new System.Numerics.Vector3(position.X, position.Y, position.Z);
        }
Esempio n. 14
0
        public async Task <IPreparedEffect> PrepareEffectAsync(EnvironmentElement element, string descriptor, PlaybackOptions options)
        {
            CreateAudioFileInputNodeResult nodeResult;

            AudioSample sample = await this.sync.GetElementByIdAsync <AudioSample> (descriptor).ConfigureAwait(false);

            StorageFile file = await GetFileAsync(sample).ConfigureAwait(false);

            AudioNodeEmitter emitter = null;            // GetEmitter (options);

            if (emitter != null)
            {
                nodeResult = await graph.CreateFileInputNodeAsync(file, emitter).ConfigureAwait(false);
            }
            else
            {
                nodeResult = await graph.CreateFileInputNodeAsync(file).ConfigureAwait(false);
            }

            var node     = nodeResult.FileInputNode;
            var prepared = new PreparedSource(node, emitter)
            {
                Duration = nodeResult.FileInputNode.Duration
            };

            /*
             * node.FileCompleted += (o, e) => {
             *      OnElementFinished (new PreparedElementEventArgs (prepared));
             * };*/

            return(prepared);
        }