Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Super Contributor
yogesh1984
Posts: 308
Registered: ‎05-31-2011
My Device: Blackberry-SDK-9800
Accepted Solution

wav file creating from raw bytes

can anybody tell me what are the api's used to create the .wav file from the recorded bytes....... is there any jar files  i need to import in my eclipes BB plugin......

   Plz if anybody know, reply me.... 

                    Actually imporing javaasounddemo(jar) file may work, i didnt try it yet.... but i am facing difficulty in importing jar files to my BB project....

                 plz any idea, respond me back....

Developer
Aviator168
Posts: 709
Registered: ‎09-10-2009
My Device: 8520, 8900, 9000, 9300, 9650, 9700, 9780, 9800, 9810, 9900, 9930

Re: wav file creating from raw bytes

Retired
Retired
BVP
Posts: 150
Registered: ‎10-19-2010
My Device: Not Specified

Re: wav file creating from raw bytes

This is a very popular ask.  So much so that I have added code to do this for you in this knowledge base article

 

It may take a day or two to show up there, in the meantime the code attachment appears to be accissible (and hopefully the link doesn't change before the revisions I made get published - if it does refer to the KB article I mentioned).

Super Contributor
yogesh1984
Posts: 308
Registered: ‎05-31-2011
My Device: Blackberry-SDK-9800

Re: wav file creating from raw bytes

thanks for the code u gave me.......

i have amr file(which i get after recording voive note)....which i need to convert to wav file..... i used your code to implement the same..... Since, AudioFormate in fmt header of wav file is 1 for pcm.... but what value should i add foe amr file ..... and do i need to remove header of amr file? 

Developer
superdirt
Posts: 541
Registered: ‎05-17-2009
My Device: Not Specified

Re: wav file creating from raw bytes

[ Edited ]

You won't be able to convert AMR to WAV unless you find or create a decoder. One does not exist with the BB Java API.

 

EDIT: Correct me if I am wrong, but the KB article BVP showed will have to be altered to get the PCM data stream if it is to work with that PCM > WAV code. PS thanks for the PCM > WAV convertor code, that is very useful.

 

Scott

Super Contributor
yogesh1984
Posts: 308
Registered: ‎05-31-2011
My Device: Blackberry-SDK-9800

Re: wav file creating from raw bytes

thanku,

May be u r true..  v cannot convert amr file to wav.... but can u plz tell me can v record voice note in blackberry in pcm formate.... means after recording i can i get pcm file as output..... so that i can try to convert that pcm to wav file,

Developer
superdirt
Posts: 541
Registered: ‎05-17-2009
My Device: Not Specified

Re: wav file creating from raw bytes

The voice notes application that comes with the device only saves in AMR format, and like I said before to convert it to PCM is tricky on the BB because there is no decoder in the API. You can try searching for specs on how to convert AMR to WAV, but I can't find that information anywhere. You can give it a shot though.

 

If you want to record a voice note in PCM format you have to make your own code for that. It's easy, use:

 

capture://audio?encoding=pcm or capture://audio?encoding=audio/basic

 as a parameter when you are creating the player and you will get PCM format.

 

However, devices intended to be used mainly on CDMA networks won't accept that above parameter when you try to make a Player. They crash when you attempt to record the audio in PCM format as they don't come with that functionality.

 

 

Scott

Super Contributor
yogesh1984
Posts: 308
Registered: ‎05-31-2011
My Device: Blackberry-SDK-9800

Re: wav file creating from raw bytes

hello ,

AS in code attached by BVP to convert pcm to wav file, 

In wavHeaderAppender the writeUnsignedIntLittleEndian function is not declered in DataParsingUtilities..... So PLz help me what i should i add in place of writeUnsignedIntLittleEndian(long, outputFileStream)...... 

Super Contributor
yogesh1984
Posts: 308
Registered: ‎05-31-2011
My Device: Blackberry-SDK-9800

Re: wav file creating from raw bytes

ya, ya right.... superdirt........ My mind has been blocked,,,,...  to create pcm ...

capture://audio?encoding=audio/basic
Super Contributor
yogesh1984
Posts: 308
Registered: ‎05-31-2011
My Device: Blackberry-SDK-9800

Re: wav file creating from raw bytes

hello,

 i want to write 32 bit unsigned integer to output stream... DOes anybody knows the code to do so....

like,

public static void writeUnSignedIntLittleEndian(int integer, OutputStream os) throws IOException

{

}