Example #1
0
        public static Stream AddPreviewDecoder(FormatData data, AudioFormat format, ProgressIndicator progress)
        {
            if (data.Song.PreviewTimes != null)
            {
                MultiDecoder multi = new MultiDecoder(RawkAudio.Decoder.BufferSize);
                multi.AddDecoder(format.Decoder);

                Stream previewstream = new TemporaryStream();
                PlatformRB2WiiCustomDLC.TranscodePreview(data.Song.PreviewTimes, format.Mappings, format.Decoder, previewstream, progress);

                previewstream.Position = 0;
                IDecoder previewdecoder = new RawkAudio.Decoder(previewstream, RawkAudio.Decoder.AudioFormat.VorbisOgg);
                multi.AddDecoder(previewdecoder);
                format.Mappings.Add(new AudioFormat.Mapping(0, previewdecoder.Channels == 1 ? 0 : -1, Instrument.Preview));
                if (previewdecoder.Channels == 2)
                {
                    format.Mappings.Add(new AudioFormat.Mapping(0, 1, Instrument.Preview));
                }
                format.Decoder = multi;
                multi.Seek(0);

                return(previewstream);
            }

            return(null);
        }
Example #2
0
        public override AudioFormat DecodeAudio(FormatData data, ProgressIndicator progress)
        {
            AudioFormat format = DecodeFormat(data);
            Stream      audio  = data.GetStream(this, AudioName);
            uint        magic  = new EndianReader(audio, Endianness.BigEndian).ReadUInt32();

            if (magic != 0x5241574b && (magic & 0xFFFFFF00) != 0x42494b00)
            {
                throw new FormatException();                 // Must start with "RAWK" or "BIK", this is to prevent encrypted biks from being decoded
            }
            audio.Position = 0;
            Stream preview = null;

            format.Decoder = new RawkAudio.Decoder(audio, RawkAudio.Decoder.AudioFormat.BinkAudio);
            if (data.HasStream(this, PreviewName))
            {
                preview          = data.GetStream(this, PreviewName);
                magic            = new EndianReader(preview, Endianness.BigEndian).ReadUInt32();
                preview.Position = 0;
                if (magic != 0x5241574b && (magic & 0xFFFFFF00) != 0x42494b00)
                {
                    throw new FormatException();
                }
                IDecoder     decoder = new RawkAudio.Decoder(preview, RawkAudio.Decoder.AudioFormat.BinkAudio);
                MultiDecoder multi   = new MultiDecoder(RawkAudio.Decoder.BufferSize);
                multi.AddDecoder(format.Decoder);
                multi.AddDecoder(decoder);
                format.Decoder = multi;
            }

            format.SetDisposeStreams(data, new Stream[] { audio, preview });

            Game game = data.Song.Game;

            if (NeversoftMetadata.IsGuitarHero4(game) || NeversoftMetadata.IsGuitarHero5(game))
            {
                format.Decoder = new AmplifyDecoder(format.Decoder, 1.30f);
            }

            return(format);
        }