简体   繁体   中英

Access audio buffer of an AVAudioSession

Hope this question makes some sense, I'm completely lost.... In my proto-app I'm recording micro input and saving it, and so far no problems at all.

I now need to access the buffer while I'm recording it in order to pass chunks of data to another class (written in C, not by me) that will do some analysis.

I spent the whole day browsing and reading, and looks like I need use Audio Queues in order to access the buffer. The problem is that the syntax is C, and I don't understand it at all :)

So my questions are:

1) Is there any other way to achieve what I'm looking for? I don't need in-depth explanation, just some hints and I will browse my way through :) I'm asking because I'm not 100% sure that Audio Queues are the only way to go

2) Any good tutorial or example about Audio Queues? The aurioTouch tutorial by Apple wasn't very useful (again, I don't know C). I could bypass my problems in C by following a good tutorial that a noob like me can understand

Thanks a lot, and for any help you could offer.

Good question. You can use code written by other people like:

Novocaine - pretty straightforward. (but there are some bugs, at least in older version I used ~ 6 months ago. Something with mono and stereo.)

Momu - quite a good thing in C++ (you need to use .mm extension for you files)

Those will save you time if you want some low level audio programming. Some basic skills in C still required though. Check out this guy . His explanations and enthusiasm are excellent.

With all mentioned above you can be ready in a 1-2 days of work carrying away good skills in C.

EDIT

Basically, everywhere you work with low-level audio you deal with a C array of numbers (represented like float *audioBuffer; ) called audio samples. You cycle through it in a loop, do some operations, copy it, send somewhere, analyze.

To copy it you have to allocate space for it. Actual byte size of the buffer can be calculated like this: numberOfSamples*sizeof(type).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM