iPhone SDK: Cross fade Sound using Core Audio-AVAudioPlayer
Crossfade sound: dim the first playing sound track & in parallel start and increase the volume of the second playing sound track.
Restrictions from Apple:
- AVAudioPlayer Class Reference:"Play multiple sounds simultaneously, one sound per audio player, with precise synchronization"
- Codecs "There are two groups of playback codecs in iOS. The first group, listed in Table 2-3, includes highly efficient formats that you can use without restriction. That is, you can play more than one instance of each of these formats at the same time."
[code]
#import "MyPlayer.h"
#import <AVFoundation/AVFoundation.h>
@interface ImageExampleViewController : UIViewController {
MyPlayer *audioPlayerForest;
MyPlayer *audioPlayerForestCalm;
MyPlayer *audioPlayerCamp;
MyPlayer *audioPlayerTown;
}
@property(nonatomic , retain)MyPlayer *audioPlayerForest;
@property(nonatomic , retain)MyPlayer *audioPlayerForestCalm;
@property(nonatomic , retain)MyPlayer *audioPlayerCamp;
@property(nonatomic , retain)MyPlayer *audioPlayerTown;
@end
[/code]
2. MyPlayer is a subclass of AVAudioPlayer with one additional property storing the state of the sound:
#import <Foundation/Foundation.h>
#import <AVFoundation/AVFoundation.h>
typedef enum {
starting = 0,
started = 1,
stopping = 2,
stopped = 3
} statePlayer;
@interface MyPlayer : AVAudioPlayer {
statePlayer state ;
}
@property(nonatomic) statePlayer state ;
@end
----------------
#import "MyPlayer.h"
@implementation MyPlayer
@synthesize state;
- (id)init
{
self = [super init];
if (self) {
// Initialization code here.
}
return self;
}
@end
- admin's blog
- Login to post comments

blogging drupal
This is just a test to see how commenting looks on a drupal blog.