void drawEQ() { bg_drawRect(10, 100 - 32, 245, 100 - 32, soundEQMedianColor); bg_drawRect(10, 100 + 32, 245, 100 + 32, soundEQMedianColor); uint16 *bgBuffer = bg_backBuffer(); switch(getSourceFmt()) { case SRC_WAV: case SRC_FLAC: case SRC_MP3: { s16 *lTmp = lBuffer; s16 *rTmp = rBuffer; if(getSoundChannels() == 1) rTmp = lTmp; for(int i=0;i<236;i++) { bgBuffer[10 + i + ((68 - (lTmp[sampleWidth * i] >> 11)) << 8)] = soundEQDataColor; bgBuffer[10 + i + ((132 - (rTmp[sampleWidth * i] >> 11)) << 8)] = soundEQDataColor; } break; } case SRC_MIKMOD: case SRC_AAC: { if(getSoundChannels() == 1) { s16 *tmp = lBuffer; for(int i=0;i<236;i++) { bgBuffer[10 + i + ((68 - (tmp[sampleWidth * i] >> 11)) << 8)] = soundEQDataColor; bgBuffer[10 + i + ((132 - (tmp[sampleWidth * i] >> 11)) << 8)] = soundEQDataColor; } } else { s16 *lTmp = lBuffer; s16 *rTmp = lBuffer + 1; for(int i=0;i<236;i++) { bgBuffer[10 + i + ((68 - (lTmp[sampleWidth * i << 1] >> 11)) << 8)] = soundEQDataColor; bgBuffer[10 + i + ((132 - (rTmp[sampleWidth * i << 1] >> 11)) << 8)] = soundEQDataColor; } } break; }
void SoundProcessor::process() { #ifdef _FMOD_SOUND for(std::list<FMOD::Channel*>::iterator i = soundChannel.begin(); i!=soundChannel.end();) { bool is_playing = false; (*i)->isPlaying(&is_playing); if(!is_playing) { i = soundChannel.erase(i); } else ++i; } for(std::list<std::pair<Sound*, float> >::iterator i = soundsToPlay.begin(); i != soundsToPlay.end(); ++i) if((soundChannel.size() < getSoundChannels())) { FMOD::Channel* mychannel = NULL; soundEngine->playSound(FMOD_CHANNEL_FREE, i->first->getData(), 0, &mychannel); mychannel->setPan(i->second); mychannel->setVolume((float)(getSoundVolume()/100.0)); soundChannel.push_back(mychannel); } #elif _SDL_MIXER_SOUND for(std::list<std::pair<boost::shared_ptr<const Sound>, float> >::iterator i = soundsToPlay.begin(); i != soundsToPlay.end(); ++i) if((soundChannel.size() < soundConfiguration->getSoundChannels())) { int mychannel = -1; mychannel = Mix_PlayChannel(-1, i->first->getData(), 0); if(mychannel == -1) { std::ostringstream os; os << "ERROR (SoundProcessor::process()): " << Mix_GetError(); throw SDLException(os.str()); } else soundChannel.push_back(mychannel); int rightVolume = static_cast<int>(254.0 * i->second); Mix_SetPanning(mychannel, static_cast<Uint8>(254 - rightVolume), static_cast<Uint8>(rightVolume)); // Mix_SetDistance TODO // int Mix_SetPosition(int channel, Sint16 angle, Uint8 distance) TODO } #endif soundsToPlay.clear(); // ------ END SOUND ENGINE ------- }