Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Create audio file manually

    • 0
    • 1
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 286
    Comment on it

    We often come across conditions where manual audio file is to be created. For example recording an audio or download audio data from server. These all need audio file in which data is to be populated.

    Below, I'm creating an sound.caf file and after successful creation, data is populating.

    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
        NSString *documentsDirectory = [paths objectAtIndex:0];
        NSString *path = [documentsDirectory stringByAppendingPathComponent:@"sound.caf"]; NSFileManager *fileManager = [NSFileManager defaultManager];
    
        path = [documentsDirectory stringByAppendingPathComponent: [NSString stringWithFormat: @"sound.caf"] ];
    
    
        [data writeToFile: path atomically:YES];  // Here data is NSData or audioData which is to be written on audioFile.
    

    One can create audio in other formats as well. Note* Make sure you are using valid format that iOS sdk supports. for example: caf, wav etc.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: