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

Reply
 
Thread Tools Display Modes
  #1  
Old 06-24-2005, 01:04 PM
Menneisyys
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:

Code:
import java.io.*;

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 = fis.read(barr);
	for (int i=0; i<fileSize/2; i++)
	  barr2[i]=barr[i*2];
	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);
		fos.flush();
		fos.close();
	}
	fis.close();
 } // 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
  #2  
Old 10-06-2008, 09:08 PM
LarryBrown
Neophyte
Join Date: Oct 2008
Posts: 1
Default Awesome!

To: Menneisyys. Thanks for this awesome program. It worked great for me, reading the pwi files from my Windows Mobile 5 device and saving the WAV.
Really great work.

I don't know why I was so stupid as to buy this brain dead Microsoft based mobile phone. Mine is T-Mobile MDA. I need something with a hardware keyboard and the ability to type notes of unlimited length because I am a writer and I am always typing stuff. I saw a guy with this phone so I bought it. I didn't even know it was Microsoft. If I had known I would have looked elsewhere. I have been very dissatisfied. On Vista, the Windows Mobile Sync software is a destructive joke. It's destroyed my data twice. To sync your contacts, you have to use Outlook, yet another example of Microsoft's malicious technique of locking you in to their stuff, at $$$ expense. Using Outlook to sync contacts with a telephone is like using a bazooka instead of a flyswatter. Also, the .pwi files are useless on the main computer, unless some genius like you helps us out.

Thanks again!
 
Reply With Quote
  #3  
Old 02-05-2009, 11:22 PM
q
Neophyte
Join Date: Feb 2009
Posts: 2

I checked it more thoroughly and it came out that exactly 50% of sounds are extracted.

If you ordered the sounds 1, 2, 3, ..., n the program would produce only every second sound in the following order:

1: sound no n-1
2: sound no n-3
3: sound no n-5
....
n/2: sound no 1

This may not always be exactly the case as I tested it with the file that had an odd numer of sound notes (39). If the number is even it may be slightly different. But you get the general idea.

I also downloaded the source code and spotted some
Code:
fileSize/2
occurences there. I am not a programming expert however so maybe it has absolutely nothing to do with it. I' m thinking of experimenting with the code myself a bit.
 
Reply With Quote
  #4  
Old 02-19-2009, 12:28 AM
Menneisyys
5000+ Posts? I Should OWN This Site!
Join Date: Jun 2007
Posts: 5,067

Quote:
Originally Posted by q View Post
I checked it more thoroughly and it came out that exactly 50% of sounds are extracted.

If you ordered the sounds 1, 2, 3, ..., n the program would produce only every second sound in the following order:

1: sound no n-1
2: sound no n-3
3: sound no n-5
....
n/2: sound no 1

This may not always be exactly the case as I tested it with the file that had an odd numer of sound notes (39). If the number is even it may be slightly different. But you get the general idea.

I also downloaded the source code and spotted some
Code:
fileSize/2
occurences there. I am not a programming expert however so maybe it has absolutely nothing to do with it. I' m thinking of experimenting with the code myself a bit.

Thanks for reporting this; I'll try to look into the problem when I have some time.
 
Reply With Quote
  #5  
Old 10-07-2009, 02:30 AM
BobM
Neophyte
Join Date: Oct 2009
Posts: 1
Lightbulb An easy method using software only

I came across this thread with the same problem of extracting WAV files from PWI files. I found a technique that works entirely through software with no need to modify anything on the mobile device.

In the PWI files the WAV file is stored at the end of the file. All that needs to be done is to delete everything before the WAV portion and then save the remaining data as a new file. Here is an easy method to do this using a freeware hex editor.
  1. Transfer the PWI files to a PC using ActiveSync.
  2. Open the PWI file in the hex editor XVI32. All following steps are in XVI32. http://www.chmaas.handshake.de/delph...vi32/xvi32.htm
  3. Search --> Find
    • "Text String" should be checked
  4. Enter the following text in the search field: RIFF
  5. Click OK
    • The "R" in RIFF will be highlighted in the window on the right
  6. In the window on the right, select the character before the R in RIFF. That is, select the character to the left of the R in RIFF.
  7. Edit --> Delete to cursor
  8. File --> Save As --> Filename.wav
Filename can be anything you like, but it needs to end in .wav.

WAV file headers begin with "RIFF" so this is just deleting everything before it and saving the rest, leaving only the WAV file.

Enjoy!
 
Reply With Quote
Reply


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 03:39 PM.