How can I implement a volume meter for a song currently playing? (iPhone OS 3.1.3)
Posted
by Adam
on Stack Overflow
See other posts from Stack Overflow
or by Adam
Published on 2010-05-28T01:58:56Z
Indexed on
2010/05/28
2:01 UTC
Read the original article
Hit count: 329
Hi i'm very new to core audio and I just would like some help in coding up a little volume meter for whatever's being outputted through headphones or built-in speaker. Like a dB meter. I have the following code, and have been trying to go through the apple source project "SpeakHere", but it's a nightmare trying to go through all that, without knowing how it works first... Could anyone shed some light?
Here's the code I have so far...
(void)displayWaveForm { while (musicIsPlaying == YES { NSLog(@"%f",sizeof(AudioQueueLevelMeterState)); } }
(IBAction)playMusic { if (musicIsPlaying == NO) { NSURL *url = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/track7.wav",[[NSBundle mainBundle] resourcePath]]];
NSError *error;
music = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:&error]; music.numberOfLoops = -1;
music.volume = 0.5; [music play]; musicIsPlaying = YES; [self displayWaveForm]; }
else { [music pause]; musicIsPlaying = NO; }
}
© Stack Overflow or respective owner