Latest 0.0.1
License APACHE
Platforms ios 8.0

![CI Status]( Arvids Kartupelis/CinchAudio.svg?style=flat)


This does not have any dependencies on other libraries other than iOS runtimes


CinchAudio is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod "CinchAudio"


John Arvids Kartupelis, [email protected]


CinchAudio is available under the Apache 2.0 license. See the LICENSE file for more info.


There is a demo application; you can fork this repo or download the zip and try it out. The demo application is a tabbed iOS app containing one tab showing the recorder working (with a very simple visualizer) and one tab showing the playback working outputting a simple sine wave.

Audio Playback

The CinchAudioPlayer can be created as follows:

CinchAudioPlayer *audioPlayer = [[CinchAudioPlayer alloc] initWithDataSource:<some data source> audioFormat:<some audio format>];

where is a class which implements the data source protocol:

@protocol CinchAudioDataSource <NSObject>


-(NSData*)floatAudioSamplesWithLength:(NSInteger)length offsetInSamples:(NSInteger)offsetInSamples;
-(NSData*)int16AudioSamplesWithLength:(NSInteger)length offsetInSamples:(NSInteger)offsetInSamples;


The data source protocol allows using either float audio samples or int16 audio samples depending on your preference / which for your existing data is in.

The CinchAudioPlayer constructor also takes an argument of an audioFormat which is an object implementing the audio format protocol:

typedef NS_ENUM(NSUInteger, CinchAudioFormatType)
    CinchAudioFormatType32BitFloat = 32,
    CinchAudioFormatType16BitShort = 16,

typedef NS_ENUM(NSUInteger, CinchAudioSampleRate)
    //TODO: add support for sample rates (can also use a numeric value cast to sample rate type)
    CinchAudioSampleRate48Khz = 48000,
    CinchAudioSampleRate44100Hz = 44100,

typedef NS_ENUM(NSUInteger, CinchAudioChannelCount)
    //TODO: add support for more audio channel types?
    CinchAudioMono = 1,
    CinchAudioStereo = 2,

@protocol CinchAudioFormat <NSObject>



The protocol defines the type of PCM audio. The type specified will set which callback is chosen in the data source – using float calls the float audio samples method and using shorts calls the other one.

After having created the player object, playing, pausing and playing from a time point in the data is as easy as using these methods:


Audio Recording

The CinchAudioRecorder takes the same audio format argument as the player, but it instead of a data source requires a data handler to handle the incoming data from the recording device (iPhone mic):

-(void)cinchAudioRecorder:(nonnull CinchAudioRecorder*)cinchAudioRecorder didReceiveInt16Data:(nonnull NSData*)data;
-(void)cinchAudioRecorder:(nonnull CinchAudioRecorder*)cinchAudioRecorder didReceiveFloatData:(nonnull NSData*)data;

Again, which method is called depends on whether floats or int16 are used in the audio format.

Starting and stopping recording is done by using the following methods:


NSData Categories

Since we’re using NSData for all callbacks instead of dealing directly with raw types (float or SInt16) there are some useful categories on NSData to allow easier conversion and convenience. NSData+PCM provides these methods:


Hopefully they’re fairly self-explanatory, but the length returns the length of samples given the type of data we’re using for samples. The subdata gives the subdata for the sample range rather than the byte range.

NSMutableData+PCM provides these methods:


for conveniently adding a PCM int16 or float to a mutable data object.


If you’d like to change anything, please do submit a pull request!

Latest podspec

    "name": "CinchAudio",
    "version": "0.0.1",
    "summary": "An audio library designed to make recording and playing back PCM audio a cinch",
    "description": "This is meant to be the easiest sound library you'll ever use for PCM audio. No more C - just plain Objective C callbacks.",
    "homepage": "",
    "license": {
        "type": "APACHE",
        "file": "LICENSE"
    "authors": {
        "onepointsixtwo": "[email protected]"
    "platforms": {
        "ios": "8.0"
    "source": {
        "git": "",
        "tag": "v0.0.1"
    "source_files": [

Pin It on Pinterest

Share This