SoundPool setVolume - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for SoundPool setVolume method.

This code example shows how to use the following methods:load, setVolume, unload
				player = new MediaPlayer();
				player.setDataSource(fileName);
				player.prepare();
			}else{ 
				if(soundID!=-1) unloadSound();
				soundID = pool.load(fileName, 1);
			} 
			setVolume(volume);
			bIsLoaded = true;
			this.fileName = fileName;
			this.stream = stream;
		} catch (Exception e) {
			Log.e("OF","couldn't load " + fileName,e);
		}  
	} 
	 
	void unloadSound(){ 
		if(player!=null){
			player.release();
			player = null;

9
CodeRank
This code example shows how to use the following methods:setRate, setVolume
 
    public synchronized void varioChanged(double newVar) {
        var = newVar;
        if (soundPool != null) {
 
            soundPool.setRate(tone_1000_stream, getRateFromTone1000(var));
 
            if (var >= varioAudioThreshold) {
                beeping = true;
            } 
            if (var < varioAudioCutoff) {
                beeping = false;
            } 
 
 
            if (var < sinkAudioThreshold) {
                soundPool.setVolume(sink_stream, 1.0f, 1.0f);
            } else { 
                soundPool.setVolume(sink_stream, 0.0f, 0.0f);
            } 

5
CodeRank
This code example shows how to use the following methods:setVolume
		if (value < 0) 
			value = 0;
		if (mVolume == value) 
			return; 
		mVolume = value;
		SOUND_POOL.setVolume(mStreamId, leftPan(mVolume, mPan), rightPan(mVolume, mPan));
	} 
	 
	/** 
	 * Get the panning factor (a value from -1 to 1) of the sound during playback. 
	 */ 
	public float getPan() { return mPan; }
	 
	/** 
	 * Alter the panning factor (a value from -1 to 1) of the sound during playback. 
	 */ 
	public void setPan(float value) {
		if (value < -1) 
			value = -1;
		if (value > 1) 
5
CodeRank
This code example shows how to use the following methods:setVolume
			return; 
		} 
		 
		mVolume = getVolumeFromAmplitude(mDeviceAmplitude, mMinDeviceAmplitude, mMaxDeviceAmplitude);
		mReadWriteSoundStreamIDLock.readLock().lock();
		mSoundPool.setVolume(mSoundPoolStreamID, mVolume, mVolume);
		mReadWriteSoundStreamIDLock.readLock().unlock();
	} 
	 
	public float getRepetitionInterval() { 
		return mRepetitionIntervalMilliseconds;
	} 
	 
	public boolean getMuted() { 
		return mMuted;
	} 
	 
	public void setMuted(boolean muted) {
		mReadWriteClosedLock.readLock().lock();
		boolean closed = mClosed;
4
CodeRank
This code example shows how to use the following methods:setVolume
	 *            ������ 
	 * @param rightVolume 
	 *            ������ 
	 */ 
	public void setVolume(int streamID, float leftVolume, float rightVolume) {
		soundPool.setVolume(streamID, leftVolume, rightVolume);
	} 
 
	/** 
	 * ����ָ�������������ȼ� 
	 *  
	 * @param streamID 
	 *            ������ID 
	 * @param priority 
	 *            ���ȼ� 
	 */ 
	public void setPriority(int streamID, int priority) {
		soundPool.setPriority(streamID, priority);
	} 
 
4
CodeRank
This code example shows how to use the following methods:setVolume
 
        } 
 
        else{ 
 
            sfx.setVolume( CollideTerrain.getStreamID(), curVolume-(curVolume*balance), curVolume+(curVolume*balance) );
            return false; 
 
        } 
    } 
 
    /** 
     * When the player ceases to make contact with the terrain, we need to stop playing the collide sound. 
     * This is how such is accomplished, and must be called to ensure that the engine knows that the collide 
     * sound is not playing, since there is no such functionality to the SoundPool. 
     * 
     * @return A boolean of whether or not the CollideTerrain loop was closed deliberately, as opposed to 
     *          encountering an already finished stream. 
     */ 
    public boolean stopCollideTerrain(){ 
3
CodeRank
This code example shows how to use the following methods:setVolume
      int wait_stream_id = stream_id;
      stream_id = wait_stream_id_map.get(wait_stream_id);
      // Log.i("SetSoundVolume", "wait stream id " + wait_stream_id + " -> stream id " + stream_id); 
    } 
 
    sound_pool.setVolume(stream_id, volume, volume);
  } 
 
  public static void SetSoundPitch(int stream_id, float pitch)
  { 
    if (stream_id >= 10000)
    { 
      int wait_stream_id = stream_id;
      stream_id = wait_stream_id_map.get(wait_stream_id);
      // Log.i("SetSoundPitch", "wait stream id " + wait_stream_id + " -> stream id " + stream_id); 
    } 
 
    sound_pool.setRate(stream_id, pitch);
  } 
   
4
CodeRank
This code example shows how to use the following methods:setVolume
     * @param streamID Id del sonido que se esta escuchando 
     * @param volume Volumen del sonido 
     */ 
    public void setVolumeSong(int streamID, float volume)
    { 
    	sndPool.setVolume(streamID, volume, volume);
    } 
	     
    /** 
     * Metodo para controlar la velocidad 
     * @param speed velocidad 
     */ 
    public void setSpeed(float speed)
    { 
    	rate = speed;
    	 
    	if(rate < 0.01f)
    	{ 
    		rate = 0.01f;
    	} 
4
CodeRank
This code example shows how to use the following methods:setVolume
	/** 
	 * Set the volume of a sound 
	 */ 
	public void volume(String sound, float volume) {
		 
		mSoundPool.setVolume(mSounds.get(sound), volume, volume);
	} 
	 
	 
	/** 
	 * Play a sound, once or loop. 
	 */ 
	public void play(String sound, boolean loop) {
		 
		float volume;
		volume  = mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
		volume /= mAudioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
		 
	    mSoundPool.play(
	    		mSounds.get(sound), 
4
CodeRank
This code example shows how to use the following methods:setVolume, stop
		int instanceId = soundPool.play(soundId, volume, volume, 1, -1, 1f);
		return instanceId;
	} 
 
	public void stop(int instanceId) {
		soundPool.stop(instanceId);
		soundPool.setVolume(instanceId, 0f, 0f);
	} 
 
	public void release() { 
		released=true;
		soundPool.release();
	} 
} 
5
CodeRank
setVolume Method Overview
Set stream volume.
See Code Examples for other Android SoundPool Methods: