示例#1
0
SoundPtr ALSubsystem::play2D(String name, bool startPaused)
{
  SoundPtr out;

  if(mAudioBuffers.find(name) == mAudioBuffers.end())
  {
    loadSound(name);

    if(mAudioBuffers.find(name) == mAudioBuffers.end())
    {
      std::cout<<"Could not play sound, could not find or load audio.\n";
      return out;
    }
  }

  if(!hasSources())
  {
    std::cout<<"Could not play sound, no available sound sources.\n";
  }
  else
  {
    out.bind(new BufferedSound(getSource(), mAudioBuffers[name], mAudioData[name]));
    mActiveSounds.push_back(out);
    if(!startPaused)
      out->play();
  }

  return out;
}
示例#2
0
SoundPtr ALSubsystem::stream2D(String filename, bool startPaused)
{
  SoundPtr out;

  String ext = filename.substr(filename.find_last_of(".") + 1);

  if(mAudioLoaders.find(ext) != mAudioLoaders.end())
  {	
    try
    {
      AudioStream* stream = mAudioLoaders[ext]->streamSound(filename);
      out.bind(new StreamedSound(stream, getSource()));
      mActiveSounds.push_back(out);
      if(!startPaused)
        out->play();
    }
    catch(Exception e)
    {
      std::cout<<"Could not stream sound.\n";
    }
  }
  else
  {
    std::cout<<"Could not stream sound, no loader found.\n";
  }	

  return out;
}
示例#3
0
SoundPtr ALSubsystem::play2D(String name, bool startPaused)
{
    SoundPtr out;

    if(mAudioBuffers.find(name) == mAudioBuffers.end())
    {
        loadSound(name);

        if(mAudioBuffers.find(name) == mAudioBuffers.end())
        {
            Logger::getPtr()->logMessage("Could not play sound, could not find or load audio.");
            return out;
        }
    }

    if(!hasSources())
    {
        Logger::getPtr()->logMessage("Could not play sound, no available sound sources.");
    }
    else
    {
        out.bind(new BufferedSound(getSource(), mAudioBuffers[name]));
        mActiveSounds.push_back(out);
        out->setGain(0.f, 1.f, 1.f);
        if(!startPaused)
            out->play();
    }

    return out;
}