PCM to WAV file - iphone

I am using
http://www.subfurther.com/blog/2010/12/13/from-ipod-library-to-pcm-samples-in-far-fewer-steps-than-were-previously-necessary/
to convert m4a file to caf, i was try to look in the setting of the export and didn't find way to convert it to wav instead.
there is a way to convert the caf to wav? there is a more good way to convert m4a to wav?

Sorry if i am quite late to the party. Though i am answering and sharing my knowledge on this issue if it helps anyone.
Converting caf file to wav file isn't too hard. caf and wav both format contains raw PCM data, the only difference is their header info. So if you just replace caf header with wav then it will do the tricks. Just get the PCM data from the caf file and add the wav header on top of the extracted PCM data. To add wav header with PCM data, check this link.

peek at the AudioFile and ExtAudioFile APIs (in AudioToolbox).

Related

How can I record an audio file in Qt and read it in MATLAB?

I'm recording an audio file in Qt. After that, I have to read the file with MATLAB and analyse it. Qt likes to save audio files in .pcm format (i.e. .wav format without header) and I can't read .pcm audio files with MATLAB (format is not supported).
What is the best solution to transfer audio from Qt to MATLAB?
Firstly, since your .pcm file has no header information, you'll need to know the number of bits per sample you used to create it in Qt. A typical value would be 16 bits per sample, or a data type of int16. Then you can use fread to read the audio waveform from the file like so:
fid = fopen('your_file.pcm', 'r');
audioWaveform = fread(fid, Inf, 'int16');
fclose(fid);
If you then want to do any processing, you will likely need to provide other pieces of information from when you created it in Qt, like the sampling frequency.

JPEG image file creation to be recognized by OS

I have applied JPEG baseline compression algorithm by writing each step in matlab. Now, I have the JPEG compresses image data in binary form and the header to be appended. Please tell me how to make a file that would be recognized as JPEG file by OS. Should it be binary file or what is the process.?
Regards
You are going to need to read two thing:
1) The JPEG standard
2) The standard for some file format (e.g., JFIF, EXIF).
You are going to need to have a JPEG file header (see file format standards). You are going to have to create DHT, DQT, SOF, and SOS markets for the compressed data (JPEG standard).
All of the data is in binary format. You have to remember to convert FF values in the compressed data stream to FFFF.

How to get headless raw audio data from iPhone's mic into NSData

I need to record 3 sec of headles raw audio data: PCM 11025 samples per second, 16 bit mono and then send it as base64 encoded string.
With AVAudioRecorder I can record .CAf file and access it at any time, but the question is: how can I get headless raw audio data from recorded file into NSData object?
Thanks!

convert WAV to ALAC

Can we convert from WAV format to apple's ALAC audio recording format ?
See the ConvertFile sample project: http://developer.apple.com/mac/library/samplecode/ConvertFile/Introduction/Intro.html

Generating an LPCM buffer in memory for AVAudioPlayer initWithData

I want to generate a sound wave programmatically and play it with AVAudioPlayer. I have the code to encode my waveform as linear PCM, 44100Hz, mono, 8 bits per sample.
I am not clear on what kind of envelope I need to wrap around this buffer so that AVAudioPlayer recognizes it as PCM.
PCM is just a digital representation of an analog audio signal. Unfortunately, it doesn't encapsulate any of the metadata about the audio - channels, bit depth, or sample rate - all necessary to properly read said PCM data. I would assume AVAudioPlayer would accept this PCM data wrapped in an NSData object as long as you were able to set those variables manually in the AVAudioPlayer object. Unfortunately, those variables are read only, so even though the documentation says AVAudioPlayer can handle anything that Core Audio can handle, it has no way to handle raw LPCM data.
As stated by zoul, I would imagine that the easiest way to go about this is throwing in a WAV header, since the header informs AVPlayer of the above necessary variables. It's 44 bytes, is easily mocked up, and is defined nicely - I used the same definition given above to implement wav header encoding and decoding. Also, it's just prepended to your unmodified LPCM data.
Maybe adding a WAV header would help?
I posted a Swift 5 example (as a GitHub Gist) of converting a buffer of audio float samples into an in-memory WAV file to use with AVAudioPlayer initWithData, here: https://gist.github.com/hotpaw2/4eb1ca16c138178113816e78b14dde8b