public void Decode_DecodesBgm(
            [Values(0x05, 0x15, 0x25, 0x35, 0x45, 0x55, 0x65, 0x75, 0x85, 0x95, 0xA5, 0xB5, 0xC5, 0xD5, 0xE5, 0xF5)] byte param0,
            [Values] DjmainChartType chartType)
        {
            // Arrange.
            var subject         = Resolve <IDjmainChartDecoder>();
            var expectedPanning = Math.Max(0, (param0 >> 4) - 1);
            var offset          = Create <ushort>();
            var param1          = Create <byte>();
            var data            = new[]
            {
                new DjmainChartEvent
                {
                    Offset = offset,
                    Param0 = param0,
                    Param1 = param1
                }
            };

            // Act.
            var output = subject.Decode(data, Create <DjmainChartType>());

            // Assert.
            output.Events.Should().HaveCount(1);
            var ev = output.Events.Single();

            ev[NumericData.PlaySound].Value.Should().Be(param1 - 1);
            ev[NumericData.Panning].Value.Should().Be(new BigRational(expectedPanning, 14));
        }
Ejemplo n.º 2
0
 public IChart Decode(IEnumerable <IDjmainChartEvent> events, DjmainChartType chartType)
 {
     return(new Chart
     {
         Events = DecodeEvents(events, chartType).ToList()
     });
 }
Ejemplo n.º 3
0
        private IEnumerable <IEvent> DecodeEvents(IEnumerable <IDjmainChartEvent> events, DjmainChartType chartType)
        {
            var noteCount = true;

            foreach (var ev in events)
            {
                var command = ev.Param0 & 0xF;

                if (noteCount)
                {
                    if (ev.Offset != 0 || command != 0)
                    {
                        noteCount = false;
                    }
                    else
                    {
                        continue;
                    }
                }

                var offset = new BigRational(ev.Offset, 58);
                var newEv  = new Event
                {
                    [NumericData.SourceCommand] = ev.Param0,
                    [NumericData.SourceData]    = ev.Param1,
                    [NumericData.SourceOffset]  = ev.Offset,
                    [NumericData.LinearOffset]  = offset,
                };

                switch (chartType)
                {
                case DjmainChartType.Beatmania:
                    _djmainEventMetadataDecoder.AddBeatmaniaMetadata(newEv, ev);
                    break;

                case DjmainChartType.Popn:
                    _djmainEventMetadataDecoder.AddPopnMetadata(newEv, ev);
                    break;
                }

                yield return(newEv);
            }
        }