Subscription preference

Notification emails are sent to your Samsung account email address.

* Email : anonymous@samsung.com

  

Close

Can't record raw audio data in async mode.

Forums View
Started by Samsung Developer bugajny.andrzej , 34430 Seed Jan 25, 2018 13:04 Replies : 7 View : 673 Likes : 0
Hello devs

I can't recored RAW audio data in async mode on Gear S3. The audio callback returns only about 50% audio data.
It somehow skips/lost other data. The issue is nice described under that link developer.tizen.org/forums/native-application-development/recording-audio-io-callback-very-slow-only-pick-up-less-45-audio 
Answers for the question from developer.tizen.org don't work. I have checked all of them.


Is sombody from Samsung devs could check why it doesn't work? or maybe some 3rd dev found workaround and might share with us?


Recording RAW audio data works for Z1/Z2/Z3 and Z4 excellent.

The issue concerns only watches: Gear S3, Gear S3 and probably Gear Sport too.



I will be appreciate for any tip.



Tags

audio , native , recording

Post Reply
Board View
Samsung Developer shihabyasin , 48910 Seed Jan 26, 2018 04:46 Post #1 0
Hi,

Check the maximum recording time and size.
Fine tuning all associated parameters will give you
optimal outcome.


Code

/* Set the maximum file size to 1024 (kB) */
error_code = recorder_attr_set_size_limit(g_recorder, 1024);

/* Set the audio encoder bitrate */
error_code = recorder_attr_set_audio_encoder_bitrate(g_recorder, 28800);

/* Set the audio sample rate */
error_code = recorder_attr_set_audio_samplerate(g_recorder, 44100); 

See this link
developer.tizen.org/development/training/native-application/creating-applications-multimedia/audio-playback-and-recording#audio_record

for details.

Hope it will help you.
If you find my post is helpful for you, please mark it as answer to promote this post to others.
Post Reply
Board View
Samsung Developer bugajny.andrzej , 34430 Seed Jan 26, 2018 07:22 Post #2 0


This content has been quoted from shihabyasin’s thought.

Hi,

Check the maximum recording time and size.
Fine tuning all associated parameters will give you 
optimal outcome. 

 

Code

/* Set the maximum file size to 1024 (kB) */
error_code = recorder_attr_set_size_limit(g_recorder, 1024);

/* Set the audio encoder bitrate */
error_code = recorder_attr_set_audio_encoder_bitrate(g_recorder, 28800);

/* Set the audio sample rate */
error_code = recorder_attr_set_audio_samplerate(g_recorder, 44100); 

See this link 
developer.tizen.org/development/training/native-application/creating-applications-multimedia/audio-playback-and-recording#audio_record

for details.

Hope it will help you.
If you find my post is helpful for you, please mark it as answer to promote this post to others.

 



I don't use Recorder API. You can't set bitrate for PCM audio data. It is raw audio data.
I use this:  developer.tizen.org/development/guides/native-application/media-and-camera/raw-audio-playback-and-recording#async_recording



Post Reply
Board View
Samsung Developer shihabyasin , 48910 Seed Jan 29, 2018 06:00 Post #3 0
Increase audio data size(int data_size ).
Of course every device has certain memory limit you need to count.

Check, compare audio data size with allocated memory to store it.
Post Reply
Board View
Samsung Developer bugajny.andrzej , 34430 Seed Jan 30, 2018 14:40 Post #4 0


This content has been quoted from shihabyasin’s thought.

Increase audio data size(int data_size ). 
Of course every device has certain memory limit you need to count.

Check, compare audio data size with allocated memory to store it.


I don't understand. How to increase data size for aysnc callback or maybe at initiating audio recording?
Async audio callback returns chunk of data in own audio buffer like this:        error_code = audio_in_drop(handle);
}

Audio data is taken by function audio_in_peek().


 

Post Reply
Board View
Samsung Developer shihabyasin , 48910 Seed Feb 01, 2018 04:56 Post #5 0
Check out code something like

Code

/* Callback invoked for each chunk of recorded audio */
void
_audio_io_stream_read_cb(audio_in_h handle, size_t nbytes, void *userdata)
{
const void * buffer = NULL;

if (nbytes > 0) {
/*
Retrieve a pointer to the internal input buffer
and the number of recorded audio data bytes
*/
int error_code = audio_in_peek(handle, &buffer, &nbytes);
if (error_code != AUDIO_IO_ERROR_NONE) {
dlog_print(DLOG_ERROR, LOG_TAG, "audio_in_peek() failed! Error code = %d", error_code);

return;
}

/* Store the recorded audio data in the file */
fwrite(buffer, sizeof(char), nbytes, fp_w);

/* Remove the recorded audio data from the internal input buffer */
error_code = audio_in_drop(handle);
if (error_code != AUDIO_IO_ERROR_NONE)
dlog_print(DLOG_ERROR, LOG_TAG, "audio_in_drop() failed! Error code = %d", error_code);
}

Also it depends on your audio data size and device storage capability provided.
 
Post Reply
Board View
Samsung Developer bugajny.andrzej , 34430 Seed Feb 01, 2018 16:32 Post #6 0


This content has been quoted from shihabyasin’s thought.

Check out code something like
 

Code

/* Callback invoked for each chunk of recorded audio */
void
_audio_io_stream_read_cb(audio_in_h handle, size_t nbytes, void *userdata)
{
const void * buffer = NULL;

if (nbytes > 0) {
/*
Retrieve a pointer to the internal input buffer
and the number of recorded audio data bytes
*/
int error_code = audio_in_peek(handle, &buffer, &nbytes);
if (error_code != AUDIO_IO_ERROR_NONE) {
dlog_print(DLOG_ERROR, LOG_TAG, "audio_in_peek() failed! Error code = %d", error_code);

return;
}

/* Store the recorded audio data in the file */
fwrite(buffer, sizeof(char), nbytes, fp_w);

/* Remove the recorded audio data from the internal input buffer */
error_code = audio_in_drop(handle);
if (error_code != AUDIO_IO_ERROR_NONE)
dlog_print(DLOG_ERROR, LOG_TAG, "audio_in_drop() failed! Error code = %d", error_code);
}

Also it depends on your audio data size and device storage capability provided.
 

 

OK, how to set data size for async audio buffer?


Post Reply
Board View
Samsung Developer shihabyasin , 48910 Seed Feb 02, 2018 05:50 Post #7 0


This content has been quoted from bugajny.andrzej’s thought.

 



This content has been quoted from shihabyasin’s thought.

Check out code something like
 

Code

/* Callback invoked for each chunk of recorded audio */
void
_audio_io_stream_read_cb(audio_in_h handle, size_t nbytes, void *userdata)
{
const void * buffer = NULL;

if (nbytes > 0) {
/*
Retrieve a pointer to the internal input buffer
and the number of recorded audio data bytes
*/
int error_code = audio_in_peek(handle, &buffer, &nbytes);
if (error_code != AUDIO_IO_ERROR_NONE) {
dlog_print(DLOG_ERROR, LOG_TAG, "audio_in_peek() failed! Error code = %d", error_code);

return;
}

/* Store the recorded audio data in the file */
fwrite(buffer, sizeof(char), nbytes, fp_w);

/* Remove the recorded audio data from the internal input buffer */
error_code = audio_in_drop(handle);
if (error_code != AUDIO_IO_ERROR_NONE)
dlog_print(DLOG_ERROR, LOG_TAG, "audio_in_drop() failed! Error code = %d", error_code);
}

Also it depends on your audio data size and device storage capability provided.
 

 

OK, how to set data size for async audio buffer?


 

Go through different code on related links. See above code for your first step.
Try setting different values.
Post Reply