Example #1
0
float SonicDog::calculatePause( ALuint source ) { 
	ALfloat x, y, z;
	alGetSource3f( source, AL_POSITION, &x, &y, &z );
	float d = sqrt( (x*x) + (z*z) );

	return ( -1.5f*exp( 0.6f*d ) ) / ( -1.0f*exp( 0.6f*d ) - 1.5f );
}
Example #2
0
Vector3f SoundSource::getPosition() const
{
    Vector3f position;
    alCheck(alGetSource3f(m_source, AL_POSITION, &position.x, &position.y, &position.z));

    return position;
}
Example #3
0
float SonicDog::calculatePitch( ALuint source ) {
	ALfloat x, y, z;
	alGetSource3f( source, AL_POSITION, &x, &y, &z );
	float d = sqrt( (x*x) + (z*z) );

	float p = ( 1.0f - (d / start_d) ) / 2.0f;
	return p + 1.0f;
}
JNIEXPORT void JNICALL Java_org_lwjgl_openal_AL10_nalGetSource3f(JNIEnv *__env, jclass clazz, jint source, jint param, jlong v1Address, jlong v2Address, jlong v3Address, jlong __functionAddress) {
	ALfloat *v1 = (ALfloat *)(intptr_t)v1Address;
	ALfloat *v2 = (ALfloat *)(intptr_t)v2Address;
	ALfloat *v3 = (ALfloat *)(intptr_t)v3Address;
	alGetSource3fPROC alGetSource3f = (alGetSource3fPROC)(intptr_t)__functionAddress;
	UNUSED_PARAMS(__env, clazz)
	alGetSource3f(source, param, v1, v2, v3);
}
QVector3D QSoundSourcePrivate::velocity() const
{
    if (!m_alSource)
        return QVector3D(0, 0, 0);
    ALfloat x, y, z;
    alGetSource3f(m_alSource, AL_VELOCITY, &x, &y, &z);
    return QVector3D(x, y, z);
}
QVector3D QSoundSourcePrivate::position() const
{
    if (!m_alSource)
        return QVector3D(0, 0, 0);
    ALfloat x, y, z;
    alGetSource3f(m_alSource, AL_POSITION, &x, &y, &z);
    return QVector3D(x, y, z);
}
QVector3D QSoundSourcePrivate::direction() const
{
    if (!m_alSource)
        return QVector3D(0, 1, 0);
    ALfloat x, y, z;
    alGetSource3f(m_alSource, AL_DIRECTION, &x, &y, &z);
    return QVector3D(x, y, z);
}
Example #8
0
 double AudioStream_Ogg::getRight()   
 {
    float panX=0;
    float panY=0;
    float panZ=0;
    alGetSource3f(source, AL_POSITION, &panX, &panY, &panZ);
    return (panX+1)/2;
 }
Example #9
0
void al_getsource3f( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] ) {

	if (NULL == alGetSource3f) mogl_glunsupported("alGetSource3f");
	alGetSource3f((ALuint)mxGetScalar(prhs[0]),
		(ALenum)mxGetScalar(prhs[1]),
		(ALfloat*)mxGetData(prhs[2]),
		(ALfloat*)mxGetData(prhs[3]),
		(ALfloat*)mxGetData(prhs[4]));

}
Example #10
0
WError WSound::SaveToWS(std::string filename) const {
	if (Valid() && m_dataV.size()) //only attempt to save if the sound is valid and there is something to save
	{
		//open the file for writing
		fstream file;
		file.open(filename, ios::out | ios::binary);

		if (!file.is_open())
			return WError(W_FILENOTFOUND);

		float temp[3];

		//write pitch & volume
		alGetSourcef(m_source, AL_PITCH, &temp[0]);
		alGetSourcef(m_source, AL_GAIN, &temp[1]);
		file.write((char*)temp, 2 * sizeof(float));

		//write position & direction
		alGetSource3f(m_source, AL_POSITION, &temp[0], &temp[1], &temp[2]);
		file.write((char*)temp, 3 * sizeof(float));
		alGetSource3f(m_source, AL_DIRECTION, &temp[0], &temp[1], &temp[2]);
		file.write((char*)temp, 3 * sizeof(float));

		char numBuffers = m_dataV.size();
		file.write((char*)&numBuffers, 1);
		for (uint i = 0; i < numBuffers; i++) {
			file.write((char*)&m_dataV[i].buffer, 4); //buffer index
			file.write((char*)&m_dataV[i].format, sizeof ALenum); //buffer format
			alGetBufferf(m_buffers[m_dataV[i].buffer], AL_FREQUENCY, &temp[0]);
			file.write((char*)&temp[0], 4); //frequency
			file.write((char*)&m_dataV[i].dataSize, 4); //size of data
			file.write((char*)&m_dataV[i].data, m_dataV[i].dataSize); //data
		}

		file.close();
	}
	else
		return WError(W_NOTVALID);

	return WError(W_SUCCEEDED);

}
Example #11
0
	value lime_al_get_source3f (int source, int param) {
		
		ALfloat val1, val2, val3;
		
		alGetSource3f (source, param, &val1, &val2, &val3);
		
		value result = alloc_array (3);
		val_array_set_i (result, 0, alloc_float (val1));
		val_array_set_i (result, 1, alloc_float (val2));
		val_array_set_i (result, 2, alloc_float (val3));
		return result;
		
	}
Example #12
0
WError WSound::SaveToWS(basic_filebuf<char>* buff, uint pos) const {
	if (Valid() && m_dataV.size()) //only attempt to save if the sound is valid and there is something to save
	{
		//use the given stream
		fstream file;
		if (!buff)
			return WError(W_INVALIDPARAM);
		file.set_rdbuf(buff);
		file.seekp(pos);

		float temp[3];

		//write pitch & volume
		alGetSourcef(m_source, AL_PITCH, &temp[0]);
		alGetSourcef(m_source, AL_GAIN, &temp[1]);
		file.write((char*)temp, 2 * sizeof(float));

		//write position & direction
		alGetSource3f(m_source, AL_POSITION, &temp[0], &temp[1], &temp[2]);
		file.write((char*)temp, 3 * sizeof(float));
		alGetSource3f(m_source, AL_DIRECTION, &temp[0], &temp[1], &temp[2]);
		file.write((char*)temp, 3 * sizeof(float));

		char numBuffers = m_dataV.size();
		file.write((char*)&numBuffers, 1);
		for (uint i = 0; i < numBuffers; i++) {
			file.write((char*)&m_dataV[i].buffer, 4); //buffer index
			file.write((char*)&m_dataV[i].format, sizeof ALenum); //buffer format
			alGetBufferf(m_buffers[m_dataV[i].buffer], AL_FREQUENCY, &temp[0]);
			file.write((char*)&temp[0], 4); //frequency
			file.write((char*)&m_dataV[i].dataSize, 4); //size of data
			file.write((char*)&m_dataV[i].data, m_dataV[i].dataSize); //data
		}
	}
	else
		return WError(W_NOTVALID);

	return WError(W_SUCCEEDED);
}
Example #13
0
void SoundManager::getChannelPosition(const ChannelHandle &handle, float &x, float &y, float &z) {
	Common::StackLock lock(_mutex);

	Channel *channel = getChannel(handle);
	if (!channel || !channel->stream)
		throw Common::Exception("Invalid channel");

	if (channel->stream->getChannels() > 1)
		throw Common::Exception("Cannot get position of a non-mono sound.");

	if (_hasSound)
		alGetSource3f(channel->source, AL_POSITION, &x, &y, &z);
}
Example #14
0
bool SonicDog::getSoundPosition( const size_t id, ALfloat *x, ALfloat *y, ALfloat *z ) {
	pthread_mutex_lock( &sources_lock_ );
	SoundMap::iterator object = sources_.find( id );

	if ( object != sources_.end() ) {
		alGetSource3f( object->second->source, AL_POSITION, x, y, z );
		pthread_mutex_unlock( &sources_lock_ );

		return true;
	} else {
		pthread_mutex_unlock( &sources_lock_ );
		return false;
	}
}
Example #15
0
 double OpenALChannel::getRight()   
 {
    if (mUseStream)
    {
       return mStream ? mStream->getRight() : 0;
    }
    else
    {
       float panX=0;
       float panY=0;
       float panZ=0;
       alGetSource3f(mSourceID, AL_POSITION, &panX, &panY, &panZ);
       return (panX+1)/2;
    }
 }
/// gets position of the soundsource
void cSoundSourceOpenAl::GetPosition(float &x, float &y, float &z){alGetSource3f(miId,AL_POSITION,&x,&y,&z);CheckOpenAl();}
/// gets velocity of the soundsource
void cSoundSourceOpenAl::GetVelocity(float &x, float &y, float &z){alGetSource3f(miId,AL_VELOCITY,&x,&y,&z);CheckOpenAl();}
Example #18
0
//*****************************************************************************
// alGetSource3f
//*****************************************************************************
//
ALAPI ALvoid ALAPIENTRY alGetSource3f(ALuint sourceName, ALenum param, ALfloat* v1, ALfloat* v2, ALfloat* v3)
{
    AL_VOID_FXN(alGetSource3f(sourceName, param, v1, v2, v3));
}
Example #19
0
ALvoid CDECL wine_alGetSource3f(ALuint sid, ALenum param, ALfloat* value1, ALfloat* value2, ALfloat* value3)
{
    alGetSource3f(sid, param, value1, value2, value3);
}
Example #20
0
static PyObject*
_sources_getprop (PyObject *self, PyObject *args)
{
    long bufnum;
    ALenum param;
    char *type;
    int size = 0, cnt;
    PropType ptype = INVALID;

    if (!CONTEXT_IS_CURRENT (((PySources*)self)->context))
    {
        PyErr_SetString (PyExc_PyGameError, "source context is not current");
        return NULL;
    }

    if (!PyArg_ParseTuple (args, "lls:get_prop", &bufnum, &param, &type))
    {
        PyErr_Clear ();
        if (!PyArg_ParseTuple (args, "lls|i:get_prop", &bufnum, &param, &type,
                               &size))
            return NULL;
        if (size <= 0)
        {
            PyErr_SetString (PyExc_ValueError, "size must not smaller than 0");
            return NULL;
        }
    }

    ptype = GetPropTypeFromStr (type);
    CLEAR_ALERROR_STATE ();
    switch (ptype)
    {
    case INT:
    {
        ALint val;
        alGetSourcei ((ALuint)bufnum, param, &val);
        if (SetALErrorException (alGetError (), 0))
            return NULL;
        return PyLong_FromLong ((long)val);
    }
    case FLOAT:
    {
        ALfloat val;
        alGetSourcef ((ALuint)bufnum, param, &val);
        if (SetALErrorException (alGetError (), 0))
            return NULL;
        return PyFloat_FromDouble ((double)val);
    }
    case INT3:
    {
        ALint val[3];
        alGetSource3i ((ALuint)bufnum, param, &val[0], &val[1], &val[2]);
        if (SetALErrorException (alGetError (), 0))
            return NULL;
        return Py_BuildValue ("(lll)", (long)val[0], (long)val[1],
                              (long)val[2]);
    }
    case FLOAT3:
    {
        ALfloat val[3];
        alGetSource3f ((ALuint)bufnum, param, &val[0], &val[1], &val[2]);
        if (SetALErrorException (alGetError (), 0))
            return NULL;
        return Py_BuildValue ("(ddd)", (double)val[0], (double)val[1],
                              (double)val[2]);
    }
    case INTARRAY:
    {
        PyObject *tuple, *item;
        ALint* val = PyMem_New (ALint, size);
        if (!val)
            return NULL;
        alGetSourceiv ((ALuint)bufnum, param, val);
        if (SetALErrorException (alGetError (), 0))
        {
            PyMem_Free (val);
            return NULL;
        }
        tuple = PyTuple_New ((Py_ssize_t) size);
        if (!tuple)
            return NULL;
        for (cnt = 0; cnt < size; cnt++)
        {
            item = PyLong_FromLong ((long)val[cnt]);
            if (!item)
            {
                PyMem_Free (val);
                Py_DECREF (tuple);
                return NULL;
            }
            PyTuple_SET_ITEM (tuple, (Py_ssize_t) cnt, item);
        }
        return tuple;
    }
    case FLOATARRAY:
    {
        PyObject *tuple, *item;
        ALfloat* val = PyMem_New (ALfloat, size);
        if (!val)
            return NULL;
        alGetSourcefv ((ALuint)bufnum, param, val);
        if (SetALErrorException (alGetError (), 0))
        {
            PyMem_Free (val);
            return NULL;
        }
        tuple = PyTuple_New ((Py_ssize_t) size);
        if (!tuple)
            return NULL;
        for (cnt = 0; cnt < size; cnt++)
        {
            item = PyFloat_FromDouble ((double)val[cnt]);
            if (!item || PyTuple_SET_ITEM (tuple, (Py_ssize_t) cnt, item) != 0)
            {
                PyMem_Free (val);
                Py_XDECREF (item);
                Py_DECREF (tuple);
                return NULL;
            }
        }
        return tuple;
    }
    default:
        PyErr_SetString (PyExc_ValueError, "invalid type specifier");
        return NULL;
    }
}
Example #21
0
math::Vec3 Source::direction()
{
  math::Vec3 result;
  alGetSource3f(source, AL_DIRECTION, &(result.x), &(result.y), &(result.z));ALDEBUG_THROW;
  return result;
}
Example #22
0
math::Vec3 Source::position()
{
  Vec3 result;
  alGetSource3f(source, AL_POSITION, &(result.x), &(result.y), &(result.z));ALDEBUG_THROW;
  return result;
}
Example #23
0
void Source::getAttribute_3f(unsigned int attrib,float & v1,float & v2,float & v3){
	alGetSource3f( sourceId,static_cast<ALenum>(attrib),&v1,&v2,&v3 );
}
Example #24
0
math::Vec3 Source::velocity()
{
  Vec3 result;
  alGetSource3f(source, AL_VELOCITY, &(result.x), &(result.y), &(result.z));ALDEBUG_THROW;
  return result;
}