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 8341693
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T05:33:38+00:00 2026-06-09T05:33:38+00:00

I am developing an iOS app that has a button with a microphone on

  • 0

I am developing an iOS app that has a button with a microphone on it (along with other features). When the user presses the microphone, it gets highlighted and the app should now start recording sound from the device´s microphone and send to a server (a server dedicated to the app, developed by people that I know, so I can affect its design).

I am looking for the simplest yet sturdiest approach to do this, i.e. I have no need to develop a complicated streaming solution or VoIP functionality, unless it is as simple to do as anything else.

The main problem is that we have no idea for how long the user will be recording sound, but we want to make sure that sounds are sent to the server continuously, we do not wish to wait until the user has finished recording. It is okay if the data arrives to the server in chunks however we do not wish to miss any information that the user may be recording, so one chunk must continue where the previous one ended and so on.

Our first thought was to create “chunks” of sound clips of for example 10 seconds and send them continuously to the server. Is there any streaming solution that is better/simpler that I am missing out on?

My question is, what would be the most simple but still reliable approach on solving this task on iOS?

Is there a way to extract chunks of sound from a running recording by AVAudioRecorder, without actually stopping the recording?

  • 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-09T05:33:39+00:00Added an answer on June 9, 2026 at 5:33 am

    look at this
    in this tutorial, the sound recorded will be saved at soundFileURL, then you will just have to create an nsdata with that content, and then send it to your server.
    hope this helped.

    EDIT :
    I just created a version that contain 3 buttons, REC, SEND and Stop :
    REC : will start recording into a file.
    SEND : will save what was recorded on that file in a NSData, and send it to a server, then will restart recording.
    and STOP : will stop recording.
    here is the code :
    in your .h file :

    #import <UIKit/UIKit.h>
    #import <AVFoundation/AVFoundation.h>
    
    @interface ViewController : UIViewController <AVAudioRecorderDelegate>
    
    @property (nonatomic, retain) AVAudioRecorder *audioRecorder;
    @property (nonatomic, retain) IBOutlet UIButton *recordButton;
    @property (nonatomic, retain) IBOutlet UIButton *stopButton;
    @property (nonatomic, retain) IBOutlet UIButton *sendButton;
    
    @property BOOL stoped;
    
    - (IBAction)startRec:(id)sender;
    - (IBAction)sendToServer:(id)sender;
    - (IBAction)stop:(id)sender;
    @end
    

    and in the .m file :

    #import "ViewController.h"
    
    @implementation ViewController
    @synthesize audioRecorder;
    @synthesize recordButton,sendButton,stopButton;
    @synthesize stoped;
    
    - (void)didReceiveMemoryWarning
    {
        [super didReceiveMemoryWarning];
        // Release any cached data, images, etc that aren't in use.
    }
    
    #pragma mark - View lifecycle
    
    - (void)viewDidLoad
    {
        [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    sendButton.enabled = NO;
    stopButton.enabled = NO;
    stoped = YES;
    
    NSArray *dirPaths;
    NSString *docsDir;
    
    dirPaths = NSSearchPathForDirectoriesInDomains(
                                                   NSDocumentDirectory, NSUserDomainMask, YES);
    docsDir = [dirPaths objectAtIndex:0];
    NSString *soundFilePath = [docsDir
                               stringByAppendingPathComponent:@"tempsound.caf"];
    
    NSURL *soundFileURL = [NSURL fileURLWithPath:soundFilePath];
    
    NSDictionary *recordSettings = [NSDictionary 
                                    dictionaryWithObjectsAndKeys:
                                    [NSNumber numberWithInt:AVAudioQualityMin],
                                    AVEncoderAudioQualityKey,
                                    [NSNumber numberWithInt:16], 
                                    AVEncoderBitRateKey,
                                    [NSNumber numberWithInt: 2], 
                                    AVNumberOfChannelsKey,
                                    [NSNumber numberWithFloat:44100.0], 
                                    AVSampleRateKey,
                                    nil];
    
    NSError *error = nil;
    
    audioRecorder = [[AVAudioRecorder alloc]
                     initWithURL:soundFileURL
                     settings:recordSettings
                     error:&error];
    audioRecorder.delegate = self;
    if (error)
    {
        NSLog(@"error: %@", [error localizedDescription]);
    
    } else {
        [audioRecorder prepareToRecord];
    }
    }
    
    - (void)viewDidUnload
    {
        [super viewDidUnload];
        // Release any retained subviews of the main view.
        // e.g. self.myOutlet = nil;
    }
    
    - (void)viewWillAppear:(BOOL)animated
    {
        [super viewWillAppear:animated];
    }
    
    - (void)viewDidAppear:(BOOL)animated
    {
        [super viewDidAppear:animated];
    }
    
    - (void)viewWillDisappear:(BOOL)animated
    {
        [super viewWillDisappear:animated];
    }
    
    - (void)viewDidDisappear:(BOOL)animated
    {
        [super viewDidDisappear:animated];
    }
    
    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
    {
        // Return YES for supported orientations
        return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
    }
    
    - (BOOL) sendAudioToServer :(NSData *)data {
        NSData *d = [NSData dataWithData:data];
        //now you'll just have to send that NSData to your server
    
        return YES;
    }
    -(void)audioRecorderDidFinishRecording:(AVAudioRecorder *)recorder successfully:(BOOL)flag
    {
    NSLog(@"stoped");
        if (!stoped) {
            NSData *data = [NSData dataWithContentsOfURL:recorder.url];
            [self sendAudioToServer:data];
            [recorder record];
    NSLog(@"stoped sent and restarted");
        }
    }
    - (IBAction)startRec:(id)sender {
    if (!audioRecorder.recording)
    {
        sendButton.enabled = YES;
        stopButton.enabled = YES;
        [audioRecorder record];
    }
    }
    
    - (IBAction)sendToServer:(id)sender {
    stoped = NO;
    [audioRecorder stop];
    }
    
    - (IBAction)stop:(id)sender {
    stopButton.enabled = NO;
    sendButton.enabled = NO;
    recordButton.enabled = YES;
    
    stoped = YES;
    if (audioRecorder.recording)
    {
        [audioRecorder stop];
    }
    }
    @end
    

    Good Luck.

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

Sidebar

Related Questions

I'm developing an iPhone (and later Android) app that has real-time features, i.e. when
I am developing an iOS app that allows users to download documents off a
I am developing an iOS app that must handle several stereo audio files (ranging
I am developing an IOS app. I need a functionality that includes undo and
I'm developing an iOS app, but i need to identify the user who made
I'm developing an app that uses iOS4 features (like MFMessageComposeViewController), but I want to
So I'm developing in Xcode for iOS, and EVERY APP that I run in
We developing a iOS app that uses CoreData. To keep ourselves from going crazy
I'm developing web-application (and also native iOS app) that uses images from different websites.
I am developing an iOS app. How can I know the current section that

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.