예제 #1
0
        public byte[] Encode(PCM16Audio lwav, string original_filename_no_ext)
        {
            if (lwav.OriginalPath != null)
            {
                switch (Path.GetExtension(lwav.OriginalPath).ToLowerInvariant())
                {
                case ".brstm":
                    return(File.ReadAllBytes(lwav.OriginalPath));

                case ".bcstm":
                    return(CSTMConverter.ToRSTM(File.ReadAllBytes(lwav.OriginalPath)));

                case ".bfstm":
                    return(FSTMConverter.ToRSTM(File.ReadAllBytes(lwav.OriginalPath)));
                }
            }

            using (var pw = new ProgressWindow(null, "BrawlLib Audio Encoder", $"Encoding {original_filename_no_ext}", true))
                using (FileMap rstm = RSTMConverter.Encode(new PCM16AudioStream(lwav), pw, WaveEncoding.ADPCM)) {
                    if (pw.Cancelled)
                    {
                        throw new AudioExporterException("RSTM export cancelled");
                    }

                    byte[] data = new byte[rstm.Length];
                    Marshal.Copy(rstm.Address, data, 0, rstm.Length);
                    return(data);
                }
        }
예제 #2
0
        public Task WriteFileAsync(PCM16Audio lwav, string output_dir, string original_filename_no_ext)
        {
            Task task = new Task(() => WriteFile(lwav, output_dir, original_filename_no_ext));

            task.Start();
            return(task);
        }
예제 #3
0
        public void WriteFile(PCM16Audio lwav, string output_dir, string original_filename_no_ext)
        {
            AudioData audio = lwav.OriginalAudioData ?? new WaveReader().Read(lwav.Export());

            audio.SetLoop(lwav.Looping, lwav.LoopStart, lwav.LoopEnd);
            byte[] data = GetData(audio);
            File.WriteAllBytes(Path.Combine(output_dir, original_filename_no_ext + GetExtension()), data);
        }
예제 #4
0
 public void WriteFile(PCM16Audio lwav, string output_dir, string original_filename_no_ext)
 {
     File.WriteAllBytes(Path.Combine(output_dir, original_filename_no_ext + ".brstm"), Encode(lwav, original_filename_no_ext));
 }
예제 #5
0
 public PCM16AudioStream(PCM16Audio lwav)
 {
     this.lwav = lwav;
 }
예제 #6
0
 public NamedAudio(PCM16Audio lwav, string name)
 {
     this.Audio = lwav;
     this.Name  = name;
 }
예제 #7
0
 public void WriteFile(PCM16Audio lwav, string output_dir, string original_filename_no_ext)
 {
     byte[] rstmData = new RSTMExporter().Encode(lwav, original_filename_no_ext);
     byte[] fstmData = FSTMConverter.FromRSTM(rstmData);
     File.WriteAllBytes(Path.Combine(output_dir, original_filename_no_ext + ".bfstm"), fstmData);
 }