Ejemplo n.º 1
0
 public IList <IEvent> Decode(
     TimingChunk timings,
     IEnumerable <Step> steps,
     IEnumerable <Trigger> triggers,
     IPanelMapper panelMapper)
 {
     return(_timingEventDecoder.Decode(timings)
            .Concat(_stepEventDecoder.Decode(steps, panelMapper))
            .Concat(_triggerEventDecoder.Decode(triggers))
            .OrderBy(ev => ev[NumericData.MetricOffset])
            .AsList());
 }
Ejemplo n.º 2
0
        public IList <IEvent> Decode(IEnumerable <Step> steps, IPanelMapper panelMapper)
        {
            IEnumerable <IEvent> Do()
            {
                if (panelMapper == null)
                {
                    throw new RhythmCodexException("Panel mapper cannot be null");
                }

                var stepList = steps.AsList();

                foreach (var step in stepList)
                {
                    var panels       = step.Panels;
                    var freeze       = false;
                    var metricOffset = (BigRational)step.MetricOffset / SsqConstants.MeasureLength;

                    if (panels == 0x00)
                    {
                        freeze = true;
                        panels = step.ExtraPanels ?? 0;
                    }

                    if ((panels & 0x0F) == 0x0F)
                    {
                        yield return(new Event
                        {
                            [NumericData.MetricOffset] = metricOffset,
                            [NumericData.Player] = 0,
                            [FlagData.Shock] = true
                        });

                        panels &= 0xF0;
                    }

                    if ((panels & 0xF0) == 0xF0)
                    {
                        yield return(new Event
                        {
                            [NumericData.MetricOffset] = metricOffset,
                            [NumericData.Player] = 1,
                            [FlagData.Shock] = true
                        });

                        panels &= 0x0F;
                    }

                    foreach (var panelNumber in _stepPanelSplitter.Split(panels))
                    {
                        var mappedPanel = panelMapper.Map(panelNumber);
                        var isMapped    = mappedPanel != null;

                        yield return(new Event
                        {
                            [NumericData.MetricOffset] = metricOffset,
                            [NumericData.SourceColumn] = panelNumber,
                            [NumericData.Column] = isMapped ? mappedPanel.Panel : (BigRational?)null,
                            [NumericData.Player] = isMapped ? mappedPanel.Player : (BigRational?)null,
                            [FlagData.Freeze] = freeze ? true : (bool?)null,
                            [FlagData.Note] = freeze ? (bool?)null : true
                        });
                    }
                }
            }

            return(Do().ToList());
        }