160 likes | 368 Views
Yu Feng CGDD 4903. Audio. Review. 1. Set up 2. IOS sound Core Audio Short Sound Long Sound Control Sound Background Sound 3.Cocos2d sound. Set up. Core Audio. High level System Sound API– short sounds AVAudioPlayer (AVFoundation)– Long sounds Lower level
E N D
Yu Feng CGDD 4903 Audio
Review 1. Set up 2. IOS sound • Core Audio • Short Sound • Long Sound • Control Sound • Background Sound 3.Cocos2d sound
Core Audio High level • System Sound API– short sounds • AVAudioPlayer (AVFoundation)– Long sounds Lower level • Audio Toolbox – recording and playback, streaming, full control • Audio Units – processing audio • OpenAL – 3D positional sound
Short Sounds • Less than 5 seconds • No looping • No volume control • Immediate playback • Limited set of formats (wav)
Short Sound Code Two process: 1. register the sound and get a ID 2. play the sound Using AduioToolkit
Long Sound • Play longer sounds (> 5 seconds) • Locally stored files or in-memory • Can loop, seek, play, pause • Provides metering • Play multiple sounds simultaneously • Supports many more formats
Long Sound Code [player play];
Simple Ways to Control Audio 1. Move Forward and Backward • Use Button • Use Slider
Add Audio in Cocos2d Audio Library: • CocosDenshion Three ways to import audio: • SimpleAudioEngine • CDSoundEngine • CDAudioManager
SimpleAudioEngine How it works: • Add header -- “SimpleAudioEngine.h” and “CocosDenshion.h” • Add sound file into support file • Code:
Different method playEffect: play a sound, play once • handle sound effect: • stopEffect • playEffect • preloadEffect • unloadEffect playBackgroundMusic: user can set loop times (.numberOfLoops=2) • handle background music: • pauseBackgroundMusic • resumeBackgroundMusic • rewindBackgroundMusic • preloadBackgroundMusic