Ejemplo n.º 1
0
static	void	update_widgets(int *status, sequence_view_t *p, int pm)
{
	multitracker_t *mt = (multitracker_t*) p->backlink;
	int *h = p->history[pm];
	if( h[PLAY_MODE] != pm )
		playmode_sensitivity( p, pm );

	if( pm == MODE_STREAM )
	{
		update_pos( p, status[TOTAL_FRAMES], 0 );
		update_speed( p, 1 );
	}
	else
	if( pm == MODE_SAMPLE || pm == MODE_PLAIN )
	{
		if( h[FRAME_NUM] != status[FRAME_NUM] )
			update_pos( p, status[TOTAL_FRAMES],status[FRAME_NUM] );
		if( h[SAMPLE_SPEED] != status[SAMPLE_SPEED] )
			update_speed( p, status[SAMPLE_SPEED] );
	}

	if( h[TOTAL_SLOTS] != status[TOTAL_SLOTS])
	{
		gvr_need_track_list( mt->preview, p->num );
		update_track_view( MAX_TRACKS, get_track_tree( p->tracks ), (void*)p );
	}
}
Ejemplo n.º 2
0
static int control(struct af_instance *af, int cmd, void *arg)
{
    struct priv *p = af->priv;

    switch (cmd) {
    case AF_CONTROL_REINIT: {
        struct mp_audio *in = arg;
        struct mp_audio orig_in = *in;
        struct mp_audio *out = af->data;

        in->format = AF_FORMAT_FLOATP;
        mp_audio_copy_config(out, in);

        if (p->rubber)
            rubberband_delete(p->rubber);

        int opts = p->opt_transients | p->opt_detector | p->opt_phase |
                   p->opt_window | p->opt_smoothing | p->opt_formant |
                   p->opt_pitch | p-> opt_channels |
                   RubberBandOptionProcessRealTime;

        p->rubber = rubberband_new(in->rate, in->channels.num, opts, 1.0, 1.0);
        if (!p->rubber) {
            MP_FATAL(af, "librubberband initialization failed.\n");
            return AF_ERROR;
        }

        update_speed(af, p->speed);
        update_pitch(af, p->pitch);
        control(af, AF_CONTROL_RESET, NULL);

        return mp_audio_config_equals(in, &orig_in) ? AF_OK : AF_FALSE;
    }
    case AF_CONTROL_SET_PLAYBACK_SPEED: {
        update_speed(af, *(double *)arg);
        return AF_OK;
    }
    case AF_CONTROL_RESET:
        if (p->rubber)
            rubberband_reset(p->rubber);
        talloc_free(p->pending);
        p->pending = NULL;
        p->rubber_delay = 0;
        return AF_OK;
    case AF_CONTROL_COMMAND: {
        char **args = arg;
        if (!strcmp(args[0], "set-pitch")) {
            char *endptr;
            double pitch = strtod(args[1], &endptr);
            if (*endptr || pitch < 0.01 || pitch > 100.0)
                return CONTROL_ERROR;
            update_pitch(af, pitch);
            return CONTROL_OK;
        } else {
            return CONTROL_ERROR;
        }
    }
    }
    return AF_UNKNOWN;
}
Ejemplo n.º 3
0
/* Redraws the IC updating everything 
 * Slowest way to go.  Should only use on init
 */
void redraw_ic() {
  blank_ic();
  update_speed();
  update_doors();
  update_turn_signals();
  SDL_RenderPresent(renderer);
}
Ejemplo n.º 4
0
/* Parses CAN fram and updates current_speed */
void update_speed_status(struct canfd_frame *cf, int maxdlen) {
  int len = (cf->len > maxdlen) ? maxdlen : cf->len;
  if(len < speed_pos + 1) return;
  int speed = cf->data[speed_pos] << 8;
  speed += cf->data[speed_pos + 1];
  speed = speed / 100; // speed in kilometers
  current_speed = speed * 0.6213751; // mph
  update_speed();
  SDL_RenderPresent(renderer);
}
Ejemplo n.º 5
0
void *show_speed(void *arg){
    int old_download = g_downloaded;
    char info[50];
    for(;;){
        sleep(2);
        int current_download = g_downloaded;
        double speed = (double)(current_download - old_download)/3.0;
        double proportion = (double)current_download/(double)g_torrentmeta->length;
        int index = (proportion >= 1)?0:(49 - (int)(proportion * 50));
        sprintf(info,"speed:%5.1fKB/s", speed / 1024);
        update_speed(info);
        old_download = current_download;
    }
}
Ejemplo n.º 6
0
//--------------------------------------------------------------------------------
// update
//--------------------------------------------------------------------------------
void zz_camera_follow::update_time (bool recursive, zz_time diff_time)
{
	update_speed(diff_time); // update camera speed

	// save last properties
	last_.pitch = current_.pitch;
	last_.yaw = current_.yaw;
	last_.distance = current_.distance;
	
	// distance between last_target and current target position
	float target_pos_diff = 0;
	float camera_dir_diff = 0;
	
	if (!target_) return; // if no target was set, do nothing.

	// retrieve target position, and save into target_pos
	get_target_pos(final_.target_pos);

	target_pos_diff = last_.target_pos.distance(final_.target_pos);
	if (target_pos_diff > EPSILON_TARGETPOS) is_dirty_ = true;
	if (follow_mode_ == BACK_MODE) is_dirty_ = true;

	if (shake_lifetime != 0) is_dirty_ = true;

	// if not changed any property, then do nothing.
	if (!is_dirty_) return;

	// adjust camera properties(follow_pitch/yaw/distance)
	if(!camera_effect_onoff)
	interpolate_camera(diff_time);
	else
    interpolate_camera_effect(diff_time);

	// set target direction
	get_target_dir(final_.target_dir);

	// update lookmode|backmode
	if (follow_mode_ == LOOK_MODE) {
		update_lookmode(last_.yaw);
	}
	else { // BACK_MODE
		update_backmode();
	}

	// apply shakeed animation
	apply_shake(diff_time);
}
Ejemplo n.º 7
0
Archivo: main.c Proyecto: alexpriem/avr
void test_switch (void) {
	
	uint8_t switchstate;

		
	switchstate=PINB & switchpin;
//	uart_printf ("s:%x\r\n",switchstate);
	 if ((switchstate!=prev_switchstate) & (prev_switchstate==0)) {
	 	turns_done++;
		timestamp0=timestamp1;
		timestamp1=timer;
		update_speed();

		if ((action==WIND_LEFT) || (action==WIND_RIGHT)) total_turns_done++;
	 	update_turns();
		if (turns_done>=turns_prog) {
			stop_winding();
			}
	 }
	 prev_switchstate=switchstate;
}
Ejemplo n.º 8
0
 void update(float dt)
 {
     update_speed(dt);
     move(dt);
 }
Ejemplo n.º 9
0
Archivo: main.c Proyecto: alexpriem/avr
int main(void)
{
	uint8_t i;
	
		  
#ifdef DEBUG
	uart_init();
	uart_puts ("\r\nreset\r\ninit port 1\r\n");	
#endif
	
	//
/*
	uart_puts ("a123\n");
	uart_puts ("b456\n");
	uart_puts ("c789\n");
	uart_puts ("d20\n");
*/	
	init_keypad_4x4s (P_PORTC);
	init_count_switch();
    init_timer ();

	lcd_setup (0, P_PA2, P_PA4, P_PA6, P_PA0,
			  P_PA1, P_PA3, P_PA5, P_PA7);	 

 //lcd_setup  (uint8_t chip,  uint8_t strobe, uint8_t clock, uint8_t io)
	lcd_setup_info (0, HD44780, 20, 2);
	
	lcd_init (0, LCD_DISP_ON);

  // relays
		//	sh_cp:11 (geel)    st_cp:12(paars)    ds:14(wit)
	//void hc595_setup (uint8_t chip, uint8_t clk, uint8_t cs, uint8_t data)

	DDRD|=P_BIT7 | P_BIT6 | P_BIT5 | P_BIT4;
#ifdef DEBUG
    test_relais();
#endif


	c=0;
	prevc=0;
	num=0;
	turns_done=0;
	turns_prog=0;	
	total_turns_done=0;
	for (i=0; i<80; i++) layer[i]=0;
	stop_motor();
	set_wind_dir_none();

	lcd_clrscr(0);
	lcd_puts (0,"*    Winding controller 20140114");
	lcd_gotoxy(0,39,0);
	lcd_puts (0,"*");
	lcd_gotoxy(0,0,3);
	lcd_puts (0,"*");
	lcd_gotoxy(0,39,3);
	lcd_puts (0,"*");
	lcd_gotoxy(0,2,2);
	lcd_printf(0,"Free RAM:%d b",freeRam());
	sleep(1);


	lcd_clrscr(0);
	update_info ();
    update_command();
	update_num ();
	update_speed ();
	update_turns();

	for (;;) {

		c=keypad_w_getch();

		if (c!=prevc)  {
			/*a=PINC;
			uart_printf ("%x %x %d\r\n",a,c,num); */
			prevc=c;

			if ((action==FILL) || (action==WIND_LEFT) || (action==WIND_RIGHT)) {
				switch (c) {
					case 0x0c: 	stop_winding();
								action=INACTIVE; //dubbel maar extra voor readability
							   	break;
				}
			}  // if !INACTIVE

			if (action==HELP) {

			switch (c) {
					case 0x0f: 	if (helppage<MAX_HELPPAGES) helppage++;
								show_help();
							   	break;
					case 0x0e: 	if (helppage>0) helppage--;
								show_help();
							   	break;
					case 0x0c: 	action=INACTIVE;
								lcd_clrscr(0);
							   	break;
					}
			}  // if HELP

			if (action==CORR) {
			switch (c) {  //corrmode is wat we de *vorige* keer gedaan hebben
					char buf[10];

					case 0x0c: 	turns_done=turns_before_corr;
								total_turns_done=total_turns_done_before_corr;
								action=INACTIVE;
								break;
					case 0x0e: 	turns_done=turns_before_corr;
								total_turns_done=total_turns_done_before_corr;
								if (corrmode==SUB) {
									turns_done+=corr;
									total_turns_done+=corr;
									corrmode=ADD;
									break;
								}
								if (corrmode==ADD) {
									if (turns_done>=corr) {
											turns_done-=corr;
											total_turns_done-=corr;
									}
									corrmode=SUB;
								}
								break;
					case 0x0f: 	turns_done=0;
							 	total_turns_done=0;
								turns_before_corr=0;
								total_turns_done_before_corr=0;
								action=INACTIVE;
								break;
			   		case 0xff:
			   		case 0xfd:
			   		case 0xfe: break;
					default:
								num=0;
								action=INACTIVE;
								itoa(corr,buf,10);
								if (corrmode==SUB) strcat(layer,"+");
								if (corrmode==ADD) strcat(layer,"+");
 								strcat (layer,buf);
								update_layer();
								break;
					}
    				update_command();
					update_turns();
							 
			}


			if (action==INACTIVE) {
				switch (c) {
					case 0x0a: 	wind_left();
								turns_prog=num;
								num=0;
								break;
					case 0x0b:  wind_right ();	
								turns_prog=num;
								num=0;
								break;
					case 0x0d:  fill ();	
								turns_prog=num;
								num=0;
								break;
					case 0x0c: 	num=0;					   
								stop_motor();
							   	break;
					case 0x0e: 	corr=num;
								turns_before_corr=turns_done;
								if (turns_done>=corr) turns_done-=corr;
								action=CORR;
								corrmode=SUB;
							   	break;
					case 0x0f:  helppage=0;
								show_help();
								action=HELP;
								break;
			   		case 0xff:
			   		case 0xfd:
			   		case 0xfe: break;

					default: if (num<1000)  {
							num=num*10 + c;						
							update_num();
							update_speed();
						}
				}
				if (action!=HELP)  {
    				update_command();
					update_turns();
					update_num();
					update_speed();
				}
			  } // if INACTIVE

		
			} // if c==prevc
	}  // mainloop
	
 return 0;
}
Ejemplo n.º 10
0
CentralWindow::CentralWindow()
{
    drawMutex = new QMutex();
    centralwidget = new QWidget(this);
    centralwidget->setObjectName(QString::fromUtf8("centralwidget"));
    gridLayout = new QGridLayout(centralwidget);
    gridLayout->setObjectName(QString::fromUtf8("gridLayout"));
    Spielfeld = new QFrame(centralwidget);
    Spielfeld->setObjectName(QString::fromUtf8("Spielfeld"));
    QSizePolicy sizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding);
    sizePolicy.setHorizontalStretch(0);
    sizePolicy.setVerticalStretch(0);
    sizePolicy.setHeightForWidth(Spielfeld->sizePolicy().hasHeightForWidth());
    Spielfeld->setSizePolicy(sizePolicy);
    Spielfeld->setFrameShape(QFrame::Panel);
    Spielfeld->setFrameShadow(QFrame::Raised);
    Spielfeld->setLineWidth(1);
    gridLayout_7 = new QGridLayout(Spielfeld);
    gridLayout_7->setSpacing(0);
    gridLayout_7->setMargin(0);
    gridLayout_7->setObjectName(QString::fromUtf8("gridLayout_7"));
    soccerView = new SoccerView(drawMutex);
    soccerView->setObjectName(QString::fromUtf8("soccerView"));
    soccerView->setEnabled(true);

    gridLayout_7->addWidget(soccerView, 1, 0, 1, 1);

    gridLayout->addWidget(Spielfeld, 0, 0, 1, 1);
    this->setCentralWidget(centralwidget);

    logControl = new QDockWidget(this);
    logControl->setObjectName(QString::fromUtf8("logControl"));
    logControl->setEnabled(true);
    logControl->setMinimumSize(QSize(79, 150));
    logControl->setFeatures(QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable);
    logControl->setAllowedAreas(Qt::BottomDockWidgetArea);
    logControlWidget = new QWidget();
    logControlWidget->setObjectName(QString::fromUtf8("logControlWidget"));
    horizontalSlider = new QSlider(logControlWidget);
    horizontalSlider->setObjectName(QString::fromUtf8("horizontalSlider"));
    horizontalSlider->setGeometry(QRect(0, 0, 631, 22));
    horizontalSlider->setMaximum(1800);
    horizontalSlider->setPageStep(60);
    horizontalSlider->setOrientation(Qt::Horizontal);
    horizontalSlider->setTickPosition(QSlider::TicksAbove);
    horizontalSlider->setTickInterval(300);
    log_backward = new QPushButton(logControlWidget);
    log_backward->setObjectName(QString::fromUtf8("log_backward"));
    log_backward->setGeometry(QRect(0, 30, 150, 25));
    log_pause = new QPushButton(logControlWidget);
    log_pause->setObjectName(QString::fromUtf8("log_pause"));
    log_pause->setGeometry(QRect(160, 30, 150, 25));
    log_forward = new QPushButton(logControlWidget);
    log_forward->setObjectName(QString::fromUtf8("log_forward"));
    log_forward->setGeometry(QRect(320, 30, 150, 25));
    log_play = new QPushButton(logControlWidget);
    log_play->setObjectName(QString::fromUtf8("log_play"));
    log_play->setGeometry(QRect(480, 30, 150, 25));
    log_slower = new QPushButton(logControlWidget);
    log_slower->setObjectName(QString::fromUtf8("log_slower"));
    log_slower->setGeometry(QRect(0, 60, 150, 25));
    log_speed = new QLabel(logControlWidget);
    log_speed->setObjectName(QString::fromUtf8("log_speed"));
    log_speed->setGeometry(QRect(160, 60, 150, 25));
    log_speed->setAlignment(Qt::AlignCenter);
    log_faster = new QPushButton(logControlWidget);
    log_faster->setObjectName(QString::fromUtf8("log_faster"));
    log_faster->setGeometry(QRect(320, 60, 150, 25));
    log_frame_back = new QPushButton(logControlWidget);
    log_frame_back->setObjectName(QString::fromUtf8("log_frame_back"));
    log_frame_back->setGeometry(QRect(0, 90, 150, 25));
    log_frameNumber = new QLCDNumber(logControlWidget);
    log_frameNumber->setObjectName(QString::fromUtf8("log_frameNumber"));
    log_frameNumber->setGeometry(QRect(160, 90, 150, 25));
    log_frameNumber->setNumDigits(7);
    log_frameNumber->setSegmentStyle(QLCDNumber::Flat);
    log_frameNumber->setProperty("intValue", QVariant(0));
    log_frame_forward = new QPushButton(logControlWidget);
    log_frame_forward->setObjectName(QString::fromUtf8("log_frame_forward"));
    log_frame_forward->setGeometry(QRect(320, 90, 150, 25));
    log_totalFrames = new QLCDNumber(logControlWidget);
    log_totalFrames->setObjectName(QString::fromUtf8("log_totalFrames"));
    log_totalFrames->setGeometry(QRect(480, 90, 150, 25));
    log_totalFrames->setAutoFillBackground(false);
    log_totalFrames->setSmallDecimalPoint(false);
    log_totalFrames->setNumDigits(7);
    log_totalFrames->setSegmentStyle(QLCDNumber::Flat);
    logControl->setWidget(logControlWidget);
    this->addDockWidget(static_cast<Qt::DockWidgetArea>(8), logControl);

    logControl->setWindowTitle(QApplication::translate("GuiControls", "LogControl", 0, QApplication::UnicodeUTF8));
    log_backward->setText(QApplication::translate("GuiControls", "backward", 0, QApplication::UnicodeUTF8));
    log_pause->setText(QApplication::translate("GuiControls", "pause", 0, QApplication::UnicodeUTF8));
    log_forward->setText(QApplication::translate("GuiControls", "forward", 0, QApplication::UnicodeUTF8));
    log_play->setText(QApplication::translate("GuiControls", "play", 0, QApplication::UnicodeUTF8));
    log_slower->setText(QApplication::translate("GuiControls", "slower", 0, QApplication::UnicodeUTF8));
    log_speed->setText(QApplication::translate("GuiControls", "Speed", 0, QApplication::UnicodeUTF8));
    log_faster->setText(QApplication::translate("GuiControls", "faster", 0, QApplication::UnicodeUTF8));
    log_frame_back->setText(QApplication::translate("GuiControls", "frame--", 0, QApplication::UnicodeUTF8));
    log_frame_forward->setText(QApplication::translate("GuiControls", "frame++", 0, QApplication::UnicodeUTF8));

    logControl->hide();
    thread = new ViewUpdateThread(soccerView, drawMutex);

    //connect all SLOTs and SIGNALs
    //Slider control
    connect(thread, SIGNAL(initializeSlider(int,int,int,int,int)), this, SLOT(initializeSlider(int, int, int, int, int)));
    connect(thread, SIGNAL(update_frame(int)), horizontalSlider,         SLOT(setValue(int)));
    connect(horizontalSlider, SIGNAL(valueChanged(int)), thread->log_control, SLOT(goto_frame(int)));
    connect(horizontalSlider, SIGNAL(sliderPressed()),   thread->log_control, SLOT(log_pause()));
    connect(horizontalSlider, SIGNAL(sliderReleased()),  thread->log_control, SLOT(log_play()));

    //Buttons for logfile control
    connect(log_forward,       SIGNAL(clicked()), thread->log_control, SLOT(log_forward()));
    connect(log_play,          SIGNAL(clicked()), thread->log_control, SLOT(log_play()));
    connect(log_backward,      SIGNAL(clicked()), thread->log_control, SLOT(log_backward()));
    connect(log_pause,         SIGNAL(clicked()), thread->log_control, SLOT(log_pause()));
    connect(log_faster,        SIGNAL(clicked()), thread->log_control, SLOT(log_faster()));
    connect(log_slower,        SIGNAL(clicked()), thread->log_control, SLOT(log_slower()));
    connect(log_frame_back,    SIGNAL(clicked()), thread->log_control, SLOT(log_frame_back()));
    connect(log_frame_forward, SIGNAL(clicked()), thread->log_control, SLOT(log_frame_forward()));

    //Log Control
    connect(thread, SIGNAL(showLogControl(bool)), logControl, SLOT(setVisible(bool)));

    //QLCDNumber control
    connect(thread, SIGNAL(update_frame(int)), log_frameNumber, SLOT(display(int)));
    connect(thread, SIGNAL(log_size(int)),     log_totalFrames, SLOT(display(int)));
    connect(thread->log_control, SIGNAL(update_speed(QString)), log_speed, SLOT(setText(QString)));

    thread->start(QThread::NormalPriority);

    //initialisation for nice start
    for(int i = 0; i < 14; i++)
    {
        soccerView->initView();
        soccerView->updateView();
    }
}
Ejemplo n.º 11
0
Archivo: main.c Proyecto: needs/anko
int main(int argc, char **argv)
{
	world_t world;
	game_t game;
	double last_time = 0;
	double current_time = 0;
	float deltatime = 0;
	float sleep_time;

	if (config_from_file("anko.cfg", 1) == 2)
		return EXIT_FAILURE;
	if (config_from_args(argc, argv))
		return EXIT_FAILURE;

	if (!init())
		goto err_init;
	if (!new_game(&game, config.board_width, config.board_height, &config.gen_params, config.sim_speed * 1000))
		goto err_game;
	if (!create_world(&world, &game))
		goto err_world;
	if ((current_ui = init_ui_game(&world)) == NULL)
		goto err_ui;

	world_set_active_player(&world, add_player(&game, TEAM_BURNER));
	events_link_frame(&current_ui); // link window event to game ui frame
	glClearColor(0, 0, 0, 1);

	last_time = 0;
	while(!glfwWindowShouldClose(window)) {
	    current_time = glfwGetTime();
		deltatime = current_time - last_time;
		update_speed(deltatime);
		glfwPollEvents();

		// Update
		update_ui(current_ui, deltatime);
		update_world(&world);
		if (update_game(&game, deltatime * 1000))
			refresh_world(&world);
		if(should_quit)
			glfwSetWindowShouldClose(window, GL_TRUE);

		// Rendering
		glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
		draw_ui(current_ui);
		font_swap_buffers();
		glfwSwapBuffers(window);

		// Update speed and sleep if necessary
		last_time = current_time;
		sleep_time = (current_time + MAX_MSPF - glfwGetTime()) * 1000 * 1000;
		if(sleep_time > 0)
			usleep(sleep_time);
	}

	destroy_ui(current_ui);
	game_over(&game);
	end_of_the_world(&world); // Tin tin tin
	terminate();

	return EXIT_SUCCESS;
err_ui:
	end_of_the_world(&world);
err_world:
	game_over(&game);
err_game:
	terminate();
err_init:
	return EXIT_FAILURE;
}
Ejemplo n.º 12
0
// Initialization and runtime control
static int control(struct af_instance *af, int cmd, void *arg)
{
    af_scaletempo_t *s = af->priv;
    switch (cmd) {
    case AF_CONTROL_REINIT: {
        struct mp_audio *data = (struct mp_audio *)arg;
        float srate  = data->rate / 1000.0;
        int nch = data->nch;
        int use_int = 0;

        mp_audio_force_interleaved_format(data);
        mp_audio_copy_config(af->data, data);

        if (data->format == AF_FORMAT_S16) {
            use_int = 1;
        } else {
            mp_audio_set_format(af->data, AF_FORMAT_FLOAT);
        }
        int bps = af->data->bps;

        s->frames_stride        = srate * s->ms_stride;
        s->bytes_stride         = s->frames_stride * bps * nch;
        af->delay = 0;

        update_speed(af, s->speed);

        int frames_overlap = s->frames_stride * s->percent_overlap;
        if (frames_overlap <= 0) {
            s->bytes_standing   = s->bytes_stride;
            s->samples_standing = s->bytes_standing / bps;
            s->output_overlap   = NULL;
            s->bytes_overlap    = 0;
        } else {
            s->samples_overlap  = frames_overlap * nch;
            s->bytes_overlap    = frames_overlap * nch * bps;
            s->bytes_standing   = s->bytes_stride - s->bytes_overlap;
            s->samples_standing = s->bytes_standing / bps;
            s->buf_overlap      = realloc(s->buf_overlap, s->bytes_overlap);
            s->table_blend      = realloc(s->table_blend, s->bytes_overlap * 4);
            if (!s->buf_overlap || !s->table_blend) {
                MP_FATAL(af, "Out of memory\n");
                return AF_ERROR;
            }
            memset(s->buf_overlap, 0, s->bytes_overlap);
            if (use_int) {
                int32_t *pb = s->table_blend;
                int64_t blend = 0;
                for (int i = 0; i < frames_overlap; i++) {
                    int32_t v = blend / frames_overlap;
                    for (int j = 0; j < nch; j++)
                        *pb++ = v;
                    blend += 65536; // 2^16
                }
                s->output_overlap = output_overlap_s16;
            } else {
                float *pb = s->table_blend;
                for (int i = 0; i < frames_overlap; i++) {
                    float v = i / (float)frames_overlap;
                    for (int j = 0; j < nch; j++)
                        *pb++ = v;
                }
                s->output_overlap = output_overlap_float;
            }
        }

        s->frames_search = (frames_overlap > 1) ? srate * s->ms_search : 0;
        if (s->frames_search <= 0)
            s->best_overlap_offset = NULL;
        else {
            if (use_int) {
                int64_t t = frames_overlap;
                int32_t n = 8589934588LL / (t * t); // 4 * (2^31 - 1) / t^2
                s->buf_pre_corr = realloc(s->buf_pre_corr,
                                          s->bytes_overlap * 2 + UNROLL_PADDING);
                s->table_window = realloc(s->table_window,
                                          s->bytes_overlap * 2 - nch * bps * 2);
                if (!s->buf_pre_corr || !s->table_window) {
                    MP_FATAL(af, "Out of memory\n");
                    return AF_ERROR;
                }
                memset((char *)s->buf_pre_corr + s->bytes_overlap * 2, 0,
                       UNROLL_PADDING);
                int32_t *pw = s->table_window;
                for (int i = 1; i < frames_overlap; i++) {
                    int32_t v = (i * (t - i) * n) >> 15;
                    for (int j = 0; j < nch; j++)
                        *pw++ = v;
                }
                s->best_overlap_offset = best_overlap_offset_s16;
            } else {
                s->buf_pre_corr = realloc(s->buf_pre_corr, s->bytes_overlap);
                s->table_window = realloc(s->table_window,
                                          s->bytes_overlap - nch * bps);
                if (!s->buf_pre_corr || !s->table_window) {
                    MP_FATAL(af, "Out of memory\n");
                    return AF_ERROR;
                }
                float *pw = s->table_window;
                for (int i = 1; i < frames_overlap; i++) {
                    float v = i * (frames_overlap - i);
                    for (int j = 0; j < nch; j++)
                        *pw++ = v;
                }
                s->best_overlap_offset = best_overlap_offset_float;
            }
        }

        s->bytes_per_frame = bps * nch;
        s->num_channels    = nch;

        s->bytes_queue = (s->frames_search + s->frames_stride + frames_overlap)
                         * bps * nch;
        s->buf_queue = realloc(s->buf_queue, s->bytes_queue + UNROLL_PADDING);
        if (!s->buf_queue) {
            MP_FATAL(af, "Out of memory\n");
            return AF_ERROR;
        }

        s->bytes_queued = 0;
        s->bytes_to_slide = 0;

        MP_DBG(af, ""
               "%.2f stride_in, %i stride_out, %i standing, "
               "%i overlap, %i search, %i queue, %s mode\n",
               s->frames_stride_scaled,
               (int)(s->bytes_stride / nch / bps),
               (int)(s->bytes_standing / nch / bps),
               (int)(s->bytes_overlap / nch / bps),
               s->frames_search,
               (int)(s->bytes_queue / nch / bps),
               (use_int ? "s16" : "float"));

        return af_test_output(af, (struct mp_audio *)arg);
    }
    case AF_CONTROL_SET_PLAYBACK_SPEED: {
        double speed = *(double *)arg;
        if (s->speed_opt & SCALE_TEMPO) {
            if (s->speed_opt & SCALE_PITCH)
                break;
            update_speed(af, speed);
        } else if (s->speed_opt & SCALE_PITCH) {
            update_speed(af, speed);
            break; // do not signal OK
        }
        return AF_OK;
    }
    case AF_CONTROL_RESET:
        s->bytes_queued = 0;
        s->bytes_to_slide = 0;
        s->frames_stride_error = 0;
        memset(s->buf_overlap, 0, s->bytes_overlap);
    }