Lompat ke konten Lompat ke sidebar Lompat ke footer

how to trim an audio file on iphone

iOS: trimming audio files with Swift

Swift Language

iOS: passementerie sound files

I've written about how to record audio on iOS victimisation Swift.
But, how do you shipshape the recording?

Introduction

Contents

Same way to trim an audio file is to use AVFoundation's AVAssetExportSession. You create an export session instance, curing its parameters, and then tell it to export the asset (your audio file) accordant to those parameters.

In the recorder project, I saved the Uniform resource locator of the recording in the soundFileURL instance variable. To use AVAssetExportSession we need to create an AVAsset from it. Here is a simple action that creates the asset and and so visit the export mathematical function I will discourse next.

Now to define the export func.

You make up the exporter from your plus and desired file format. Here I'm using the Apple lossless data formatting.
Then I set the exporter's outputURL dimension to a file in URL in the documents directory. This testament be the position of the clipped sound file.

I make up a core media sentence range using CMTimeRangeFromTimeToTime that specifies the time offsets for the commencement and close for the clipped file. Here I just insensitive code the values, but of course you'd habituate a Pseudemys scripta or a waveform view to choose the time boundaries.

Piece you're in that respect, you can also specify an AVMutableAudioMix for the volume. You can even specify a volume ramp.

Once the exporter's properties are set, you call exportAsynchronouslyWithCompletionHandler to do the actual work. You can check the status of the export in the completion handler.

Or exploitation Fast 4 syntax:

Groovy, huh?

Succinct

Table of Table of contents

To trim an audio (or picture) charge, use AVFoundation's AVAssetExportSession.

Resources

Table of Contents

how to trim an audio file on iphone

Source: http://www.rockhoppertech.com/blog/ios-trimming-audio-files/

Posting Komentar untuk "how to trim an audio file on iphone"