Code example for SoundPool

Methods: play

0
		float leftVolume = this.mLeftVolume * gain * (1.0f - this.clamp(pan, 0.0f, 1.0f));
		float rightVolume = this.mRightVolume * gain * (1.0f - this.clamp(-pan, 0.0f, 1.0f));
		float soundRate = this.clamp(SOUND_RATE * pitch, 0.5f, 2.0f);
 
		// play sound 
		int streamID = this.mSoundPool.play(soundId, this.clamp(leftVolume, 0.0f, 1.0f), this.clamp(rightVolume, 0.0f, 1.0f), Cocos2dxSound.SOUND_PRIORITY, pLoop ? -1 : 0, soundRate);
 
		// record stream id 
		ArrayList<Integer> streamIDs = this.mPathStreamIDsMap.get(pPath);
		if (streamIDs == null) {
			streamIDs = new ArrayList<Integer>();
			this.mPathStreamIDsMap.put(pPath, streamIDs);
		} 
		streamIDs.add(streamID);
 
		return streamID;
	} 
 
	// =========================================================== 
	// Inner and Anonymous Classes 
	// ===========================================================