Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8005709
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T17:18:02+00:00 2026-06-04T17:18:02+00:00

I searched a lot and couldn’t find anything relevant… I am working on iOS

  • 0

I searched a lot and couldn’t find anything relevant… I am working on iOS audio files and here is what I want to do…

  1. Record Audio and Save Clip (Checked, I did this using AVAudioRecorder)
  2. Change the pitch (Checked, Did this using Dirac)
  3. Trimming 🙁

I have two markers i.e. starting & ending offset and using this info I want to trim recorded file and want to save it back. I don’t want to use “seek” because later on I want to play all recorded files in sync (just like flash movie clips in timeline) and then finally I want to export as one audio file.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T17:18:03+00:00Added an answer on June 4, 2026 at 5:18 pm

    Here’s the code that I’ve used to trim audio from a pre-existing file. You’ll need to change the M4A related constants if you’ve saved or are saving to another format.

    - (BOOL)trimAudio
    {
        float vocalStartMarker = <starting time>;
        float vocalEndMarker = <ending time>;
    
        NSURL *audioFileInput = <your pre-existing file>;
        NSURL *audioFileOutput = <the file you want to create>;
    
        if (!audioFileInput || !audioFileOutput)
        {
            return NO;
        }
    
        [[NSFileManager defaultManager] removeItemAtURL:audioFileOutput error:NULL];
        AVAsset *asset = [AVAsset assetWithURL:audioFileInput];
    
        AVAssetExportSession *exportSession = [AVAssetExportSession exportSessionWithAsset:asset
                                                                                presetName:AVAssetExportPresetAppleM4A];
    
        if (exportSession == nil)
        {        
            return NO;
        }
    
        CMTime startTime = CMTimeMake((int)(floor(vocalStartMarker * 100)), 100);
        CMTime stopTime = CMTimeMake((int)(ceil(vocalEndMarker * 100)), 100);
        CMTimeRange exportTimeRange = CMTimeRangeFromTimeToTime(startTime, stopTime);
    
        exportSession.outputURL = audioFileOutput;
        exportSession.outputFileType = AVFileTypeAppleM4A;
        exportSession.timeRange = exportTimeRange;
    
        [exportSession exportAsynchronouslyWithCompletionHandler:^
         {
             if (AVAssetExportSessionStatusCompleted == exportSession.status)
             {
                 // It worked!
             } 
             else if (AVAssetExportSessionStatusFailed == exportSession.status)
             {
                 // It failed...
             }
         }];
    
        return YES;
    }
    

    There’s also Technical Q&A 1730, which gives a slightly more detailed approach.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I searched a lot, but couldn't find anything.. I just want to ask if
I searched a lot, but couldn't find anything: unsigned int unicodeChar = 0x5e9; unsigned
I've searched a lot here but couldn't find a similar topic: i need to
Hy there I searched a lot on google, but couldn't find an answer. Maybe
I've searched in here and other forums and couldn't find a good answer.. I
I have searched a lot for this issue. But couldn't find the exact answer.
I searched a lot and still couldn't find a solid solution for this. Suppose
I searched for this a lot but couldn't find the answer. Tomcat documentation on
I searched a lot but couldn't find the way to measure web page loading
i am new to android, i searched a lot and couldn't find a satisfying

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.