double buffer_sample_rate(t_symbol *buffer)
{
    void *ptr = ibuffer_get_ptr(buffer);

    if (ptr)
        return ibuffer_sample_rate(ptr);
    else
        return 0;
}
void ibufconcatenate_entry(t_ibufconcatenate *x, double start, double end)
{
	// Default sr to something sensible
	
    double sr = ibuffer_sample_rate(x->attachment->buffer_name);
	
	double *starts = x->attachment->starts;
	double *ends = x->attachment->ends;
	
	long samp_offset = x->attachment->samp_offset;
	long num_items = x->attachment->num_items;
	
	t_atom last_added_list[3];

	if (num_items >= MAX_ITEMS)
		return;
    
	// Store values
	
	starts[num_items] = start;
	ends[num_items] = end; 
		
	if ((long) (end * sr / 1000.0) > samp_offset)
		samp_offset = end * sr / 1000.0;
		
	x->attachment->num_items = num_items + 1;
	x->attachment->samp_offset = samp_offset;
	
	// Output
	
	atom_setlong(last_added_list, num_items + 1);
	atom_setfloat(last_added_list+1, starts[num_items]);
	atom_setfloat(last_added_list+2, ends[num_items]);
	
	outlet_list(x->last_added_out, 0, 3, last_added_list);
}