Example #1
0
void TimeBase::checkCallBacks() {
	// Nothing to do if we're paused or not running
	if (_paused || !isRunning())
		return;

	Common::Rational startTime = Common::Rational(_startTime, _startScale);
	Common::Rational stopTime = Common::Rational(_stopTime, _stopScale);

	// First step: update the times
	updateTime();

	// Clip time to the boundaries
	if (_time >= stopTime)
		_time = stopTime;
	else if (_time <= startTime)
		_time = startTime;

	Common::Rational time = Common::Rational(getTime(), getScale());

	// Check if we've triggered any callbacks
	for (TimeBaseCallBack *runner = _callBackList; runner != 0; runner = runner->_nextCallBack) {
		if (runner->_hasBeenTriggered)
			continue;

		if (runner->_type == kCallBackAtTime && runner->_trigger == kTriggerTimeFwd) {
			if (getTime() >= (runner->_param2 * _preferredScale / runner->_param3) && getRate() > 0) {
				uint param2 = runner->_param2, param3 = runner->_param3;
				runner->callBack();
				// HACK: Only stop future time forward callbacks if the parameters have not been changed
				// This fixes striding callbacks. Since only striding callbacks do this kind of
				// craziness, I'm not too worried about this.
				runner->_hasBeenTriggered = (runner->_param2 == param2 && runner->_param3 == param3);
			}
		} else if (runner->_type == kCallBackAtExtremes) {
			if (runner->_trigger == kTriggerAtStop) {
				if (time == stopTime) {
					runner->callBack();
					runner->_hasBeenTriggered = true;
				}
			} else if (runner->_trigger == kTriggerAtStart) {
				if (time == startTime) {
					runner->callBack();
					runner->_hasBeenTriggered = true;
				}
			}
		}
	}

	if (getFlags() & kLoopTimeBase) {
		// Loop if necessary
		if (getRate() < 0 && time == startTime)
			setTime(_stopTime, _stopScale);
		else if (getRate() > 0 && time == stopTime)
			setTime(_startTime, _startScale);
	} else {
		// Stop at the end
		if ((getRate() > 0 && time == stopTime) || (getRate() < 0 && time == startTime))
			stop();
	}
}
Example #2
0
VorbisStream::VorbisStream(Common::SeekableReadStream *inStream, DisposeAfterUse::Flag dispose) :
	_inStream(inStream),
	_disposeAfterUse(dispose),
	_length(0, 1000),
	_bufferEnd(_buffer + ARRAYSIZE(_buffer)) {

	int res = ov_open_callbacks(inStream, &_ovFile, NULL, 0, g_stream_wrap);
	if (res < 0) {
		warning("Could not create Vorbis stream (%d)", res);
		_pos = _bufferEnd;
		return;
	}

	// Read in initial data
	if (!refill())
		return;

	// Setup some header information
	_isStereo = ov_info(&_ovFile, -1)->channels >= 2;
	_rate = ov_info(&_ovFile, -1)->rate;

#ifdef USE_TREMOR
	_length = Timestamp(ov_time_total(&_ovFile, -1), getRate());
#else
	_length = Timestamp(uint32(ov_time_total(&_ovFile, -1) * 1000.0), getRate());
#endif
}
Example #3
0
vector<Oligo *> ACO::getSequence() {
	initPheromoneValues();
	while (!satisfiedConditions()) {
		vector<vector<Oligo*>> iterationSolutions;
		int c = 0;
		for (Ant *ant : ants)
			iterationSolutions.push_back(ant->conctructSolution());
		getBestIterationResult(ants);
		if (bestRestartResult.empty() || getRate(bestIterationResult) > getRate(bestRestartResult)) {
			bestRestartResult = bestIterationResult;
		}
		if (bestSoFarResult.empty() || getRate(bestIterationResult) > getRate(bestSoFarResult)) {
			bestSoFarResult = bestIterationResult;
		}
		pheromonesUpdate();
		converganceFactor = computeConverganceFactor();
		if (converganceFactor > 0.9999) {
			if (bsUpdate) {
				resetPheromoneValues();
				bestRestartResult.clear();
				bsUpdate = false;
			}
			else {
				bsUpdate = true;
			}
		}
	}
	return bestSoFarResult;
}
Example #4
0
SubSeekableAudioStream::SubSeekableAudioStream(SeekableAudioStream *parent, const Common::Timestamp start, const Common::Timestamp end, DisposeAfterUse::Flag disposeAfterUse)
    : _parent(parent, disposeAfterUse),
      _start(convertTimeToStreamPos(start, getRate(), getChannels())),
      _pos(0, getRate() * getChannels()),
      _length(convertTimeToStreamPos(end, getRate(), getChannels()) - _start) {

	assert(_length.totalNumberOfFrames() % getChannels() == 0);
	_parent->seek(_start);
}
Example #5
0
SubSeekableAudioStream::SubSeekableAudioStream(SeekableAudioStream *parent, const Timestamp start, const Timestamp end, DisposeAfterUse::Flag disposeAfterUse)
    : _parent(parent), _disposeAfterUse(disposeAfterUse),
      _start(convertTimeToStreamPos(start, getRate(), isStereo())),
       _pos(0, getRate() * (isStereo() ? 2 : 1)),
      _length(convertTimeToStreamPos(end - start, getRate(), isStereo())) {

	assert(_length.totalNumberOfFrames() % (isStereo() ? 2 : 1) == 0);
	_parent->seek(_start);
}
Example #6
0
SubLoopingAudioStream::SubLoopingAudioStream(SeekableAudioStream *stream,
                                             uint loops,
                                             const Timestamp loopStart,
                                             const Timestamp loopEnd,
                                             DisposeAfterUse::Flag disposeAfterUse)
    : _parent(stream), _disposeAfterUse(disposeAfterUse), _loops(loops),
      _pos(0, getRate() * (isStereo() ? 2 : 1)),
      _loopStart(convertTimeToStreamPos(loopStart, getRate(), isStereo())),
      _loopEnd(convertTimeToStreamPos(loopEnd, getRate(), isStereo())),
      _done(false) {
	assert(loopStart < loopEnd);

	if (!_parent->rewind())
		_done = true;
}
Example #7
0
	EMISubLoopingAudioStream(Audio::SeekableAudioStream *stream, uint loops,
		const Audio::Timestamp start,
		const Audio::Timestamp loopStart,
		const Audio::Timestamp loopEnd,
		DisposeAfterUse::Flag disposeAfterUse = DisposeAfterUse::YES)
		: _parent(stream, disposeAfterUse),
		_pos(convertTimeToStreamPos(start, getRate(), isStereo())),
		_loopStart(convertTimeToStreamPos(loopStart, getRate(), isStereo())),
		_loopEnd(convertTimeToStreamPos(loopEnd, getRate(), isStereo())),
		_done(false), _hasLooped(false) {
		assert(loopStart < loopEnd);

		if (!_parent->seek(_pos))
			_done = true;
	}
void
VideoDeviceImpl::setDeviceParams(const DeviceParams& params)
{
    size_ = getSize({params.width, params.height});
    rate_ = getRate(params.framerate);
    emitSignal<DRing::VideoSignal::SetParameters>(name, fmt_->code, size_.first, size_.second, rate_.real());
}
//-----------------------------------------------------------------------------
// Our main thread function
//-----------------------------------------------------------------------------
unsigned long PeriodicTask::mainThreadFunc()
{
   if (getParent()->isMessageEnabled(MSG_INFO) ) {
      std::cout << "Thread(" << this << ")::mainLoopFunc(): Parent = " << getParent() << std::endl;
      std::cout << "Thread(" << this << ")::mainLoopFunc(): Starting main loop ..." << std::endl;
   }

   // Delta time
   const double dt = 1.0/static_cast<double>(getRate());
   int sec0 = static_cast<int>(dt);
   int nsec0 = static_cast<int>((dt - static_cast<double>(sec0)) * 1000000000.0);

   // Reference time
   struct timespec tp;
   clock_gettime(CLOCK_REALTIME, &tp);

   // Mutex
   pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
   pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
   pthread_mutex_lock(&mutex);

   // ---
   // Inital wait for one frame --
   // --- Linux seems to need this otherwise the userFunc() call failes.
   // ---
   tp.tv_nsec += (nsec0);
   if (tp.tv_nsec >= 1000000000) {
      tp.tv_sec++;
      tp.tv_nsec -= 1000000000;
   }
   pthread_cond_timedwait(&cond, &mutex, &tp);

   while (!getParent()->isShutdown()) {

      // ---
      // User defined tasks
      // ---
      this->userFunc(dt);
      tcnt++;

      // ---
      // Wait for the end of frame
      // ---
      tp.tv_nsec += (nsec0);
      if (tp.tv_nsec >= 1000000000) {
         tp.tv_sec++;
         tp.tv_nsec -= 1000000000;
      }
      pthread_cond_timedwait(&cond, &mutex, &tp);

   }

   pthread_mutex_unlock(&mutex);

   if (getParent()->isMessageEnabled(MSG_INFO) ) {
      std::cout << "Thread(" << this << ")::mainLoopFunc(): ... end of main loop." << std::endl;
   }

   return 0;
}
Example #10
0
void VtxSceneTabs::updateControls(){
	if(changing)
		return;
	Scene *obj=object();
	getTime();
	getRate();
	TexMipSlider->setValue(obj->tex_mip);
	ColorMipSlider->setValue(obj->color_mip);
	BumpMipSlider->setValue(obj->bump_mip);
	FreqMipSlider->setValue(obj->freq_mip);
	FOVSlider->setValue(obj->fov);
	LODSlider->setValue(obj->cellsize);
	updateSlider(ColorAmpSlider,Raster.filter_color_ampl);
	updateSlider(NormalAmpSlider,Raster.filter_normal_ampl);
	updateSlider(HDRMinSlider,Raster.hdr_min);
	updateSlider(HDRMaxSlider,Raster.hdr_max);
	m_aa_check->SetValue(Render.dealias());
	m_show_check->SetValue(Raster.filter_show());
	m_ave_check->SetValue(Render.avenorms());
	m_hdr->SetValue(Raster.hdr());
	m_shadows->SetValue(Raster.shadows());
	m_geometry->SetValue(Render.geometry());

	m_occlusion->SetValue(Adapt.overlap_test());
	m_clip->SetValue(Adapt.clip_test());
	m_backface->SetValue(Adapt.back_test());
	m_curvature->SetValue(Adapt.curve_test());

	updateSlider(ShadowBlurSlider,Raster.shadow_blur);
	updateSlider(ShadowResSlider,Raster.shadow_vsteps);
	updateSlider(ShadowFovSlider,Raster.shadow_fov);
	updateSlider(ShadowDovSlider,Raster.shadow_dov);
}
    void getProbeReal()
	{
		//首先读取probe_t.txt 文件,对于每一个rate,找出对应的实际打分
		ifstream in("probe_t.txt");
		ofstream out("probe_real.txt");
		ofstream logNP("n_p.txt");
		char rateStr[256];
		int pos1,pos2;
		string strTemp;
		int rateValue,itemId,userId;
		//load userIdMap
		while(in.getline(rateStr,256)){
	    	strTemp = rateStr;
		    pos1 = strTemp.find(",");
	    	itemId = atoi(strTemp.substr(0,pos1).c_str());
	    	userId = atoi(strTemp.substr(pos1+1).c_str());
	    	//cout<<itemId<<'\t'<<userId<<'\t'<<endl;	    	exit(0);
	    	rateValue = getRate(rateMatrix[userId],itemId);
	    	if(rateValue == 0) {
	    		logNP<<itemId<<','<<userId<<','<<rateValue<<endl;
	    	}
	    	out<<itemId<<','<<userId<<','<<rateValue<<endl;
	    }
		in.close(); //load userId map完毕
		out.close();
		logNP.close();
	}
Example #12
0
void AttackTower::shoot(float dt)
{
    GameManager *instance = GameManager::getInstance();
    auto bulletVector = instance->bulletVector;
    
    checkNearestEnemy();
    if(nearestEnemy!=NULL && nearestEnemy->getCurrHp() > 0 )
    {
        auto currBullet = AttackTowerBullet();
        instance->bulletVector.pushBack(currBullet);
        
        auto moveDuration = getRate();
        Point shootVector = nearestEnemy->sprite->getPosition() - this->getPosition();
		Point normalizedShootVector = -shootVector.normalize();
        
        auto farthestDistance = Director::getInstance()->getWinSize().width;
		Point overshotVector = normalizedShootVector * farthestDistance;
		Point offscreenPoint = (currBullet->getPosition() - overshotVector);
        
		currBullet->runAction(Sequence::create(MoveTo::create(moveDuration, offscreenPoint),
                                               CallFuncN::create(CC_CALLBACK_1(AttackTower::removeBullet, this)),
                                               NULL));
        currBullet = NULL;
    }
}
int EmergenceInstallation::getRateMidiControlValue(float multiplier) {
    float ret = getRate() * multiplier;
    ret = ofClamp(ret, getMinRate(), getMaxRate());
    ret = ofMap(ret, getMinRate(), getMaxRate(), 0, 127);
    //printf("\nir=%f, m=%f, minr=%f, maxr=%f, retf=%f, reti=%i\n", getRate(), multiplier, getMinRate(), getMaxRate(), ret, (int) ret);
    return (int) ret;
}
Example #14
0
Mp3PspStream::Mp3PspStream(Common::SeekableReadStream *inStream, DisposeAfterUse::Flag dispose) :
	_inStream(inStream),
	_disposeAfterUse(dispose),
	_pcmLength(0),
	_posInFrame(0),
	_state(MP3_STATE_INIT),
	_length(0, 1000),
	_sampleRate(0),
	_totalTime(mad_timer_zero) {

	DEBUG_ENTER_FUNC();

	assert(_decoderInit);	// must be initialized by now

	// let's leave the buffer guard -- who knows, it may be good?
	memset(_buf, 0, sizeof(_buf));
	memset(_codecInBuffer, 0, sizeof(_codecInBuffer));

	initStream();	// init needed stuff for the stream

	findValidHeader();	// get a first header so we can read basic stuff

	_sampleRate = _header.samplerate;	// copy it before it gets destroyed
	_stereo = (MAD_NCHANNELS(&_header) == 2);

	while (_state != MP3_STATE_EOS)
		findValidHeader();	// get a first header so we can read basic stuff

	_length = Timestamp(mad_timer_count(_totalTime, MAD_UNITS_MILLISECONDS), getRate());

	deinitStream();

	_state = MP3_STATE_INIT;
}
void ArtilleryTower::shoot(float dt)
{
	auto instance = GameManager::getInstance();
	auto bulletVector = instance->bulletVector;

	if (nearestEnemy != nullptr && nearestEnemy->getCurrHp() > 0 && nearestEnemy->getIsVisible() && !isSilenced) //敌人可见才能攻击
	{
		auto currBullet = ArtilleryTowerBullet();
		currBullet->setTag(attack);//将tag作为攻击力,碰撞检测时直接获取tag即可知道子弹的攻击力了
		(instance->bulletVector).pushBack(currBullet);

		auto moveDuration = getRate();
		Vec2 shootVector = nearestEnemy->getPosition() - this->getPosition();
		Vec2 normalizedShootVector = -shootVector.getNormalized();   //单位化向量,使其长度为1
		auto farthestDistance = Director::getInstance()->getWinSize().width;   //子弹射程最远为屏幕的宽
		Point overshotVector = normalizedShootVector * farthestDistance;
		Point offscreenPoint = (rotateArtillery->getPosition() - overshotVector);  //算出子弹在屏幕上消失的点

		currBullet->runAction(Sequence::create(MoveTo::create(moveDuration, offscreenPoint),  //不是恒定的速率飞过去我擦
			CallFuncN::create(CC_CALLBACK_1(ArtilleryTower::removeBullet, this)),
			NULL));
		currBullet = NULL;

	}
}
Example #16
0
bool FLACStream::seek(const Timestamp &where) {
	_sampleCache.bufFill = 0;
	_sampleCache.bufReadPos = NULL;
	// FLAC uses the sample pair number, thus we always use "false" for the isStereo parameter
	// of the convertTimeToStreamPos helper.
	return seekAbsolute((FLAC__uint64)convertTimeToStreamPos(where, getRate(), false).totalNumberOfFrames());
}
int Recollection::getRateMidiControlValue(float multiplier) {
    float ret = ((getRate() - MIN_HEART_RATE) * multiplier) + MIN_HEART_RATE;
    ret = ofClamp(ret, MIN_HEART_RATE, MAX_HEART_RATE);
    ret = ofMap(ret, MIN_HEART_RATE, MAX_HEART_RATE, 1, 127);
    //printf("\nvr=%f, m=%f, minr=%f, maxr=%f, retf=%f, reti=%i\n", getRate(), multiplier, getMinRate(), getMaxRate(), ret, (int) ret);
        //cout << "\n" << ret;
    return (int) ret;
}
int EmergenceViewer::getRateMidiControlValue(float multiplier) {
    float ret = ((getRate() - getMinRate()) * multiplier) + getMinRate();
    //float ret = getRate() * multiplier;
    ret = ofClamp(ret, getMinRate(), getMaxRate());
    ret = ofMap(ret, getMinRate(), getMaxRate(), 1, 127);
    //printf("\nvr=%f, m=%f, minr=%f, maxr=%f, retf=%f, reti=%i\n", getRate(), multiplier, getMinRate(), getMaxRate(), ret, (int) ret);
    return (int) ret;
}
Example #19
0
String Card::getAll() {
	String all = getQuantity()+","+getText()+","+getThumb()+","+getFront()+
			","+getBack()+","+getId()+","+getRate()+","+getValue()+","+getNote()+","+getOrientation()+",";
	for (int i = 0; i < stats.size(); i++) {
		all += stats[i]->getAll() + "$";
	}
	return all;
}
Example #20
0
void TimeBase::pause() {
	if (isRunning() && !_paused) {
		_pausedRate = getRate();
		_rate = 0;
		_paused = true;
		_pauseStart = g_system->getMillis();
	}
}
Example #21
0
RobotAudioStream::StreamState RobotAudioStream::getStatus() const {
	Common::StackLock lock(_mutex);
	StreamState status;
	status.bytesPlaying = _readHeadAbs;
	status.rate = getRate();
	status.bits = 8 * sizeof(int16);
	return status;
}
Example #22
0
void QueuingAudioStreamImpl::queueAudioStream(AudioStream *stream, DisposeAfterUse::Flag disposeAfterUse) {
	assert(!_finished);
	if ((stream->getRate() != getRate()) || (stream->isStereo() != isStereo()))
		error("QueuingAudioStreamImpl::queueAudioStream: stream has mismatched parameters");

	Common::StackLock lock(_mutex);
	_queue.push(StreamHolder(stream, disposeAfterUse));
}
Example #23
0
BOOLEAN CFG80211DRV_StaGet(
	VOID						*pAdOrg,
	VOID						*pData)
{
	PRTMP_ADAPTER pAd = (PRTMP_ADAPTER)pAdOrg;
	CMD_RTPRIV_IOCTL_80211_STA *pIbssInfo;


	pIbssInfo = (CMD_RTPRIV_IOCTL_80211_STA *)pData;


#ifdef CONFIG_STA_SUPPORT
{
	HTTRANSMIT_SETTING PhyInfo;
	ULONG DataRate = 0;
	UINT32 RSSI;


	/* fill tx rate */
    if ((pAd->CommonCfg.PhyMode <= PHY_11G) ||
		(pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE <= MODE_OFDM))
	{
		PhyInfo.word = pAd->StaCfg.HTPhyMode.word;
	}
    else
		PhyInfo.word = pAd->MacTab.Content[BSSID_WCID].HTPhyMode.word;
	/* End of if */

	getRate(PhyInfo, &DataRate);

	if ((PhyInfo.field.MODE == MODE_HTMIX) ||
		(PhyInfo.field.MODE == MODE_HTGREENFIELD))
	{
		if (PhyInfo.field.BW)
			pIbssInfo->TxRateFlags |= RT_CMD_80211_TXRATE_BW_40;
		/* End of if */
		if (PhyInfo.field.ShortGI)
			pIbssInfo->TxRateFlags |= RT_CMD_80211_TXRATE_SHORT_GI;
		/* End of if */

		pIbssInfo->TxRateMCS = PhyInfo.field.MCS;
	}
	else
	{
		pIbssInfo->TxRateFlags = RT_CMD_80211_TXRATE_LEGACY;
		pIbssInfo->TxRateMCS = DataRate*10; /* unit: 100kbps */
	} /* End of if */

	/* fill signal */
	RSSI = (pAd->StaCfg.RssiSample.AvgRssi0 +
			pAd->StaCfg.RssiSample.AvgRssi1 +
			pAd->StaCfg.RssiSample.AvgRssi2) / 3;
	pIbssInfo->Signal = RSSI;
}
#endif /* CONFIG_STA_SUPPORT */

	return TRUE;
}
Example #24
0
INT Show_Repeater_Cli_Proc(RTMP_ADAPTER *pAd, RTMP_STRING *arg)
{
	INT i;
    UINT32 RegValue;
	ULONG DataRate=0;

	if (!pAd->ApCfg.bMACRepeaterEn)
		return TRUE;

	printk("\n");

#ifdef DOT11_N_SUPPORT
	printk("HT Operating Mode : %d\n", pAd->CommonCfg.AddHTInfo.AddHtInfo2.OperaionMode);
	printk("\n");
#endif /* DOT11_N_SUPPORT */
	
	printk("\n%-19s%-4s%-4s%-4s%-4s%-8s%-7s%-7s%-7s%-10s%-6s%-6s%-6s%-6s%-7s%-7s\n",
		   "MAC", "AID", "BSS", "PSM", "WMM", "MIMOPS", "RSSI0", "RSSI1", 
		   "RSSI2", "PhMd", "BW", "MCS", "SGI", "STBC", "Idle", "Rate");

	for (i = 0; i < MAX_LEN_OF_MAC_TABLE; i++)
	{
		PMAC_TABLE_ENTRY pEntry = &pAd->MacTab.Content[i];
		if (pEntry && IS_ENTRY_APCLI(pEntry)&& (pEntry->Sst == SST_ASSOC) && (pEntry->bReptCli))
		{
			DataRate=0;
			getRate(pEntry->HTPhyMode, &DataRate);

			printk("%02X:%02X:%02X:%02X:%02X:%02X  ",
					pEntry->ReptCliAddr[0], pEntry->ReptCliAddr[1], pEntry->ReptCliAddr[2],
					pEntry->ReptCliAddr[3], pEntry->ReptCliAddr[4], pEntry->ReptCliAddr[5]);

			printk("%-4d", (int)pEntry->Aid);
			printk("%-4d-%d", (int)pEntry->apidx, pEntry->func_tb_idx);
			printk("%-4d", (int)pEntry->PsMode);
			printk("%-4d", (int)CLIENT_STATUS_TEST_FLAG(pEntry, fCLIENT_STATUS_WMM_CAPABLE));
#ifdef DOT11_N_SUPPORT
			printk("%-8d", (int)pEntry->MmpsMode);
#endif /* DOT11_N_SUPPORT */
			printk("%-7d", pEntry->RssiSample.AvgRssi[0]);
			printk("%-7d", pEntry->RssiSample.AvgRssi[1]);
			printk("%-7d", pEntry->RssiSample.AvgRssi[2]);
			printk("%-10s", get_phymode_str(pEntry->HTPhyMode.field.MODE));
			printk("%-6s", get_bw_str(pEntry->HTPhyMode.field.BW));
			printk("%-6d", pEntry->HTPhyMode.field.MCS);
			printk("%-6d", pEntry->HTPhyMode.field.ShortGI);
			printk("%-6d", pEntry->HTPhyMode.field.STBC);
			printk("%-7d", (int)(pEntry->StaIdleTimeout - pEntry->NoDataIdleCount));
			printk("%-7d", (int)DataRate);
			printk("%-10d, %d, %d%%\n", pEntry->DebugFIFOCount, pEntry->DebugTxCount, 
						(pEntry->DebugTxCount) ? ((pEntry->DebugTxCount-pEntry->DebugFIFOCount)*100/pEntry->DebugTxCount) : 0);
			printk("\n");
		}
	} 

	return TRUE;
}
Example #25
0
int MidiDriver_MT32::open() {
	MT32Emu::SynthProperties prop;

	if (_isOpen)
		return MERR_ALREADY_OPEN;

	MidiDriver_Emulated::open();

	memset(&prop, 0, sizeof(prop));
	prop.sampleRate = getRate();
	prop.useReverb = true;
	prop.useDefaultReverb = false;
	prop.reverbType = 0;
	prop.reverbTime = 5;
	prop.reverbLevel = 3;
	prop.userData = this;
	prop.printDebug = MT32_PrintDebug;
	prop.report = MT32_Report;
	prop.openFile = MT32_OpenFile;

	_synth = new MT32Emu::Synth();

	Graphics::PixelFormat screenFormat = g_system->getScreenFormat();

	if (screenFormat.bytesPerPixel == 1) {
		const byte dummy_palette[] = {
			0, 0, 0,		// background
			0, 171, 0,	// border, font
			171, 0, 0	// fill
		};

		g_system->getPaletteManager()->setPalette(dummy_palette, 0, 3);
	}

	_initializing = true;
	drawMessage(-1, _s("Initializing MT-32 Emulator"));
	if (!_synth->open(prop))
		return MERR_DEVICE_NOT_AVAILABLE;

	double gain = (double)ConfMan.getInt("midi_gain") / 100.0;
	_synth->setOutputGain(1.0f * gain);
	_synth->setReverbOutputGain(0.68f * gain);

	_initializing = false;

	if (screenFormat.bytesPerPixel > 1)
		g_system->fillScreen(screenFormat.RGBToColor(0, 0, 0));
	else
		g_system->fillScreen(0);

	g_system->updateScreen();

	_mixer->playStream(Audio::Mixer::kSFXSoundType, &_mixerSoundHandle, this, -1, Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::NO, true);

	return 0;
}
Example #26
0
void QueuingAudioStreamImpl::queueAudioStream(AudioStream *stream, bool disposeAfterUse) {
	if (_finished)
		throw Common::Exception("QueuingAudioStreamImpl::queueAudioStream(): Trying to queue another audio stream, but the QueuingAudioStream is finished.");

	if ((stream->getRate() != getRate()) || (stream->getChannels() != getChannels()))
		throw Common::Exception("QueuingAudioStreamImpl::queueAudioStream(): stream has mismatched parameters");

	Common::StackLock lock(_mutex);
	_queue.push(StreamHolder(stream, disposeAfterUse));
}
Example #27
0
//starts timer if stopped, adjusts interval if necessary
void IRCQueue::adjustTimer()
{
    int msec;
    msec=getRate().nextInterval(nextSize(), elapsed());
    //if (m_myIndex == 0)
    //    KX << _S(msec) << endl;
    m_timer->start(msec);
    m_startedAt.start();
    return;
}
Example #28
0
float
VideoAndroidSize::getRate(std::string rate) const
{
    unsigned r;
    std::stringstream ss;
    ss << rate;
    ss >> r;

    return getRate(r);
}
Example #29
0
bool VorbisStream::seek(const Timestamp &where) {
	// Vorbisfile uses the sample pair number, thus we always use "false" for the isStereo parameter
	// of the convertTimeToStreamPos helper.
	int res = ov_pcm_seek(&_ovFile, convertTimeToStreamPos(where, getRate(), false).totalNumberOfFrames());
	if (res) {
		warning("Error seeking in Vorbis stream (%d)", res);
		_pos = _bufferEnd;
		return false;
	}

	return refill();
}
void SparDiskPanel::updateIntro()
{
	auto typeId = _selectSparBox->getSpar();
	_introSpar = typeId;
	if(typeId <= 0)
	{
		setSelectSparBox(nullptr);
		return;
	}
	
	auto spar = _sparDisk->getSpar(typeId);
	if(spar == nullptr) return;
	auto owner = dynamic_cast<Player*>(_sparDisk->getOwner());
	if(owner == nullptr) return;
	auto sparPatchNum = owner->getItemBag()->getPropSizeByType(2002005);
	_patchNumLab->setString(a2u("ËéƬ:")+cocos2d::Value(sparPatchNum).asString()+a2u("  Éý¼¶ÏûºÄ:")+cocos2d::Value(spar->getCostPatchNum()).asString());

	std::string nickName;
	std::string introduce;
	nickName = spar->getNickName();
	introduce = spar->getModelByName("introduce").asString();

	stringReplace(introduce, "%rate", cocos2d::Value(int(spar->getRate() * 100)).asString()+"%");
	stringReplace(introduce, "%drate", cocos2d::Value(int(spar->getDrate() * 100)).asString()+"%");

	_nickNameLab->setString(nickName);
	_introLab->setString(introduce);

	if(spar->getRate() >= spar->getMaxRate() || spar->getDrate() >= spar->getMaxDrate())
	{
		_completeLab->setVisible(true);
		_refineBtn->setVisible(false);
	}
	else
	{
		_completeLab->setVisible(false);
		_refineBtn->setVisible(true);
	}
}