Exemplo n.º 1
0
void CPSampleManager::copy_to(CPSample_ID p_from,CPSample_ID &p_to) {
	
	ERR_FAIL_COND(!check( p_from ));

	
	if (p_to.is_null()) {
		
		p_to=create( is_16bits( p_from), is_stereo( p_from), get_size(p_from));
	} else {
		
		recreate( p_to, is_16bits( p_from), is_stereo( p_from), get_size(p_from));
		
	}
	
	int len=get_size( p_from );
	int ch=is_stereo( p_from ) ? 2 : 1;
	
	for (int c=0;c<ch;c++) {
		
		for (int i=0;i<len;i++) {
			
			int16_t s=get_data( p_from, i, c );
			set_data( p_to, i, s, c );
		}
	}
	
	set_loop_type( p_to, get_loop_type( p_from ) );
	set_loop_begin( p_to, get_loop_begin( p_from ) );
	set_loop_end( p_to, get_loop_end( p_from ) );
	set_c5_freq( p_to, get_c5_freq( p_from ) );
	
		
	
}
void SampleManager_MemPool::fix_loop_end(Sample_ID p_id) {
	/* Set the last frame to the begining of the loop, so interpolation works well */
	int ch=is_stereo( p_id) ?2:1;
	
	for (int i=0;i<ch;i++) {
		
		set_data( p_id, -1, 0 , i );
	}
	
	if (get_loop_type( p_id)!=LOOP_NONE && get_loop_end( p_id)==get_size( p_id) ) {
		
		
		if (get_loop_type( p_id)==LOOP_FORWARD) {
		
			for (int i=0;i<ch;i++) {
				
				set_data( p_id, get_size( p_id), get_data( p_id,  get_loop_begin( p_id) + 1, i ), i );
				set_data( p_id, get_size( p_id)+1, get_data( p_id,  get_loop_begin( p_id) + 1, i ), i );
			}
		} else {
			
			for (int i=0;i<ch;i++) {
				
				set_data( p_id, get_size( p_id), get_data( p_id,  get_loop_end( p_id) -1 , i ), i );
				set_data( p_id, get_size( p_id)+1, get_data( p_id,  get_loop_end( p_id) -1 , i ), i );
			}
			
			
		}

	} else {
		
		for (int i=0;i<ch;i++) {
			
			set_data( p_id, get_size( p_id), 0 , i );
			set_data( p_id, get_size( p_id)+1, 0 , i );
		}
		
	}
}