Note that there are some explanatory texts on larger screens.

plurals
  1. POMake a .caf file out of buffer data
    primarykey
    data
    text
    <p>I have inBuffer->mAudioData converted into NSData coming via Network. I do this using the Audio Queue Callback.</p> <p>How do I convert this NSData so that I can either create a .caf sound file or directly give output to the speaker on the other side ?</p> <p>Thanks for help.</p> <p><strong>Edit 1:</strong> Below is the code I have used on the sender side to send Data on a wifi network:</p> <pre><code>void AudioInputCallback(void * inUserData, AudioQueueRef inAQ, AudioQueueBufferRef inBuffer, const AudioTimeStamp * inStartTime, UInt32 inNumberPacketDescriptions, const AudioStreamPacketDescription * inPacketDescs) { RecordState * recordState = (RecordState*)inUserData; if (!recordState-&gt;recording) { printf("Not recording, returning\n"); } // if (inNumberPacketDescriptions == 0 &amp;&amp; recordState-&gt;dataFormat.mBytesPerPacket != 0) // { // inNumberPacketDescriptions = inBuffer-&gt;mAudioDataByteSize / recordState-&gt;dataFormat.mBytesPerPacket; // } printf("Writing buffer %lld\n", recordState-&gt;currentPacket); OSStatus status = AudioFileWritePackets(recordState-&gt;audioFile, false, inBuffer-&gt;mAudioDataByteSize, inPacketDescs, recordState-&gt;currentPacket, &amp;inNumberPacketDescriptions, inBuffer-&gt;mAudioData); NSLog(@"DATA = %@",[NSData dataWithBytes:inBuffer-&gt;mAudioData length:inBuffer-&gt;mAudioDataByteSize*NUM_BUFFERS]); [[NSNotificationCenter defaultCenter] postNotificationName:@"Recording" object:[NSData dataWithBytes:inBuffer-&gt;mAudioData length:inBuffer-&gt;mAudioDataByteSize*NUM_BUFFERS]]; if (status == 0) { recordState-&gt;currentPacket += inNumberPacketDescriptions; } AudioQueueEnqueueBuffer(recordState-&gt;queue, inBuffer, 0, NULL); } </code></pre> <p>Here I have casted inBuffer->mAudioData to NSData and then I have sent to the outputStream.</p> <p>On the other end that is the receivers side I have used the below code:</p> <pre><code>-(void)audioMessageData:(NSData *)audioData fromUser:(NSString *)userName { NSLog(@"DATA = %@",audioData); } </code></pre> <p>Whenever I get data the above function gets called and I get NSData which I have sent from the sender iPhone. Now I want to play whatever audioData I am receiving.</p> <p>Thanks for the help.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload