Example #1
0
 private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
 {
     int n = listBox1.SelectedIndex;
     if (n == -1)
         return;
     rtb1.Text = "";
     rtb1.Visible = true;
     hb1.Visible = false;
     int index = ObjectIndexes[n];
     IExportEntry ex = pcc.Exports[index];
     if (ex.ClassName == "WwiseStream")
     {
         w = new WwiseStream(pcc as ME3Package, index);                
         string s = "#" + index + " WwiseStream : " + ex.ObjectName + "\n\n";
         s += "Filename : \"" + w.FileName + "\"\n";
         s += "Data size: " + w.DataSize + " bytes\n";                    
         s += "Data offset: 0x" + w.DataOffset.ToString("X8") + "\n";
         s += "ID: 0x" + w.Id.ToString("X8") + " = " + w.Id +"\n";
         rtb1.Text = s;
     }
     if (ex.ClassName == "WwiseBank")
     {
         rtb1.Visible = false;
         hb1.Visible = true;
         wb = new WwiseBank(pcc as ME3Package, index);
         hb1.ByteProvider = new DynamicByteProvider(wb.getBinary());
     }
 }
        /// <summary>
        /// Creates wav file in temp directory
        /// </summary>
        /// <param name="ws"></param>
        /// <returns></returns>
        public static string CreateWave(this WwiseStream ws)
        {
            string basePath = WwiseStreamHelper.GetATempSoundPath();
            string wavPath  = basePath + ".wav";

            if (ws.CreateWaveStream() is MemoryStream dataStream)
            {
                File.WriteAllBytes(wavPath, dataStream.ToArray());
            }
            return(wavPath);
        }
        /// <summary>
        /// Creates wav stream from this WwiseStream
        /// </summary>
        /// <param name="afcPath"></param>
        /// <returns></returns>
        public static MemoryStream CreateWaveStream(this WwiseStream ws)
        {
            string basePath = WwiseStreamHelper.GetATempSoundPath();
            string wemPath  = basePath + ".wem";

            if (ws.ExtractRawFromSourceToFile(wemPath))
            {
                return(ISBankEntry.ConvertAudioToWave(wemPath));
            }

            return(null);
        }
 public static bool ExtractRawFromSourceToFile(this WwiseStream ws, string outputFile)
 {
     if (ws.IsPCCStored)
     {
         if (ws.EmbeddedData is null || ws.EmbeddedData.Length == 0)
         {
             return(false);
         }
         if (File.Exists(outputFile))
         {
             File.Delete(outputFile);
         }
         File.WriteAllBytes(outputFile, ws.EmbeddedData);
         return(true);
     }
     return(WwiseStreamHelper.ExtractRawFromSourceToFile(outputFile, ws.GetPathToAFC(), ws.DataSize, ws.DataOffset));
 }
        /// <summary>
        /// This method is deprecated and will be removed eventually
        /// </summary>
        /// <param name="path"></param>
        /// <param name="pathtoafc"></param>
        public static void ImportFromFile(this WwiseStream ws, string path, string pathtoafc = "")
        {
            if (ws.Filename == "")
            {
                return;
            }
            using FileStream stream = new FileStream(path, FileMode.Open, FileAccess.Read);

            if (ws.IsPCCStored)
            {
                ws.ImportWwiseOgg(pathtoafc, stream);
            }
            else if (pathtoafc != "")
            {
                if (File.Exists(pathtoafc))
                {
                    ws.ImportWwiseOgg(pathtoafc, stream);
                }
                else if (File.Exists(pathtoafc + ws.Filename + ".afc")) //legacy code for old soundplorer
                {
                    ws.ImportWwiseOgg(pathtoafc + ws.Filename + ".afc", stream);
                }
                else
                {
                    OpenFileDialog d = new OpenFileDialog();
                    d.Filter = ws.Filename + ".afc|" + ws.Filename + ".afc";
                    if (d.ShowDialog() == DialogResult.OK)
                    {
                        ws.ImportWwiseOgg(d.FileName, stream);
                    }
                }
            }
            else
            {
                OpenFileDialog d = new OpenFileDialog();
                d.Filter = ws.Filename + ".afc|" + ws.Filename + ".afc";
                if (d.ShowDialog() == DialogResult.OK)
                {
                    ws.ImportWwiseOgg(d.FileName, stream);
                }
            }
        }
        private static void ImportWwiseOgg(this WwiseStream ws, string pathafc, Stream wwiseOggStream)
        {
            if ((!ws.IsPCCStored && !File.Exists(pathafc)) || wwiseOggStream == null)
            {
                return;
            }
            //Convert wwiseoggstream
            MemoryStream convertedStream = WwiseStreamHelper.ConvertWwiseOggToME3Ogg(wwiseOggStream);

            byte[] newWavfile = convertedStream.ToArray();

            if (ws.IsPCCStored)
            {
                ws.EmbeddedData = newWavfile;
                //DataSize and DataOffset are automatically calculated during serialization
                //when EmbeddedData != null
                return;
            }


            //Open AFC
            FileStream fs     = new FileStream(pathafc, FileMode.Open, FileAccess.Read);
            var        Header = new byte[94];

            //Seek to data we are replacing and read header
            fs.Seek(ws.DataOffset, SeekOrigin.Begin);
            fs.Read(Header, 0, 94);
            fs.Close();


            //append new wav
            fs = new FileStream(pathafc, FileMode.Append, FileAccess.Write, FileShare.Write);
            int newWavDataOffset = (int)fs.Length;
            int newWavSize       = newWavfile.Length;

            fs.Write(newWavfile, 0, newWavSize);
            fs.Close();

            ws.DataSize     = newWavSize;
            ws.DataOffset   = newWavDataOffset;
            ws.EmbeddedData = null;
        }
Example #7
0
 public void ImportSound()
 {
     if (listView1.SelectedItems.Count != 1 || pcc == null)
         return;
     ListViewItem item = listView1.SelectedItems[0];
     int index = Convert.ToInt32(item.Name);
     if (pcc.Exports[index].ClassName == "WwiseStream")
     {
         OpenFileDialog o = new OpenFileDialog();
         o.Filter = "Wwise wav (*.wav)|*.wav";
         if (o.ShowDialog() == DialogResult.OK)
         {
             w = new WwiseStream(pcc, pcc.Exports[index].Data);
             w.ImportFromFile(o.FileName, pathBIOGame, pathCooked);
             byte[] buff = new byte[w.memsize];
             for (int i = 0; i < w.memsize; i++)
                 buff[i] = w.memory[i];
             PCCObject.ExportEntry ent = pcc.Exports[index];
             ent.Data = buff;
             //pcc.ChangeExportEntry(index, CopyExport(ent));
             MessageBox.Show("Done.");
         }
     }
 }
Example #8
0
 public void PlaySound()
 {
     if (listView1.SelectedItems.Count != 1 || pcc == null)
         return;
     ListViewItem item = listView1.SelectedItems[0];
     int index = Convert.ToInt32(item.Name);
     if (pcc.Exports[index].ClassName == "WwiseStream")
     {
         w = new WwiseStream(pcc, pcc.Exports[index].Data);
         w.Play(pathCooked);
     }
 }
Example #9
0
 private void playToolStripMenuItem_Click(object sender, EventArgs e)
 {
     int n = listBox1.SelectedIndex;
     if (n == -1)
         return;
     int index = ObjectIndexes[n];
     IExportEntry ex = pcc.Exports[index];
     if (ex.ClassName == "WwiseStream")
     {
         Stop();
         w = new WwiseStream(pcc as ME3Package, index);
         string path;
         if (w.IsPCCStored)
         {
             path = pcc.FileName;
         }
         else
         {
             path = getPathToAFC();
         }
         if (path != "")
         {
             Status.Text = "Loading...";
             w.Play(path);
             Status.Text = "Ready";
         }
     }
 }
Example #10
0
 private void playToolStripMenuItem_Click(object sender, EventArgs e)
 {
     int n = listBox1.SelectedIndex;
     if (n == -1)
         return;
     int index = ObjectIndexes[n];
     PCCObject.ExportEntry ex = pcc.Exports[index];
     if (ex.ClassName == "WwiseStream")
     {
         Stop();
         w = new WwiseStream(pcc, ex.Data);
         string path = ME3Directory.cookedPath;
         Status.Text = "Loading...";
         w.Play(path);
         Status.Text = "Ready";
     }
 }
Example #11
0
 public void PlaySound()
 {
     if (listView1.SelectedItems.Count != 1 || pcc == null)
         return;
     ListViewItem item = listView1.SelectedItems[0];
     int index = Convert.ToInt32(item.Name);
     if (pcc.Exports[index].ClassName == "WwiseStream")
     {
         using (ME3Package package = MEPackageHandler.OpenME3Package(pcc.pccFileName))
         {
             w = new WwiseStream(package, index);
             w.Play(pathCooked);
         }
     }
 }