示例#1
0
t_cylinder	*get_cylinder(int fd)
{
	int			r;
	char		*line;
	t_cylinder	*c;

	c = new_cylinder(NULL, 0, NULL, NULL);
	while ((r = get_next_line(fd, &line)) > 0 && ft_strcmp(line, "----------"))
	{
		if (!ft_strcmp("p1:", line))
			c->center = get_vector(fd);
		if (!ft_strcmp("p2:", line))
			c->upper = get_vector(fd);
		if (!ft_strcmp("radius:", line))
		{
			r = get_next_line(fd, &line);
			c->radius = ft_atodouble(&line);
		}
		if (!ft_strcmp("color:", line))
			c->color = get_color(fd);
		if (!ft_strcmp("axis:", line))
			c->axis = normalize(get_vector(fd));
	}
	if (r == -1)
		exit(-1);
	return (c);
}
示例#2
0
/// Evaluates a expression using these templates.
///
/// An expression is a query on the current templates to fetch a particular
/// value.  The value is always returned as a string, as this is how templates
/// are internally stored.
///
/// \param expression The expression to evaluate.  This should not include any
///     of the delimiters used in the user input, as otherwise the expression
///     will not be evaluated properly.
///
/// \return The result of the expression evaluation as a string.
///
/// \throw text::syntax_error If there is any problem while evaluating the
///     expression.
std::string
text::templates_def::evaluate(const std::string& expression) const
{
    const std::string::size_type paren_open = expression.find('(');
    if (paren_open == std::string::npos) {
        return get_variable(expression);
    } else {
        const std::string::size_type paren_close = expression.find(
            ')', paren_open);
        if (paren_close == std::string::npos)
            throw text::syntax_error(F("Expected ')' in expression '%s')") %
                                     expression);
        if (paren_close != expression.length() - 1)
            throw text::syntax_error(F("Unexpected text found after ')' in "
                                       "expression '%s'") % expression);

        const std::string arg0 = expression.substr(0, paren_open);
        const std::string arg1 = expression.substr(
            paren_open + 1, paren_close - paren_open - 1);
        if (arg0 == "defined") {
            return exists(arg1) ? "true" : "false";
        } else if (arg0 == "length") {
            return F("%s") % get_vector(arg1).size();
        } else {
            return get_vector(arg0, arg1);
        }
    }
}
示例#3
0
文件: camera.c 项目: SimonBoeuf/RT
t_camera	*get_camera(int fd)
{
	int			r;
	t_camera	*c;
	char		*line;
	t_vect		*diff_btw;
	t_vect		*look_at;

	c = new_camera(NULL, NULL, NULL, NULL);
	while ((r = get_next_line(fd, &line)) > 0 && ft_strcmp(line, "----------"))
	{
		if (!ft_strcmp("pos:", line))
			c->campos = get_vector(fd);
		if (!ft_strcmp("dir:", line))
			look_at = get_vector(fd);
	}
	if (r == -1)
		exit(-1);
	diff_btw = new_vector(c->campos->x - look_at->x,
							c->campos->y - look_at->y,
							c->campos->z - look_at->z);
	c->camdir = normalize(negative(diff_btw));
	c->camright = normalize(cross_product(new_vector(0, 1, 0), c->camdir));
	c->camdown = cross_product(c->camright, c->camdir);
	return (c);
}
示例#4
0
void sphere_to_rect_collision(object * ball, object * box) {

    matrix faces = *(box->mat);
    struct point p1, p2, p3, int_pt;
    vector nml, ray_dir, plane_pt, ray_pt, int_vec, v1, v2;
    int i;
    double t;

    /*
     * Calculate time at which ray from radius of circle intersects
     * with triangle face.  Make sure that time is within correct range.
     */
    for (i = 6; i < faces.width; i += 3) {
        p1.x = faces.mat[i - 2][0];
        p1.y = faces.mat[i - 2][1];
        p1.z = faces.mat[i - 2][2];
        p2.x = faces.mat[i - 1][0];
        p2.y = faces.mat[i - 1][1];
        p2.z = faces.mat[i - 1][2];
        p3.x = faces.mat[i][0];
        p3.y = faces.mat[i][1];
        p3.z = faces.mat[i][2];

        v1 = get_vector(p1, p2);
        v2 = get_vector(p3, p2);

        nml = cross_product(v1, v2);
        normalize(&nml);

        ray_dir = nml;
        ray_dir.x *= -1;
        ray_dir.y *= -1;
        ray_dir.z *= -1;

        plane_pt.x = p1.x;
        plane_pt.y = p1.y;
        plane_pt.z = p1.z;

        ray_pt.x = ball->x;
        ray_pt.y = ball->y;
        ray_pt.z = ball->z;

        t = (dot_product(nml, plane_pt) - dot_product(nml, ray_pt)) / (dot_product(nml, ray_dir));

        int_vec.x = t * ray_dir.x;
        int_vec.y = t * ray_dir.y;
        int_vec.z = t * ray_dir.z;

        if(t < 0 || magnitude(int_vec) > ball->r)
            continue;

        ball->vx *= -1;
        ball->vy *= -1;
        ball->vz *= -1;
        break;
    }
    return;
}
示例#5
0
文件: g726_tests.c 项目: vir/spandsp
static int get_test_vector(const char *file, uint8_t buf[], int max_len)
{
    int octets;
    int i;
    int sum;
    FILE *infile;

    if ((infile = fopen(file, "r")) == NULL)
    {
        fprintf(stderr, "    Failed to open '%s'\n", file);
        exit(2);
    }
    octets = 0;
    while ((i = get_vector(infile, buf + octets)) > 0)
        octets += i;
    fclose(infile);
    /* The last octet is a sumcheck, so the real data octets are one less than
       the total we have */
    octets--;
    /* Test the checksum */
    for (sum = i = 0;  i < octets;  i++)
        sum += buf[i];
    if (sum%255 != (int) buf[i])
    {
        fprintf(stderr, "    Sumcheck failed in '%s' - %x %x\n", file, sum%255, buf[i]);
        exit(2);
    }
    return octets;
}
示例#6
0
			void move()
			{
				set_vector(trans * get_vector());
				character::move();
				if(!get_position().is_inside(paint::rect(-5, -5, 805, 605)))
					set_active(false);
			}
示例#7
0
文件: bullet.cpp 项目: BigDwarf/ennui
static btTransform get_transform(ErlNifEnv *env, const ERL_NIF_TERM arg) {
    double x,y,z,w;
    const ERL_NIF_TERM *tuple;
    int arity;
    enif_get_tuple(env, arg, &arity, &tuple);
    return btTransform(get_quaternion(env,tuple[0]),get_vector(env,tuple[1]));
}
void black_line() {
L_velocity = VELOCITY_MAX; 
R_velocity = VELOCITY_MAX;
get_vector();
lcd_cursor(1,1);
lcd_string("Straight");
forward();
if (Center_white_line > THRESHOLD) {
if (Left_white_line > THRESHOLD)
L_velocity = VELOCITY_MIN;
else if (Right_white_line > THRESHOLD)
R_velocity = VELOCITY_MIN;
}
else {
if (Left_white_line > THRESHOLD)
L_velocity = 20;
else if (Right_white_line > THRESHOLD)
R_velocity = 20;
}
velocity(L_velocity, R_velocity);
if (Center_white_line < THRESHOLD && Left_white_line < THRESHOLD && Right_white_line < THRESHOLD) {
forward();
stop();
}
}
示例#9
0
inline Vec3f GameTerrain::calc_normal(int x, int y, unsigned char *data, int width, int height, int pitch)
{
	Vec3f vectors[9];
	for (int yy = 0; yy < 3; yy++)
	{
		for (int xx = 0; xx < 3; xx++)
		{
			vectors[xx+yy*3] = get_vector(x, y, xx-1, yy-1, data, width, height, pitch);
		}
	}

	Vec3f normals[8] =
	{
		Vec3f::cross(vectors[1], vectors[0]),
		Vec3f::cross(vectors[2], vectors[1]),
		Vec3f::cross(vectors[5], vectors[2]),
		Vec3f::cross(vectors[8], vectors[5]),
		Vec3f::cross(vectors[7], vectors[8]),
		Vec3f::cross(vectors[6], vectors[7]),
		Vec3f::cross(vectors[3], vectors[6]),
		Vec3f::cross(vectors[0], vectors[3])
	};
	for (int i = 0; i < 8; i++)
		normals[i].normalize();

	Vec3f normal(0.0f, 0.0f, 0.0f);
	for (int i = 0; i < 8; i++)
		normal += normals[i];
	normal /= 8.0f;
	normal.normalize();
	return normal;
}
示例#10
0
void solve_triangle_eq_omp()
{
	char *results_file = "solve_triangle_eq_omp.txt";
	FILE *res;
	if((res=fopen(results_file, "w"))==NULL)
	{
		printf("Can't open file %s.\n", results_file);
		exit(1);
	}
	for(int i = 10; i < ROW; i*=10)
	{
		double **A = get_matrix(i,i);
		double 	*X = get_vector(i,i);
		double start = omp_get_wtime();
		#pragma omp parallel for collapse(2)
		for (int s=i-1; s>=0; s--) 
		{
			X[s] = A[s][i]/A[s][s];
			for (int k=s-1;k>=0; k--)
			    A[k][i] -= A[k][s] * X[s];
		}
		double end = omp_get_wtime();
		fprintf(res, "%lf\n", end-start);
		free(X);
		for(int s = 0; s < i; s++)
			free(A[s]);
		free(A);
	}
	fclose(res);
}
示例#11
0
文件: bullet.cpp 项目: BigDwarf/ennui
static ERL_NIF_TERM btDynamicsWorld_setGravity(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]) {
    ((btDynamicsWorld*)unwrap_pointer(
        env,
        btDynamicsWorld_resource,
        argv[0]
    ))->setGravity(get_vector(env,argv[1]));
    return enif_make_atom(env, "ok");
}
示例#12
0
文件: eval.c 项目: jshou/matasano
float cosin_sim_freq_eval(char *message, int length) {
  int n = 1;
  int combinations = pow(26, n);
  float vector[combinations + 1];
  for (int i = 0; i < combinations; i++) { vector[i] = 0.0; }

  get_vector(message, length, vector, combinations + 1);
  return cosin_sim(english, vector, combinations + 1);
}
示例#13
0
//----------------------------------------------------------------------
//
//      add entrypoints to the database and name vectors
//
static bool add_entry_points( linput_t *li )
{
    ea_t ea;

    ea = get_vector( NMI_VECTOR_START_ADDRESS );
    add_entry( ea, ea, "NMI_routine", true );
    name_vector( NMI_VECTOR_START_ADDRESS, "NMI_vector" );

    ea = get_vector( RESET_VECTOR_START_ADDRESS );
    add_entry( ea, ea, "RESET_routine", true );
    name_vector( RESET_VECTOR_START_ADDRESS, "RESET_vector" );

    ea = get_vector( IRQ_VECTOR_START_ADDRESS );
    add_entry( ea, ea, "IRQ_routine", true );
    name_vector( IRQ_VECTOR_START_ADDRESS, "IRQ_vector" );

    return true;
}
示例#14
0
VariantBuilder& VariantBuilder::set_genotypes(const VariantBuilderMultiSampleVector<int32_t>& genotypes_for_all_samples) {
  // Since the user has chosen to pass by lvalue, make a copy before encoding the genotypes
  auto encoded_genotypes = genotypes_for_all_samples;
  Genotype::encode_genotypes(encoded_genotypes);

  // We've made a copy, so we can move the copy into the storage layer
  m_individual_region.bulk_set_genotype_field(m_individual_region.gt_index(), move(encoded_genotypes.get_vector()));
  return *this;
}
示例#15
0
//----------------------------------------------------------------------
//
//      set entrypoint, minEA, maxEA, start_cs and filetype
//
static void set_ida_export_data( void )
{
    // set entrypoint
    inf.startIP = inf.beginEA = get_vector( RESET_VECTOR_START_ADDRESS );
    
    // set minEA, maxEA, etc.
    inf.start_cs = 0;
    inf.minEA = RAM_START_ADDRESS;
    inf.maxEA = ROM_START_ADDRESS + ROM_SIZE;
}
示例#16
0
文件: bullet.cpp 项目: BigDwarf/ennui
static ERL_NIF_TERM new_btRigidBodyConstructionInfo(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]) {
    double mass;
    btVector3 inertia = get_vector(env,argv[3]);
    enif_get_double(env, argv[0], &mass);
    return wrap_pointer(env,btRigidBodyConstructionInfo_resource, new btRigidBody::btRigidBodyConstructionInfo(
        mass,
        (btMotionState*)unwrap_pointer(env,btMotionState_resource,argv[1]),
        (btCollisionShape*)unwrap_pointer(env,btCollisionShape_resource,argv[2]),
        inertia
        ));
}
bool MeshImporter::is_flat_face(unsigned int *nind, COLLADAFW::MeshVertexData& nor, int count)
{
	float a[3], b[3];

	get_vector(a, nor, *nind, 3);
	normalize_v3(a);

	nind++;

	for (int i = 1; i < count; i++, nind++) {
		get_vector(b, nor, *nind, 3);
		normalize_v3(b);

		float dp = dot_v3v3(a, b);

		if (dp < 0.99999f || dp > 1.00001f)
			return false;
	}

	return true;
}
示例#18
0
void solve_triangle_eq_mkl()
{
	char *results_file = "solve_triangle_eq_mkl.txt";
	FILE *res;
	if((res=fopen(results_file, "w"))==NULL)
	{
		printf("Can't open file %s.\n", results_file);
		exit(1);
	}
	for(int i = 10; i < ROW; i*=10)
	{
		double *A = get_vector(i*i,i);
		double *X = get_vector(i,i);
		double start = omp_get_wtime();
		cblas_dtrsv(CblasRowMajor, CblasUpper, CblasNoTrans, CblasNonUnit, i, A, i, X, 1);
		double end = omp_get_wtime();
		fprintf(res, "%lf\n", end-start);
		free(X);free(A);
	}
	fclose(res);
}
示例#19
0
文件: ejercicio6.c 项目: Miguelrn/MPI
int main(int argc, char *argv[]){
	
	srand (time(NULL));
	int i, j, z;
	int tamanio = 400;

	float* vectorA;
	float* vectorB;
	int resultado = 0;
	double startwtime, endwtime;
	int myrank, size;

	MPI_Init(&argc, &argv);
	MPI_Comm_rank(MPI_COMM_WORLD, &myrank);
	MPI_Comm_size(MPI_COMM_WORLD, &size);

	vectorA = get_vector(tamanio);
	vectorB = get_vector(tamanio);

	if(tamanio <= 15) { //Mostramos hasta vectores de 15 elementos	
		print_vector ( vectorA, tamanio);
		print_vector ( vectorB, tamanio);
	}

	startwtime = MPI_Wtime();
	
	for(i = 0; i < tamanio; i++)//cada elemento del vector
    {
    	resultado += vectorA[i]*vectorB[i];     
   	}

	endwtime = MPI_Wtime();
	printf("Tiempo de ejecucion: %f, usando %d+1 maquinas\n", endwtime - startwtime, size - 1);	

	printf("\nEl resultado del producto escalar de los vectores es: %d\n\n", resultado);	  
	MPI_Finalize();	

	return 0;

}
int if_intersection () {
get_vector();
if (Center_white_line > THRESHOLD && Left_white_line > THRESHOLD && Right_white_line > THRESHOLD) {
forward();
//velocity(VELOCITY_MIN, VELOCITY_MIN);
lcd_cursor(1,1);
lcd_string("Intersection");
stop();
return 1;

}
return 0;
}
示例#21
0
void cmdBoot(char *buf)
{
	int n = get_arg(buf);	//引数の数.
	int adr = 0;
	int vect= 0;
	if(n != 0) {
		adr = arg_hex[0];
	}
	vect = get_vector(adr);

	printf("reset vect=0x%x\n",vect);

	UsbBootTarget(vect,1);
}
示例#22
0
inline bool line3<T>::is_point_on_line(const vec3<T>& point) const
{
	/*the point is on the line if there exists some t such that
	start + getVector()*t==point =>
	getVector()*t==point-start =>
	getVector().normalize()==(point-start).normalize()
	we also need to account for a negative T, however
	*/
	vec3<T> vec1(get_vector().normalize());
	vec3<T> vec2((point - start).normalize());

	bool onInfiniteLine = equals(vec1, vec2) || equals(vec1, -vec2);	
	return onInfiniteLine;	
}
示例#23
0
文件: tools.c 项目: FHedin/mc_LJ
/**
 * @brief Generates an initial cluster of atoms for starting simulation
 * 
 * @param at Atom array
 * @param dat Common data for simulation
 * @param from first atom of the list on which to work
 * @param to last atom of the list on which to work
 * @param mode Building mode : -1 sets coordinates to 9999.9 (infinity), 0 sets all atom at the origin, 1 sets atom at a random position (with constraints)
 */
void build_cluster(ATOM at[], DATA *dat, uint32_t from, uint32_t to, int32_t mode)
{
    uint32_t i = 0 ;
    
//     fprintf(stdout,"Entered in build cluster : from %d to %d mode %d\n",from,to,mode);
//     fflush(stdout);
                    
    if (mode==-1)	//infinite initialisation mode
    {
        for (i=from; i<to; i++)
            at[i].x=at[i].y=at[i].z=9999.9;
    }
    else if (mode==0)	//zero everywhere : all at origin
    {
        for (i=from; i<to; i++)
            at[i].x=at[i].y=at[i].z=0.0;
    }
    else if (mode==1)	//random mode
    {
        double randvec[3] = {0.0} ;
//        double rtot=0.0;
//
//        for (i=0; i<dat->natom; i++)
//            rtot += at[i].ljp.sig;
//        
//        rtot /= (double)dat->natom;
//        rtot = (double)dat->natom*4.0*3.14159*X3(rtot)/3.0;
//        dat->inid = pow(3.0*rtot/(4.0*3.14159),0.333);
        dat->inid = dat->natom/8.0;
        
        for (i=from; i<to; i++)
        {
            
//             fprintf(stdout,"loop %d\n",i);
//             fflush(stdout);
            
            do
            {
                get_vector(dat,-1,randvec);
                at[i].x = dat->inid*randvec[0];
                at[i].y = dat->inid*randvec[1];
                at[i].z = dat->inid*randvec[2];
            }
            while( (X2(at[i].x)+X2(at[i].y)+X2(at[i].z))>X2(dat->inid) || no_conflict(at,i) != NO_CONFLICT );
        }
    }
}
void MeshImporter::read_vertices(COLLADAFW::Mesh *mesh, Mesh *me)
{
	// vertices
	COLLADAFW::MeshVertexData& pos = mesh->getPositions();
	int stride = pos.getStride(0);
	if (stride == 0) stride = 3;
	
	me->totvert = mesh->getPositions().getFloatValues()->getCount() / stride;
	me->mvert = (MVert *)CustomData_add_layer(&me->vdata, CD_MVERT, CD_CALLOC, NULL, me->totvert);

	MVert *mvert;
	int i;

	for (i = 0, mvert = me->mvert; i < me->totvert; i++, mvert++) {
		get_vector(mvert->co, pos, i, stride);
	}
}
void turn_bot(char ch) {
get_vector();
velocity(VELOCITY_MIN,VELOCITY_MIN);
/*
if (ch == 'l') {
velocity(VELOCITY_MAX,VELOCITY_MIN);
_delay_ms(2000);
}
else if (ch == 'r') {
velocity(VELOCITY_MIN,VELOCITY_MAX);
_delay_ms(2000);
}
*/
stop();
_delay_ms(1000);
if (ch == 'l') 
left_degrees(90); 
else 
right_degrees(90); 
/*
while (1) {
get_vector();

lcd_cursor(1,1);
lcd_string("LorR           ");
L_velocity = VELOCITY_MIN; 
R_velocity = VELOCITY_MIN;
if (Center_white_line > THRESHOLD) {
if (Left_white_line > THRESHOLD)
L_velocity = VELOCITY_MIN;
else if (Right_white_line > THRESHOLD)
R_velocity = VELOCITY_MIN;
}
else {
if (Left_white_line > THRESHOLD)
L_velocity = 20;
else if (Right_white_line > THRESHOLD)
R_velocity = 20;
}
velocity(L_velocity, R_velocity);
if (Center_white_line > THRESHOLD  && Left_white_line < THRESHOLD && Right_white_line < THRESHOLD) {
break;
}
}
*/
} 
示例#26
0
文件: main.c 项目: Elytum/Lemins
static void		remove_used(t_map *map)
{
	size_t		i;
	void		*tmp;

	tmp = map->working_list;
	map->working_list = map->list;
	map->list = tmp;
	map->list->len = 0;
	i = 0;
	while (i < map->working_list->len)
	{
		tmp = get_vector(*(map->working_list), i);
		if (!in_vector(*(map->solution), tmp))
			add_vector(map->list, tmp);
		++i;
	}
}
示例#27
0
/// Indexes a vector and gets the value.
///
/// \param name The name of the vector to index.
/// \param index_name The name of a variable representing the index to use.
///     This must be convertible to a natural.
///
/// \return The value of the vector at the given index.
///
/// \throw text::syntax_error If the vector does not existor if the index is out
///     of range.
const std::string&
text::templates_def::get_vector(const std::string& name,
                                const std::string& index_name) const
{
    const strings_vector& vector = get_vector(name);
    const std::string& index_str = get_variable(index_name);

    std::size_t index;
    try {
        index = text::to_type< std::size_t >(index_str);
    } catch (const text::syntax_error& e) {
        throw text::syntax_error(F("Index '%s' not an integer, value '%s'") %
                                 index_name % index_str);
    }
    if (index >= vector.size())
        throw text::syntax_error(F("Index '%s' out of range at position '%s'") %
                                 index_name % index);

    return vector[index];
}
示例#28
0
int		damier(t_vector3 eye, t_vector3 cam, t_best best)
{
  double	x;
  double	z;

  translate(&eye, best.obj.p, 1);
  rot_inv(&eye, best.obj.r);
  rot_inv(&cam, best.obj.r);
  scale(&cam, best.obj.s);
  best.inter = get_vector(cam, eye, best.k);
  translate(&(best.inter), best.obj.p, -1);
  if (best.inter.x < 0)
    best.inter.x -= 40;
  if (best.inter.z < 0)
    best.inter.z -= 40;
  x = (int)(abs(best.inter.x) % 80);
  z = (int)(abs(best.inter.z) % 80);
  if ((z <= 40 && x <= 40) || (z > 40 && x > 40))
    return (0xFFFFFF00);
  else
    return (0x00000000);
  return (best.color);
}
示例#29
0
t_cylinder	*get_cylinder(int fd)
{
	int			r;
	char		*line;
	t_vect		*center;
	double		radius;
	t_color		*color;

	while ((r = get_next_line(fd, &line)) > 0 && ft_strcmp(line, "----------"))
	{
		if (!ft_strcmp("pos:", line))
			center = get_vector(fd);
		if (!ft_strcmp("radius:", line))
		{
			r = get_next_line(fd, &line);
			radius = ft_atodouble(&line);
		}
		if (!ft_strcmp("color:", line))
			color = get_color(fd);
	}
	if (r == -1)
		exit(-1);
	return (new_cylinder(center, radius, color));
}
示例#30
0
void FadeCurve::process(AudioBus *bus, nframes_t nframes)
{

        if (is_bypassed()) {
		return;
	}
	
	
        audio_sample_t* mixdown[bus->get_channel_count()];
        int outputRate = audiodevice().get_sample_rate();
        uint framesToProcess = nframes;

        TimeRef trackStartLocation, trackEndLocation, mix_pos;
        TimeRef fadeRange = TimeRef(get_range());

        TimeRef transportLocation = m_session->get_transport_location();
        TimeRef upperRange = transportLocation + TimeRef(framesToProcess, outputRate);

	
	if (m_type == FadeIn) {
                trackStartLocation = m_clip->get_track_start_location();
        } else {
                trackStartLocation = m_clip->get_track_end_location() - fadeRange;
	}

        trackEndLocation = trackStartLocation + fadeRange;


        if ( (trackStartLocation < upperRange) && (trackEndLocation > transportLocation) ) {
                if (transportLocation < trackStartLocation) {
                        // Using to_frame() for both the m_trackStartLocation and transportLocation seems to round
                        // better then using (m_trackStartLocation - transportLocation).to_frame()
                        // TODO : find out why!
                        uint offset = (trackStartLocation).to_frame(outputRate) - transportLocation.to_frame(outputRate);
                        mix_pos = TimeRef();
//                        printf("offset %d\n", offset);

                        for (int chan=0; chan<bus->get_channel_count(); ++chan) {
                                audio_sample_t* buf = bus->get_buffer(chan, framesToProcess);
                                mixdown[chan] = buf + offset;
                        }
                        framesToProcess = framesToProcess - offset;
                } else {
                        mix_pos = (transportLocation - trackStartLocation);

                        for (int chan=0; chan<bus->get_channel_count(); ++chan) {
                                mixdown[chan] = bus->get_buffer(chan, framesToProcess);
                        }
                }
                if (trackEndLocation < upperRange) {
                        // Using to_frame() for both the upperRange and m_trackEndLocation seems to round
                        // better then using (upperRange - m_trackEndLocation).to_frame()
                        // TODO : find out why!
                        framesToProcess -= upperRange.to_frame(outputRate) - trackEndLocation.to_frame(outputRate);
// 			printf("if (m_trackEndLocation < upperRange): framesToProcess %d\n", framesToProcess);
                }
        } else {
                return;
        }


        upperRange = mix_pos + TimeRef(framesToProcess, outputRate);

        get_vector(mix_pos.universal_frame(), upperRange.universal_frame(), m_session->gainbuffer, framesToProcess);

        for (int chan=0; chan<bus->get_channel_count(); ++chan) {
                for (nframes_t frame = 0; frame < framesToProcess; ++frame) {
                        mixdown[chan][frame] *= m_session->gainbuffer[frame];
                }
        }
}