コード例 #1
0
ファイル: VGAudioFile.cs プロジェクト: week9/Switch-Toolbox
        public void LoadAudio(Stream stream, IFileFormat format)
        {
            stream.Position = 0;

            Format = format;

            foreach (string ext in Format.Extension)
            {
                string extension = ext.TrimStart('*');
                switch (extension)
                {
                case ".bfstm":
                case ".bcstm":
                case ".bfwav":
                case ".bcwav":
                    var bcfstmReader = new BCFstmReader();
                    audioWithConfig = bcfstmReader.ReadWithConfig(stream);
                    stream.Position = 0;
                    bxstmStructure  = bcfstmReader.ReadMetadata(stream);
                    break;

                case ".brstm":
                case ".brwav":
                    var brstmReader = new BrstmReader();
                    bxstmStructure  = brstmReader.ReadMetadata(stream);
                    stream.Position = 0;
                    audioWithConfig = brstmReader.ReadWithConfig(stream);
                    break;

                case ".idsp":
                    var idspReader = new IdspReader();
                    idspStructure   = idspReader.ReadMetadata(stream);
                    stream.Position = 0;
                    audioWithConfig = idspReader.ReadWithConfig(stream);
                    break;

                case ".hps":
                    var hpsReader = new HpsReader();
                    hpsStructure    = hpsReader.ReadMetadata(stream);
                    stream.Position = 0;
                    audioWithConfig = hpsReader.ReadWithConfig(stream);
                    break;

                case ".wav":
                    var wavReader = new WaveReader();
                    waveStructure   = wavReader.ReadMetadata(stream);
                    stream.Position = 0;
                    audioWithConfig = wavReader.ReadWithConfig(stream);
                    break;

                default:
                    throw new Exception("Unsupported Extension " + ext);
                }
                audioData = audioWithConfig.Audio;
            }
        }
コード例 #2
0
        public void BrstmLoopAlignmentIsSet()
        {
            GcAdpcmFormat audio = GenerateAudio.GenerateAdpcmSineWave(BuildParseTestOptions.Samples, 1, BuildParseTestOptions.SampleRate);

            audio = audio.WithLoop(true, 1288, 16288);
            var writer = new BrstmWriter {
                Configuration = { LoopPointAlignment = 700 }
            };

            byte[]       builtFile   = writer.GetFile(audio);
            IAudioFormat parsedAudio = new BrstmReader().ReadFormat(builtFile);

            Assert.Equal(1400, parsedAudio.LoopStart);
            Assert.Equal(16400, parsedAudio.LoopEnd);
        }