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
Highlighted
Developer
Posts: 104
Registered: ‎08-03-2010
My Device: Blackberry Z10
My Carrier: Idea
Accepted Solution

How to Stop Audio Recording when no Sound is detect

Hello Friends,

 

    I want to develop application which is  record the audio( this part i had already implement)...but i want to stop the audio recording when device was not detect any sound  more than 2 sec...

 

i have already convert byte data in tosigned short data which is give me the length of the level of the sound...

 

int level = (signedShortToInt(b) * 100 / 32767); // b isthe buffer data

 

public static final int signedShortToInt(byte[] b) {
        int result = (b[0] & 0xff) | (b[1] & 0xff) << 8;
        return result;
 }

 

i m familiar with the air noise sound is there in the normal recording ..

Air noise not more than 100 level(im guessing).

so i had checked the  level of voice is less than 100 than it will stop the recording ...

My idea is correct or not ????

 

private void getSound( byte[] buffer) {
 
        for (int i = 0; i < buffer.length; i++) {
                byte[] b = new byte[] { buffer[i], buffer[i + 1] };
                int level = (signedShortToInt(b) * 100 / 32767);
                if (100 > level) {
                            Voice.stopthread();
                    }
        }
 }

 

My Question is... How can i stop the Recording when level is low till 2 sec and Is this the Correctmethod to find the level of sound ???


Please mark posts as solved if you found a solution.
Feel free to press the kudos button to thank the user that helped you
Developer
Posts: 104
Registered: ‎08-03-2010
My Device: Blackberry Z10
My Carrier: Idea

Re: How to Stop Audio Recording when no Sound is detect

No ones seems to know about that???

 

I have queation...

 

How should i store the Audio recored data to Device (I m Using PCM encoding).

it has another process to store PCM raw data to device...

 

i can store the amr encode data to device but i cant PCM data.

It is work fine  for AMR ..

 

Thanks

Rajesh


Please mark posts as solved if you found a solution.
Feel free to press the kudos button to thank the user that helped you
Developer
Posts: 104
Registered: ‎08-03-2010
My Device: Blackberry Z10
My Carrier: Idea

Re: How to Stop Audio Recording when no Sound is detect

Hello Guys,

 

I had no found no Solution for that so i had drop that Idea..

I had found my solution up to  to convert the PCM data to ampltude ..By using Amplitude level i can find the what is noise data and hat is  voice data. and stop the Audio by usin it

 

But it is not store recorded audio in device ..

 

Thanks ..

 


Please mark posts as solved if you found a solution.
Feel free to press the kudos button to thank the user that helped you