Esempio n. 1
0
void AudioSource::resume()
{
  alSourcePlay(m_sourceID);

#if NORI_DEBUG
  checkAL("Failed to resume source");
#endif
}
Esempio n. 2
0
void AudioSource::start()
{
  alSourcePlay(m_sourceID);

#if NORI_DEBUG
  checkAL("Failed to start source");
#endif
}
Esempio n. 3
0
void AudioSource::pause()
{
  alSourcePause(m_sourceID);

#if NORI_DEBUG
  checkAL("Failed to pause source");
#endif
}
Esempio n. 4
0
void AudioSource::stop()
{
  alSourceStop(m_sourceID);

#if NORI_DEBUG
  checkAL("Failed to stop source");
#endif
}
Esempio n. 5
0
bool AudioSource::init()
{
  alGenSources(1, &m_sourceID);

  if (!checkAL("Error during audio buffer creation"))
    return false;

  return true;
}
Esempio n. 6
0
void Context::setListenerPosition(const vec3& newPosition)
{
    if (listenerPosition != newPosition)
    {
        listenerPosition = newPosition;
        alListenerfv(AL_POSITION, value_ptr(listenerPosition));

#if WENDY_DEBUG
        checkAL("Failed to set listener position");
#endif
    }
}
Esempio n. 7
0
void AudioSource::setPosition(const vec3& newPosition)
{
  if (m_position != newPosition)
  {
    m_position = newPosition;
    alSourcefv(m_sourceID, AL_POSITION, value_ptr(m_position));

#if NORI_DEBUG
    checkAL("Failed to set source position");
#endif
  }
}
Esempio n. 8
0
void AudioSource::setLooping(bool newState)
{
  if (m_looping != newState)
  {
    m_looping = newState;
    alSourcei(m_sourceID, AL_LOOPING, m_looping);

#if NORI_DEBUG
    checkAL("Failed to set source looping state");
#endif
  }
}
Esempio n. 9
0
void Context::setListenerVelocity(const vec3& newVelocity)
{
    if (listenerVelocity != newVelocity)
    {
        listenerVelocity = newVelocity;
        alListenerfv(AL_VELOCITY, value_ptr(listenerVelocity));

#if WENDY_DEBUG
        checkAL("Failed to set listener velocity");
#endif
    }
}
Esempio n. 10
0
void AudioSource::setPitch(float newPitch)
{
  if (m_pitch != newPitch)
  {
    m_pitch = newPitch;
    alSourcefv(m_sourceID, AL_PITCH, &m_pitch);

#if NORI_DEBUG
    checkAL("Failed to set source pitch");
#endif
  }
}
Esempio n. 11
0
void AudioSource::setVelocity(const vec3& newVelocity)
{
  if (m_velocity != newVelocity)
  {
    m_velocity = newVelocity;
    alSourcefv(m_sourceID, AL_VELOCITY, value_ptr(m_velocity));

#if NORI_DEBUG
    checkAL("Failed to set source velocity");
#endif
  }
}
Esempio n. 12
0
void Context::setListenerGain(float newGain)
{
    if (listenerGain != newGain)
    {
        listenerGain = newGain;
        alListenerfv(AL_GAIN, &listenerGain);

#if WENDY_DEBUG
        checkAL("Failed to set listener gain");
#endif
    }
}
Esempio n. 13
0
void AudioSource::setGain(float newGain)
{
  if (m_gain != newGain)
  {
    m_gain = newGain;
    alSourcefv(m_sourceID, AL_GAIN, &m_gain);

#if NORI_DEBUG
    checkAL("Failed to set source gain");
#endif
  }
}
Esempio n. 14
0
void AudioContext::setListenerGain(float newGain)
{
  if (m_listenerGain != newGain)
  {
    m_listenerGain = newGain;
    alListenerfv(AL_GAIN, &m_listenerGain);

#if NORI_DEBUG
    checkAL("Failed to set listener gain");
#endif
  }
}
Esempio n. 15
0
void AudioContext::setListenerPosition(const vec3& newPosition)
{
  if (m_listenerPosition != newPosition)
  {
    m_listenerPosition = newPosition;
    alListenerfv(AL_POSITION, value_ptr(m_listenerPosition));

#if NORI_DEBUG
    checkAL("Failed to set listener position");
#endif
  }
}
Esempio n. 16
0
void AudioContext::setListenerVelocity(const vec3& newVelocity)
{
  if (m_listenerVelocity != newVelocity)
  {
    m_listenerVelocity = newVelocity;
    alListenerfv(AL_VELOCITY, value_ptr(m_listenerVelocity));

#if NORI_DEBUG
    checkAL("Failed to set listener velocity");
#endif
  }
}
Esempio n. 17
0
void AudioSource::setBuffer(AudioBuffer* newBuffer)
{
  if (m_buffer != newBuffer)
  {
    m_buffer = newBuffer;

    if (m_buffer)
      alSourcei(m_sourceID, AL_BUFFER, m_buffer->m_bufferID);
    else
      alSourcei(m_sourceID, AL_BUFFER, AL_NONE);

#if NORI_DEBUG
    checkAL("Failed to set source buffer");
#endif
  }
}
Esempio n. 18
0
bool AudioBuffer::init(const Sample& data)
{
  alGenBuffers(1, &m_bufferID);
  alBufferData(m_bufferID,
               convertToAL(data.format),
               data.data.data(), (ALsizei) data.data.size(),
               data.frequency);

  if (!checkAL("Error during OpenAL buffer creation"))
    return false;

  m_format = data.format;
  m_duration = Time(data.data.size()) / (getFormatSize(m_format) * data.frequency);

  return true;
}
Esempio n. 19
0
void Context::setListenerRotation(const quat& newRotation)
{
    if (listenerRotation != newRotation)
    {
        listenerRotation = newRotation;

        const vec3 at = newRotation * vec3(0.f, 0.f, -1.f);
        const vec3 up = newRotation * vec3(0.f, 1.f, 0.f);

        const float orientation[] = { at.x, at.y, at.z, up.x, up.y, up.z };

        alListenerfv(AL_ORIENTATION, orientation);

#if WENDY_DEBUG
        checkAL("Failed to set listener rotation");
#endif
    }
}
Esempio n. 20
0
AudioSource::State AudioSource::state() const
{
  ALenum state;
  alGetSourcei(m_sourceID, AL_SOURCE_STATE, &state);

#if NORI_DEBUG
  checkAL("Failed to get source state");
#endif

  switch (state)
  {
    case AL_INITIAL:
    case AL_STOPPED:
      return STOPPED;
    case AL_PLAYING:
      return STARTED;
    case AL_PAUSED:
      return PAUSED;
  }

  panic("Unknown OpenAL source state %u", state);
}