00001 /* 00002 * REAL2CPX.C 00003 * 00004 * Complex data generator script. 00005 * Propagates its input data unchanged on its first output. 00006 * Generates an identically sized zero-filled data buffer for the second 00007 * output. 00008 * Can be used to generate the complex input for the FFT script from 00009 * single channel real data. 00010 * Uses no context. 00011 */ 00012 #include "scripts.h" 00013 00014 void real2complex_script(void) 00015 { 00016 mgk_data_type type; 00017 float *data; 00018 printf("real2complex\n"); 00019 fflush(stdout); 00020 data = mgk_receive(0,&type); 00021 if(data && (type == (T_FLOAT | T_BUFFER))) { 00022 int i,size = mgk_buffer_size(data) / sizeof(float); 00023 float *zero = mgk_allocate_buffer((sizeof(float) * size),0); 00024 if(zero) { 00025 for(i = 0; i < size; i++) { 00026 zero[i] = 0.0f; 00027 } 00028 mgk_propagate(0,data,(T_FLOAT | T_BUFFER)); 00029 mgk_propagate(1,zero,(T_FLOAT | T_BUFFER)); 00030 } 00031 } 00032 } 00033