Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)

Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781

Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4362: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4364: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4365: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4366: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
anddev.org • View topic - Anyone able to use ENCODING_PCM_8BIT in recording and playin

Anyone able to use ENCODING_PCM_8BIT in recording and playin

All your problems with Audio, Video and Images.

Anyone able to use ENCODING_PCM_8BIT in recording and playin

Postby sarah.kho » Mon Dec 20, 2010 5:34 pm

Hi
I am trying to use AudioFormat.ENCODING_PCM_8BIT with AudioRecord and AudioTrack to record some voice from mic and then play it to the speaker.

Here is my code:



Code: Select all


int   sampleRate = 11025;
      int   bufferSize = AudioRecord.getMinBufferSize(11025*2,
          AudioFormat.CHANNEL_CONFIGURATION_MONO,
          AudioFormat.ENCODING_PCM_8BIT);
      
   

      AudioRecord arec = new AudioRecord(MediaRecorder.AudioSource.MIC,
            sampleRate, AudioFormat.CHANNEL_CONFIGURATION_MONO,
            AudioFormat.ENCODING_PCM_8BIT, bufferSize);



      short[] buffer = new short[bufferSize];
      arec.startRecording();
arec.read(buffer, 0, bufferSize);



and here is the code portion for playing the content from the buffer


Code: Select all
      AudioTrack atrack = new AudioTrack(AudioManager.STREAM_MUSIC,
            sampleRate, AudioFormat.CHANNEL_CONFIGURATION_MONO,
            AudioFormat.ENCODING_PCM_8BIT, bufferSize,
            AudioTrack.MODE_STREAM);

      atrack.setPlaybackRate(sampleRate);
atrack.play();
         atrack.write(buffer, 0, buffer.length);




The error I get is an IllegalArgumentException in the line where I am initializing the arec object. Any idea why it is happening?

The same code works fine with ENCODING_PCM_16BIT and I do not know what is wrong with it. I tried using byte[] with no luck.

Thanks.
sarah.kho
Once Poster
Once Poster
 
Posts: 1
Joined: Mon Dec 20, 2010 5:31 pm

Top

Return to Multimedia Problems

Who is online

Users browsing this forum: Yahoo [Bot] and 9 guests