コード例 #1
0
        public Result[] Run()
        {
            Parallel.For(0, Files.Length, i =>
            {
                try
                {
                    byte[] inFile         = File.ReadAllBytes(Files[i]);
                    AudioWithConfig audio = Reader().ReadWithConfig(inFile);

                    audio.Configuration.TrimFile = false;
                    if (audio.Configuration is BxstmConfiguration a)
                    {
                        a.RecalculateLoopContext = false;
                        a.RecalculateSeekTable   = false;
                    }

                    int bytesDiff = 0;
                    if (Writer != null)
                    {
                        byte[] outFile = Writer().GetFile(audio.AudioFormat, audio.Configuration);
                        bytesDiff      = Common.DiffArrays(inFile, outFile);
                    }
                    else
                    {
                        audio.AudioFormat.ToPcm16();
                    }
                    Results[i] = new Result(Files[i], bytesDiff);
                }
                catch (Exception ex)
                {
                    Results[i] = new Result(Files[i], -4, ex.Message);
                }
            });
            return(Results);
        }
コード例 #2
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;
            }
        }
コード例 #3
0
        private void ReadFile(AudioFileStream file)
        {
            ContainerTypes.Containers.TryGetValue(file.Type, out ContainerType type);

            if (type == null)
            {
                throw new ArgumentOutOfRangeException(nameof(file.Type), file.Type, null);
            }

            AudioWithConfig audio = type.GetReader().ReadWithConfig(file.Stream);

            file.Audio    = audio.Audio;
            Configuration = audio.Configuration;
        }
コード例 #4
0
        private void ReadFile(AudioFile file)
        {
            using (var stream = new FileStream(file.Path, FileMode.Open, FileAccess.Read))
            {
                ContainerTypes.Containers.TryGetValue(file.Type, out ContainerType type);

                if (type == null)
                {
                    throw new ArgumentOutOfRangeException(nameof(file.Type), file.Type, null);
                }

                AudioWithConfig audio = type.GetReader().ReadWithConfig(stream);
                file.Audio    = audio.Audio;
                Configuration = audio.Configuration;
            }
        }