avaudioplayer

iPhone - AVAudioPlayer - convert decibel level into percent

元气小坏坏 提交于 2019-12-04 11:18:13
I like to update an existing iPhone application which is using AudioQueue for playing audio files. The levels (peakPowerForChannel, averagePowerForChannel) were linear form 0.0f to 1.0f. Now I like to use the simpler class AVAudioPlayer which works fine, the only issue is that the levels which are now in decibel, not linear from -120.0f to 0.0f. Has anyone a formula to convert it back to the linear values between 0.0f and 1.0f? Thanks Tom Several Apple examples use the following formula to convert the decibels into a linear range (from 0.0 to 1.0): double percentage = pow (10, (0.05 * power));

MonoTouch: Playing sound

杀马特。学长 韩版系。学妹 提交于 2019-12-04 10:41:47
I am trying to play a short sound when user taps on the specific button. But the problem is that I always receive Object reference not set to an instance object . means Null! I first tried MonoTouch.AudioToolBox.SystemSound. MonoTouch.AudioToolbox.AudioSession.Initialize(); MonoTouch.AudioToolbox.AudioSession.Category = MonoTouch.AudioToolbox.AudioSessionCategory.MediaPlayback; MonoTouch.AudioToolbox.AudioSession.SetActive(true); var t = MonoTouch.AudioToolbox.SystemSound.FromFile("click.mp3"); t.PlaySystemSound(); Let me notice that "click.mp3" is in my root solution folder and it is flagged

Resuming execution of code after interruption while app is in background

橙三吉。 提交于 2019-12-04 10:28:51
I have spent days researching on SO and other websites for the answer to this but without any luck. Essentially, the challenge I've set for myself is to create an alarm clock app for iOS that will sound no matter where the user may be (foreground or background). This I have already accomplished by using an AVAudioPlayer instance and starting to play an empty sound file when the user sets the alarm in order for the app to keep running in the background. When it is time for the alarm to go off (ie when the NSTimer is fired) a second player, which has already been initiated and prepared to play,

Swift 2: AVAudioPlayers to play multiple sounds at once

自古美人都是妖i 提交于 2019-12-04 10:19:44
So hey I've been searching around, trying to find a way to solve this, but there's basically no solutions to this yet. I desperately need a way to instantiate and play a sound whenever I want, without it cutting out any other sounds. I know that AVAudioPlayer can only play one sound at a time, so I'm trying to figure out how to make a dynamic array of AVAudioPlayers that I can add to any time I need to play a sound. My current code, that I got from a different answer on this site, is this: func Sound(sound: String) { do { if let bundle = NSBundle.mainBundle().pathForResource(sound, ofType:

AVAudioPlayer stop a sound and play it from the beginning

夙愿已清 提交于 2019-12-04 09:57:30
问题 I used the AVAudioPlayer to play a 10 sec wav file and it works fine. Now I what to stop the wav at the 4th sec and then play it again from the very 1st sec. Here is the code I tried: NSString *ahhhPath = [[NSBundle mainBundle] pathForResource:@"Ahhh" ofType:@"wav"]; AVAudioPlayer *ahhhhhSound =[[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:ahhhPath] error:NULL]; [ahhhhhSound stop]; [ahhhhhSound play]; What I get is, the wav stops at the 4th sec but when I run the [XXX

Swift - How can I convert Saved Audio file conversations to Text?

若如初见. 提交于 2019-12-04 09:30:31
I work on speech recognition. I solve the text-to-speech and speech-to-text with IOS frameworks. But now i want to convert saved audio file conversations to text. How can i solve this ? Thank you for all replies. I have worked on same things which are working for me. I have audio file in my project bundle which. So I have written following code to convert audio to text. let audioURL = Bundle.main.url(forResource: "Song", withExtension: "mov") let recognizer = SFSpeechRecognizer(locale: Locale(identifier: "en-US")) let request = SFSpeechURLRecognitionRequest(url: audioURL!) request

AVAudioRecorder - Proper MPEG4 AAC Recording Settings

老子叫甜甜 提交于 2019-12-04 09:30:02
问题 I've got a live app with an estimated 15% of users reporting that the record feature is not working. This isn't happening on our test devices, but the reports show that the problem is that prepareToRecord is returning NO. I've had trouble finding sample settings for AAC format. Are any of my settings off? App requires iOS5 and uses ARC. AVAudioSession *audioSession = [AVAudioSession sharedInstance]; [audioSession setCategory:AVAudioSessionCategoryRecord error:nil]; NSDictionary

The Mute Button Won't Mute AVAudioPlayer

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-04 09:21:16
问题 I need to loop play a .caf file in my iPhone app. The AVAudioPlayer looks promising. But there's one problem. It won't stop or mute even if I pressed the mute button on the iPhone. And I understand that there would be no way to programmatically find out whether that mute button is pressed or not in iOS 5. So, what I need to know might be some properties about AVAudioPlayer or AVAudioSession. Or, perhaps, I may need to consider other libraries to loop playing my .caf file. Any idea? 回答1: I

Trying to understand AVAudioPlayer and audio level metering

北战南征 提交于 2019-12-04 08:34:48
I'm trying to understand AVAudioPlayer and audio level metering. What I have below is an object "AudioPlayer" that is playing a short audio sound. Now I want to output the power of this sound (decibels). Somehow I don't think I'm doing this right. audioPlayer.meteringEnabled = YES; [audioPlayer play]; int channels = audioPlayer.numberOfChannels; [audioPlayer updateMeters]; for (int i=0; i<channels; i++) { //Log the peak and average power NSLog(@"%d %0.2f %0.2f", i, [audioPlayer peakPowerForChannel:0],[audioPlayer averagePowerForChannel:0]); The NSLog output of this is 0 -160.00 -160.00 1 -160

How to get audio to play at time from NSDatePicker?

放肆的年华 提交于 2019-12-04 07:37:07
问题 I'm making an app which requires a sound to play at a time in the future set by the user using NSDatePicker how would I do so? I already have the AVAudioPlayer setup, I just need the help with the playing itself. And please write how to do so that answers the entire question instead of leading me elsewhere. The aim is to get an alarm that can be set by the user at a specific time using NSDatePicker and using a sound I have made and added to the project. And then for the user to have to turn