Click here to Skip to main content
15,881,624 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

I'm working on a project to create a wave bank file.

I have been using a hex editor to create them ,

but it's very time consuming.

I have tried using StreamWriter, but to no avail.

I think I can use BinaryWriter, but I need to

have it search for the word Riff cause it's the

word at the beginning of every pcm .wav file.

Here is a sample binary of a 3 wav bank file:


RIFF,...WAVEfmt { binarycode }
RIFF,...WAVEfmt { binarycode }
RIFF,...WAVEfmt { binarycode }

Any help would be great

I open a wave bank file, reading the xml file connected with the bank file

Sample XML

XML
<?xml version="1.0" encoding="iso-8859-1"?>
<wavebank name="menu_music_wave" dir="data/sound/music/menu_music/" size_before="18639744" size="27268046" compression="28 %" xmlns:xi="x">
<wave name="menu_music01" file="menu_music01.wav" stream="true" file_priority="low" quality="44100 adpcm" size_before="36286068" size="10205544" compression="28 %" bank="menu_music_wave.bank" offset="0"/>
<wave name="outro_music01" file="outro_music01.wav" stream="true" file_priority="low" quality="44100 adpcm" size_before="29990778" size="8434200" compression="28 %" bank="menu_music_wave.bank" offset="10205544"/>
<wave name="menu_music02" file="menu_music02.wav" stream="true" file_priority="low" quality="44100 adpcm" size_before="36286068" size="10205544" compression="28 %" bank="menu_music_wave.bank" offset="18639744"/>
</wavebank>


Here is the code I use to read the xml

C#
if (this.openFileDialog1.ShowDialog() != DialogResult.OK)
 {
	 return;
 }
 string fileName = this.openFileDialog1.FileName;
 this.listView1.Items.Clear();
 Directory.SetCurrentDirectory(Path.GetDirectoryName(fileName));
 FileStream fileStream = null;
 try
 {
	 fileStream = File.Open(fileName, FileMode.Open);
	 XmlTextReader xmlTextReader = new XmlTextReader(fileStream);
	 while (xmlTextReader.Read())
	 {
		 if (xmlTextReader.Name == "wave" && xmlTextReader.NodeType == XmlNodeType.Element)
		 {
			 Hashtable hashtable = new Hashtable();
			 _ = xmlTextReader.Name;
			 if (xmlTextReader.HasAttributes)
			 {
				 for (int i = 0; i < xmlTextReader.AttributeCount; ++i)
				 {
					 xmlTextReader.MoveToAttribute(i);
					 hashtable.Add(xmlTextReader.Name, xmlTextReader.Value);
				 }
			 }
			 this.listView1.Items.Add(new ListViewItem()
			 {
				 Text = hashtable["file"].ToString(),
				 SubItems = { hashtable["size"].ToString(), hashtable["bank"].ToString(), hashtable["offset"].ToString() },
				 Tag = hashtable
			 });
		 }
	 }
 }
 finally
 {
	 fileStream?.Close();
 }


Now I want to save the *.bank file

What I have tried:

I have tried using StreamWriter, but to no avail.
Posted
Updated 20-Dec-20 6:21am
v2

1 solution

 
Share this answer
 
v2
Comments
RickZeeland 22-Dec-20 1:34am    
Bummer, but I think if your xml file isn't too large working with Xelement could simplify things, as the whole xml file is read into memory it will consume more memory than XmlTextReader of course.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900