public ISound Decode(BeatmaniaPcAudioEntry entry) { using (var wavDataMem = new ReadOnlyMemoryStream(entry.Data)) { var result = _wavDecoder.Decode(wavDataMem); var panning = entry.Panning; if (panning > 0x7F || panning < 0x01) { panning = 0x40; } var volume = entry.Volume; if (volume < 0x01) { volume = 0x01; } else if (volume > 0xFF) { volume = 0xFF; } result[NumericData.Panning] = (panning - 1.0d) / 126.0d; result[NumericData.Volume] = BeatmaniaPcConstants.VolumeTable[volume]; result[NumericData.Channel] = entry.Channel; result[NumericData.SourceVolume] = entry.Volume; result[NumericData.SourcePanning] = entry.Panning; return(result); } }
public BmsSoundLoader( IWavDecoder wavDecoder, IMp3Decoder mp3Decoder, IOggDecoder oggDecoder, IFlacDecoder flacDecoder) { _wavDecoder = wavDecoder; _mp3Decoder = mp3Decoder; _oggDecoder = oggDecoder; _flacDecoder = flacDecoder; Extensions = new Dictionary <string, Func <Stream, ISound> > { { "wav", s => _wavDecoder.Decode(s) }, { "flac", s => _flacDecoder.Decode(s) }, { "ogg", s => _oggDecoder.Decode(s) }, { "mp3", s => _mp3Decoder.Decode(s) } }; }