public ICollection <int> GetSampleMapOffsets(DjmainChunkFormat format) { switch (format) { case DjmainChunkFormat.Unknown: throw new RhythmCodexException("Can't get sample map offsets for unknown format."); case DjmainChunkFormat.BeatmaniaFirst: case DjmainChunkFormat.BeatmaniaSecond: case DjmainChunkFormat.BeatmaniaThird: case DjmainChunkFormat.BeatmaniaComplete: return(new List <int> { 0x000000, 0x000200 }); case DjmainChunkFormat.BeatmaniaFinal: return(new List <int> { 0x000000, 0x001000 }); default: return(new List <int> { 0x000000, 0x000400 }); } }
private DjmainChartType GetChartType(DjmainChunkFormat format) { switch (format) { case DjmainChunkFormat.Popn1: case DjmainChunkFormat.Popn2: case DjmainChunkFormat.Popn3: return(DjmainChartType.Popn); case DjmainChunkFormat.BeatmaniaClub: case DjmainChunkFormat.BeatmaniaComplete: case DjmainChunkFormat.BeatmaniaComplete2: case DjmainChunkFormat.BeatmaniaCore: case DjmainChunkFormat.BeatmaniaDct: case DjmainChunkFormat.BeatmaniaFifth: case DjmainChunkFormat.BeatmaniaFinal: case DjmainChunkFormat.BeatmaniaFirst: case DjmainChunkFormat.BeatmaniaFourth: case DjmainChunkFormat.BeatmaniaSecond: case DjmainChunkFormat.BeatmaniaSeventh: case DjmainChunkFormat.BeatmaniaSixth: case DjmainChunkFormat.BeatmaniaThird: return(DjmainChartType.Beatmania); default: throw new RhythmCodexException($"Not sure what chart type this format is: {format}"); } }
public ICollection <int> GetChartOffsets(DjmainChunkFormat format) { switch (format) { case DjmainChunkFormat.Unknown: throw new RhythmCodexException("Can't get chart offsets for unknown format."); case DjmainChunkFormat.BeatmaniaFirst: case DjmainChunkFormat.BeatmaniaSecond: return(new List <int> { 0x000400 }); case DjmainChunkFormat.BeatmaniaThird: case DjmainChunkFormat.BeatmaniaComplete: return(new List <int> { 0x000400, 0xF02000, 0xF03000 }); case DjmainChunkFormat.BeatmaniaFinal: return(new List <int> { 0x002000, 0x006000, 0x00A000, 0x00E000, 0x012000, 0x016000 }); default: return(new List <int> { 0x000800, 0xF02000, 0xF03000 }); } }
public ICollection <string> GetChartNames(DjmainChunkFormat format) { switch (format) { case DjmainChunkFormat.Unknown: throw new RhythmCodexException("Can't get chart names for unknown format."); case DjmainChunkFormat.BeatmaniaFirst: case DjmainChunkFormat.BeatmaniaSecond: return(new List <string> { BeatmaniaDifficultyConstants.Normal }); case DjmainChunkFormat.BeatmaniaFinal: return(new List <string> { BeatmaniaDifficultyConstants.Normal, BeatmaniaDifficultyConstants.Light, BeatmaniaDifficultyConstants.Another, BeatmaniaDifficultyConstants.Normal, BeatmaniaDifficultyConstants.Light, BeatmaniaDifficultyConstants.Another }); default: return(new List <string> { BeatmaniaDifficultyConstants.Normal, BeatmaniaDifficultyConstants.Light, BeatmaniaDifficultyConstants.Another, }); } }
private IDjmainArchive DecodeChunk(byte[] data, DjmainChunkFormat format) { return(Resolve <IDjmainDecoder>().Decode(new DjmainChunk { Data = data, Format = format }, new DjmainDecodeOptions())); }
private IDictionary <int, IDjmainSample> DecodeSamples(Stream stream, DjmainChunkFormat format, int sampleMapOffset, IEnumerable <IDjmainChartEvent> events) { stream.Position = sampleMapOffset; var infos = _sampleInfoStreamReader.Read(stream); var filteredInfos = _usedSampleFilter.Filter(infos, events); return(_sampleDecoder.Decode(stream, filteredInfos, _offsetProvider.GetSoundOffset(format))); }
public int GetSoundOffset(DjmainChunkFormat format) { switch (format) { case DjmainChunkFormat.Unknown: throw new RhythmCodexException("Can't get sound offsets for unknown format."); case DjmainChunkFormat.BeatmaniaFinal: return(0x020000); default: return(0x002000); } }
private IDictionary <int, IChart> DecodeCharts( IEnumerable <KeyValuePair <int, IEnumerable <IDjmainChartEvent> > > events, IReadOnlyDictionary <int, int> chartSoundMap, DjmainChunkFormat chunkFormat) { return(events.ToDictionary(x => x.Key, x => { if (x.Value == null) { return null; } var chart = _chartDecoder.Decode(x.Value, GetChartType(chunkFormat)); chart[NumericData.Id] = x.Key; chart[NumericData.SampleMap] = chartSoundMap[x.Key]; _djmainChartMetadataDecoder.AddMetadata(chart, chunkFormat, x.Key); return chart; })); }
public void AddMetadata(IChart chart, DjmainChunkFormat format, int index) { switch (format) { case DjmainChunkFormat.BeatmaniaFirst: case DjmainChunkFormat.BeatmaniaSecond: { if (index == 0) { chart[NumericData.Difficulty] = BeatmaniaDifficultyConstants.NormalId; } break; } default: { switch (index) { case 0: case 3: chart[NumericData.Difficulty] = BeatmaniaDifficultyConstants.NormalId; break; case 1: case 4: chart[NumericData.Difficulty] = BeatmaniaDifficultyConstants.LightId; break; case 2: case 5: chart[NumericData.Difficulty] = BeatmaniaDifficultyConstants.AnotherId; break; } break; } } }
private IDictionary <int, IDictionary <int, ISound> > DecodeSounds(Stream stream, DjmainChunkFormat format, IReadOnlyDictionary <int, int> chartSoundMap, IEnumerable <KeyValuePair <int, IEnumerable <IDjmainChartEvent> > > charts, IEnumerable <KeyValuePair <int, IChart> > decodedCharts, DjmainDecodeOptions options) { return(_offsetProvider.GetSampleMapOffsets(format) .Select((offset, index) => new KeyValuePair <int, int>(index, offset)) .ToDictionary(kv => kv.Key, kv => { var chartData = charts .Where(c => chartSoundMap[c.Key] == kv.Key) .SelectMany(c => c.Value) .ToList(); var samples = DecodeSamples(stream, format, kv.Value, chartData); var decodedSamples = _soundDecoder.Decode(samples); if (!options.DoNotConsolidateSamples) { _soundConsolidator.Consolidate(decodedSamples.Values, decodedCharts.SelectMany(dc => dc.Value?.Events ?? Enumerable.Empty <IEvent>())); } foreach (var sample in decodedSamples.Where(s => s.Value.Samples.Any())) { var s = sample.Value; s[NumericData.SampleMap] = kv.Key; } foreach (var discardedSample in decodedSamples.Where(s => !s.Value.Samples.Any()).ToList()) { decodedSamples.Remove(discardedSample); } return decodedSamples; })); }
public IList <int> GetSampleChartMap(DjmainChunkFormat format) { switch (format) { case DjmainChunkFormat.Unknown: throw new RhythmCodexException("Can't get sample chart map for unknown format."); case DjmainChunkFormat.BeatmaniaFinal: return(new List <int> { 0, 0, 0, 1, 1, 1 }); case DjmainChunkFormat.BeatmaniaFirst: case DjmainChunkFormat.BeatmaniaSecond: return(new List <int> { 0 }); default: return(new List <int> { 0, 0, 0 }); } }
private IDictionary <int, IEnumerable <IDjmainChartEvent> > ExtractCharts(Stream stream, DjmainChunkFormat format) { return(_offsetProvider.GetChartOffsets(format) .Select((offset, index) => new KeyValuePair <int, int>(index, offset)) .ToDictionary(kv => kv.Key, kv => { stream.Position = kv.Value; var events = _chartEventStreamReader.Read(stream); if (events.Count == 0 || events[0].Offset != 0 || (events[0].Param0 == 0 && events[0].Param1 == 0)) { return null; } return events.Cast <IDjmainChartEvent>(); })); }