Latest 0.9.6
Homepage https://github.com/PRX/TWLEncoder
License MIT
Platforms ios 7.0, osx 10.7, requires ARC
Dependencies sndfile-Framework, TwoLAME-Framework
Authors

Helps with creating MPEG-1 Layer 2 (.mp2) audio files in Cocoa and iOS apps.

Usage

TWLEncoder works similarly to the NSURLSession library that was introduced in iOS 7. You use configure an encoder, and use it to create and runs tasks. Information about the encoder and its tasks is communicated to delegates. Behind the scenese the tasks are processed in an operation queue.

One of the primary uses of MP2 audio is in broadcast systems for public radio in the United States. TWLEncoder comes with a basic configuration that should work with most systems. You could customize that configuration before using it, or build a configuration from scratch to meet your needs.

Building an encoder

TWLEncoderConfiguration *config = TWLEncoderConfiguration.publicRadioConfiguration;
TWLEncoder *encoder = [TWLEncoder encoderWithConfiguration:config delegate:self operationQueue:nil];

Creating a task

NSURL *fileURL = [NSURL fileURLWithPath:@"~/Desktop/master-2014_02_19-b.wav"];
TWLEncoderTask *task = [encoder taskWithURL:fileURL];
[task resume]; // Tasks start suspended and must be resumed to begin

Delegate

- (void)encoder:(TWLEncoder *)encoder task:(TWLEncoderTask *)task didWriteFrames:(int64_t)framesWritten totalFramesWritten:(int64_t)totalFramesWritten totalFrameExpectedToWrite:(int64_t)totalFramesExpectedToWrite bytesWritten:(int64_t)bytessWritten totalBytesWritten:(int64_t)totalBytesWritten {
  // eg Update a progress bar in the UI
}

- (void)encoder:(TWLEncoder *)encoder task:(TWLEncoderTask *)task didFinishEncodingToURL:(NSURL *)location {
  // eg Copy the encoded file to a permanent location
  // The temporary file that the encoding was written to will be removed as soon
  // as this method returns, so you must read or relocate the data before then.
}

Latest podspec

{
    "name": "TWLEncoder",
    "version": "0.9.6",
    "license": "MIT",
    "summary": "An iPhone and OS X libary for creating MP2 files with TwoLAME",
    "homepage": "https://github.com/PRX/TWLEncoder",
    "social_media_url": "https://twitter.com/prx",
    "authors": {
        "Chris Kalafarski": "[email protected]"
    },
    "source": {
        "git": "https://github.com/PRX/TWLEncoder.git",
        "tag": "0.9.6"
    },
    "requires_arc": true,
    "platforms": {
        "ios": "7.0",
        "osx": "10.7"
    },
    "source_files": "**/*.{h,m}",
    "dependencies": {
        "sndfile-Framework": [],
        "TwoLAME-Framework": []
    }
}

Pin It on Pinterest

Share This