Exemplo n.º 1
0
        private void btnOkay_Click(object sender, EventArgs e)
        {
            Stop();
#if LOOP_SELECTION_DIALOG_LIB
#else
            using (ProgressWindow progress = new ProgressWindow(this, String.Format("{0} Converter", _type == 0 ? "Brstm" : "Wave"), "Encoding, please wait...", false))
                switch (_type)
                {
                case 0:
                    var encoding = (WaveEncoding)ddlEncoding.SelectedItem;
                    PreviousEncoding = encoding;
                    _audioData       = RSTMConverter.Encode(_sourceStream, progress, encoding);
                    break;

                case 1:
                    _audioData = RSARWaveConverter.Encode(_sourceStream, progress);
                    break;

                case 2:
                    _audioData = RWAVConverter.Encode(_sourceStream, progress);
                    break;
                }
#endif

            DialogResult = DialogResult.OK;
            Close();
        }
Exemplo n.º 2
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);
                }
        }
Exemplo n.º 3
0
        public override unsafe void Replace(string fileName)
        {
            IAudioStream stream = null;

            if (fileName.EndsWith(".wav"))
            {
                stream = WAV.FromFile(fileName);
            }
            else
            {
                base.Replace(fileName);
            }

            if (stream != null)
            {
                try { ReplaceRaw(RSTMConverter.Encode(stream, null)); }
                finally { stream.Dispose(); }
            }

            int offset = ((int)(Header->DATAData->Data) - (int)(Header));

            if (offset < WorkingUncompressed.Length)
            {
                _audioSource = new DataSource(Header->DATAData->Data, WorkingUncompressed.Length - offset);
                SetSizeInternal(offset);
            }
        }
Exemplo n.º 4
0
        private void btnOkay_Click(object sender, EventArgs e)
        {
            Stop();

            if (_sourceStream is InitialStreamWrapper w && w.BaseStream == _initialStream)
            {
                _initialStream.LoopStartSample = _sourceStream.LoopStartSample;
                _initialStream.LoopEndSample   = _sourceStream.LoopEndSample;
                _initialStream.IsLooping       = _sourceStream.IsLooping;
            }

            if (_initialStream == null)
            {
                using (ProgressWindow progress = new ProgressWindow(this, String.Format("{0} Converter", _type == 0 ? "Brstm" : "Wave"), "Encoding, please wait...", false))
                    switch (_type)
                    {
                    case 0:
                        var encoding = (WaveEncoding)ddlEncoding.SelectedItem;
                        PreviousEncoding = encoding;
                        _audioData       = RSTMConverter.Encode(_sourceStream, progress, encoding);
                        break;

                    case 1:
                        _audioData = RSARWaveConverter.Encode(_sourceStream, progress);
                        break;

                    case 2:
                        _audioData = RWAVConverter.Encode(_sourceStream, progress);
                        break;
                    }
            }

            DialogResult = DialogResult.OK;
            Close();
        }
Exemplo n.º 5
0
        public override void build(Form parent, IProgressTracker tracker, string tmpwav, string output, bool looping, int loopStart, int length, bool loopTrim)
        {
            FileMap audioData;

            if (loopStart == -2)
            {
                BrstmConverterDialog bcd = new BrstmConverterDialog();
                bcd.AudioSource = tmpwav;
                bcd.ShowDialog(parent);
                if (bcd.DialogResult != DialogResult.OK)
                {
                    throw new MusicFileException("Build cancelled.");
                }
                audioData = bcd.AudioData;
            }
            else
            {
                IAudioStream audioStream = WAV.FromFile(tmpwav);
                audioStream.IsLooping       = looping;
                audioStream.LoopStartSample = loopStart;
                audioStream.LoopEndSample   = length;
                //if (tracker == null) tracker = new ProgressWindow(parent, Shared.PROGRAM_TITLE, "Encoding, please wait...", false);
                audioData = RSTMConverter.Encode(audioStream, tracker);
                audioStream.Dispose();
            }
            FileMapWriter.write(audioData, output, FileMode.Create);
            audioData.Dispose();
        }
Exemplo n.º 6
0
 private void btnOkay_Click(object sender, EventArgs e)
 {
     Stop();
     using (ProgressWindow progress = new ProgressWindow(this, "Brstm Converter", "Encoding, please wait...", false))
         _audioData = RSTMConverter.Encode(_sourceStream, progress);
     DialogResult = DialogResult.OK;
     Close();
 }
Exemplo n.º 7
0
        public override unsafe void Replace(string fileName)
        {
            stream = null;

            if (fileName.EndsWith(".wav"))
            {
                stream = WAV.FromFile(fileName);
            }
            else
            {
                base.Replace(fileName);
            }

            if (stream != null)
            {
                try { ReplaceRaw(RSTMConverter.Encode(stream, null)); }
                finally { stream.Dispose(); }
            }
        }
Exemplo n.º 8
0
        private void btnOkay_Click(object sender, EventArgs e)
        {
            Stop();
            using (ProgressWindow progress = new ProgressWindow(this, String.Format("{0} Converter", _type == 0 ? "Brstm" : "Wave"), "Encoding, please wait...", false))
                switch (_type)
                {
                case 0:
                    _audioData = RSTMConverter.Encode(_sourceStream, progress);
                    break;

                case 1:
                    _audioData = RSARWaveConverter.Encode(_sourceStream, progress);
                    break;

                case 2:
                    _audioData = RWAVConverter.Encode(_sourceStream, progress);
                    break;
                }

            DialogResult = DialogResult.OK;
            Close();
        }
Exemplo n.º 9
0
        public override unsafe void Replace(string fileName)
        {
            IAudioStream stream = null;

            if (fileName.EndsWith(".wav"))
            {
                stream = WAV.FromFile(fileName);
            }
            else
            {
                base.Replace(fileName);
            }

            if (stream != null)
            {
                try
                {
                    ReplaceRaw(RSTMConverter.Encode(stream, null));
                }
                finally
                {
                    stream.Dispose();
                }
            }

            if (Header->_header._tag == CSTMHeader.Tag || Header->_header._tag == FSTMHeader.Tag)
            {
                throw new NotImplementedException();
            }

            int offset = (int)Header->DATAData->Data - (int)Header;

            if (offset < WorkingUncompressed.Length)
            {
                _audioSource = new DataSource(Header->DATAData->Data, WorkingUncompressed.Length - offset);
                SetSizeInternal(offset);
            }
        }