Windows Phone Thoughts - Daily News, Views, Rants and Raves

Check out the hottest Windows Mobile devices at our Expansys store!

Digital Home Thoughts

Loading feed...

Laptop Thoughts

Loading feed...

Android Thoughts

Loading feed...

Go Back   Thoughts Media Forums > WINDOWS PHONE THOUGHTS > Windows Phone Software

Thread Tools Display Modes
Prev Previous Post   Next Post Next
Old 06-24-2005, 01:04 PM
5000+ Posts? I Should OWN This Site!
Join Date: Jun 2007
Posts: 5,067
Default AT LAST: Extracting embedded sound (WAV) files from Pocket Notes (PWI) files!

ActiveSync has always been unable to extract embedded sound files from Notes (.PWI) files, causing a lot of problems to people using this way to create notes with embedded voice notes - the embedded voice notes couldn't be played off your dekstop computer. Also, up to now, there has been a complete lack of an app doing this.

I've published the algorithm to extract these files from PWI files a long time ago (see for example this and this). So far, however, I hadn't the time to actually code, test with various JVM's (including Pocket PC JVM's) and document an actual utility that makes this possible.

Now that I had some free hours today, the waiting is over

The source code is pretty straightforward:


class PWIEmbeddedWAVExport
public static void main(String[] s) throws Exception
	FileInputStream fis = new FileInputStream (s[0]);
	File f = new File (s[0]);
	int fileSize = (int)f.length();
	byte[] barr = new byte[fileSize];
	byte[] barr2 = new byte[fileSize/2];
	int readCount =;
	for (int i=0; i<fileSize/2; i++)
	String str = new String(barr2);
	java.util.Vector indeces = new java.util.Vector();
	int lastIndexFound = 0; 
	while ((lastIndexFound = str.indexOf("VoiceNote.wav", lastIndexFound+1)) != -1)
			indeces.addElement(new Integer(lastIndexFound*2));
	// now, we have the exact position of all VoiceNote.wav's in the file; 
	// we can go on for the actual extraction
	int sumSize = 0;
	for (int i=0; i<indeces.size(); i++)
		int embFileStartsAt = ((Integer)indeces.elementAt(i)).intValue()+ "VoiceNote.wav".length()*2-2 + 4146 + 4;
		int embFileEndsAt = readCount;
		if (i<indeces.size()-1) embFileEndsAt = ((Integer)indeces.elementAt(i+1)).intValue() - 528;
		FileOutputStream fos = new FileOutputStream (s[0].substring(0, s[0].length()-4)+(indeces.size()-i)+".wav"); 
		// indeces.size()-i is needed because of the LIFO order in the file
		fos.write(barr, embFileStartsAt, embFileEndsAt-embFileStartsAt);
 } // main
}// class
Feel free to compile (preferably with JDK1.1 if you need 100% compliance with all of the PPC JVM's - please note that I deliberately made it JDK1.1-compliant for the best compliance with current PPC JVM's) and JAR it. To make your life easier, you can also download it from here.

On the desktop, put it in the classpath and issue the

java -jar PWIEmbeddedWAVExport.jar <PWI name>

command. The extracted sound files will be created in the current directory.

If you plan to do the extraction on the PDA so that you don't need to have access to any desktop computer, you can use any of the following four JVM's (others may also work): NetFront 3.1+, CrEme, Jeode, J9 PJava. Please read this thread for more information on getting them if you don't have any of them (not even the Java-enabled Netfront - perhaps this is the best solution because you may already have it on your Pocket PC, which makes it unnecessary to install another JVM.

To run the converter on the PDA, make a directory in it with the name, say, \conv in there. Copy the JAR file and one of the following batch files (I've also listed their contents here).

NetFront jvlite (tested with NF 3.1):

"\Program Files\NetFront3\jvlite.exe" -classpath \conv\PWIEmbeddedWAVExport.jar PWIEmbeddedWAVExport %1

CrEme 3.x/4.x (tested with 3.26):

"\SD-MMCard\creme\bin\CrEme.exe" -Ob -classpath \conv\PWIEmbeddedWAVExport.jar PWIEmbeddedWAVExport %1

Jeode (tested with 1.7.3):

\SD-MMCard\jeode\evm.exe -Djeode.evm.console.local.keep=true -cp \conv\PWIEmbeddedWAVExport.jar PWIEmbeddedWAVExport %1

IBM J9 PJ (tested with 5.7.2):

"\SD-MMCard\IBM PPRO10\bin\J9.exe" "-jclpro10" -cp \conv\PWIEmbeddedWAVExport.jar PWIEmbeddedWAVExport %1

Please modify the path to the executable according to the directory your JVM/NetFront is installed to!

The next step is installing PPC Command Shell - please see my post on doing this here (second page, third post) - to provide a console to run batch files to avoid the need for editing link files with wired-in filenames.

After installing it, fire up the console and go to \conv. Assuming you've already copied here the .BAT batch file(s) you want to invoke your JVM('s) with, PWIEmbeddedWAVExport.jar and the source PWI file(s), you can start working right away by issuing the <batchname> \conv\<PWI name> command. (Note that you need to supply the full directory path, here, \conv to the JVM so that it finds the input file.) The embedded WAV files will be created in the same directory.

I may rewrite/repackage this app using the CF framework some day (but not in the very near future!).
Reply With Quote

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT +1. The time now is 12:05 AM.