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[/url] and [url=http://pocketpcmag.com/forum/topic.asp?TOPIC_ID=14211]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));
RandomAccessFile raf = new RandomAccessFile (s[0], "r");
// 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
[/code]
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).
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!).
Very cool...course you could also use a freebie like notem, which allows notes to be created in mp3 format, but I can definitely use this, as I have quite a few old meeting notes around in the older format. Now if you could use some kind of speech-to-text recognition software to index them, and make them searchable...wow!
Some time after Menneisyys published his algorithm, the same question came up on another site. Not thinking that suggesting Menneisyys' code was exactly the sort of answer the person asking wanted, I came up with a way of making the conversion with available software. (As soon as I did so, someone pointed out that if--instead of using the Record function inside Notes [which embeds the .wav file in the .pwi shell]--you simply hit the hardware Record button, the file is saved as a .wav file to start with. Well, there's no pleasing some folks. Myself, I'm with hillbillynater--using notem to save space.)
But if you're stuck with a bunch of Notes recordings, and Menneisyys' programming is beyond your capacities (as it is mine), here's an alternate route:
You'll need to download a freeware audio editor named Audacity. I did this on a Mac, but it's cross-platform, and I'm assuming the menus are the same for Windows.
(4) Select all of the audio by clicking below its file name at left of the graphic of the file
(5) Click on dropdown menu (arrow next to file name)
Set Rate to 11025 Hz
(6) Convert to WAV by:
File menu
Export as wav
That did it for me.
Now, I didn't try to see whether this would also work on a note that had both audio and text in it. But it will certainly work on a note with just audio in it. I was really impressed with Audacity.
quote:Originally posted by MarcoMillions
But if you're stuck with a bunch of Notes recordings, and Menneisyys' programming is beyond your capacities (as it is mine), here's an alternate route:
Thanks for the feedback. It indeed works, but is pretty hard to use, especially if you have more than one recording in a file and/or a file used with the GSM encoder.
In the meantime, I've written a small tutorial on downloading and using a desktop-based Java Runtime Environment (JRE) athttp://www.pocketpcthoughts.com/forums/viewtopic.php?t=41049 for running my converter. Feel free to post any questions.
And yes, I will some day rewrite this stuff in C# [:)]
quote:Originally posted by MenneisyysIt indeed works, but is pretty hard to use, especially if you have more than one recording in a file and/or a file used with the GSM encoder.
Well, M, I don't know about GSM encoders (that sounds scary), but multiple recordings in a single note were a piece of cake. (Mind you, I didn't even know you were allowed to put more than a single recording into one note. If I did a recording, I then closed the note to save it, like a good boy, and opened a new note for the next recording. But, then, the depths of my ignorance are very very profound.)
In any case, I first ran across Audacity as a utility for splitting long audio files into shorter tracks, so splitting the separate recordings up from the note was one of the things it was made for: simple cut and paste and export, piece by piece. (You actually don't even have to paste. You can "Export Selection as WAV," then go back and make a different selection.) The only thing that came as a bit of a surprise was that the recordings appeared in the file in reverse order. That is, the last made recording was first in the audio file.
I think you're just more comfortable with Java run-time environments than you are with music-editing software, and I've a fair amount of experience with the latter and none with the former.
But I always learn something from your posts, and I look forward to it when I see you've posted to a thread I've been following.
2, extract the CAB file meant for your device. For example, all WM2003+ users should extract PWI_Embedded_Sound_Extractor_ARMV4.CAB. Transfer it to your PDA.
3, start File Explorer on your PDA and click the CAB file. Alternatively, you can use CabInstl or other tools like FileDialogChanger to install it on a storage card.
4, start the application (it doesn't have any fancy icon - just look for the name PWISoundExtractor). You'll be presented the following screen:
5, As instructed, click ‘Convert!’ and, on the next screen, just click on a PWI file that contains embedded sound files. The app will extract the files and tells you how many of them there were and into what directory it extracted them.
The PC version is similar but it lacks error detection (which isn’t a problem if you don’t pass it files that don’t have embedded sound files etc) and has a slightly different GUI (I didn’t have the time to synchronize the two GUI’s.) It works the same way: it puts the extracted files into the same directory as the input file.
Well, Mr. M, I'm blown away by it! Slickissimo, one might say. Clipped the sound right out from among the text in my small test note with three recordings surrounded by four lines of text. No extra (text) noise; no lost recording. Better, obviously, than I could do by hand, and, need I say, faster. Bravo!
(i wondered why you'd been silent about this thread, You sly fox.)
If there's one little problem, it's that the recordings appear in reverse order. The third (last) recorded passage appears as WAV file 1 and so on. But big deal. In most cases that'll not be an issue. It's a triumph.
Marc
Oh. An icon would be nice. Also a proper Exit command. Picky, picky.
I never had a problem with this until one day I just had this interview and no voice recorder but my phone (good old wizard).
After i got home, i was totally surprised that outlook 2003 could not even open the voice recordings inside the note, after it was sync'd over. word 2003 stops responding if i try to convert the note, after transfering the file over. and there's no 3rd party solution either
what a stupid thing
this utiliy is what i expect MS to provide. but they didn't. thanks Menneisyys!
edit: forgot to say, i know this solution was posted 2 years ago, but still, it deserves to be honored ;)
Hi,
The ppc version works a treat.
Thanks for a great app, I have been looking for this for some time.
I have a 4 MB file that I want to extract so I thought it would be better on the PC.
I think this might be a bit big a file for the iMate EVDO and the app.
,
So I installed NETCFSetupv2.msi (assuming this was CF Framework)and then ran your app.(PWISoundExtract.exe)
Unfortunately on Win XP SP2 I get an error ""The application failed to initalise properly (Oxc0000135).
Have I misread your instructions?
Is there something else I need to install onto the PC?
I appologise for sounding like a dummy, -probably because I am I suppose.
Regards
Johnno
I re-downloaded the app with the same result.
quote:this utiliy is what i expect MS to provide. but they didn't. thanks Menneisyys!
edit: forgot to say, i know this solution was posted 2 years ago, but still, it deserves to be honored ;)
Thanks :)
------------------------------------------------------------------- You really want to check out the Smartphone & Pocket PC Magazine Expert Blog athttp://www.pocketpcmag.com/blogs/ - tons of unique reviews, roundups, tips, hacks!
Hi,
The ppc version works a treat.
Thanks for a great app, I have been looking for this for some time.
I have a 4 MB file that I want to extract so I thought it would be better on the PC.
I think this might be a bit big a file for the iMate EVDO and the app.
,
So I installed NETCFSetupv2.msi (assuming this was CF Framework)and then ran your app.(PWISoundExtract.exe)
Unfortunately on Win XP SP2 I get an error ""The application failed to initalise properly (Oxc0000135).
Have I misread your instructions?
Is there something else I need to install onto the PC?
I appologise for sounding like a dummy, -probably because I am I suppose.
Regards
Johnno
I re-downloaded the app with the same result.
Frankly, dunno why the PC version isn't working. Use the PPC version instead.
------------------------------------------------------------------- You really want to check out the Smartphone & Pocket PC Magazine Expert Blog athttp://www.pocketpcmag.com/blogs/ - tons of unique reviews, roundups, tips, hacks!
Very cool...course you could also use a freebie like notem, which allows notes to be created in mp3 format, but I can definitely use this, as I have quite a few old meeting notes around in the older format. Now if you could use some kind of speech-to-text recognition software to index them, and make them searchable...wow!
Some time after Menneisyys published his algorithm, the same question came up on another site. Not thinking that suggesting Menneisyys' code was exactly the sort of answer the person asking wanted, I came up with a way of making the conversion with available software. (As soon as I did so, someone pointed out that if--instead of using the Record function inside Notes [which embeds the .wav file in the .pwi shell]--you simply hit the hardware Record button, the file is saved as a .wav file to start with. Well, there's no pleasing some folks. Myself, I'm with hillbillynater--using notem to save space.)
But if you're stuck with a bunch of Notes recordings, and Menneisyys' programming is beyond your capacities (as it is mine), here's an alternate route:
You'll need to download a freeware audio editor named Audacity. I did this on a Mac, but it's cross-platform, and I'm assuming the menus are the same for Windows.
http://audacity.sourceforge.net/
Then.
(1) Copy .pwi (Note) file to PC
(2) Open Audacity
(3) Get the Note audio into Audacity by:
Project menu
Import as raw data
(4) Select all of the audio by clicking below its file name at left of the graphic of the file
(5) Click on dropdown menu (arrow next to file name)
Set Rate to 11025 Hz
(6) Convert to WAV by:
File menu
Export as wav
That did it for me.
Now, I didn't try to see whether this would also work on a note that had both audio and text in it. But it will certainly work on a note with just audio in it. I was really impressed with Audacity.
Marc
Thanks for the feedback. It indeed works, but is pretty hard to use, especially if you have more than one recording in a file and/or a file used with the GSM encoder.
In the meantime, I've written a small tutorial on downloading and using a desktop-based Java Runtime Environment (JRE) athttp://www.pocketpcthoughts.com/forums/viewtopic.php?t=41049 for running my converter. Feel free to post any questions.
And yes, I will some day rewrite this stuff in C# [:)]
Well, M, I don't know about GSM encoders (that sounds scary), but multiple recordings in a single note were a piece of cake. (Mind you, I didn't even know you were allowed to put more than a single recording into one note. If I did a recording, I then closed the note to save it, like a good boy, and opened a new note for the next recording. But, then, the depths of my ignorance are very very profound.)
In any case, I first ran across Audacity as a utility for splitting long audio files into shorter tracks, so splitting the separate recordings up from the note was one of the things it was made for: simple cut and paste and export, piece by piece. (You actually don't even have to paste. You can "Export Selection as WAV," then go back and make a different selection.) The only thing that came as a bit of a surprise was that the recordings appeared in the file in reverse order. That is, the last made recording was first in the audio file.
I think you're just more comfortable with Java run-time environments than you are with music-editing software, and I've a fair amount of experience with the latter and none with the former.
But I always learn something from your posts, and I look forward to it when I see you've posted to a thread I've been following.
Marc
I may rewrite/repackage this app using the CF framework some day (but not in the very near future!).
Yes! It's here! :D
The Pocket PC version can be found here[/url], while the PC version can be found [url=http://winmobiletech.com/062005PWIEmbeddedWAVExport/PC/PWISoundExtract.exe]here. Both require the CF framework, which is installed by default on all WM2003+ devices.
Tested on both an iPAQ 2210 and a Pocket Loox 720 (and, of course, the PC version on the desktop); works flawlessly.
Using on the Pocket PC:
1, download the ZIP file
2, extract the CAB file meant for your device. For example, all WM2003+ users should extract PWI_Embedded_Sound_Extractor_ARMV4.CAB. Transfer it to your PDA.
3, start File Explorer on your PDA and click the CAB file. Alternatively, you can use CabInstl or other tools like FileDialogChanger to install it on a storage card.
4, start the application (it doesn't have any fancy icon - just look for the name PWISoundExtractor). You'll be presented the following screen:
5, As instructed, click ‘Convert!’ and, on the next screen, just click on a PWI file that contains embedded sound files. The app will extract the files and tells you how many of them there were and into what directory it extracted them.
The PC version is similar but it lacks error detection (which isn’t a problem if you don’t pass it files that don’t have embedded sound files etc) and has a slightly different GUI (I didn’t have the time to synchronize the two GUI’s.) It works the same way: it puts the extracted files into the same directory as the input file.
Well, Mr. M, I'm blown away by it! Slickissimo, one might say. Clipped the sound right out from among the text in my small test note with three recordings surrounded by four lines of text. No extra (text) noise; no lost recording. Better, obviously, than I could do by hand, and, need I say, faster. Bravo!
(i wondered why you'd been silent about this thread, You sly fox.)
If there's one little problem, it's that the recordings appear in reverse order. The third (last) recorded passage appears as WAV file 1 and so on. But big deal. In most cases that'll not be an issue. It's a triumph.
Marc
Oh. An icon would be nice. Also a proper Exit command. Picky, picky.
Excellent work.
I never had a problem with this until one day I just had this interview and no voice recorder but my phone (good old wizard).
After i got home, i was totally surprised that outlook 2003 could not even open the voice recordings inside the note, after it was sync'd over. word 2003 stops responding if i try to convert the note, after transfering the file over. and there's no 3rd party solution either
what a stupid thing
this utiliy is what i expect MS to provide. but they didn't. thanks Menneisyys!
edit: forgot to say, i know this solution was posted 2 years ago, but still, it deserves to be honored ;)
Hi,
The ppc version works a treat.
Thanks for a great app, I have been looking for this for some time.
I have a 4 MB file that I want to extract so I thought it would be better on the PC.
I think this might be a bit big a file for the iMate EVDO and the app.
,
So I installed NETCFSetupv2.msi (assuming this was CF Framework)and then ran your app.(PWISoundExtract.exe)
Unfortunately on Win XP SP2 I get an error ""The application failed to initalise properly (Oxc0000135).
Have I misread your instructions?
Is there something else I need to install onto the PC?
I appologise for sounding like a dummy, -probably because I am I suppose.
Regards
Johnno
I re-downloaded the app with the same result.
Thanks :)
-------------------------------------------------------------------
You really want to check out the Smartphone & Pocket PC Magazine Expert Blog athttp://www.pocketpcmag.com/blogs/ - tons of unique reviews, roundups, tips, hacks!
Frankly, dunno why the PC version isn't working. Use the PPC version instead.
-------------------------------------------------------------------
You really want to check out the Smartphone & Pocket PC Magazine Expert Blog athttp://www.pocketpcmag.com/blogs/ - tons of unique reviews, roundups, tips, hacks!