Esempio n. 1
0
void ViZscoreNoiseDetector::setWindowSize(const int &size)
{
	mWindowSize = size;
	mHalfWindow = qFloor(size / 2.0);
	setOffset(mHalfWindow);
}
Esempio n. 2
0
void NotePlayHandle::play( sampleFrame * _working_buffer )
{
	if( m_muted )
	{
		return;
	}

	// if the note offset falls over to next period, then don't start playback yet
	if( offset() >= Engine::mixer()->framesPerPeriod() )
	{
		setOffset( offset() - Engine::mixer()->framesPerPeriod() );
		return;
	}

	lock();
	if( m_frequencyNeedsUpdate )
	{
		updateFrequency();
	}

	// number of frames that can be played this period
	f_cnt_t framesThisPeriod = m_totalFramesPlayed == 0
		? Engine::mixer()->framesPerPeriod() - offset()
		: Engine::mixer()->framesPerPeriod();

	// check if we start release during this period
	if( m_released == false &&
		instrumentTrack()->isSustainPedalPressed() == false &&
		m_totalFramesPlayed + framesThisPeriod > m_frames )
	{
		noteOff( m_totalFramesPlayed == 0
			? ( m_frames + offset() ) // if we have noteon and noteoff during the same period, take offset in account for release frame
			: ( m_frames - m_totalFramesPlayed ) ); // otherwise, the offset is already negated and can be ignored
	}

	// under some circumstances we're called even if there's nothing to play
	// therefore do an additional check which fixes crash e.g. when
	// decreasing release of an instrument-track while the note is active
	if( framesLeft() > 0 )
	{
		// clear offset frames if we're at the first period
		// skip for single-streamed instruments, because in their case NPH::play() could be called from an IPH without a buffer argument
		// ... also, they don't actually render the sound in NPH's, which is an even better reason to skip...
		if( m_totalFramesPlayed == 0 && ! ( m_instrumentTrack->instrument()->flags() & Instrument::IsSingleStreamed ) )
		{
			memset( _working_buffer, 0, sizeof( sampleFrame ) * offset() );
		}
		// play note!
		m_instrumentTrack->playNote( this, _working_buffer );
	}

	if( m_released )
	{
		f_cnt_t todo = framesThisPeriod;

		// if this note is base-note for arpeggio, always set
		// m_releaseFramesToDo to bigger value than m_releaseFramesDone
		// because we do not allow NotePlayHandle::isFinished() to be true
		// until all sub-notes are completely played and no new ones
		// are inserted by arpAndChordsTabWidget::processNote()
		if( ! m_subNotes.isEmpty() )
		{
			m_releaseFramesToDo = m_releaseFramesDone + 2 * Engine::mixer()->framesPerPeriod();
		}
		// look whether we have frames left to be done before release
		if( m_framesBeforeRelease )
		{
			// yes, then look whether these samples can be played
			// within one audio-buffer
			if( m_framesBeforeRelease <= framesThisPeriod )
			{
				// yes, then we did less releaseFramesDone
				todo -= m_framesBeforeRelease;
				m_framesBeforeRelease = 0;
			}
			else
			{
				// no, then just decrease framesBeforeRelease
				// and wait for next loop... (we're not in
				// release-phase yet)
				todo = 0;
				m_framesBeforeRelease -= framesThisPeriod;
			}
		}
		// look whether we're in release-phase
		if( todo && m_releaseFramesDone < m_releaseFramesToDo )
		{
			// check whether we have to do more frames in current
			// loop than left in current loop
			if( m_releaseFramesToDo - m_releaseFramesDone >= todo )
			{
				// yes, then increase number of release-frames
				// done
				m_releaseFramesDone += todo;
			}
			else
			{
				// no, we did all in this loop!
				m_releaseFramesDone = m_releaseFramesToDo;
			}
		}
	}

	// update internal data
	m_totalFramesPlayed += framesThisPeriod;
	unlock();
}
Esempio n. 3
0
/**
 * Constructor.
 */
QG_GraphicView::QG_GraphicView(QWidget* parent, Qt::WindowFlags f, RS_Document* doc)
        :RS_GraphicView(parent, f)
        ,hScrollBar(new QG_ScrollBar(Qt::Horizontal, this))
        ,vScrollBar(new QG_ScrollBar(Qt::Vertical, this))
        ,layout(new QGridLayout(this))
        ,gridStatus(new QLabel("-", this))
        ,curCad(new QCursor(QPixmap(":ui/cur_cad_bmp.png"), CURSOR_SIZE, CURSOR_SIZE))
        ,curDel(new QCursor(QPixmap(":ui/cur_del_bmp.png"), CURSOR_SIZE, CURSOR_SIZE))
        ,curSelect(new QCursor(QPixmap(":ui/cur_select_bmp.png"), CURSOR_SIZE, CURSOR_SIZE))
        ,curMagnifier(new QCursor(QPixmap(":ui/cur_glass_bmp.png"), CURSOR_SIZE, CURSOR_SIZE))
        ,curHand(new QCursor(QPixmap(":ui/cur_hand_bmp.png"), CURSOR_SIZE, CURSOR_SIZE))
        ,redrawMethod(RS2::RedrawAll)
        ,isSmoothScrolling(false)
{
    RS_DEBUG->print("QG_GraphicView::QG_GraphicView()..");

    RS_DEBUG->print("  Setting Container..");
    if (doc) {
        setContainer(doc);
        doc->setGraphicView(this);
    }
    RS_DEBUG->print("  container set.");
    setFactorX(4.0);
    setFactorY(4.0);
    setOffset(50, 50);
    setBorders(10, 10, 10, 10);

	if (doc) {
		setDefaultAction(new RS_ActionDefault(*doc, *this));
	}

    layout->setMargin(0);
    layout->setSpacing(0);
    layout->setColumnStretch(0, 1);
    layout->setColumnStretch(1, 0);
    layout->setColumnStretch(2, 0);
    layout->setRowStretch(0, 1);
    layout->setRowStretch(1, 0);

    hScrollBar->setSingleStep(50);
    hScrollBar->setCursor(Qt::ArrowCursor);
    layout->addWidget(hScrollBar, 1, 0);
    layout->addItem(new QSpacerItem(0, hScrollBar->sizeHint().height()), 1, 0);
    connect(hScrollBar, SIGNAL(valueChanged(int)),
            this, SLOT(slotHScrolled(int)));

    vScrollBar->setSingleStep(50);
    vScrollBar->setCursor(Qt::ArrowCursor);
    layout->addWidget(vScrollBar, 0, 2);
    layout->addItem(new QSpacerItem(vScrollBar->sizeHint().width(), 0), 0, 2);
    connect(vScrollBar, SIGNAL(valueChanged(int)),
            this, SLOT(slotVScrolled(int)));

    // Dummy widgets for scrollbar corners:
    //layout->addWidget(new QWidget(this), 1, 1);
    //QWidget* w = new QWidget(this);
    //w->setEraseColor(QColor(255,0,0));

    gridStatus->setAlignment(Qt::AlignRight);
    layout->addWidget(gridStatus, 1, 1, 1, 2);
    layout->addItem(new QSpacerItem(50, 0), 0, 1);

    setMouseTracking(true);
        // flickering under win:
    //setFocusPolicy(WheelFocus);

    setFocusPolicy(Qt::NoFocus);

    // See https://sourceforge.net/tracker/?func=detail&aid=3289298&group_id=342582&atid=1433844 (Left-mouse drag shrinks window)
    setAttribute(Qt::WA_NoMousePropagation);

	int aa = RS_SETTINGS->readNumEntry("/Appearance/Antialiasing");
	set_antialiasing(aa?true:false);
}
Esempio n. 4
0
void AudioInfo::operator=(const IAudioInfo &info){
	setSamples(info.getSamples());
	setOffset(info.getOffset());
	setSamplerate(info.getSamplerate());
	setChannels(info.getChannels());
}
Esempio n. 5
0
bool Wind::buttonPressCallback( GuiButton* b )
{
	//oflog( of_log_verbose, "button pressed: %s (%s)", b->gettitle().c_str(), b->gettag().c_str() );
	bool close_menu = false;
	
	string tag = b->getTag();
	if ( tag == "view_focus" )
	{
		showing_image = SI_FOCUS;
		if ( xoffs == -1 )
		{
			xoffs = colorImg.getWidth()/2-80;
			yoffs = colorImg.getHeight()/2-60;
		}
	}
	else if ( tag == "view_focus_centre" )
	{
		xoffs = colorImg.getWidth()/2-80;
		yoffs = colorImg.getHeight()/2-60;
	}
	else if ( tag == "view_focus_left" )
	{
		xoffs = max(0,xoffs-10);
	}
	else if ( tag == "view_focus_right" )
	{
		xoffs = min(int(colorImg.getWidth()-160),xoffs+10);
	}
	else if ( tag == "view_focus_up" )
	{
		yoffs = max(0,yoffs-10);
	}
	else if ( tag == "view_focus_down" )
	{
		yoffs = min(int(colorImg.getHeight()-120),yoffs+10);
	}

	else if ( tag == "view_none" )
		showing_image = SI_NONE;
	
	else if ( tag == "view_diff" )
		showing_image = SI_DIFF;
	
	else if ( tag == "view_gray_contrasted" )
		showing_image = SI_GRAY_CONTRASTED;
	
	else if ( tag == "calc_cont1_+" )
		setContrast1( contrast_1 * 1.05f );
	else if ( tag == "calc_cont1_-" )
		setContrast1( contrast_1 / 1.05f );
	
#ifndef NEW_TINY
	else if ( tag == "calc_cont2_+" )
		setContrast2( contrast_2 * 1.05f );
	else if ( tag == "calc_cont2_-" )
		setContrast2( contrast_2 / 1.05f );
#endif
	
	else if ( tag == "calc_stride_+" )
		setStride( stride+1 );
	else if ( tag == "calc_stride_-" )
		setStride( stride-1 );
	else if ( tag == "calc_offset_+" )
		setOffset( offset+1 );
	else if ( tag == "calc_offset_-" )
		setOffset( offset-1 );
	else if ( tag == "calc_step_+" )
		setStep( step + 0.25f );
	else if ( tag == "calc_step_-" )
		setStep( step - 0.25f );
	
	else if ( tag == "calc_hsv_seth" )
		setWhichHSVChannel(0);
	else if ( tag == "calc_hsv_sets" )
		setWhichHSVChannel(1);
	else if ( tag == "calc_hsv_setv" )
		setWhichHSVChannel(2);
	else if ( tag == "calc_hsv_setall" )
		setWhichHSVChannel(3);
	
	else if ( tag == "sys_save" )
	{
		((testApp*)ofGetAppPtr())->saveSettings();
		close_menu = true;
	}
	else if ( tag == "sys_reboot_n" || tag == "sys_shutdown_n" )
		close_menu = true;
	else if ( tag == "sys_shutdown_y" )
		system("sudo poweroff");
	else if ( tag == "sys_reboot_y" )
		system("sudo reboot");
	else if ( tag == "sys_cyclewifi" )
	{
		system("sudo cyclewlan0" );
		close_menu = true;
	}
	
	return close_menu;
}
Esempio n. 6
0
void Wind::setup( ofxXmlSettings& data )
{
	
	tiny = (unsigned char*)malloc( TINY_WIDTH*TINY_HEIGHT );
	
	draw_debug = false;
	first_frame = true;
	
	
	pd = new ofxPd();
	pd->init( 0,2,FREQ );
	
	
	pd->openPatch( "sound1/_main.pd" );
	
	bLearnBakground = true;
	threshold = 30;
	
	
	data_send_start_timer = DATA_SEND_START_TIMER;
	
	
#ifdef SCREEN
	screen.setup( "/dev/spidev1.1", /*SPI_CPHA | SPI_CPOL*/0, 40000000 );
	input.setup( "/dev/spidev1.0", 0, 10000000 );
	if ( !input.loadCalibration( data ) )
	{
		input.startCalibration();
	}
#endif
	
	// gui
	gui.setup( 320, 240 );
	gui.setListener( this );
	gui.addButton( "View", "view" );
	gui.addButton( "view", "None", "view_none" );
	gui.addButton( "view", "Focus", "view_focus" );
	gui.addButton( "view_focus", "Centre", "view_focus_centre" );
	gui.addButton( "view_focus", "<-", "view_focus_left" );
	gui.addButton( "view_focus", "->", "view_focus_right" );
	gui.addButton( "view_focus", "/\\", "view_focus_up" );
	gui.addButton( "view_focus", "\\/", "view_focus_down" );
	gui.addButton( "view", "Calc", "view_calc" );
	gui.addButton( "view_calc", "GrayCn", "view_gray_contrasted" );
	gui.addButton( "view_calc", "Diff", "view_diff" );
	
	gui.addButton( "Calc", "calc" );
	gui.addButton( "calc", "Cont 1", "calc_cont1" );
	gui.addButton( "calc_cont1", "+", "calc_cont1_+" );
	gui.addButton( "calc_cont1", "-", "calc_cont1_-" );
#ifndef NEW_TINY
	gui.addButton( "calc", "Cont 2", "calc_cont2" );
	gui.addButton( "calc_cont2", "+", "calc_cont2_+" );
	gui.addButton( "calc_cont2", "-", "calc_cont2_-" );
#endif
	gui.addButton( "calc", "Offset", "calc_offset" );
	gui.addButton( "calc_offset", "+", "calc_offset_+" );
	gui.addButton( "calc_offset", "-", "calc_offset_-" );
	gui.addButton( "calc", "Stride", "calc_stride" );
	gui.addButton( "calc_stride", "+", "calc_stride_+" );
	gui.addButton( "calc_stride", "-", "calc_stride_-" );
	gui.addButton( "calc", "Step", "calc_step" );
	gui.addButton( "calc_step", "+", "calc_step_+" );
	gui.addButton( "calc_step", "-", "calc_step_-" );
	gui.addButton( "calc", "HSV", "calc_hsv" );
	gui.addButton( "calc_hsv", "H(0)", "calc_hsv_seth" );
	gui.addButton( "calc_hsv", "S(1)", "calc_hsv_sets" );
	gui.addButton( "calc_hsv", "V(2)", "calc_hsv_setv" );
	gui.addButton( "calc_hsv", "All(3)", "calc_hsv_setall" );
	
	
	
	gui.addButton( "Sys", "sys" );
	gui.addButton( "sys", "Save", "sys_save" );
	gui.addButton( "sys", "S/down", "sys_shutdown" );
	gui.addButton( "sys_shutdown", "S/down", "sys_shutdown_y" );
	gui.addButton( "sys_shutdown", "Cancel", "sys_shutdown_n" );
	gui.addButton( "sys", "Reboot", "sys_reboot" );
	gui.addButton( "sys_reboot", "Reboot", "sys_reboot_y" );
	gui.addButton( "sys_reboot", "Cancel", "sys_reboot_n" );
	gui.addButton( "sys", "CyWifi", "sys_cyclewifi" );
	
	
	gui.addValue( "Contr1", "cont1", "%.2f" );
	gui.addValue( "Contr2", "cont1", "%.2f" );
	gui.addValue( "Offset", "offset", "%.0f" );
	gui.addValue( "Stride", "stride", "%.0f" );
	gui.addValue( "Step", "step", "%.2f" );
	gui.addValue( "HSV", "hsv", "%.0f" );
	
	showing_image = SI_NONE;
	prev_showing_image = SI_FOCUS;
	xoffs = -1;
	yoffs = -1;
	
	
	
	setWhichHSVChannel( data.getValue( "which_hsv_channel", DEFAULT_HSV_CHANNEL ));
	setContrast1(data.getValue("contrast_1", DEFAULT_CONTRAST_1 ));
	setContrast2(data.getValue("contrast_2", DEFAULT_CONTRAST_2 ));
	setStride(data.getValue( "stride", DEFAULT_STRIDE ));
	setOffset(data.getValue( "offset", DEFAULT_OFFSET ));
	setStep(data.getValue( "step", DEFAULT_STEP ));
	
	
	
	
}
Esempio n. 7
0
void ShiftImageTimesDialog::dcDateTimeChanged(const QDateTime &newDateTime)
{
	if (!dcImageEpoch)
		return;
	setOffset(newDateTime.toTime_t() - dcImageEpoch);
}
Esempio n. 8
0
/**
*@brief サインスマート製4自由度ロボットアーム制御クラスのコンストラクタ
*/
RobotArm::RobotArm()
{
	jl = new Vector3d[4];
	pl = new Vector3d[4];
	l[0] = ArmLength0;
	l[1] = ArmLength1;
	l[2] = ArmLength2;
	l[3] = ArmLength3;
	lh = HandLength;
	lf = FingerLength;
	m[0] = ArmMath0;
	m[1] = ArmMath1;
	m[2] = ArmMath2;
	m[3] = ArmMath3;
	mh = HandMath;
	mf = FingerMath;
	wi = ArmWidth;
	wf = FingerWidth;
	hi = ArmHeight;
	hf = FingerHeight;
	rh = HandRadius;
	jl[0](0) = 0;
	jl[0](1) = 0;
	jl[0](2) = 0;
	pl[0](0) = jl[0](0);
	pl[0](1) = jl[0](1);
	pl[0](2) = jl[0](2)+l[0]/2;
	jl[1](0) = pl[0](0);
	jl[1](1) = pl[0](1);
	jl[1](2) = pl[0](2)+l[0]/2;
	pl[1](0) = jl[1](0);
	pl[1](1) = jl[1](1);
	pl[1](2) = jl[1](2)+l[1]/2;
	jl[2](0) = pl[1](0);
	jl[2](1) = pl[1](1);
	jl[2](2) = pl[1](2)+l[1]/2;
	pl[2](0) = jl[2](0);
	pl[2](1) = jl[2](1);
	pl[2](2) = jl[2](2)+l[2]/2;
	jl[3](0) = pl[2](0);
	jl[3](1) = pl[2](1);
	jl[3](2) = pl[2](2)+l[2]/2;
	pl[3](0) = jl[3](0);
	pl[3](1) = jl[3](1)+l[3]/2;
	pl[3](2) = jl[3](2);
	jh(0) = pl[3](0);
	jh(1) = pl[3](1)+l[3]/2;
	jh(2) = pl[3](2);
	ph(0) = jh(0);
	//pyh = jyh+lh/2;
	ph(1) = jh(1);
	ph(2) = jh(2);
	jf(0) = ph(0);
	//jyf = pyh+lh/2;
	jf(1) = ph(1);
	jf(2) = ph(2);
	pf(0) = jf(0);
	pf(1) = jf(1);
	pf(2) = jf(2)-lf/2;
	hw = 0.02;

	setAngle(0, 0, 0, 0);


	dt = 0.01;
	//endTime = -1;
	//time = 0;
	/*targetPoint(0) = 0;
	targetPoint(1) = 0;
	targetPoint(2) = 0;

	startPoint(0) = 0;
	startPoint(1) = 0;
	startPoint(2) = 0;*/

	setOffset(0,0,0,0);

	Kp = 10;
	Kjp = 10;
	
	openGripper();

	maxSpeedCartesian = Vector3d(1000, 1000, 1000);
	maxSpeedJoint[0] = 1000;
	maxSpeedJoint[1] = 1000;
	maxSpeedJoint[2] = 1000;
	maxSpeedJoint[3] = 1000;

	softUpperLimitCartesian = Vector3d(1000, 1000, 1000);
	softLowerLimitCartesian = Vector3d(-1000, -1000, -1000);

	pauseFalg = false;
	stopFalg = false;

	//homePosition = Vector3d(0, 0, 0);
	


	softUpperLimitJoint[0] = MOTOR_UPPER__LIMIT_0;
	softUpperLimitJoint[1] = MOTOR_UPPER__LIMIT_1;
	softUpperLimitJoint[2] = MOTOR_UPPER__LIMIT_2;
	softUpperLimitJoint[3] = MOTOR_UPPER__LIMIT_3;

	softLowerLimitJoint[0] = MOTOR_LOWER__LIMIT_0;
	softLowerLimitJoint[1] = MOTOR_LOWER__LIMIT_1;
	softLowerLimitJoint[2] = MOTOR_LOWER__LIMIT_2;
	softLowerLimitJoint[3] = MOTOR_LOWER__LIMIT_3;

	serbo = true;

	manifactur = "SainSmart";
	type = "DIY 4-Axis Servos Control Palletizing Robot Arm";
	axisNum = 4;
	cmdCycle = 50;
	isGripper = false;

	//speedPoint = 10;
	//speedJointPos = 1;

	MaxSpeedJoint[0] = 2;
	MaxSpeedJoint[1] = 2;
	MaxSpeedJoint[2] = 2;
	MaxSpeedJoint[3] = 2;
	MaxSpeedCartesianTrans = 0.5;
	MaxSpeedCartesianRot = 2;

	MinTime = dt;

	jointOffset[0] = MOTOR_OFFSET_0;
	jointOffset[1] = MOTOR_OFFSET_1;
	jointOffset[2] = MOTOR_OFFSET_2;
	jointOffset[3] = MOTOR_OFFSET_3;
	

}