Exemplo n.º 1
0
        /// <summary>
        /// this sucks honestly but i lost hope with all wav conversion types
        /// </summary>
        private bool TryVGMStreamConvert(ListBoxViewModel2 selectedItem, out string wavFilePath)
        {
            if (File.Exists(Properties.Settings.Default.OutputPath + "\\Vgm\\test.exe"))
            {
                Directory.CreateDirectory(Properties.Settings.Default.OutputPath + "\\Sounds\\" + selectedItem.Folder + "\\");
                File.WriteAllBytes(Properties.Settings.Default.OutputPath + "\\Sounds\\" + selectedItem.Folder + "\\" + selectedItem.Content, selectedItem.Data);

                wavFilePath = Path.ChangeExtension(Properties.Settings.Default.OutputPath + "\\Sounds\\" + selectedItem.Folder + "\\" + selectedItem.Content, ".wav");
                var vgmstream = Process.Start(new ProcessStartInfo
                {
                    FileName               = Properties.Settings.Default.OutputPath + "\\Vgm\\test.exe",
                    Arguments              = $"-o \"{wavFilePath}\" \"{Properties.Settings.Default.OutputPath + "\\Sounds\\" + selectedItem.Folder + "\\" + selectedItem.Content}\"",
                    UseShellExecute        = false,
                    RedirectStandardOutput = true,
                    CreateNoWindow         = true
                });
                vgmstream.WaitForExit();

                ListBoxVm.soundFiles.Remove(selectedItem);
                File.Delete(Properties.Settings.Default.OutputPath + "\\Sounds\\" + selectedItem.Folder + "\\" + selectedItem.Content);

                return(vgmstream.ExitCode == 0 && File.Exists(wavFilePath));
            }
            wavFilePath = string.Empty;
            return(false);
        }
Exemplo n.º 2
0
        public void LoadFile(string filepath)
        {
            ListBoxViewModel2 item = ListBoxVm.soundFiles.Where(x => x.FullPath.Equals(filepath)).FirstOrDefault();

            if (item == null)
            {
                Focus();
                item = new ListBoxViewModel2
                {
                    Content  = Path.GetFileName(filepath),
                    Data     = null,
                    FullPath = filepath,
                    Folder   = string.Empty
                };

                ListBoxVm.soundFiles.Add(item);

                if (ListBoxVm.soundFiles.Count == 1) // auto play if one in queue
                {
                    output.Stop();
                    output.Load(filepath);
                    output.Play();
                    Sound_LstBox.SelectedIndex = 0;

                    string name = Path.GetFileName(filepath);
                    InputFileVm.inputFileViewModel.Set(name, output);
                    DiscordIntegration.Update(string.Empty, string.Format(Properties.Resources.Listening, name));
                    PlayPauseImg.Source = new BitmapImage(new Uri("pack://application:,,,/Resources/pause.png"));
                }
                else
                {
                    Sound_LstBox.SelectedIndex = ListBoxVm.soundFiles.IndexOf(item);
                    Sound_LstBox.ScrollIntoView(item);
                }
            }
            else
            {
                Focus();
                Sound_LstBox.SelectedIndex = ListBoxVm.soundFiles.IndexOf(item);
                Sound_LstBox.ScrollIntoView(item);
            }
        }