Esempio n. 1
0
 public MixEntryTable(int mixId, string input, bool isRoot, MixType type)
 {
     MixId  = mixId;
     Input  = input;
     IsRoot = isRoot;
     Type   = type;
 }
Esempio n. 2
0
        public static bool TryParse(string text, out MixType result)
        {
            if (text.Match(Keywords.w_MIXED))
            {
                result = MixType.MIX1;
            }
            else if (text.Match(Keywords.w_2COMP))
            {
                result = MixType.MIX2;
            }
            else if (text.Match(Keywords.w_FIFO))
            {
                result = MixType.FIFO;
            }
            else if (text.Match(Keywords.w_LIFO))
            {
                result = MixType.LIFO;
            }
            else
            {
                result = (MixType)(-1);
                return(false);
            }

            return(true);
        }
Esempio n. 3
0
 public StringMixEvaluator(PropertyInfo targetProperty, string target, StringEvalType evalType, MixType type)
 {
     TargetProperty = targetProperty;
     Target         = target;
     EvalType       = evalType;
     MixType        = type;
 }
 public StringMixEvaluator(PropertyInfo targetProperty, string target, StringEvalType evalType, MixType type)
 {
     TargetProperty = targetProperty;
     Target = target;
     EvalType = evalType;
     MixType = type;
 }
Esempio n. 5
0
 public RangeMixEvaluator(PropertyInfo targetProperty, int target, RangeEvalType evalType, MixType type)
 {
     TargetProperty = targetProperty;
     Target         = target;
     EvalType       = evalType;
     MixType        = type;
 }
Esempio n. 6
0
 public NumericMixEvaluator(PropertyInfo targetProperty, T target, NumericEvalType evalType, MixType type)
 {
     TargetProperty = targetProperty;
     Target         = target;
     EvalType       = evalType;
     MixType        = type;
 }
Esempio n. 7
0
 public MixEntryTable(int mixId, string input, bool isRoot, MixType type)
 {
     MixId = mixId;
     Input = input;
     IsRoot = isRoot;
     Type = type;
 }
Esempio n. 8
0
        public static IMixEvaluator NestedMixEntryModelToMixEvaluator(MixType mixType, List <IMixEvaluator> mixes)
        {
            NestedEvalType nestedEvalType = NestedEvalType.Unknown;

            switch (mixType)
            {
            case MixType.And:
                nestedEvalType = NestedEvalType.All;
                break;

            case MixType.Or:
                nestedEvalType = NestedEvalType.Any;
                break;

            case MixType.Not:
                nestedEvalType = NestedEvalType.None;
                break;

            default:
                DebugHelper.Alert(new CallerInfo(), "Unexpected NESTED_TYPE MixType {0}", mixType);
                break;
            }

            return(new NestedMixEvaluator(mixes, nestedEvalType, mixType));
        }
 public RangeMixEvaluator(PropertyInfo targetProperty, int target, RangeEvalType evalType, MixType type)
 {
     TargetProperty = targetProperty;
     Target = target;
     EvalType = evalType;
     MixType = type;
 }
Esempio n. 10
0
 public void Copy(MediaType other)
 {
     BackendType  = other.BackendType;
     InternalName = other.InternalName;
     MassFration  = other.MassFration;
     Mix          = other.Mix;
 }
Esempio n. 11
0
        public static IMixEvaluator RangeMixEntryModelToMixEvaluator(MixType mixType, string input)
        {
            PropertyInfo info = null;

            switch (mixType & MixType.SUBTYPE_MASK)
            {
            case MixType.LASTPLAYED_SUBTYPE:
                info = typeof(SongViewModel).GetRuntimeProperty(SongViewModel.Properties.LastPlayed);
                break;

            default:
                DebugHelper.Alert(new CallerInfo(), "Unexpected RANGE_TYPE MixType {0}", mixType);
                break;
            }

            RangeEvalType rangeEvalType = RangeEvalType.Unknown;

            switch (mixType & MixType.VARIANT_MASK)
            {
            case MixType.RANGE_DAYS_VARIANT:
                rangeEvalType = RangeEvalType.Days;
                break;

            default:
                DebugHelper.Alert(new CallerInfo(), "Unexpected RANGE_TYPE VARIANT_MASK MixType {0}", mixType);
                break;
            }

            if (info != null)
            {
                return(new RangeMixEvaluator(info, int.Parse(input), rangeEvalType, mixType));
            }

            return(null);
        }
Esempio n. 12
0
        public static IMixEvaluator StringMixEntryModelToMixEvaluator(MixType type, string input)
        {
            PropertyInfo info = null;

            switch (type & MixType.SUBTYPE_MASK)
            {
            case MixType.ALBUM_SUBTYPE:
                info = typeof(SongViewModel).GetRuntimeProperty(SongViewModel.Properties.AlbumSortName);
                break;

            case MixType.ALBUMARTIST_SUBTYPE:
                info = typeof(SongViewModel).GetRuntimeProperty(SongViewModel.Properties.AlbumArtistSortName);
                break;

            case MixType.ARTIST_SUBTYPE:
                info = typeof(SongViewModel).GetRuntimeProperty(SongViewModel.Properties.AlbumSortName);
                break;

            case MixType.TRACK_SUBTYPE:
                info = typeof(SongViewModel).GetRuntimeProperty(SongViewModel.Properties.Name);
                break;

            default:
                DebugHelper.Alert(new CallerInfo(), "Unexpected ALBUM_TYPE MixType {0}", type);
                break;
            }

            StringEvalType stringEvalType = StringEvalType.Unknown;

            switch (type & MixType.VARIANT_MASK)
            {
            case MixType.STRING_CONTAINS_VARIANT:
                stringEvalType = StringEvalType.SubString;
                break;

            case MixType.STRING_ENDSWITH_VARIANT:
                stringEvalType = StringEvalType.EndsWith;
                break;

            case MixType.STRING_EQUAL_VARIANT:
                stringEvalType = StringEvalType.Equal;
                break;

            case MixType.STRING_STARTSWITH_VARIANT:
                stringEvalType = StringEvalType.StartsWith;
                break;

            default:
                DebugHelper.Alert(new CallerInfo(), "Unexpected ALBUM_TYPE VARIANT_MASK MixType {0}", type);
                break;
            }

            if (info != null)
            {
                return(new StringMixEvaluator(info, input, stringEvalType, type));
            }

            return(new NoneMixEvaluator());
        }
Esempio n. 13
0
        public MediaType(string backendType, string internalName, MixType mix = MixType.Mass, double massFration = 1)
        {
            BackendType = backendType;

            InternalName = internalName;

            MassFration = massFration;

            Mix = mix;
        }
Esempio n. 14
0
 public RecipeViewModel(Recipe recipe, Library library, MixType mixType)
     : base()
 {
     Id           = recipe.Id;
     LibraryId    = library.Id;
     LibraryName  = library.Name;
     Name         = recipe.Name;
     MixTypeId    = mixType.Id;
     MixTypeName  = mixType.Name;
     Instructions = recipe.Instructions;
     Source       = recipe.Source;
 }
Esempio n. 15
0
        public void StartClip(string clipName, MixType t, float playbackRate)
        {
            this.PlaybackRate = playbackRate;
            pauseAtEnd        = false;
            paused            = false;
            mixing            = false;
            secondClipValue   = null;
            switch (t)
            {
            case MixType.None:
                currentClipValue = skinningDataValue.AnimationClips[clipName];
                currentTimeValue = TimeSpan.Zero;
                currentKeyframe  = 0;

                // Initialize bone transforms to the bind pose.
                skinningDataValue.BindPose.CopyTo(boneTransforms, 0);
                break;

            case MixType.MixOnce:
                mixing          = true;
                playMixedOnce   = true;
                secondClipValue = skinningDataValue.AnimationClips[clipName];
                mixDur          = secondClipValue.Duration;
                secondTimeValue = TimeSpan.Zero;
                secondKeyframe  = 0;
                break;

            case MixType.MixInto:
                playMixedOnce   = false;
                mixing          = true;
                secondClipValue = skinningDataValue.AnimationClips[clipName];
                //takes the shortest: 1 second, time remaining in current animation, or half of the new animation's duration
                mixDur          = TimeSpan.FromMilliseconds(Math.Min(1000, Math.Min((currentClipValue.Duration - CurrentTime).TotalMilliseconds, secondClipValue.Duration.TotalMilliseconds / 2)));
                secondTimeValue = TimeSpan.Zero;
                secondKeyframe  = 0;
                bonesToIgnore   = null;
                break;

            case MixType.PauseAtEnd:
                currentClipValue = skinningDataValue.AnimationClips[clipName];
                currentTimeValue = TimeSpan.Zero;
                currentKeyframe  = 0;

                // Initialize bone transforms to the bind pose.
                skinningDataValue.BindPose.CopyTo(boneTransforms, 0);

                pauseAtEnd = true;
                break;
            }
        }
Esempio n. 16
0
        public static string ParseStr(this MixType value)
        {
            switch (value)
            {
            case MixType.FIFO:   return(Keywords.w_FIFO);

            case MixType.LIFO:   return(Keywords.w_LIFO);

            case MixType.MIX1:   return(Keywords.w_MIXED);

            case MixType.MIX2:   return(Keywords.w_2COMP);

            default:                  return(null);
            }
        }
Esempio n. 17
0
        /// <summary>
        /// Fills the specified buffer with wave data.
        /// </summary>
        /// <param name="buffer">The buffer to fill with wave data.</param>
        /// <param name="offset">The offset into the specified buffer.</param>
        /// <param name="sampleCount">The number of samples to read.</param>
        /// <param name="mixType">The type of mixing to use when outputting.</param>
        /// <returns>The number of samples written to the buffer.</returns>
        public int Read(float[] buffer, int offset, int sampleCount, MixType mixType)
        {
            // Amplitude is adjusted down based on the velocity and the general amplitude scale
            float appliedAmplitude = Amplitude * Velocity * Config.AmplitudeScale;
            int   sampleRate       = WaveFormat.SampleRate;

            // The time of a full cycle, as a portion of the full sample rate.
            float cycleTime = sampleRate / Frequency;

            // For square waves, the ratio is the portion of the cycle time that the wave is positive.
            float ratio        = cycleTime * Duty;
            float outputSample = 0;

            for (int n = 0; n < sampleCount; n++)
            {
                switch (GeneratorType)
                {
                case WaveType.Square:
                default:
                    // Sample is between 1 and -1, and is positive for a time dependent on the duty cycle.
                    outputSample = appliedAmplitude * Math.Sign(ratio - currentSample);
                    break;

                case WaveType.WhiteNoise:
                    // Sample is random and doesn't take the current sample into account
                    outputSample = appliedAmplitude * (float)(2 * r.NextDouble() - 1);
                    break;
                }
                // Depending on the mix mode, either overwrite the sample that exists in the buffer,
                // or add to it. Each sample is also modified by the envelope.
                if (mixType == MixType.Overwrite)
                {
                    buffer[n + offset] = outputSample * envelope.Process();
                }
                else
                {
                    buffer[n + offset] += outputSample * envelope.Process();
                }
                // Increment the sample and cap it to the cycle time.
                currentSample++;
                if (currentSample > cycleTime)
                {
                    currentSample = (int)(currentSample - cycleTime + 0.5f);
                }
            }
            return(sampleCount);
        }
Esempio n. 18
0
        private void UpdateMemberState(MixType type)
        {
            switch (type & MixType.SUBTYPE_MASK)
            {
            case MixType.PLAYLISTMEMBER_SUBTYPE:
                VisualStateManager.GoToState(this, "MemberPlaylistSelected", false);
                break;

            case MixType.MIXMEMBER_SUBTYPE:
                VisualStateManager.GoToState(this, "MemberMixSelected", false);
                break;

            default:
                DebugHelper.Alert(new CallerInfo(), "Unexpected numeric mix type: {0}", type);
                VisualStateManager.GoToState(this, "MemberUnknownSelected", false);
                return;
            }
        }
Esempio n. 19
0
        private string ConvertNumericValueToString(MixType type)
        {
            switch (type & MixType.SUBTYPE_MASK)
            {
            case MixType.LENGTH_SUBTYPE:
                return(NumericValue.Text);

            case MixType.RATING_SUBTYPE:
                return(NumericStarRater.Rating.ToString());

            case MixType.PLAYCOUNT_SUBTYPE:
                return(NumericValue.Text);

            default:
                DebugHelper.Alert(new CallerInfo(), "Unexpected numeric mix type: {0}", type);
                return("0");
            }
        }
Esempio n. 20
0
        public static IMixEvaluator MemberMixEntryModelToMixEvaluator(MixType mixType, string input)
        {
            MemberEvalType memberEvalType = MemberEvalType.Unknown;

            switch (mixType & MixType.SUBTYPE_MASK)
            {
            case MixType.MIXMEMBER_SUBTYPE:
                memberEvalType = MemberEvalType.Mix;
                break;

            case MixType.PLAYLISTMEMBER_SUBTYPE:
                memberEvalType = MemberEvalType.Playlist;
                break;

            default:
                DebugHelper.Alert(new CallerInfo(), "Unexpected MEMBER_TYPE MixType {0}", mixType);
                break;
            }

            return(new MemberMixEvaluator(int.Parse(input), memberEvalType, mixType));
        }
Esempio n. 21
0
        private void UpdateNumericStartingValue(MixType type, IComparable target)
        {
            switch (type & MixType.SUBTYPE_MASK)
            {
            case MixType.LENGTH_SUBTYPE:
                NumericValue.Text = target.ToString();
                break;

            case MixType.RATING_SUBTYPE:
                NumericStarRater.Rating = DebugHelper.CastAndAssert <uint>(target);
                break;

            case MixType.PLAYCOUNT_SUBTYPE:
                NumericValue.Text = target.ToString();
                break;

            default:
                DebugHelper.Alert(new CallerInfo(), "Unexpected numeric mix type: {0}", type);
                NumericValue.Text = "0";
                return;
            }
        }
Esempio n. 22
0
        private void UpdateNumericState(MixType type)
        {
            switch (type & MixType.SUBTYPE_MASK)
            {
            case MixType.LENGTH_SUBTYPE:
                VisualStateManager.GoToState(this, "NumericDurationSelected", false);
                break;

            case MixType.RATING_SUBTYPE:
                VisualStateManager.GoToState(this, "NumericRatingSelected", false);
                break;

            case MixType.PLAYCOUNT_SUBTYPE:
                VisualStateManager.GoToState(this, "NumericPlayCountSelected", false);
                break;

            default:
                DebugHelper.Alert(new CallerInfo(), "Unexpected numeric mix type: {0}", type);
                VisualStateManager.GoToState(this, "NumericUnknownSelected", false);
                return;
            }
        }
Esempio n. 23
0
 private void UpdateMemberState(MixType type)
 {
     switch (type & MixType.SUBTYPE_MASK)
     {
         case MixType.PLAYLISTMEMBER_SUBTYPE:
             VisualStateManager.GoToState(this, "MemberPlaylistSelected", false);
             break;
         case MixType.MIXMEMBER_SUBTYPE:
             VisualStateManager.GoToState(this, "MemberMixSelected", false);
             break;
         default:
             DebugHelper.Alert(new CallerInfo(), "Unexpected numeric mix type: {0}", type);
             VisualStateManager.GoToState(this, "MemberUnknownSelected", false);
             return;
     }
 }
Esempio n. 24
0
 private void UpdateNumericStartingValue(MixType type, IComparable target)
 {
     switch (type & MixType.SUBTYPE_MASK)
     {
         case MixType.LENGTH_SUBTYPE:
             NumericValue.Text = target.ToString();
             break;
         case MixType.RATING_SUBTYPE:
             NumericStarRater.Rating = DebugHelper.CastAndAssert<uint>(target);
             break;
         case MixType.PLAYCOUNT_SUBTYPE:
             NumericValue.Text = target.ToString();
             break;
         default:
             DebugHelper.Alert(new CallerInfo(), "Unexpected numeric mix type: {0}", type);
             NumericValue.Text = "0";
             return;
     }
 }
Esempio n. 25
0
 private string ConvertNumericValueToString(MixType type)
 {
     switch (type & MixType.SUBTYPE_MASK)
     {
         case MixType.LENGTH_SUBTYPE:
             return NumericValue.Text;
         case MixType.RATING_SUBTYPE:
             return NumericStarRater.Rating.ToString();
         case MixType.PLAYCOUNT_SUBTYPE:
             return NumericValue.Text;
         default:
             DebugHelper.Alert(new CallerInfo(), "Unexpected numeric mix type: {0}", type);
             return "0";
     }
 }
Esempio n. 26
0
 private IMixEvaluator ConvertToStringEvaluator(MixType selectedType)
 {
     throw new System.NotImplementedException();
 }
Esempio n. 27
0
 public NoneMixEvaluator()
 {
     MixType = MixType.None;
 }
Esempio n. 28
0
        public static int SaveMix(MixType mixType, string input, int mixId, bool isRoot)
        {
            MixEntryTable newEntry = new MixEntryTable(mixId, input, isRoot, mixType);

            return(DatabaseManager.Current.AddMixEntry(newEntry));
        }
Esempio n. 29
0
 private IMixEvaluator ConvertToStringEvaluator(MixType selectedType)
 {
     throw new System.NotImplementedException();
 }
 public NestedMixEvaluator(List<IMixEvaluator> mixes, NestedEvalType evalType, MixType type)
 {
     Mixes = mixes;
     EvalType = evalType;
     MixType = type;
 }
 public MemberMixEvaluator(int target, MemberEvalType evalType, MixType type)
 {
     Target = target;
     EvalType = evalType;
     MixType = type;
 }
Esempio n. 32
0
 /// <summary>
 /// Starts decoding the specified animation clip.
 /// </summary>
 public void StartClip(string clipName, MixType t)
 {
     StartClip(clipName, t, 1);
 }
Esempio n. 33
0
        private void MixRtp(MixType mixtype)
        {
            if (timer != null) timer.Enabled = false;

            if (listIn == null || listOut == null) return;

            List<ReceivedRtp> linin = null;
            List<ReceivedRtp> linout = null;

            lock (listIn)
            {
                linin = new List<ReceivedRtp>(listIn);
            }

            lock (listOut)
            {
                linout = new List<ReceivedRtp>(listOut);
            }

            //Com.Huen.Libs.SortRtpSeq sorting = new Com.Huen.Libs.SortRtpSeq();
            //linin.Sort(sorting);
            //linout.Sort(sorting);
            linin.OrderBy(x => x.seq);
            linout.OrderBy(x => x.seq);

            var itemIn = linin.FirstOrDefault();
            var itemOut = linout.FirstOrDefault();

            DelayedMil _delayedms = DelayedMil.same;
            if (itemIn == null || itemOut == null)
            {
                return;
            }
            else
            {
                byte[] mixedbytes = null;
                float times = 0.8f;
                if ((itemIn.size - headersize) == 80 && (itemOut.size - headersize) == 160)
                {
                    _delayedms = DelayedMil.i80o160;

                    float xtimes = (float)linin.Count / (float)(linout.Count * 2);
                    int _count = 0;
                    if (xtimes >= 1)
                    {
                        _count = mixtype == MixType.NORMAL ? (int)(linout.Count * times) : linout.Count;
                    }
                    else
                    {
                        _count = mixtype == MixType.NORMAL ? (int)((((float)linout.Count) * xtimes) * times) : (int)(((float)linout.Count) * xtimes);
                    }

                    for (int i = 0; i < _count; i++)
                    {
                        mixedbytes = this.Mixing(linin, linout[i], _delayedms);
                        this.WaveFileWriting(mixedbytes);
                    }
                }
                else if ((itemIn.size - headersize) == 160 && (itemOut.size - headersize) == 80)
                {
                    _delayedms = DelayedMil.i160o80;

                    float xtimes = (float)linout.Count / (float)(linin.Count * 2);
                    int _count = 0;
                    if (xtimes >= 1)
                    {
                        _count = mixtype == MixType.NORMAL ? (int)(linout.Count * times) : linout.Count;
                    }
                    else
                    {
                        _count = mixtype == MixType.NORMAL ? (int)((((float)linout.Count) * xtimes) * times) : (int)(((float)linout.Count) * xtimes);
                    }

                    for (int i = 0; i < _count; i++)
                    {
                        mixedbytes = this.Mixing(linout, linin[i], _delayedms);
                        this.WaveFileWriting(mixedbytes);
                    }
                }
                else if ((itemIn.size - headersize) == 80 && (itemOut.size - headersize) == 240)
                {
                    _delayedms = DelayedMil.i80o240;

                    float xtimes = (float)linin.Count / (float)(linout.Count * 3);
                    int _count = 0;
                    if (xtimes >= 1)
                    {
                        _count = mixtype == MixType.NORMAL ? (int)(linout.Count * times) : linout.Count;
                    }
                    else
                    {
                        _count = mixtype == MixType.NORMAL ? (int)((((float)linout.Count) * xtimes) * times) : (int)(((float)linout.Count) * xtimes);
                    }

                    for (int i = 0; i < _count; i++)
                    {
                        mixedbytes = this.Mixing(linin, linout[i], _delayedms);
                        this.WaveFileWriting(mixedbytes);
                    }
                }
                else if ((itemIn.size - headersize) == 240 && (itemOut.size - headersize) == 80)
                {
                    _delayedms = DelayedMil.i240o80;

                    float xtimes = (float)linout.Count / (float)(linin.Count * 3);
                    int _count = 0;
                    if (xtimes >= 1)
                    {
                        _count = mixtype == MixType.NORMAL ? (int)(linout.Count * times) : linout.Count;
                    }
                    else
                    {
                        _count = mixtype == MixType.NORMAL ? (int)((((float)linout.Count) * xtimes) * times) : (int)(((float)linout.Count) * xtimes);
                    }

                    for (int i = 0; i < _count; i++)
                    {
                        mixedbytes = this.Mixing(linout, linin[i], _delayedms);
                        this.WaveFileWriting(mixedbytes);
                    }
                }
                else if (itemIn.size == itemOut.size)
                {
                    _delayedms = DelayedMil.same;

                    float xtimes = (float)linin.Count / (float)linout.Count;
                    int _count = 0;
                    if (xtimes >= 1)
                    {
                        _count = mixtype == MixType.NORMAL ? (int)(linout.Count * times) : linout.Count;
                    }
                    else
                    {
                        _count = mixtype == MixType.NORMAL ? (int)((((float)linout.Count) * xtimes) * times) : (int)(((float)linout.Count) * xtimes);
                    }

                    for (int i = 0; i < _count; i++)
                    {
                        mixedbytes = this.Mixing(linin, linout[i], _delayedms);
                        this.WaveFileWriting(mixedbytes);
                    }
                }
            }

            if (timer != null) timer.Enabled = true;
        }
Esempio n. 34
0
        public void LoadEvaluator(IMixEvaluator evaluator)
        {
            MixType mixType = evaluator.MixType;

            SelectableOption <MixType> selectedMixTypeEntry = AllMixTypes.Where((m) => { return(m.Type == (mixType & MixType.SUBTYPE_MASK) || m.Type == mixType); }).FirstOrDefault();

            MixEntryType.SelectedItem = selectedMixTypeEntry;

            switch (mixType & MixType.TYPE_MASK)
            {
            case MixType.NUMBER_TYPE:
                NumericMixEvaluator <IComparable> numericEvaluator = DebugHelper.CastAndAssert <NumericMixEvaluator <IComparable> >(evaluator);

                SelectableOption <NumericEvalType> selectedNumericTypeEntry = NumericInfo.Where((m) => { return(m.Type == numericEvaluator.EvalType); }).FirstOrDefault();
                NumericPicker.SelectedItem = selectedNumericTypeEntry;

                UpdateNumericStartingValue(mixType, numericEvaluator.Target);
                return;

            case MixType.STRING_TYPE:
                StringMixEvaluator stringEvaluator = DebugHelper.CastAndAssert <StringMixEvaluator>(evaluator);

                SelectableOption <StringEvalType> selectedStringTypeEntry = StringInfo.Where((m) => { return(m.Type == stringEvaluator.EvalType); }).FirstOrDefault();
                StringPicker.SelectedItem = selectedStringTypeEntry;

                StringValue.Text = stringEvaluator.Target;
                return;

            case MixType.NESTED_TYPE:
                NestedMixEvaluator nestedEvaluator = DebugHelper.CastAndAssert <NestedMixEvaluator>(evaluator);

                foreach (IMixEvaluator mixEvaluator in nestedEvaluator.Mixes)
                {
                    MixEntry nestedEntry = new MixEntry(this, Depth + 1);
                    nestedEntry.LoadEvaluator(mixEvaluator);
                    NestedList.Children.Add(nestedEntry);
                    nestedEntry.TextBotGotFocus  += HandleTextBoxGotFocus;
                    nestedEntry.TextBotLostFocus += HandleTextBoxLostFocus;
                }

                return;

            case MixType.MEMBER_TYPE:
                MemberMixEvaluator memberEvaluator = DebugHelper.CastAndAssert <MemberMixEvaluator>(evaluator);

                if ((mixType & MixType.SUBTYPE_MASK) == MixType.PLAYLISTMEMBER_SUBTYPE)
                {
                    PlaylistViewModel playlist = LibraryViewModel.Current.LookupPlaylistById(memberEvaluator.Target);

                    PlaylistMemberPicker.SelectedItem = playlist;
                }
                else if ((mixType & MixType.SUBTYPE_MASK) == MixType.MIXMEMBER_SUBTYPE)
                {
                    MixViewModel mix = LibraryViewModel.Current.LookupMixById(memberEvaluator.Target);

                    MixMemberPicker.SelectedItem = mix;
                }
                else
                {
                    DebugHelper.Alert(new CallerInfo(), "Unexpected member type: {0}", mixType);
                    return;
                }

                return;

            case MixType.RANGE_TYPE:
                RangeMixEvaluator rangeEvaluator = DebugHelper.CastAndAssert <RangeMixEvaluator>(evaluator);

                RangeValue.Text = rangeEvaluator.Target.ToString();

                return;

            default:
                DebugHelper.Assert(new CallerInfo(), mixType == MixType.None, "Unexpected mix type: {0}", mixType);
                VisualStateManager.GoToState(this, "UnknownSelected", false);
                return;
            }
        }
Esempio n. 35
0
        public void StartClip(string clipName, MixType t, float playbackRate)
        {
            this.PlaybackRate = playbackRate;
            pauseAtEnd = false;
            paused = false;
            mixing = false;
            secondClipValue = null;
            switch (t)
            {
                case MixType.None:
                    currentClipValue = skinningDataValue.AnimationClips[clipName];
                    currentTimeValue = TimeSpan.Zero;
                    currentKeyframe = 0;

                    // Initialize bone transforms to the bind pose.
                    skinningDataValue.BindPose.CopyTo(boneTransforms, 0);
                    break;
                case MixType.MixOnce:
                    mixing = true;
                    playMixedOnce = true;
                    secondClipValue = skinningDataValue.AnimationClips[clipName];
                    mixDur = secondClipValue.Duration;
                    secondTimeValue = TimeSpan.Zero;
                    secondKeyframe = 0;
                    break;
                case MixType.MixInto:
                    playMixedOnce = false;
                    mixing = true;
                    secondClipValue = skinningDataValue.AnimationClips[clipName];
                    //takes the shortest: 1 second, time remaining in current animation, or half of the new animation's duration
                    mixDur = TimeSpan.FromMilliseconds(Math.Min(1000, Math.Min((currentClipValue.Duration - CurrentTime).TotalMilliseconds, secondClipValue.Duration.TotalMilliseconds / 2)));
                    secondTimeValue = TimeSpan.Zero;
                    secondKeyframe = 0;
                    bonesToIgnore = null;
                    break;
                case MixType.PauseAtEnd:
                    currentClipValue = skinningDataValue.AnimationClips[clipName];
                    currentTimeValue = TimeSpan.Zero;
                    currentKeyframe = 0;

                    // Initialize bone transforms to the bind pose.
                    skinningDataValue.BindPose.CopyTo(boneTransforms, 0);

                    pauseAtEnd = true;
                    break;
            }
        }
Esempio n. 36
0
 private void UpdateNumericState(MixType type)
 {
     switch (type & MixType.SUBTYPE_MASK)
     {
         case MixType.LENGTH_SUBTYPE:
             VisualStateManager.GoToState(this, "NumericDurationSelected", false);
             break;
         case MixType.RATING_SUBTYPE:
             VisualStateManager.GoToState(this, "NumericRatingSelected", false);
             break;
         case MixType.PLAYCOUNT_SUBTYPE:
             VisualStateManager.GoToState(this, "NumericPlayCountSelected", false);
             break;
         default:
             DebugHelper.Alert(new CallerInfo(), "Unexpected numeric mix type: {0}", type);
             VisualStateManager.GoToState(this, "NumericUnknownSelected", false);
             return;
     }
 }
Esempio n. 37
0
 /// <summary>
 /// Starts decoding the specified animation clip.
 /// </summary>
 public void StartClip(string clipName, MixType t)
 {
     StartClip(clipName, t, 1);
 }
Esempio n. 38
0
        public static IMixEvaluator NumericMixEntryModelToMixEvaluator(MixType type, string input)
        {
            PropertyInfo info = null;

            switch (type & MixType.SUBTYPE_MASK)
            {
            case MixType.RATING_SUBTYPE:
                info = typeof(SongViewModel).GetRuntimeProperty(SongViewModel.Properties.Rating);
                break;

            case MixType.LENGTH_SUBTYPE:
                info = typeof(SongViewModel).GetRuntimeProperty(SongViewModel.Properties.DurationSeconds);
                break;

            case MixType.PLAYCOUNT_SUBTYPE:
                info = typeof(SongViewModel).GetRuntimeProperty(SongViewModel.Properties.PlayCount);
                break;

            default:
                DebugHelper.Alert(new CallerInfo(), "Unexpected NUMBER_TYPE MixType {0}", type);
                break;
            }

            NumericEvalType numericEvalType = NumericEvalType.Unknown;

            switch (type & MixType.VARIANT_MASK)
            {
            case MixType.NUMERIC_STRICTLYLESS_VARIANT:
                numericEvalType = NumericEvalType.StrictLess;
                break;

            case MixType.NUMERIC_LESS_VARIANT:
                numericEvalType = NumericEvalType.Less;
                break;

            case MixType.NUMERIC_EQUAL_VARIANT:
                numericEvalType = NumericEvalType.Equal;
                break;

            case MixType.NUMERIC_MORE_VARIANT:
                numericEvalType = NumericEvalType.More;
                break;

            case MixType.NUMERIC_STRICTLYMORE_VARIANT:
                numericEvalType = NumericEvalType.StrictMore;
                break;

            default:
                DebugHelper.Alert(new CallerInfo(), "Unexpected NUMBER_TYPE VARIANT_MASK MixType {0}", type);
                break;
            }

            if (info != null)
            {
                Type t = info.PropertyType;

                IComparable inputAsType = DebugHelper.CastAndAssert <IComparable>(Utilities.GetDefault(t));

                try
                {
                    inputAsType = DebugHelper.CastAndAssert <IComparable>(Convert.ChangeType(input, t));
                }
                catch (FormatException)
                {
                    // If cast is bad, ignore and use default type
                }

                return(new NumericMixEvaluator <IComparable>(info, inputAsType, numericEvalType, type));
            }

            return(new NoneMixEvaluator());
        }
Esempio n. 39
0
        /// <summary>
        /// Fills the specified buffer with wave data.
        /// </summary>
        /// <param name="buffer">The buffer to fill with wave data.</param>
        /// <param name="offset">The offset into the specified buffer.</param>
        /// <param name="sampleCount">The number of samples to read.</param>
        /// <param name="mixType">The type of mixing to use when outputting.</param>
        /// <returns>The number of samples written to the buffer.</returns>
        public int Read(float[] buffer, int offset, int sampleCount, MixType mixType)
        {
            float appliedAmplitude = Amplitude * Velocity * ampScale;
            int sampleRate = WaveFormat.SampleRate;
            float cycleTime = sampleRate / Frequency;
            float ratio = cycleTime * this.Duty;
            float currentSample = 0;
            for (int n = 0; n < sampleCount; n++)
            {
                switch (GeneratorType)
                {
                    case WaveType.Square:
                    default:
                        currentSample = appliedAmplitude * (float)(Math.Sign(ratio - sample));
                        break;

                    case WaveType.WhiteNoise:
                        currentSample = appliedAmplitude * (float)(2 * r.NextDouble() - 1);
                        break;
                }
                if (mixType == MixType.Overwrite)
                {
                    buffer[n + offset] = currentSample * envelope.Process();
                }
                else
                {
                    buffer[n + offset] += currentSample * envelope.Process();
                }
                sample++;
                if (sample > cycleTime)
                {
                    sample = (int)(sample - cycleTime + 0.5f);
                }
            }
            return sampleCount;
        }
Esempio n. 40
0
 public NoneMixEvaluator()
 {
     MixType = MixType.None;
 }
Esempio n. 41
0
        private void MixRtp(MixType mixtype)
        {
            if (timer != null)
            {
                timer.Enabled = false;
            }

            if (listIn == null || listOut == null)
            {
                return;
            }

            List <ReceivedRtp> linin  = null;
            List <ReceivedRtp> linout = null;

            lock (listIn)
            {
                linin = new List <ReceivedRtp>(listIn);
            }

            lock (listOut)
            {
                linout = new List <ReceivedRtp>(listOut);
            }

            //Com.Huen.Libs.SortRtpSeq sorting = new Com.Huen.Libs.SortRtpSeq();
            //linin.Sort(sorting);
            //linout.Sort(sorting);
            linin.OrderBy(x => x.seq);
            linout.OrderBy(x => x.seq);

            var itemIn  = linin.FirstOrDefault();
            var itemOut = linout.FirstOrDefault();

            DelayedMil _delayedms = DelayedMil.same;

            if (itemIn == null || itemOut == null)
            {
                return;
            }
            else
            {
                byte[] mixedbytes = null;
                float  times      = 0.8f;
                if ((itemIn.size - headersize) == 80 && (itemOut.size - headersize) == 160)
                {
                    _delayedms = DelayedMil.i80o160;

                    float xtimes = (float)linin.Count / (float)(linout.Count * 2);
                    int   _count = 0;
                    if (xtimes >= 1)
                    {
                        _count = mixtype == MixType.NORMAL ? (int)(linout.Count * times) : linout.Count;
                    }
                    else
                    {
                        _count = mixtype == MixType.NORMAL ? (int)((((float)linout.Count) * xtimes) * times) : (int)(((float)linout.Count) * xtimes);
                    }

                    for (int i = 0; i < _count; i++)
                    {
                        mixedbytes = this.Mixing(linin, linout[i], _delayedms);
                        this.WaveFileWriting(mixedbytes);
                    }
                }
                else if ((itemIn.size - headersize) == 160 && (itemOut.size - headersize) == 80)
                {
                    _delayedms = DelayedMil.i160o80;

                    float xtimes = (float)linout.Count / (float)(linin.Count * 2);
                    int   _count = 0;
                    if (xtimes >= 1)
                    {
                        _count = mixtype == MixType.NORMAL ? (int)(linout.Count * times) : linout.Count;
                    }
                    else
                    {
                        _count = mixtype == MixType.NORMAL ? (int)((((float)linout.Count) * xtimes) * times) : (int)(((float)linout.Count) * xtimes);
                    }

                    for (int i = 0; i < _count; i++)
                    {
                        mixedbytes = this.Mixing(linout, linin[i], _delayedms);
                        this.WaveFileWriting(mixedbytes);
                    }
                }
                else if ((itemIn.size - headersize) == 80 && (itemOut.size - headersize) == 240)
                {
                    _delayedms = DelayedMil.i80o240;

                    float xtimes = (float)linin.Count / (float)(linout.Count * 3);
                    int   _count = 0;
                    if (xtimes >= 1)
                    {
                        _count = mixtype == MixType.NORMAL ? (int)(linout.Count * times) : linout.Count;
                    }
                    else
                    {
                        _count = mixtype == MixType.NORMAL ? (int)((((float)linout.Count) * xtimes) * times) : (int)(((float)linout.Count) * xtimes);
                    }

                    for (int i = 0; i < _count; i++)
                    {
                        mixedbytes = this.Mixing(linin, linout[i], _delayedms);
                        this.WaveFileWriting(mixedbytes);
                    }
                }
                else if ((itemIn.size - headersize) == 240 && (itemOut.size - headersize) == 80)
                {
                    _delayedms = DelayedMil.i240o80;

                    float xtimes = (float)linout.Count / (float)(linin.Count * 3);
                    int   _count = 0;
                    if (xtimes >= 1)
                    {
                        _count = mixtype == MixType.NORMAL ? (int)(linout.Count * times) : linout.Count;
                    }
                    else
                    {
                        _count = mixtype == MixType.NORMAL ? (int)((((float)linout.Count) * xtimes) * times) : (int)(((float)linout.Count) * xtimes);
                    }

                    for (int i = 0; i < _count; i++)
                    {
                        mixedbytes = this.Mixing(linout, linin[i], _delayedms);
                        this.WaveFileWriting(mixedbytes);
                    }
                }
                else if (itemIn.size == itemOut.size)
                {
                    _delayedms = DelayedMil.same;

                    float xtimes = (float)linin.Count / (float)linout.Count;
                    int   _count = 0;
                    if (xtimes >= 1)
                    {
                        _count = mixtype == MixType.NORMAL ? (int)(linout.Count * times) : linout.Count;
                    }
                    else
                    {
                        _count = mixtype == MixType.NORMAL ? (int)((((float)linout.Count) * xtimes) * times) : (int)(((float)linout.Count) * xtimes);
                    }

                    for (int i = 0; i < _count; i++)
                    {
                        mixedbytes = this.Mixing(linin, linout[i], _delayedms);
                        this.WaveFileWriting(mixedbytes);
                    }
                }
            }

            if (timer != null)
            {
                timer.Enabled = true;
            }
        }
Esempio n. 42
0
 public NestedMixEvaluator(List <IMixEvaluator> mixes, NestedEvalType evalType, MixType type)
 {
     Mixes    = mixes;
     EvalType = evalType;
     MixType  = type;
 }
Esempio n. 43
0
 public MemberMixEvaluator(int target, MemberEvalType evalType, MixType type)
 {
     Target   = target;
     EvalType = evalType;
     MixType  = type;
 }