コード例 #1
0
ファイル: SoundEffects.cpp プロジェクト: FeodorFitsner/Urho3D
void SoundEffects::HandlePlaySound(StringHash eventType, VariantMap& eventData)
{
    Button* button = static_cast<Button*>(GetEventSender());
    const String& soundResourceName = button->GetVar(VAR_SOUNDRESOURCE).GetString();

    // Get the sound resource
    ResourceCache* cache = GetSubsystem<ResourceCache>();
    Sound* sound = cache->GetResource<Sound>(soundResourceName);

    if (sound)
    {
        // Create a scene node with a SoundSource component for playing the sound. The SoundSource component plays
        // non-positional audio, so its 3D position in the scene does not matter. For positional sounds the
        // SoundSource3D component would be used instead
        Node* soundNode = scene_->CreateChild("Sound");
        SoundSource* soundSource = soundNode->CreateComponent<SoundSource>();
        soundSource->Play(sound);
        // In case we also play music, set the sound volume below maximum so that we don't clip the output
        soundSource->SetGain(0.75f);

        // Subscribe to the "sound finished" event generated by the SoundSource for removing the node once the sound has played
        // Note: the event is sent through the Node (similar to e.g. node physics collision and animation trigger events)
        // to not require subscribing to the particular component
        SubscribeToEvent(soundNode, E_SOUNDFINISHED, URHO3D_HANDLER(SoundEffects, HandleSoundFinished));
    }
}
コード例 #2
0
ファイル: SoundManager.cpp プロジェクト: HermanHGF/amorphous
bool SoundManager::PlayStream( const std::string& resource_path, double fadein_time, bool looped, int sound_group, U8 volume )
{
//	m_pSoundManagerImpl->PlayStream( resource_path, fadein_time, looped, sound_group, volume );

    if( m_mapNameToSoundSource.find( resource_path ) != m_mapNameToSoundSource.end() )
    {
        // A stream sound with the same name has already been loaded.
        return false;
    }

    SoundDesc desc;
    desc.Loop             = looped == 1 ? true : false;
    desc.Streamed         = true;
    desc.SourceManagement = SoundSource::Manual;

    SoundSource *pSource = CreateSoundSource( resource_path, desc );
    if( pSource )
    {
        m_mapNameToSoundSource[resource_path] = pSource;
        pSource->Play();
        return true;
    }
    else
    {
        LOG_PRINT_ERROR( "Cannot play streamed sound of: " + resource_path );
        return false;
    }
}
コード例 #3
0
void
SoundManager::update()
{
  if (!sound_enabled)
    return;

  // check for finished sound sources
  for(SoundSources::iterator i = sources.begin(); i != sources.end(); ) {
    SoundSource* source = *i;
    if(!source->playing()) {
      delete source;
      i = sources.erase(i);
    } else {
      ++i;
    }
  }
  // check streaming sounds
  if(music_source) {
    music_source->update();
  }
  
  if(next_music_source && (!music_source || !music_source->playing())) {
    delete music_source;
    music_source = next_music_source;
    //music_source->setFading(StreamSoundSource::FadingOn, 1.0f);
    music_source->play();
    next_music_source = 0;
  }
  
  alcProcessContext(context);
  check_alc_error("Error while processing audio context: ");
}
コード例 #4
0
void CSound::PlaySample(size_t id, const float3& p, const float3& velocity, float volume, bool relative)
{
	boost::mutex::scoped_lock lck(soundMutex);

	if (sources.empty() || volume == 0.0f)
		return;

	if (id == 0)
	{
		numEmptyPlayRequests++;
		return;
	}

	if (p.distance(myPos) > sounds[id].MaxDistance())
	{
		if (!relative)
			return;
		else
			LogObject(LOG_SOUND) << "CSound::PlaySample: maxdist ignored for relative payback: " << sounds[id].Name();
	}

	SoundSource* best = GetNextBestSource(false);
	if (!best->IsPlaying() || (best->GetCurrentPriority() <= 0 && best->GetCurrentPriority() < sounds[id].GetPriority()))
		best->Play(&sounds[id], p, velocity, volume, relative);
	CheckError("CSound::PlaySample");
}
コード例 #5
0
ファイル: DeviceAudioDX11.cpp プロジェクト: 9heart/DT3
SoundSource* DeviceAudioDX11::playQuick (SoundResource *sound)
{
	SoundSource* source = SoundSource::create();
    ScriptingSound* sound_loader = ScriptingSound::create();
    
    // Build the sound file loader
    sound_loader->setSoundProperty(sound);
    
    // Connect sound packet outputs
    PlugBase *s1 = source->getPlugByName("Sound_Packet");
    PlugBase *s2 = sound_loader->getPlugByName("Sound_Packet");
    s1->setIncomingConnection(s2);
    
    // Play the sound source
	if (play(source, sound_loader)) {
    
        if (source->countReferences() <= 1) {
            RELEASE(source);
        } else {
            source->release();	// Playing increments ref count so this pointer is still good
        }
        
        RELEASE(sound_loader);
		return source;
	} else {
        RELEASE(sound_loader);
		RELEASE(source);
		return NULL;
	}
}
コード例 #6
0
void
SoundManager::update()
{
  static float lasttime = real_time;

  if(real_time - lasttime < 0.3)
    return;
  lasttime = real_time;

  // update and check for finished sound sources
  for(SoundSources::iterator i = sources.begin(); i != sources.end(); ) {
    SoundSource* source = *i;

    source->update();
    
    if(!source->playing()) {
      delete source;
      i = sources.erase(i);
    } else {
      ++i;
    }
  }
  // check streaming sounds
  if(music_source) {
    music_source->update();
  }
  
  alcProcessContext(context);
  check_alc_error("Error while processing audio context: ");
}
コード例 #7
0
ファイル: mastercontrol.cpp プロジェクト: sabotage3d/heXon
void MasterControl::Start()
{
    new InputMaster(context_, this);
    cache_ = GetSubsystem<ResourceCache>();
    graphics_ = GetSubsystem<Graphics>();
    renderer_ = GetSubsystem<Renderer>();
    CreateSineLookupTable();

    // Get default style
    defaultStyle_ = cache_->GetResource<XMLFile>("UI/DefaultStyle.xml");
    //Create console and debug HUD.
    CreateConsoleAndDebugHud();
    //Create the scene content
    CreateScene();
    //Create the UI content
    CreateUI();
    //Hook up to the frame update and render post-update events
    SubscribeToEvents();

    Sound* music = cache_->GetResource<Sound>("Resources/Music/Alien Chaos - Disorder.ogg"); //Battle
    music->SetLooped(true);
    Node* musicNode = world.scene->CreateChild("Music");
    SoundSource* musicSource = musicNode->CreateComponent<SoundSource>();
    musicSource->SetGain(0.32f);
    musicSource->SetSoundType(SOUND_MUSIC);
    musicSource->Play(music);
    
    
}
コード例 #8
0
ファイル: Bullet.cpp プロジェクト: lyz4534/Urho3DSamples
void Bullet::Init(bool isPlayer, Vector2 spawnPosition)
{
	ResourceCache* cache = GetSubsystem<ResourceCache>();
	Graphics* graphics = GetSubsystem<Graphics>();

	halfHeight_ = graphics->GetHeight()  * PIXEL_SIZE * 0.5f;
	isPlayer_ = isPlayer;
	

	Sound* laserSound = cache->GetResource<Sound>(isPlayer_ ? "Sounds/laser01.wav" : "Sounds/laser02.wav");
	StaticSprite2D* sprite2D = node_->CreateComponent<StaticSprite2D>();

	if (isPlayer_)
		sprite2D->SetSprite( cache->GetResource<Sprite2D>("Sprites/blue_beam.png"));
	else
		sprite2D->SetSprite(cache->GetResource<Sprite2D>("Sprites/green_beam.png"));

	sprite2D->SetBlendMode(BLEND_ADDALPHA);

	SoundSource* soundSource = node_->CreateComponent<SoundSource>();
	soundSource->SetSoundType(SOUND_EFFECT);
	soundSource->SetGain(0.75f);
	soundSource->Play(laserSound);

	node_->SetPosition2D(spawnPosition);

	if (!isPlayer)
	{
		node_->Roll(180.0f);
	}
}
コード例 #9
0
ファイル: Test.cpp プロジェクト: Jbtyson/EmawEngine
void TDtest(){
	AudioEasyAccess* aea = AudioEasyAccess::getInstance();

	aea->playMusic("a", "drumloop.wav");
	aea->playSFX("b", "drumloop.wav");
	SoundSource* s = aea->getSoundSource("c", "jaguar.wav", -1.0, 0.0, 0.0);
	s->playSound();
}
コード例 #10
0
ファイル: Sound.cpp プロジェクト: nandor/nEngine
	// ------------------------------------------------------------------
	void Sound::loop()
	{
		alSourceStop(mSource);
		SoundSource* source = nEngine::Resources::inst().require<SoundSource> (mSourceName);
		mStarted = true;

		alSourcei(mSource, AL_BUFFER, source->getBuffer());
		alSourcei(mSource, AL_LOOPING, AL_TRUE);
		alSourcePlay(mSource);
	}
コード例 #11
0
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void MissileVisual::onModelChanged()
{
    RigidBodyVisual::onModelChanged();
    
    // particle trail
    s_effect_manager.createEffect("missile_smoke", osg_wrapper_->getOsgNode());

    // fly by sound effect
    SoundSource * snd = s_soundmanager.playLoopingEffect(s_params.get<std::string>("sfx.projectile"),
                                                         getWrapperNode()->getOsgNode());
    snd->setReferenceDistance(PROJECTILE_FLY_REF_DIST);
}
コード例 #12
0
ファイル: Sound.cpp プロジェクト: Dmytry/spring
void CSound::StartThread(int maxSounds)
{
#if BOOST_VERSION >= 103500
	try
	{
#endif
		{
			boost::mutex::scoped_lock lck(soundMutex);

			// Generate sound sources
			for (int i = 0; i < maxSounds; i++)
			{
				SoundSource* thenewone = new SoundSource();
				if (thenewone->IsValid())
				{
					sources.push_back(thenewone);
				}
				else
				{
					maxSounds = std::max(i-1,0);
					LogObject(LOG_SOUND) << "Your hardware/driver can not handle more than " << maxSounds << " soundsources";
					delete thenewone;
					break;
				}
			}

			// Set distance model (sound attenuation)
			alDistanceModel(AL_INVERSE_DISTANCE_CLAMPED);
			//alDopplerFactor(1.0);

			alListenerf(AL_GAIN, masterVolume);
		}
		configHandler->Set("MaxSounds", maxSounds);

		soundThreadRunning = true;
		while (soundThreadRunning) {
#if BOOST_VERSION >= 103500
			boost::this_thread::sleep(boost::posix_time::millisec(50)); // sleep
#else
			SDL_Delay(50);
#endif
			boost::mutex::scoped_lock lck(soundMutex); // lock
			Update(); // call update
		}
#if BOOST_VERSION >= 103500
	}
	catch(boost::thread_interrupted const&)
	{
		// do cleanup here
	}
#endif
}
コード例 #13
0
ファイル: SoundSynthesis.cpp プロジェクト: boberfly/Urho3D
void SoundSynthesis::CreateSound()
{
    // Sound source needs a node so that it is considered enabled
    node_ = new Node(context_);
    SoundSource* source = node_->CreateComponent<SoundSource>();

    soundStream_ = new BufferedSoundStream();
    // Set format: 44100 Hz, sixteen bit, mono
    soundStream_->SetFormat(44100, true, false);

    // Start playback. We don't have data in the stream yet, but the SoundSource will wait until there is data,
    // as the stream is by default in the "don't stop at end" mode
    source->Play(soundStream_);
}
コード例 #14
0
ファイル: basic_translator.cpp プロジェクト: imclab/spatosc
void BasicTranslator::pushConnectionChanges(Connection * conn)
{
    SoundSource *src = conn->getSource();
    Listener *snk = conn->getSink();
    
    sendPosition("/spatosc/core/listener/" + snk->getID(), snk);

    std::string srcPath = "/spatosc/core/source/" + src->getID();
    sendPosition(srcPath, src);

    std::string connectionPath = "/spatosc/core/connection/" + conn->getID();
    sendAED(connectionPath, conn);
    sendDelay(connectionPath, conn);
    sendGainDB(connectionPath, conn);
}
コード例 #15
0
ファイル: Audio.cpp プロジェクト: tungsteen/Urho3D
void Audio::MixOutput(void* dest, unsigned samples)
{
    if (!playing_ || !clipBuffer_)
    {
        memset(dest, 0, samples * sampleSize_ * SAMPLE_SIZE_MUL);
        return;
    }

    while (samples)
    {
        // If sample count exceeds the fragment (clip buffer) size, split the work
        unsigned workSamples = Min(samples, fragmentSize_);
        unsigned clipSamples = workSamples;
        if (stereo_)
            clipSamples <<= 1;

        // Clear clip buffer
        int* clipPtr = clipBuffer_.Get();
        memset(clipPtr, 0, clipSamples * sizeof(int));

        // Mix samples to clip buffer
        for (PODVector<SoundSource*>::Iterator i = soundSources_.Begin(); i != soundSources_.End(); ++i)
        {
            SoundSource* source = *i;

            // Check for pause if necessary
            if (!pausedSoundTypes_.Empty())
            {
                if (pausedSoundTypes_.Contains(source->GetSoundType()))
                    continue;
            }

            source->Mix(clipPtr, workSamples, mixRate_, stereo_, interpolation_);
        }
        // Copy output from clip buffer to destination
#ifdef __EMSCRIPTEN__
        float* destPtr = (float*)dest;
        while (clipSamples--)
            *destPtr++ = (float)Clamp(*clipPtr++, -32768, 32767) / 32768.0f;
#else
        short* destPtr = (short*)dest;
        while (clipSamples--)
            *destPtr++ = (short)Clamp(*clipPtr++, -32768, 32767);
#endif
        samples -= workSamples;
        ((unsigned char*&)dest) += sampleSize_ * SAMPLE_SIZE_MUL * workSamples;
    }
}
コード例 #16
0
ファイル: SoundSource.cpp プロジェクト: JSandrew4/FastGdk
	Bool SoundSource::operator!=(const SoundSource &that) const {
		if (&this->GetCollection() != &that.GetCollection())
			return true;
		if (this->mID != that.mID)
			return true;
		return false;
	}
コード例 #17
0
StaticSoundBinding::StaticSoundBinding(SoundSource& source, StaticSoundSample& sample)
: SoundBinding(source), mSample(sample)
{
	// Bind it to the buffer.
	alSourcei(source.getALSource(), AL_BUFFER, sample.getBuffer());
	SoundGeneral::checkAlError("Binding sound source to static sound buffer.");
}
コード例 #18
0
ファイル: DeviceAudioDX11.cpp プロジェクト: 9heart/DT3
void DeviceAudioDX11::stopOnChannel (DeviceAudioDX11Channel &channel)
{
	SoundSource *source = channel._source;
	
 	// Tell sound source that the sound is stopped
    if (source) {
        source->stopSound();

        channel._x_voice->Stop();

		// Release the connected sources and sound
		RELEASE(channel._source); 
        RELEASE(channel._sound_loader);
        
        channel._needs_priming = true;
	}
}
コード例 #19
0
ファイル: SoundEffects.cpp プロジェクト: zhzhxtrrk/Urho3D
void SoundEffects::HandlePlayMusic(StringHash eventType, VariantMap& eventData)
{
    // Check if the music player node/component already exist
    if (scene_->GetChild("Music"))
        return;
    
    ResourceCache* cache = GetSubsystem<ResourceCache>();
    Sound* music = cache->GetResource<Sound>("Music/Ninja Gods.ogg");
    // Set the song to loop
    music->SetLooped(true);
    
    // Create a scene node and a sound source for the music
    Node* musicNode = scene_->CreateChild("Music");
    SoundSource* musicSource = musicNode->CreateComponent<SoundSource>();
    // Set the sound type to music so that master volume control works correctly
    musicSource->SetSoundType(SOUND_MUSIC);
    musicSource->Play(music);
}
コード例 #20
0
void
SoundManager::play(const std::string& filename, const Vector& pos)
{
  try {
    SoundSource* source = create_sound_source(filename);
    if(source == 0)
      return;
    if(pos == Vector(-1, -1)) {
      alSourcef(source->source, AL_ROLLOFF_FACTOR, 0);
    } else {
      source->set_position(pos);
    }
    source->play();
    sources.push_back(source);
  } catch(std::exception& e) {
    log_warning << "Couldn't play sound " << filename << ": " << e.what() << std::endl;
  }
}
コード例 #21
0
ファイル: Audio.cpp プロジェクト: tungsteen/Urho3D
void Audio::UpdateInternal(float timeStep)
{
    URHO3D_PROFILE(UpdateAudio);

    // Update in reverse order, because sound sources might remove themselves
    for (unsigned i = soundSources_.Size() - 1; i < soundSources_.Size(); --i)
    {
        SoundSource* source = soundSources_[i];

        // Check for pause if necessary; do not update paused sound sources
        if (!pausedSoundTypes_.Empty())
        {
            if (pausedSoundTypes_.Contains(source->GetSoundType()))
                continue;
        }

        source->Update(timeStep);
    }
}
コード例 #22
0
  virtual void onSound(AudioIOData& io) {
    static cuttlebone::Stats fps("onSound()");
    fps(io.secondsPerBuffer());

    tap.pose(Pose(state->p[state->pokedVertex], Quatd(1, 0, 0, 0)));

    int popCount = taker.get(*state);
    float f = (state->p[state->pokedVertex] - state->pokedVertexRest).mag() - 0.304134 /* mean */;
    if (f > 0.8) f = 0.8;
    if (f < 0) f = 0;
    while (io()) {
      // XXX rnd::uniformS() should be gamma noise
      // XXX use interpolation on gain
      tap.writeSample(rnd::uniformS() * f);
      // io.out(0) = rnd::uniformS() * f;
    }
    listener()->pose(state->pose);
    scene()->render(io);
  }
コード例 #23
0
ファイル: SoundManager.cpp プロジェクト: HermanHGF/amorphous
bool SoundManager::StopStream( const std::string& resource_path, double fadeout_time )
{
    map<string,SoundSource *>::iterator itr
        = m_mapNameToSoundSource.find( resource_path );

    if( itr == m_mapNameToSoundSource.end() )
    {
        return false;
    }

    SoundSource *pSource = itr->second;
    if( pSource )
    {
        pSource->Stop();
        GetSoundManager().ReleaseSoundSource( pSource );
    }

    m_mapNameToSoundSource.erase( itr );

    return true;
}
コード例 #24
0
void CSound::StartThread(int maxSounds)
{
	{
		boost::mutex::scoped_lock lck(soundMutex);

		// Generate sound sources
		for (int i = 0; i < maxSounds; i++)
		{
			SoundSource* thenewone = new SoundSource();
			if (thenewone->IsValid())
			{
				sources.push_back(thenewone);
			}
			else
			{
				maxSounds = i-1;
				LogObject(LOG_SOUND) << "Your hardware/driver can not handle more than " << maxSounds << " soundsources";
				delete thenewone;
				break;
			}
		}

		// Set distance model (sound attenuation)
		alDistanceModel(AL_INVERSE_DISTANCE_CLAMPED);
		//alDopplerFactor(1.0);

		alListenerf(AL_GAIN, masterVolume);
	}

	while (true) {
		boost::this_thread::sleep(boost::posix_time::millisec(50));
		boost::this_thread::interruption_point();

		boost::mutex::scoped_lock lck(soundMutex);

		Update();
	}
}
コード例 #25
0
ファイル: SoundEffects.cpp プロジェクト: zhzhxtrrk/Urho3D
void SoundEffects::HandlePlaySound(StringHash eventType, VariantMap& eventData)
{
    Button* button = static_cast<Button*>(GetEventSender());
    const String& soundResourceName = button->GetVar(VAR_SOUNDRESOURCE).GetString();
    
    // Get the sound resource
    ResourceCache* cache = GetSubsystem<ResourceCache>();
    Sound* sound = cache->GetResource<Sound>(soundResourceName);
    
    if (sound)
    {
        // Create a scene node with a SoundSource component for playing the sound. The SoundSource component plays
        // non-positional audio, so its 3D position in the scene does not matter. For positional sounds the
        // SoundSource3D component would be used instead
        Node* soundNode = scene_->CreateChild("Sound");
        SoundSource* soundSource = soundNode->CreateComponent<SoundSource>();
        soundSource->Play(sound);
        // In case we also play music, set the sound volume below maximum so that we don't clip the output
        soundSource->SetGain(0.75f);
        // Set the sound component to automatically remove its scene node from the scene when the sound is done playing
        soundSource->SetAutoRemove(true);
    }
}
コード例 #26
0
ファイル: SoundSource.cpp プロジェクト: krruzic/cpp3ds
SoundSource::SoundSource(const SoundSource& copy)
: m_channel(copy.m_channel)
{
    setPitch(copy.getPitch());
    setVolume(copy.getVolume());
    setPosition(copy.getPosition());
    setRelativeToListener(copy.isRelativeToListener());
    setMinDistance(copy.getMinDistance());
    setAttenuation(copy.getAttenuation());
}
コード例 #27
0
ファイル: SoundSource.cpp プロジェクト: 42bottles/SFML
SoundSource::SoundSource(const SoundSource& copy)
{
    alCheck(alGenSources(1, &m_source));
    alCheck(alSourcei(m_source, AL_BUFFER, 0));

    setPitch(copy.getPitch());
    setVolume(copy.getVolume());
    setPosition(copy.getPosition());
    setRelativeToListener(copy.isRelativeToListener());
    setMinDistance(copy.getMinDistance());
    setAttenuation(copy.getAttenuation());
}
コード例 #28
0
ファイル: zzzSndSystem.cpp プロジェクト: drwbns/1stperson
void zzzSndSystem::LoadSound(std::string name, std::string file, SceneNode* owner = nullptr, bool loop = false, float gain = 1)
{
	SoundSource* s = soundsys->createSource(name, file);
	s->setLoop(loop);
	s->setMinGain(0);
	s->setGain(gain);
	s->setMaxGain(1);
	s->setDistanceValues(75.0,0.5,2.5);
	if (owner != nullptr)
	{
		owner->attachObject(s);
	}
	snds[name] = s;
}
コード例 #29
0
ファイル: SoundEngine.cpp プロジェクト: nriviere/Pathogen
void SoundEngine::playSound(unsigned int bufferIndex)
{
	SoundSource *source = new SoundSource(soundBuffers[bufferIndex]);
	addSource(source);
	source->play();
}
コード例 #30
0
ファイル: DeviceAudioDX11.cpp プロジェクト: 9heart/DT3
void DeviceAudioDX11::tick (const DTfloat dt)
{		

	PROFILER(PROFILER_SOUND);
    
    if (!_x_audio_2)
        return;

    DTfloat sound_on = castFromString<DTboolean>(Globals::getGlobal("SYS_SOUND")) ? 1.0F : 0.0F;		
    DTfloat sound_gain = Globals::hasGlobal("SYS_SOUND_GAIN") ? castFromString<DTfloat>(Globals::getGlobal("SYS_SOUND_GAIN")) : 1.0F;

    _gain = sound_on * sound_gain;
    
    //
    // Update Camera
    //

    if (getCamera()) {
        // Update Listener
        Vector3 position = getCamera()->getTranslation();
        Vector3 velocity = getCamera()->getVelocity();
        
        Vector3 forward = getCamera()->getForwards();
        Vector3 up = getCamera()->getUp();

        _x3_listener.OrientFront = X3DAUDIO_VECTOR(forward.x,forward.y,forward.z);

        _x3_listener.OrientTop = X3DAUDIO_VECTOR(up.x,up.y,up.z);

        _x3_listener.Position = X3DAUDIO_VECTOR(position.x,position.y,position.z);

        _x3_listener.Velocity = X3DAUDIO_VECTOR(velocity.x,velocity.y,velocity.z);
        
        _x_master_voice->SetVolume(_gain);
    } else {
        _x3_listener.OrientFront = X3DAUDIO_VECTOR(0.0F,0.0F,-1.0F);

        _x3_listener.OrientTop = X3DAUDIO_VECTOR(0.0F,1.0F,0.0F);

        _x3_listener.Position = X3DAUDIO_VECTOR(0.0F,0.0F,0.0F);

        _x3_listener.Velocity = X3DAUDIO_VECTOR(0.0F,0.0F,0.0F);
        
        _x_master_voice->SetVolume(_gain);
    }


    //
    // Update channels
    //

    for (DTuint c = 0; c < _channels.size(); ++c) {
        DeviceAudioDX11Channel &channel = _channels[c];
        SoundSource *source = channel._source;
    
        // If there's a source and a sound then this channel is playing
        if (source) {
            SoundPacket &packet = channel._packets[channel._current_packet];

            // Check to see if sound buffer was starved
            if (!channel._ready_to_start && packet.getNumBytes() > 0 && !channel._is_playing) {
                
                channel._ready_to_start = true;
                LOG_MESSAGE << "Audio stream starved";
            
            // Check if sound data has been depleted
            } else if (!channel._ready_to_start && packet.getNumBytes() == 0 && !channel._is_playing) {
#if DT2_MULTITHREADED_AUDIO
                AutoSpinLockRecursive lock(&_lock);
#endif

                stopOnChannel(channel);
                LOG_MESSAGE << "Audio stream done";
                
            // Update sound
            } else {
                // Maybe channel needs to be started
                if (channel._ready_to_start) {
#if DT2_MULTITHREADED_AUDIO
                    AutoSpinLockRecursive lock(&_lock);
#endif

                    // Fill buffers
                    if (channel._needs_priming)
                        primeStreaming (channel);

                    channel._is_playing = true;
                    channel._x_voice->Start();
              
                    channel._ready_to_start = false;
                }
                
                Vector3 position = source->getTranslation();
                Vector3 velocity = source->getVelocity();
                //DTboolean looping = source->Get_Looping();	// Instead we loop sounds ourselves
                DTfloat pitch = source->getPitch();
                DTfloat rolloff = source->getRolloff();
                DTfloat gain = source->getGain();

                // position sound
                if (!getCamera()) {
                    channel._x3_emitter.Position = X3DAUDIO_VECTOR(0.0F,0.0F,0.0F);

                } else if (position == Vector3(0.0F,0.0F,0.0F)) {
                    Vector3 camera_position = getCamera()->getTranslation();
                    channel._x3_emitter.Position = X3DAUDIO_VECTOR(camera_position.x, camera_position.y, camera_position.z);

                } else {
                    channel._x3_emitter.Position = X3DAUDIO_VECTOR(position.x, position.y, position.z);

                }

                channel._x3_emitter.Velocity = X3DAUDIO_VECTOR(velocity.x, velocity.y, velocity.z);
                channel._x_voice->SetVolume(gain);

                //::alSourcef(channel._al_source, AL_PITCH, pitch);
                //CheckAL();

                //::alSourcef(channel._al_source, AL_ROLLOFF_FACTOR, rolloff);
                //CheckAL();
                
            }
        }
    }
    
    // Update Busses
    List<Bus>::iterator i;
    FOR_EACH (i,_busses) {
        Bus &bus = *i;
    
        // Get the number of buffers that have been processed
        //ALint num_buffers;
        //::alGetSourcei(bus._al_source, AL_BUFFERS_PROCESSED, &num_buffers);
        //bus._num_active -= num_buffers;
            
        // Pump all of the buffers
        //while (bus._num_active < 3) {
        //
        //    // Deque one buffer
        //    //ALuint buffer;
        //    //while (num_buffers > 0) {
        //    //    ::alSourceUnqueueBuffers(bus._al_source, 1, &buffer );
        //    //    --num_buffers;
        //    //    CheckAL();
        //    //}
        //    
        //    // Stream chunk in	
        //    SoundPacket packet = bus._source->getNextSoundPacket();
        //    if (packet.getNumBytes() == 0)
        //        break;

        //    // Choose appropriate format
        //    //ALenum format;
        //    //switch(packet.getFormat()) {
        //    //    case SoundResource::FORMAT_MONO8:		format = AL_FORMAT_MONO8;		break;
        //    //    case SoundResource::FORMAT_MONO16:		format = AL_FORMAT_MONO16;		break;
        //    //    case SoundResource::FORMAT_STEREO8:		format = AL_FORMAT_STEREO8;		break;
        //    //    case SoundResource::FORMAT_STEREO16:	format = AL_FORMAT_STEREO16;	break;
        //    //};
        //        
        //    // Store data into the buffer
        //    //CheckAL();
        //    //::alBufferData(bus._buffer[0], format, packet.getBuffer(), packet.getNumBytes(), packet.getFrequency());
        //    //CheckAL();
        //    
        //    // Enqueue the buffer
        //    //::alSourceQueueBuffers(bus._al_source, 1, &(bus._buffer[0]));
        //    
        //    // Rotate the ring buffer
        //    //ALuint temp = bus._buffer[0];
        //    //bus._buffer[0] = bus._buffer[1];
        //    //bus._buffer[1] = bus._buffer[2];
        //    //bus._buffer[2] = temp;

        //    ++bus._num_active;
        //}
        
        if (bus._num_active > 0) {
            // Check to make sure source is playing if there is new data
            //ALenum state;
            //::alGetSourcei(bus._al_source, AL_SOURCE_STATE, &state);
            //CheckAL();
            //    
            //// Check to see if sound buffer was starved
            //if (state != AL_PLAYING) {
            //    ::alSourcePlay(bus._al_source);
            //}
        }
    }