Esempio n. 1
0
        public override void handleUpdate(List <PackageUpdate> updates)
        {
            List <PackageChange> changes = updates.Select(x => x.change).ToList();
            bool importChanges           = changes.Contains(PackageChange.Import) || changes.Contains(PackageChange.ImportAdd);
            bool exportNonDataChanges    = changes.Contains(PackageChange.ExportHeader) || changes.Contains(PackageChange.ExportAdd);

            var loadedIndexes = BindedExportsList.Where(x => x.Export != null).Select(y => y.Export.Index).ToList();

            List <SoundplorerExport> exportsRequiringReload = new List <SoundplorerExport>();

            foreach (PackageUpdate pc in updates)
            {
                if (loadedIndexes.Contains(pc.index))
                {
                    SoundplorerExport sp = BindedExportsList.First(x => x.Export.Index == pc.index);
                    exportsRequiringReload.Add(sp);
                }
            }



            if (exportsRequiringReload.Count() > 0)
            {
                SoundplorerExport spExport = (SoundplorerExport)SoundExports_ListBox.SelectedItem;
                if (spExport == null)
                {
                    if (exportsRequiringReload.Contains(spExport))
                    {
                        soundPanel.FreeAudioResources(); //unload the current export
                    }
                }
                LoadObjects(exportsRequiringReload);
                soundPanel.LoadExport(spExport.Export); //reload
            }
        }
Esempio n. 2
0
        private void CloneAndReplace(bool fromWave)
        {
            string result = PromptDialog.Prompt("Enter a new object name for the cloned item.", "Cloned export name");

            if (result != null)
            {
                SoundplorerExport spExport = (SoundplorerExport)SoundExports_ListBox.SelectedItem;
                if (spExport != null && spExport.Export.ClassName == "WwiseStream")
                {
                    IExportEntry clone = spExport.Export.Clone();
                    clone.idxObjectName = clone.FileRef.FindNameOrAdd(result);
                    spExport.Export.FileRef.addExport(clone);
                    SoundplorerExport newExport = new SoundplorerExport(clone);
                    BindedExportsList.Add(newExport);
                    var reloadList = new List <SoundplorerExport>();
                    reloadList.Add(newExport);
                    SoundExports_ListBox.ScrollIntoView(newExport);
                    SoundExports_ListBox.UpdateLayout();
                    var item = SoundExports_ListBox.ItemContainerGenerator.ContainerFromItem(newExport) as ListBoxItem;
                    if (item != null)
                    {
                        item.Focus();
                    }
                    if (fromWave)
                    {
                        soundPanel.ReplaceAudioFromWwiseOgg(forcedExport: clone);
                    }
                    else
                    {
                        soundPanel.ReplaceAudioFromWave(forcedExport: clone);
                    }
                    LoadObjects(reloadList);
                }
            }
        }
Esempio n. 3
0
        private void ExportRaw_Clicked(object sender, RoutedEventArgs e)
        {
            SoundplorerExport spExport = (SoundplorerExport)SoundExports_ListBox.SelectedItem;

            if (spExport != null && spExport.Export.ClassName == "WwiseStream")
            {
                SaveFileDialog d = new SaveFileDialog();

                d.Filter   = "Wwise WEM|*.wem";
                d.FileName = spExport.Export.ObjectName + ".wem";
                bool?res = d.ShowDialog();
                if (res.HasValue && res.Value)
                {
                    WwiseStream w = new WwiseStream(spExport.Export);
                    if (w.ExtractRawFromStream(d.FileName, w.getPathToAFC()))
                    {
                        MessageBox.Show("Done.");
                    }
                    else
                    {
                        MessageBox.Show("Error extracting WEM file.\nMetadata for this raw data may be incorrect (e.g. too big for file).");
                    }
                }
            }
        }
Esempio n. 4
0
        private void CloneAndReplaceFromWav_Clicked(object sender, RoutedEventArgs e)
        {
            SoundplorerExport spExport = (SoundplorerExport)SoundExports_ListBox.SelectedItem;

            if (spExport != null)
            {
                CloneAndReplace(true);
            }
        }
Esempio n. 5
0
        private void ReplaceAudioFromWav_Clicked(object sender, RoutedEventArgs e)
        {
            SoundplorerExport spExport = (SoundplorerExport)SoundExports_ListBox.SelectedItem;

            if (spExport != null)
            {
                soundPanel.ReplaceAudioFromWave(forcedExport: spExport.Export);
            }
        }
Esempio n. 6
0
        private void ExtractBankToWav(SoundplorerExport spExport, string location = null)
        {
            if (spExport != null && spExport.Export.ClassName == "WwiseBank")
            {
                WwiseBank wb = new WwiseBank(spExport.Export);
                var       embeddedWEMFiles = wb.GetWEMFilesMetadata();
                if (embeddedWEMFiles.Count > 0)
                {
                    if (location == null)
                    {
                        var dlg = new CommonOpenFileDialog("Select output folder")
                        {
                            IsFolderPicker = true
                        };

                        if (dlg.ShowDialog() != CommonFileDialogResult.Ok)
                        {
                            return;
                        }
                        location = dlg.FileName;
                    }

                    var data = wb.GetChunk("DATA");
                    if (embeddedWEMFiles.Count > 0)
                    {
                        foreach (var singleWemMetadata in embeddedWEMFiles)
                        {
                            byte[] wemData = new byte[singleWemMetadata.Item3];
                            //copy WEM data to buffer. Add 0x8 to skip DATA and DATASIZE header for this block.
                            Buffer.BlockCopy(data, singleWemMetadata.Item2 + 0x8, wemData, 0, singleWemMetadata.Item3);
                            //check for RIFF header as some don't seem to have it and are not playable.
                            string wemHeader = "" + (char)wemData[0] + (char)wemData[1] + (char)wemData[2] + (char)wemData[3];
                            string wemName   = spExport.Export.ObjectName + "_0x" + singleWemMetadata.Item1.ToString("X8");

                            if (wemHeader == "RIFF")
                            {
                                EmbeddedWEMFile wem        = new EmbeddedWEMFile(wemData, wemName, spExport.Export.FileRef.Game); //will correct truncated stuff
                                Stream          waveStream = soundPanel.getPCMStream(forcedWemFile: wem);
                                if (waveStream != null && waveStream.Length > 0)
                                {
                                    string outputname = wemName + ".wav";
                                    string outpath    = System.IO.Path.Combine(location, outputname);
                                    using (var fileStream = File.Create(outpath))
                                    {
                                        waveStream.Seek(0, SeekOrigin.Begin);
                                        waveStream.CopyTo(fileStream);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Esempio n. 7
0
        private void SoundExports_ListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            SoundplorerExport spExport = (SoundplorerExport)SoundExports_ListBox.SelectedItem;

            if (spExport == null)
            {
                soundPanel.UnloadExport();
                return;
            }
            soundPanel.LoadExport(spExport.Export);
        }
Esempio n. 8
0
        private void ExportWave(SoundplorerExport spExport, string outputLocation = null)
        {
            if (spExport != null && spExport.Export.ClassName == "WwiseStream")
            {
                bool silent = outputLocation != null;
                if (outputLocation == null)
                {
                    SaveFileDialog d = new SaveFileDialog();

                    d.Filter   = "Wave PCM|*.wav";
                    d.FileName = spExport.Export.ObjectName + ".wav";
                    bool?res = d.ShowDialog();
                    if (res.HasValue && res.Value)
                    {
                        outputLocation = d.FileName;
                    }
                    else
                    {
                        return;
                    }
                }

                WwiseStream w      = new WwiseStream(spExport.Export);
                Stream      source = w.CreateWaveStream(w.getPathToAFC());
                if (source != null)
                {
                    using (var fileStream = File.Create(outputLocation))
                    {
                        source.Seek(0, SeekOrigin.Begin);
                        source.CopyTo(fileStream);
                    }
                    if (!silent)
                    {
                        MessageBox.Show("Done.");
                    }
                }
                else
                {
                    if (!silent)
                    {
                        MessageBox.Show("Error creating Wave file.\nThis might not be a supported codec or the AFC data may be incorrect.");
                    }
                }
            }
        }
Esempio n. 9
0
        private void ExtractBank_Clicked(object sender, RoutedEventArgs e)
        {
            SoundplorerExport spExport = (SoundplorerExport)SoundExports_ListBox.SelectedItem;

            if (spExport != null && spExport.Export.ClassName == "WwiseBank")
            {
                SaveFileDialog d = new SaveFileDialog();

                d.Filter   = "WwiseBank|*.bnk";
                d.FileName = spExport.Export.ObjectName + ".bnk";
                bool?res = d.ShowDialog();
                if (res.HasValue && res.Value)
                {
                    //File.WriteAllBytes(d.FileName, spExport.Export.getBinaryData());
                    File.WriteAllBytes(d.FileName, spExport.Export.Data);
                    MessageBox.Show("Done.");
                }
            }
        }
Esempio n. 10
0
        private void ExportOgg_Clicked(object sender, RoutedEventArgs e)
        {
            SoundplorerExport spExport = (SoundplorerExport)SoundExports_ListBox.SelectedItem;

            if (spExport != null && spExport.Export.ClassName == "WwiseStream")
            {
                SaveFileDialog d = new SaveFileDialog();

                d.Filter   = "Ogg Vorbis|*.ogg";
                d.FileName = spExport.Export.ObjectName + ".ogg";
                bool?res = d.ShowDialog();
                if (res.HasValue && res.Value)
                {
                    WwiseStream w = new WwiseStream(spExport.Export);
                    string      riffOutputFile = System.IO.Path.Combine(Directory.GetParent(d.FileName).FullName, System.IO.Path.GetFileNameWithoutExtension(d.FileName)) + ".dat";

                    if (w.ExtractRawFromStream(riffOutputFile, w.getPathToAFC()))
                    {
                        MemoryStream oggStream = WwiseStream.ConvertRIFFToWWwiseOGG(riffOutputFile, spExport.Export.FileRef.Game == MEGame.ME2);
                        //string outputOggPath =
                        if (oggStream != null)// && File.Exists(outputOggPath))
                        {
                            oggStream.Seek(0, SeekOrigin.Begin);
                            using (FileStream fs = new FileStream(d.FileName, FileMode.OpenOrCreate))
                            {
                                oggStream.CopyTo(fs);
                                fs.Flush();
                            }
                            MessageBox.Show("Done.");
                        }
                        else
                        {
                            MessageBox.Show("Error extracting Ogg file.\nMetadata for the raw data may be incorrect (e.g. header specifies data is longer than it actually is).");
                        }
                    }
                }
            }
        }
Esempio n. 11
0
        private void ExtractWEMAsWaveFromBank_Clicked(object sender, RoutedEventArgs e)
        {
            SoundplorerExport spExport = (SoundplorerExport)SoundExports_ListBox.SelectedItem;

            ExtractBankToWav(spExport);
        }