Ejemplo n.º 1
0
int main(int argc, char *argv[])
{
	unsigned short t = 1; 
	unsigned short n = 0;
	unsigned short bit = 0;
	unsigned short potPeriod = fs * POT_MS / 1000; 
	
	configure_shit();
	
  wait_wdclk_fall(); // to sync
	
	while(1)
	{
		if (read_pots(&t))
			t = potPeriod;
      
    adat_io(sampling, resolution);  

    mix_data(); // Launch thread to mix. Takes sampling time?
  }
	return 0;
}
int lp_ladspa_audio_ports::run_interlaced_buffer(float *buffer, int tot_len)
{
	if(pv_routing == MONO_NORMAL){
		// Copy interlaced to plugin input
		pv_in_data[0].set_data_copy(buffer, tot_len);
		if(connect_ports() < 0){
			std::cerr << "lp_ladspa_audio_ports::" << __FUNCTION__ << ": connect_ports failed\n";
			return -1;
		}
		pv_instances[0].run(tot_len);
		pv_out_data[0].get_data_copy(buffer, tot_len);
	}else if(pv_routing == MONO_HALF_USED){
		// Only use One I/O port, the others must simply benn allocated to run
		pv_in_data[0].set_data_copy(buffer, tot_len);
		if(connect_ports() < 0){
			std::cerr << "lp_ladspa_audio_ports::" << __FUNCTION__ << ": connect_ports failed\n";
			return -1;
		}
		pv_instances[0].run(tot_len);
		pv_out_data[0].get_data_copy(buffer, tot_len);
	}else if(pv_routing == MONO_1H_MERGE_OUTPUT){
		// Copy interlaced to plugin input
		pv_in_data[0].set_data_copy(buffer, tot_len);
		if(connect_ports() < 0){
			std::cerr << "lp_ladspa_audio_ports::" << __FUNCTION__ << ": connect_ports failed\n";
			return -1;
		}
		pv_instances[0].run(tot_len);
		// Mix the two outputs result to the passed buffer back
		mix_data(buffer, pv_out_data[0].data_ptr(), pv_out_data[1].data_ptr(), tot_len);
	}else if(pv_routing == MONO_1H_SPLIT_INPUT){
		// Copy interlaced to plugin input (same data to each)
		pv_in_data[0].set_data_copy(buffer, tot_len);
		pv_in_data[1].set_data_copy(buffer, tot_len);
		if(connect_ports() < 0){
			std::cerr << "lp_ladspa_audio_ports::" << __FUNCTION__ << ": connect_ports failed\n";
			return -1;
		}
		pv_instances[0].run(tot_len);
		pv_out_data[0].get_data_copy(buffer, tot_len);
	}else if(pv_routing == MONO_1H_NO_INPUT){
		// No input..
		if(connect_ports() < 0){
			std::cerr << "lp_ladspa_audio_ports::" << __FUNCTION__ << ": connect_ports failed\n";
			return -1;
		}
		pv_instances[0].run(tot_len);
		pv_out_data[0].get_data_copy(buffer, tot_len);
	}else if(pv_routing == MONO_1H_NO_INPUT_MERGE_OUTPUT){
		// No input..
		if(connect_ports() < 0){
			std::cerr << "lp_ladspa_audio_ports::" << __FUNCTION__ << ": connect_ports failed\n";
			return -1;
		}
		pv_instances[0].run(tot_len);
		mix_data(buffer, pv_out_data[0].data_ptr(), pv_out_data[1].data_ptr(), tot_len);
	}else if(pv_routing == STEREO_NORMAL){
		// Copy interlaced to plugin inputs
		pv_in_data[0].set_data_left_copy(buffer, tot_len);
		pv_in_data[1].set_data_right_copy(buffer, tot_len);
		if(connect_ports() < 0){
			std::cerr << "lp_ladspa_audio_ports::" << __FUNCTION__ << ": connect_ports failed\n";
			return -1;
		}
		pv_instances[0].run(tot_len/2);
		pv_out_data[0].get_data_left_copy(buffer, tot_len);
		pv_out_data[1].get_data_right_copy(buffer, tot_len);
	}else if(pv_routing == STEREO_2H){
		// Copy interlaced to plugin inputs
		pv_in_data[0].set_data_left_copy(buffer, tot_len);
		pv_in_data[0].set_data_right_copy(buffer, tot_len);
		if(connect_ports() < 0){
			std::cerr << "lp_ladspa_audio_ports::" << __FUNCTION__ << ": connect_ports failed\n";
			return -1;
		}
		pv_instances[0].run(tot_len/2);
		pv_instances[1].run(tot_len/2);
		pv_out_data[0].get_data_left_copy(buffer, tot_len);
		pv_out_data[0].get_data_right_copy(buffer, tot_len);
	}else if(pv_routing == STEREO_2H_MERGE_OUTPUT){
		// Copy interlaced to plugin inputs
		pv_in_data[0].set_data_left_copy(buffer, tot_len);
		pv_in_data[0].set_data_right_copy(buffer, tot_len);
		if(connect_ports() < 0){
			std::cerr << "lp_ladspa_audio_ports::" << __FUNCTION__ << ": connect_ports failed\n";
			return -1;
		}
		pv_instances[0].run(tot_len/2);
		pv_instances[1].run(tot_len/2);
		// Mix data 0 and 2, and store it temporary to passed buffer (half len)
		mix_data(buffer, pv_out_data[0].data_ptr(), pv_out_data[2].data_ptr(), tot_len/2);
		// Store buffer content to tmp 0
		pv_tmp_data[0].set_data_copy(buffer, tot_len/2);
		// The same with 1 and 3
		mix_data(buffer, pv_out_data[1].data_ptr(), pv_out_data[3].data_ptr(), tot_len/2);
		pv_tmp_data[1].set_data_copy(buffer, tot_len/2);
		// Copy tmp 1 and 2 to passed buffer - Ouf !
		pv_tmp_data[0].get_data_left_copy(buffer, tot_len);
		pv_tmp_data[0].get_data_right_copy(buffer, tot_len);
	}else{
		return -1;
	}

	return tot_len;
}