示例#1
0
void Flywheel::run(){
   switch(getCurrentState()){
      case OFF:
         setRate(0.0);
         break;
      case NOTREADY:
      case READY:
         setRate(calculateSpeed());
         break;
   }
}
示例#2
0
void Card::setAll(const char* allch) {
		String all = allch;
		int indexof = all.find(delim);
		if (indexof > -1) {
			setQuantity(all.substr(0,indexof++).c_str());
			all=all.substr(indexof);
			indexof = all.find(delim);
			setText(all.substr(0,indexof++).c_str());
			all=all.substr(indexof);
			indexof = all.find(delim);
			setThumb(all.substr(0,indexof++).c_str());
			all=all.substr(indexof);
			indexof = all.find(delim);
			setFront(all.substr(0,indexof++).c_str());
			all=all.substr(indexof);
			indexof = all.find(delim);
			setBack(all.substr(0,indexof++).c_str());
			all=all.substr(indexof);
			indexof = all.find(delim);
			setId(all.substr(0,indexof++).c_str());
			all=all.substr(indexof);
			indexof = all.find(delim);
			setRate(all.substr(0,indexof++).c_str());
			all=all.substr(indexof);
			indexof = all.find(delim);
			setValue(all.substr(0,indexof++).c_str());
			all=all.substr(indexof);
			indexof = all.find(delim);
			setNote(all.substr(0,indexof++).c_str());
			all=all.substr(indexof);

			setLoaded(true);
			if ((getText().length() <= 0)||(getQuantity().length() <= 0)) {
				setQuantity("");
				setText("");
				setLoaded(false);
			}
		} else {
			setQuantity("");
			setText("");
			setThumb("");
			setFront("");
			setBack("");
			setId("");
			setRate("");
			setValue("");
			setNote("");
			setLoaded(false);
		}
}
RawMultiAxisThread::RawMultiAxisThread(RawMultiAxisScaffold* scaffold, RawMultiAxisScaffold::DeviceData* deviceData) :
	BasicThread("RawMultiAxis thread"),
	m_scaffold(scaffold),
	m_deviceData(deviceData)
{
	setRate(100.0);
}
示例#4
0
文件: speech.c 项目: junwuwei/brltty
static int
openStream (void) {
  const char *command = festivalParameters[PARM_COMMAND];
  if (!command || !*command) command = "festival";

  logMessage(LOG_DEBUG, "starting festival: command=%s", command);
  if ((festivalStream = popen(command, "w"))) {
    setvbuf(festivalStream, NULL, _IOLBF, 0X1000);

    if (!writeCommand("(gc-status nil)", 0)) return 0;
    if (!writeCommand("(audio_mode 'async)", 0)) return 0;
    if (!writeCommand("(Parameter.set 'Audio_Method 'netaudio)", 0)) return 0;

    {
      const char *name = festivalParameters[PARM_NAME];
      if (name && *name) {
        if (strcasecmp(name, "Kevin") == 0) {
          if (!writeCommand("(voice_ked_diphone)", 0)) return 0;
        } else if (strcasecmp(name, "Kal") == 0) {
          if (!writeCommand("(voice_kal_diphone)", 0)) return 0;
        } else {
          logMessage(LOG_WARNING, "unknown Festival voice name: %s", name);
        }
      }
    }

    if (festivalRate != 0.0)
      if (!setRate(festivalRate, 0))
        return 0;

    return 1;
  }

  return 0;
}
示例#5
0
bool PIDFlowController::setParams(const PIDFCParams & pin)
{
  mut.lock();
  if (running() && (params.dev_ai != pin.dev_ai || params.dev_ao != pin.dev_ao
                    || params.subdev_ai != pin.subdev_ai
                    || params.subdev_ao != pin.subdev_ao)) {
    mut.unlock();
    return false;
  }
  double flow_actual_backup, v_in_backup, v_out_backup; // don't overwrite our params for these 3 since our notion is more accurate 
  Cpy(flow_actual_backup, params.flow_actual);
  Cpy(v_in_backup, params.last_v_in);
  Cpy(v_out_backup, params.last_v_out);
  params = pin;
  Cpy(params.flow_actual, flow_actual_backup);
  Cpy(params.last_v_in, v_in_backup);
  if (!running()) {
    WriteVFunctor f(const_cast<PIDFlowController *>(this));
    Thread::doFuncInRT(f); // force user-set voltage if PID loop isn't running
  } else { // otherwise if PID loop is running don't tinker with voltage
    Cpy(params.last_v_out, v_out_backup);
  }
  setRate(params.rate_hz);
  setControlParams(params.controlParams);
  mut.unlock();
  return true;
}
示例#6
0
bool moveThread::threadInit()
{
  setRate(int(20.0));
  port.open("/moveHead/check:o");
    optGaze.put("device", "remote_controlboard");
    optGaze.put("local", "/mover/motor/client");
    optGaze.put("remote", "/icubSim/head");
    robotHead.open(optGaze);
    if (!robotHead.isValid()) 
    {
        printf("Cannot connect to robot head\n");
        return 1;
    }
    robotHead.view(pos1);
    robotHead.view(vel1);
    robotHead.view(enc1);
    if (pos1==NULL || vel1==NULL || enc1==NULL) 
    {
        printf("Cannot get interface to robot head\n");
        robotHead.close();
        return 1;
    }
    jnts = 0;
    pos1->getAxes(&jnts);
    setpoints.resize(jnts);
    Flag = false;
  home();
  i = 0;
  return true;
}
示例#7
0
    void DynamicLoudnessCH2012::configureModelParameters(const string& setName)
    {
        //common to all
        setRate(1000);
        setOuterEarType(OME::ANSIS342007_FREEFIELD);
        setSpectrumSampledUniformly(true);
        setHoppingGoertzelDFTUsed(false);
        setExcitationPatternInterpolated(false);
        setInterpolationCubic(true);
        setSpecificLoudnessOutput(true);
        setBinauralInhibitionUsed(true);
        setPresentationDiotic(true);
        setFirstSampleAtWindowCentre(true);
        setFilterSpacingInCams(0.1);
        setCompressionCriterionInCams(0.0);
        attackTimeSTL_ = 0.016;
        releaseTimeSTL_ = 0.032;
        attackTimeLTL_ = 0.1;
        releaseTimeLTL_ = 2.0;

        if (setName == "Faster")
        {
            setFilterSpacingInCams(0.5);
            setCompressionCriterionInCams(0.3);
            LOUDNESS_DEBUG(name_ << ": using a filter spacing of 0.5 Cams"
                   << " with 0.3 Cam spectral compression criterion.");
        }
        else if (setName != "CH2012")
        {
            configureModelParameters("CH2012");
            LOUDNESS_DEBUG(name_ << "Using Settings from Chen and Hu 2012 paper.");
        }
    }
示例#8
0
bool ArrowTower::init()
{
	if (!TowerBase::init())
	{
		return false;
	}

	setScope(120);
	setLethality(1);
	setTowerValue(120);
	setRate(3);
	setLevel(0);
	setTowerType(0);



	auto ll = getLevel();
	if( ll == 0 )
	{
		tower= Sprite::createWithSpriteFrameName("tower1.png");
	}
	else if ( ll == 1)
	{
		tower= Sprite::createWithSpriteFrameName("tower2.png");
	}
	else 
	{
		tower= Sprite::createWithSpriteFrameName("tower3.png");
	}
	this->addChild(tower);
	schedule(schedule_selector(ArrowTower::rotateAndShoot), 0.8f);
	return true;
}
示例#9
0
bool VisuoThread::threadInit()
{
    string name=rf.find("name").asString().c_str();

    Bottle bVision=rf.findGroup("vision");

    setRate(bVision.check("period",Value(20)).asInt());

    minMotionBufSize=bVision.check("minMotionBufSize",Value(10)).asInt();
    minTrackBufSize=bVision.check("minTrackBufSize",Value(1)).asInt();
    maxTrackBufSize=bVision.check("maxTrackBufSize",Value(2)).asInt();
    timeTol=bVision.check("timeTol",Value(0.5)).asDouble();
    motionStdThresh=bVision.check("motionStdThresh",Value(5.0)).asDouble();
    speedStdThresh=bVision.check("speedStdThresh",Value(700.0)).asDouble();
    stereoDistThresh=bVision.check("stereoDistThresh",Value(300.0)).asDouble();
    dominant_eye=bVision.check("dominant_eye",Value("left")).asString()=="left"?LEFT:RIGHT;

    rawWaitThresh=bVision.check("raw_detection_wait_thresh",Value(15.0)).asDouble();
    motionWaitThresh=bVision.check("motion_detection_wait_thresh",Value(5.0)).asDouble();
    objectWaitThresh=bVision.check("object_detection_wait_thresh",Value(5.0)).asDouble();

    // open ports
    outPort[LEFT].open(("/"+name+"/left/img:o").c_str());
    outPort[RIGHT].open(("/"+name+"/right/img:o").c_str());

    imgPort[LEFT].open(("/"+name+"/left/img:i").c_str());
    imgPort[RIGHT].open(("/"+name+"/right/img:i").c_str());

    mCUTPort[LEFT].open(("/"+name+"/left/blobs:i").c_str());
    mCUTPort[RIGHT].open(("/"+name+"/right/blobs:i").c_str());

    rawInPort[LEFT].open(("/"+name+"/left/raw:i").c_str());
    rawInPort[RIGHT].open(("/"+name+"/right/raw:i").c_str());

    boundMILPort.open(("/"+name+"/MIL/window:o").c_str());
    cmdMILPort.open(("/"+name+"/MIL/cmd:o").c_str());
    recMILPort.open(("/"+name+"/MIL/rec:i").c_str());

    cmdMSRPort.open(("/"+name+"/MSR/cmd:o").c_str());
    recMSRPort.open(("/"+name+"/MSR/rec:i").c_str());


    pftInPort.open(("/"+name+"/tracker:i").c_str());
    pftOutPort.open(("/"+name+"/tracker:o").c_str());

    segPort.open(("/"+name+"/seg:o").c_str());

    newImage[LEFT]=false;
    newImage[RIGHT]=false;

    show=false;

    interrupted=false;

    trackMode=MODE_TRACK_TEMPLATE;

    closed=false;
    return true;
}
示例#10
0
LFO::LFO(float samplerate, const float rate, waveform_t waveform)
  : samplerate(samplerate),
    phase(0),
    inc(0)
{
    setWaveform(waveform);  // default triangle
    setRate(rate);  // default 1 Hz
}
示例#11
0
 SerialPort::SerialPort()
 {
     _port_is_open = false;
     setPortName("");
     setRate(0);
     setFlags(0);
     _file_descriptor = -1;
 }
示例#12
0
 SerialPort::SerialPort(const std::string &name)
 {
     _port_is_open = false;
     setPortName(name);
     setRate(0);
     setFlags(0);
     _file_descriptor = -1;
 }
示例#13
0
 SerialPort::SerialPort(const std::string &name,int rate, long flags)
 {
     _port_is_open = false;
     setPortName(name);
     setRate(rate);
     setFlags(flags);
     _file_descriptor = -1;
 }
示例#14
0
LFO::LFO(float samplerate)
  : samplerate(samplerate),
    phase(0),
    inc(0)
{
  setWaveform(LFO::sinus);   
  setRate(1.0f); //1Hz
}
示例#15
0
void SoundTimeBase::playSoundSegment(uint32 startTime, uint32 endTime) {
	_startTime = startTime;
	_stopTime = endTime;
	_setToStart = true;
	_time = Common::Rational(startTime, getScale());
	setRate(1);
	Sound::playSoundSegment(startTime, endTime);
}
示例#16
0
/** 
 * Device initialization: check device capability and open for recording.
 * 
 * @param sfreq [in] required sampling frequency.
 * @param dummy [in] dummy data
 * 
 * @return TRUE on success, FALSE on failure.
 */
boolean
adin_mic_standby(int sfreq, void *dummy)
{
  buffer = (SP16 *) malloc( sizeof(SP16) * limit );

  // Tell handling script the requested rate
  EM_ASM_ARGS({
    setRate(+$0);
  }, sfreq);
示例#17
0
void SoundDialog::restore() {
	for (std::size_t i = 0, n = mw_.numAudioEngines(); i < n; ++i)
		mw_.audioEngineConf(i).rejectSettings();

	engineSelector_.reject();
	resamplerSelector_.reject();
	setRate(rateBox_, rate_);
	latencyBox_->setValue(latency_);
}
void InterpolatingDelayLine::setLength(const float withLength, float withFs)
{
    length = withLength * withFs;
    circularBuffer = new float[length];
    clearBuffer(); // clear the buffer before we start writing into it
    readHead = length*0.5;
    writeHead = 0;
    setRate(1.0);
}
示例#19
0
void ChainResampler::adjustRate(const long inRate, const long outRate) {
	unsigned long mul, div;
	
	exactRatio(mul, div);
	
	bigSinc->adjustDiv(static_cast<int>(static_cast<double>(inRate) * mul / (static_cast<double>(div / bigSinc->div()) * outRate) + 0.5));
	
	reallocateBuffer();
	setRate(inRate, outRate);
}
示例#20
0
/** Power on and prepare for general usage.
 * This device is ready to use automatically upon power-up. It defaults to
 * single-shot read mode, P0/N1 mux, 2.048v gain, 128 samples/sec, default
 * comparator with hysterysis, active-low polarity, non-latching comparator,
 * and comparater-disabled operation. 
 */
void ADS1115::initialize() {
  setMultiplexer(ADS1115_MUX_P0_N1);
  setGain(ADS1115_PGA_2P048);
  setMode(ADS1115_MODE_SINGLESHOT);
  setRate(ADS1115_RATE_128);
  setComparatorMode(ADS1115_COMP_MODE_HYSTERESIS);
  setComparatorPolarity(ADS1115_COMP_POL_ACTIVE_LOW);
  setComparatorLatchEnabled(ADS1115_COMP_LAT_NON_LATCHING);
  setComparatorQueueMode(ADS1115_COMP_QUE_DISABLE);
}
示例#21
0
bool ScalerFunc::setSlotRate(const base::Number* const msg)
{
   bool ok = false;
   if (msg != nullptr) {
      int v = msg->getInt();
      if (v > 0) {
         setRate( static_cast<unsigned int>(v) );
         ok = true;
      }
   }
   return ok;
}
示例#22
0
//------------------------------------------------------------------------------
// Set slot functions
//------------------------------------------------------------------------------
bool ScalerFunc::setSlotRate(const base::Frequency* const msg)
{
   bool ok = false;
   if (msg != nullptr) {
      int v = static_cast<int>( base::Hertz::convertStatic( *msg ) + 0.5f );
      if (v > 0) {
         setRate( static_cast<unsigned int>(v) );
         ok = true;
      }
   }
   return ok;
}
示例#23
0
文件: PID.cpp 项目: ruby6117/ccode
void PID::start(Callback *c, unsigned r, const ControlParams *p, Thread::Priority prio)
{
  if (!c) return;
  if (running()) stop();
  if (r) setRate(r);
  if (p) setControlParams(*p);
  mut.lock();
  cb = c;
  pleaseStop = false;
  mut.unlock();
  Thread::start(prio);
}
示例#24
0
Lfo::Lfo(float samplerate) : samplerate(samplerate), phase(0), inc(0) {
	setWaveform(0);   
	setWaveform(1);   
	setWaveform(2);   
	setWaveform(3);   
	setWaveform(4);   
	setRate(1.0f); //1Hz

	noiseOsc= new OscNoise(samplerate);
	randomValue= 0.0f;
	randomValueOld= 0.0f;
	resultSmooth= 0.0f;
}
示例#25
0
void SoundDialog::rateIndexChange(int const index) {
	if (getCustomIndex(rateBox_) == index) {
		QSize const size = rateBox_->itemData(index).toSize();
		int const currentRate = rate_;
		bool ok = false;
		int r = QInputDialog::getInteger(this, tr("Set Sample Rate"),
		                                 tr("Sample rate (Hz):"), currentRate,
		                                 size.width(), size.height(), 1, &ok);
		if (!ok)
			r = currentRate;

		setRate(rateBox_, r);
	}
}
示例#26
0
bool ArrowTower::init() {
    setScope(90);
    setLethality(1);
    setRate(2);

    auto baseplate = Sprite::createWithSpriteFrameName("baseplate.png");
    addChild(baseplate);

    rotateArrow = Sprite::createWithSpriteFrameName("arrow.png");
    rotateArrow->setPosition(Vec2(0,baseplate->getContentSize().height/4));
    addChild(rotateArrow);

    schedule(CC_CALLBACK_1(ArrowTower::rotateAndShoot, this),0.5, "shoot");

    return true;
}
示例#27
0
文件: phaser.cpp 项目: ErNancy/kosm
/**
 * @param aRate     {float} desired LFO rate in Hz
 * @param aFeedback {float} 0 - 1
 * @param aDepth    {float} 0 - 1
 * @param aMinFreq  {float} minimum frequency value in Hz allowed for the filters range
 * @param aMaxFreq  {float} maxiumum frequency value in Hz allowed for the filters range
 */
Phaser::Phaser( float aRate, float aFeedback, float aDepth, float aMinFreq, float aMaxFreq )
{
    _lfoPhase = 0.0;
    _zm1      = 0.0;

    setRange( aMinFreq, aMaxFreq );
    setRate( aRate );

    _fb       = aFeedback;
    _depth    = aDepth;

    int stages = 6; // six-stage phaser

    for ( int i = 0; i < stages; ++i )
        _alps[ i ] = new AllPassDelay();
}
示例#28
0
bool AttackTower::init()
{
    if (!TowerBase::init())
	{
		return false;
	}
    
    setScope(90);
	setTowerValue(200);
    setLethality(1);
    setRate(2);
    tower= Sprite::createWithSpriteFrameName("attackTower.png");
    this->addChild(tower);
    
    schedule(schedule_selector(AttackTower::shoot), 0.8f);
	return true;
}
示例#29
0
PIDFlowController::PIDFlowController(DataLogger *l, unsigned log_id, const PIDFCParams &p, DAQTask *dt_in, DAQTask *dt_out)
  :  DataLogable(l, log_id), ok(false), dev_ai(0), dev_ao(0), params(p)
{
  daq_ai = dt_in;
  daq_ao = dt_out;
  if (!initComedi()) { 
    uninitComedi();
    return;
  }
  if (!setRate(p.rate_hz)) {
    Error("PIDFlowController rate of %u is out of range.\n", p.rate_hz);
    uninitComedi();
    return;
  }
  /*  if (daq_ai && daq_ao) {
    Msg("PIDFlow using daq tasks %s, %s\n", daq_ai->name(), daq_ao->name());
    }*/
  ok = true;
}
示例#30
0
	//-----------------------------------------------------------------
	FlangeDSP::FlangeDSP( XMLParser& parser, XMLNode* flangeNode )
		:	DSP( MONKY_DSP_TYPE_FLANGE )
	{
		const float NO_VALUE_SPECIFIED = -1000000000.0f;
		parser.validateXMLAttributes( flangeNode, "", "type,dryMixVolume,wetMixVolume,depth,rate" );
		float dryMix = parser.getXMLAttributeAsFloat( flangeNode, "dryMixVolume", NO_VALUE_SPECIFIED );
		float wetMix = parser.getXMLAttributeAsFloat( flangeNode, "wetMixVolume", NO_VALUE_SPECIFIED );
		float depth = parser.getXMLAttributeAsFloat( flangeNode, "depth", NO_VALUE_SPECIFIED );
		float rate = parser.getXMLAttributeAsFloat( flangeNode, "rate", NO_VALUE_SPECIFIED );

		if( dryMix != NO_VALUE_SPECIFIED )
			setDryMixVolume( dryMix );
		if( wetMix != NO_VALUE_SPECIFIED )
			setWetMixVolume( wetMix );
		if( depth != NO_VALUE_SPECIFIED )
			setDepth( depth );
		if( rate != NO_VALUE_SPECIFIED )
			setRate( rate );
	}