avaudioplayer

Generating a tone using DTMF and playing it with AVAudioPlayer.

I want to generate a custom DTMF tone and play it on the iPhone. In order to do so, I have created and allocated a memory buffer with a custom tone (ptr). Now I want to create a NSData object, initialized with the memory buffer, and pass it to AVAudioPlayer using initWithData:error: instance method. I wrote the following code, but when ...

Cocoa Touch - Loading AVAudioPlayer

I have this code to play a sound but the first time you play it it takes a good 5 seconds to load... How can I speed this up? -(IBAction)playSound{ //play the cricket noise NSString *soundPath = [[NSBundle mainBundle] pathForResource:@"Cricket_Sound" ofType:@"mp3"]; audioPlayer =[[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fil...

Playing Audio in an iPhone App

What do you think is the best (i.e. most memory efficient) way of playing a few 30 second audio files (m4v) from the bundle within an app to the external speaker? The audio files have to play automatically as soon a specific view appears. There is no mixing, etc. going on. However I'm listening to the microphone at the same time via AVA...

How do you send messages between two instances of a custom UITableViewCell?

Hi guys, I have a UITableView populated with a bunch of music players that I've made using a custom UITableViewCell. (as shown in the screenshot linked here: screenshot). The problem with the way I have it coded is that since each cell is completely independent, there's no way for one tableviewcell to check if any other the other cells ...

AVAudioPlayer time display

I have a simple mp3 playing through AVAudioPlayer and I want to be able to display how much time is left. I know the answer includes subtracting AVAudioPlayer.duration from AVAudioPlayer.currentTime but I don't know how to implement a function which calculates it while it's playing (like an onEnterFrame in Actionscript I guess). At pre...

Persiting data / instance variables in NavigationController View

I have a root view and a detail view, in the detail view is a AVAudioPlayer with a basic play/pause button setup. All works, however if I play the file and then click back (popViewControllerAnimated) to the root, the file keeps playing which is correct, but then if I click back to the detail view the view has reset and doesn't find the i...

AvAudioPlayer memory leaks!?

Hi! Im doing an application that needs to play alot of short sounds (mp3-files). Im using AvAudioPlayer and the sounds are playing just fine, BUT the leaks are building up until my app crashes. I have a seperate class for the player AVSnd.h #import <Foundation/Foundation.h> #import <AVFoundation/AVFoundation.h> @interface AVSoundPla...

Problem with AVAudioplayer or delegate getting dallocated prematurely

Hi! I am making a counting game for kids. At the start the child is asked find a number of items, for example: "Can you find five bikes". This is all randomly put together from seperate arrays of sounds with parts of the sentence: "Can you find" + "5" + "bikes" =three seperate mp3s. When the child starts clicking on the items, they disa...

How do I code for different versions of iPhone OS in XCode?

I seem to have a bug because I'm using -[AVAudioSession setActive:withFlags:error:] in an iPhone project that is for 3.0 - 4.0.2. So I guess I need to put one of those #IF lines in, so I can get it to do different things based on the OS version... But I can't find out how to do it. Can anyone help please? Thanks! :) ...

didSelectRowAtIndexPath - access tapCount or similar

I'd like to control an instance of AVAudioPlayer from a UITableView item in a didSelectRowAtIndexPath instance. First touch of the row item triggers 'play' of the AVAudioPlayer. Second touch of the row item triggers 'stop' of the AVAudioPlayer. I can make the 'play' work but can't get the 'stop' to work. Also, subsequent touches of t...

iPhone AVAudioPlayer - play WHILE clicking, stop on lift of finger

Hi, I am using AVAudioPlayer and am trying to get it so while the user presses on the device, it continuously plays until their finger lifts up. My code is below: NSString *audioPath = [[NSBundle mainBundle] pathForResource:@"HahahaLong" ofType:@"mp3"]; primaryAudio = [[AVAudioPlayer alloc]initWithContentsOfURL:[NSURL fileURLWithPa...

linking a button to a certain sound in xcode?

I'm using avaudioplayer and want to add a button to play the sound but i'm not sure how to. Here's current code: #import UIKit/UIKit.h @class AudioPlayerViewController; @interface AudioPlayerAppDelegate : NSObject <UIApplicationDelegate> { UIWindow *window; AudioPlayerViewController *viewController; } @property (nonatomic, re...

How to handle error code -43 from NSOSStatusErrorDomain when initializing AVAudioPlayer Object?

I observed strange behavior while working with AVAudioPlayer Following is the code. AVAudioPlayer *newPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL: [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@",fileName]] error: &error]; In this, I downloaded the file from server and stored in application's Cache directory. I a...

play audio from internet using AVAudioPlayer

Hey all, I am implementing AVAudioPlayer to play audio and it works perfectly well while playing files locally stored in the PC. But when i give the url of some audio file over the internet, it fails sadly. Here's what the code looks like: NSString *url = [[NSString alloc] init]; url = @"http://files.website.net/audio/files/audioFile.m...

How to use MPMusicPlayerController with AVAudioPlayer

Hi All, I am trying to play an in app audio with ipod the code I am using to play the audio file is: Code: [[AVAudioSession sharedInstance] setCategory: AVAudioSessionCategoryPlayback error: nil]; UInt32 doSetProperty = 1; AudioSessionSetProperty (kAudioSessionProperty_OverrideCategoryMixWithOthers, sizeof(doSetP...

seamless dynamic audio loop on iPhone

Ok, So I am trying to seamlessly loop together three sound files with the second file being looped against itself n times. Let's assume I can get them to loop seemlessly together in another program by butting them together. however when I use audioPlayerDidFinishPlaying delegate method of avaudioplayer there is a slight delay in the but...

How can i compare two audio files on the basis of certain parameter say maximum decibel ?

Hello all, I am trying to compare two .caf files on the basis of some parameter, say maximum decibels or duration of files. I have recorded these two files using the AVAudioRecorder class using the following settings: NSMutableDictionary* recordSetting = [[NSMutableDictionary alloc] init]; [recordSetting setValue :[NSNumber numberW...

Routing iPhone Audio Sound

I have an app which does listen and play sound at the same time. By default, the sound output goes through the earphone. So I use the following code to route it through the speaker: UInt32 audioRouteOverride = kAudioSessionOverrideAudioRoute_Speaker; AudioSessionSetProperty (kAudioSessionProperty_OverrideAudioRoute, sizeof(audioRouteOve...

iPhone/iPad sound playback with setCurrentTimeFunction. Non AVAudioPlayer.

Hello, I've recently been trying to incorporate an intensive sound management class, where sound playback precision is a must. What I'm looking for is the option to load a sound, set the playback starting position (or playhead), play for a certain time, pause the sound, set the 'playhead' position to a new interval and resume playback a...

Audioplayer play on condition

hi all, i hv few images , and i am showing these images through for loop, so i am getting a value in mCurrentImageView , which indicates which image is currently shown up. now i want to play audio on each image view, different audios. for ex, if(mCurrentImageView ==0) { play "a" } if (mCurrentImageView ==1) { play "b" } .... someth...