예제 #1
0
        public override unsafe void Export(string outPath)
        {
            if (outPath.EndsWith(".wav"))
            {
                WAV.ToFile(CreateStreams()[0], outPath);
            }
            else
            {
                if (_audioSource != DataSource.Empty)
                {
                    int size = WorkingUncompressed.Length + _audioSource.Length;
                    using (FileStream stream = new FileStream(outPath, FileMode.OpenOrCreate, FileAccess.ReadWrite,
                                                              FileShare.None))
                    {
                        stream.SetLength(size);
                        using (FileMap map = FileMap.FromStreamInternal(stream, FileMapProtect.ReadWrite, 0, size))
                        {
                            VoidPtr addr = map.Address;

                            //Write header
                            Memory.Move(addr, WorkingUncompressed.Address, (uint)WorkingUncompressed.Length);

                            //Set the offset to the audio samples (_dataLocation)
                            RSTMHeader *hdr = (RSTMHeader *)addr;
                            hdr->_header._length = WorkingUncompressed.Length + _audioSource.Length;
                            hdr->DATAData->Set(_audioSource.Length + 0x20);

                            addr += WorkingUncompressed.Length;

                            //Append audio samples to the end
                            Memory.Move(addr, _audioSource.Address, (uint)_audioSource.Length);

                            if (outPath.EndsWith(".bcstm"))
                            {
                                ShowADPCMConversionWarning();
                                byte[] bcstm_temp = CSTMConverter.FromRSTM(hdr);
                                fixed(byte *ptr = bcstm_temp)
                                {
                                    Memory.Move(map.Address, ptr, (uint)bcstm_temp.Length);
                                }
                            }
                            else if (outPath.EndsWith(".bfstm"))
                            {
                                ShowADPCMConversionWarning();
                                byte[] bfstm_temp = FSTMConverter.FromRSTM(hdr);
                                fixed(byte *ptr = bfstm_temp)
                                {
                                    Memory.Move(map.Address, ptr, (uint)bfstm_temp.Length);
                                }
                            }
                        }
                    }
                }
                else
                {
                    base.Export(outPath);
                }
            }
        }
예제 #2
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);
 }