/*
 * D2A
 * Copyright (C) SatisKia. All rights reserved.
 */

package net.satis.d2a;

import android.media.*;

public class _Sound
{
	private _Main _m;
	private int _num;
	private SoundPool _pool;
	private int[] _id;

	private int _volume;

	public _Sound( _Main m, int num )
	{
		_m = m;
		_num = num;
		_pool = new SoundPool( _num, AudioManager.STREAM_MUSIC, 0 );
		_id = new int[_num];

		_volume = 100;
	}

	public void create( int index, int res_id )
	{
		_id[index] = _pool.load( _m, res_id, 1 );
	}

	public void dispose( int index )
	{
		_pool.unload( _id[index] );
	}

	public void play( int index )
	{
		_pool.play( _id[index], (float)_volume / 100.0f, (float)_volume / 100.0f, 1, 0, 1.0f );
	}

	public void setVolume( int volume )
	{
		_volume = volume;
	}

	public void release()
	{
		_pool.release();
		_pool = new SoundPool( _num, AudioManager.STREAM_MUSIC, 0 );
	}
}
