Exemplo n.º 1
0
void AdvGaits::setParams(Params *pvar)
{
    setCoupling(0);

    p = pvar;

    ui->wavOddBox->setValue(pvar->wavelengthOdd);
    ui->wavEvenBox->setValue(pvar->wavelengthEven);
    ui->freqOddBox->setValue(pvar->frequencyOdd);
    ui->freqEvenBox->setValue(pvar->frequencyEven);
    ui->phaseOddBox->setValue(pvar->phaseOdd);
    ui->phaseEvenBox->setValue(pvar->phaseEven);


    if (pvar->manualoffset)
        setOffset(pvar->offset);
    else
        setOffset(pvar->masteroffsetOdd,pvar->masteroffsetEven);

    if (pvar->manualamplitude)
        setAmplitude(pvar->amplitude);
    else
        setAmplitude(pvar->amplitudeOdd,pvar->amplitudeEven);

}
Exemplo n.º 2
0
// ---------------------------------------------------------------------------
//	addNoiseEnergy
// ---------------------------------------------------------------------------
//!	Add noise (bandwidth) energy to this Breakpoint by computing new 
//!	amplitude and bandwidth values. enoise may be negative, but 
//!	noise energy cannot be removed (negative energy added) in excess 
//!	of the current noise energy.
//!	
//!	\param enoise is the amount of noise energy to add to
//!	this Breakpoint.
//
void 
Breakpoint::addNoiseEnergy( double enoise )
{
	//	compute current energies:
	double e = amplitude() * amplitude();	//	current total energy
	double n = e * bandwidth();				//	current noise energy
	
	//	Assert( e >= n );
	//	could complain, but its recoverable, just fix it:
	if ( e < n )
    {
		e = n;
	}
    
	//	guard against divide-by-zero, and don't allow
	//	the sinusoidal energy to decrease:
	if ( n + enoise > 0. ) 
	{
		//	if new noise energy is positive, total
		//	energy must also be positive:
		//	Assert( e + enoise > 0 );
		setBandwidth( (n + enoise) / (e + enoise) );
		setAmplitude( std::sqrt(e + enoise) );
	}
	else 
	{
		//	if new noise energy is negative, leave 
		//	all sinusoidal energy:
		setBandwidth( 0. );
		setAmplitude( std::sqrt( e - n ) );
	}
}
Exemplo n.º 3
0
/*!
    Constructs an easing curve of the given \a type, with the given \a
    amplitude and \a period. You only have to use this constructor if 
    \a type is one of QtEasingCurve::InElastic, QtEasingCurve::OutElastic, 
    QtEasingCurve::InBounce or QtEasingCurve::OutBounce.
 */
QtEasingCurve::QtEasingCurve(Type type, qreal amplitude, qreal period)
    : d_ptr(new QtEasingCurvePrivate)
{
    setType(type);
    setAmplitude(amplitude);
    setPeriod(period);
}
Exemplo n.º 4
0
bool STF_DDS::dds::setSweep(which_channel channel, sweep_type sweep, uInt32 startPoint, uInt32 endPoint, int delta, Int64 time)
{
	// for linear sweeps - start point (S0) is loaded into word 0 register
	// end point (e0) is loaded into word 1 register (0x0A) - MSB aligned as usual (ideally use setAmplitude, setPhase, etc... code)
	
	if (channel != currentChannel)
	{
		setChannel(channel, time-operationTime);
	}

	int address = 0x00 & 0x05;
	addressList.push_back(address);
	
	switch(sweep)
	{
		case amplitude :
			setAmplitude(channel, startPoint, time);
			break;
		case phase :
			setPhase(channel, startPoint, time);
			break;
		case frequency :
			setFrequency(channel, startPoint, time);
			break;
		default :
			std::cerr << "What did you want to do?" << std::endl;
			break;
	}
	return true;
}
Exemplo n.º 5
0
GuitarTuner::GuitarTuner(QWidget *parent) :
    QMainWindow(parent)
{

    // Set up the QML.
    m_guitarTunerUI = new QDeclarativeView(QUrl("qrc:/src/application.qml"), this);
    setCentralWidget(m_guitarTunerUI);
    m_guitarTunerUI->setResizeMode(QDeclarativeView::SizeRootObjectToView);
    qmlObject = m_guitarTunerUI->rootObject();

    // Init audio output and input.
    initAudioOutput();
    initAudioInput();

    // Connect the quit signal of m_guitarTunerUI
    // into the close slot of this.
    connect(m_guitarTunerUI->engine(), SIGNAL(quit()), SLOT(close()));

    // Connect the signals from qmlObject into proper slots
    // of this and m_voicegenerator.
    connect(qmlObject, SIGNAL(muteStateChanged(bool)),
            SLOT(muteStateChanged(bool)));
    connect(qmlObject, SIGNAL(volumeChanged(qreal)),
            m_voicegenerator, SLOT(setAmplitude(qreal)));
    connect(qmlObject, SIGNAL(volumeChanged(qreal)),
            SLOT(setMaxVolumeLevel(qreal)));

    // Connect the modeChanged signal from qmlObject
    // into modeChanged slot of this class.
    connect(qmlObject, SIGNAL(modeChanged(bool)),
            SLOT(modeChanged(bool)));

    // Connect the microphoneSensitivityChanged signal from
    // m_guitarTunerUI into setCutOffPercentage slot of m_analyzer class.
    connect(qmlObject, SIGNAL(microphoneSensitivityChanged(qreal)),
            m_analyzer, SLOT(setCutOffPercentage(qreal)));

    // Connect the signals from m_analyzer into slots of qmlObject.
    connect(m_analyzer, SIGNAL(lowVoice()),
            qmlObject, SLOT(lowVoice()));
    connect(m_analyzer, SIGNAL(correctFrequency()),
            qmlObject, SLOT(correctFrequencyObtained()));
    connect(m_analyzer, SIGNAL(voiceDifference(QVariant)),
            qmlObject, SLOT(voiceDifferenceChanged(QVariant)));

    // Initialise the MaximumVoiceDifference
    // value of qmlObject with the value obtained from m_analyzer.
    qmlObject->setProperty("maxVoiceDifference",
                           m_analyzer->getMaximumVoiceDifference());

    // Connect the targetFrequencyChanged signal of qmlObject
    // into targetFrequencyChanged slot of this class.
    connect(qmlObject, SIGNAL(targetFrequencyChanged(qreal)),
            SLOT(targetFrequencyChanged(qreal)));

    // Start voice output or input by using the modeChanged function,
    // depending of the current mode.
    modeChanged(qmlObject->property("isInput").toBool());

}
Exemplo n.º 6
0
Oscillator::Oscillator(double sampleRate)
    : Generator(sampleRate, 0.0),
    curAngle(0.0)
{
    setAmplitude(1.0);
    setFrequency(440);
    setPhase(0);
}
Exemplo n.º 7
0
void Normalization::init(Normalization::Type nt, double max, double min, double threshold, double amp, double elong)
{
	setType(nt);
	setMaxValue(max);
	setMinValue(min);
	setThreshold(threshold);
	setAmplitude(amp);
	setElongation(elong);
}
void RobotControl::moveTimeout()
{
	setSpeed(events.value(moveIndex).Speed);
	setAmplitude(events.value(moveIndex).Amplitude);
	moveSine(events.value(moveIndex).NCycles);
	moveIndex++;
	if (moveIndex >= events.size()) return;
	long deltaT =
			events.value(moveIndex).StartTime -
			events.value(moveIndex-1).StartTime;
        moveTimer.start(deltaT*1000);
}
Exemplo n.º 9
0
Normalization &Normalization::operator=(const Normalization &nor)
{
	if(this != &nor){
		setMaxValue(nor.getMaxValue());
		setMinValue(nor.getMinValue());
		setThreshold(nor.getThreshold());
		setType(nor.getType());
		setAmplitude(nor.getAmplitude());
		setElongation(nor.getElongation());
	}
	return *this;
}
Exemplo n.º 10
0
void
updateHeight (Water  *w)
{
    int i;

    if (!w)
	return;

    for (i = 0; i < w->nSVer + (w->nWVer / 2); i++)
        setAmplitude(&w->vertices[i], w->bh, w->wave1, w->wave2, w->wa,
		     w->swa, w->wf, w->swf);
}
Exemplo n.º 11
0
void AdvGaits::resetParams()
{
    setCoupling(0);

    setAmplitude(0,0);
    setOffset(0,0);
    ui->ampSliders->resetSliders();
    ui->offsetSliders->resetSliders();
    ui->wavOddBox->setValue(8);
    ui->wavEvenBox->setValue(8);
    ui->freqOddBox->setValue(0);
    ui->freqEvenBox->setValue(0);
    ui->phaseOddBox->setValue(0);
    ui->phaseEvenBox->setValue(0);
}
Exemplo n.º 12
0
float* ofxFftw::ifft(float* a, float* b, fftMode mode) {
	if(mode == OF_FFT_POLAR) {
		setAmplitude(a);
		setPhase(b);
		updateCartesian();
	} else if(mode == OF_FFT_CARTESIAN) {
		setReal(a);
		setImaginary(b);
	}

	memcpy(ifftIn, amplitude, sizeof(float) * bins);
	for(int i = 1; i < signalSize; i++)
		ifftIn[signalSize - i] = phase[i];

	fftwf_execute(ifftPlan);

	setSignal(ifftOut);
	signalReady = false;

	return getSignal();
}
Exemplo n.º 13
0
GuitarTuner::GuitarTuner(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::GuitarTuner),
    m_maximumPrecision(0)
{
    ui->setupUi(this);

    timer = new QTimer(this);
    connect(timer, SIGNAL(timeout()), this, SLOT(setNoteInChromatic()));
    timer->start(5);

    m_outputActive = false;
    m_muted = false;
    m_outputVolumeLevel = getVolumeFromSoundSlider();
    m_inputVolumeLevel = 1.0 - m_outputVolumeLevel;

    m_currentToneIndex = 5;


    updateFrequencyByToneIndex(m_currentToneIndex);

    connect(ui->soundSlider, SIGNAL(valueChanged(int)),
           SLOT(changeVolume()));
    connect(ui->modeButton, SIGNAL(clicked()),
           SLOT(toggleInputOrOutput()));
    connect(ui->buttonNext, SIGNAL(clicked()), SLOT(next()));
    connect(ui->buttonPrev, SIGNAL(clicked()), SLOT(prev()));

    initAudioInput();
    initAudioOutput();

    connect(this, SIGNAL(volumeChanged(qreal)), m_voicegenerator, SLOT(setAmplitude(qreal)));
    connect(this, SIGNAL(microphoneSensitivityChanged(qreal)),m_analyzer, SLOT(setCutOffPercentage(qreal)));
    connect(m_analyzer, SIGNAL(lowVoice()),this, SLOT(lowVoice()));
    connect(m_analyzer, SIGNAL(correctFrequency()), this, SLOT(correctFrequencyObtained()));

    modeChanged(m_outputActive);

    toggleInputOrOutput();
}