2

I need to send audio data in real-time in PCM format 8 KHz 16 Bit Mono.

Audio must been sent like array of chars with length (<#char *data#>, <#int len#>).

Now I'm beginner in Audio processing and cant really understand how to accomplish that. My best try was been to convert to iLBC format and try but it couldn't work. Is there any sample how to record and convert audio to any format. I have already read Learning Core Audio from Chris Adamson and Kevin Avila but I really didn't find solution that works.

Simple what i need:

(record)->(convert?)-> send(char *data, int length);

Couse I need to send data like arrays of chars i cant use player.

EDIT: I managed to make everything work with recording and with reading buffers. What I can't manage is :

 if (ref[i]->mAudioDataByteSize != 0){
       char * data = (char*)ref[i]->mAudioData;
       sendData(mHandle, data, ref[i]->mAudioDataByteSize);
        }

1 Answers1

0

This is not really a beginner task. The solutions are to use either the RemoteIO Audio Unit, the Audio Queue API, or an AVAudioEngine installTapOnBus block. These will give you near real-time (depending on the buffer size) buffers of audio samples (Int16's or Floats, etc.) that you can convert, compress, pack into other data types or arrays, etc. Usually by calling a callback function or block that you provide to do whatever you want with the incoming recorded audio sample buffers.

hotpaw2
  • 70,107
  • 14
  • 90
  • 153
  • Yes, but when i get array of audio samples and just convert int-s or floats in chars it isn't really that sound on the other end (just some noise). So maybe other question is there any function or any convertor that returns audio data as array of chars. – Izudin Zudda Vragić May 12 '17 at 10:33
  • Post the code of how you are doing the type conversion, and print out some samples. – hotpaw2 May 12 '17 at 10:56
  • Ok, because of editing code and no versioning (cause trying code in demo project) i can't post it before Monday. – Izudin Zudda Vragić May 12 '17 at 15:04
  • Hi, sorry for late response, I can't recover old code (working on this for about month without code versioning), but I posted problematic part. – Izudin Zudda Vragić May 16 '17 at 11:12