void ForceEAM::init_style()
{
  // convert read-in file(s) to arrays and spline them

  file2array();
  array2spline();
}
Beispiel #2
0
double durOfTone(int filenum,double startTime){
	
	int i;
	double toneLength = 0;
	double toneEnd = 0;
	
	char file_name[64] ;
	sprintf(file_name, "%dD", filenum) ;

	printf("\tLine counting file %s...", file_name);
	
	int mallocD;
	mallocD = filecount(file_name);
	printf("Done.\n");
	
	double* D;
	D = (double *)Malloc(mallocD * sizeof(double));
	
	printf("\tfile2array file %s...", file_name);
	
	file2array(file_name, D);
	
	printf("Done.\n");
	
	for(i =0;i<mallocD;i++)
		toneLength = toneLength + D[i];	

	Free(D);
	
	toneEnd = startTime + toneLength;
	
	return toneEnd;
}
Beispiel #3
0
/*
備忘錄
amount=1時 回傳和該neuro有關的所有資料
*/
int main() {
    int *neuroindex;
    int start, end, i, amount;
    char neuroListOri[22835][20], **neuroListCustom; //所有neuro, 被選擇的neuro
    char file_name[50], *pData;

    //----------使用者輸入----------
    printf("輸入起始ZONE編號 59為GOBAL(0~59):");
    scanf("%d", &start);
    do {
        printf("輸入結束ZONE編號(%d~59):",start);
        scanf("%d", &end);
    } while(start > end);
    printf("輸入檔案名稱(<50char):");
    scanf("%s", file_name);
    printf("輸入neuro數量:");
    scanf("%d", &amount);
    /*strcpy(file_name,"642ver.txt");
    amount = 642;*/
    //------------------------------

    //----------malloc----------
    printf("malloc start\n");
    //儲存來源檔案(neuro清單)中neuro名稱的二維字元陣列
    neuroListCustom = (char **)malloc(amount*sizeof(void *));
    for(i=0; i<amount; i++) neuroListCustom[i] = (char *)malloc(20*sizeof(char *));
    printf("malloc over\n");

    //儲存來源檔案(neuro清單)中neuro名稱對應的index
    neuroindex = (int *)malloc(amount*sizeof(int));
    printf("malloc over\n");
    //---------------------------
    printf("start setOriNeuroArray\n");
    setOriNeuroArray(neuroListOri);
    printf("start file2array\n");
    file2array(neuroListCustom, amount, file_name);
    printf("name2index\n");
    name2index(neuroListOri, neuroListCustom, amount, neuroindex);
    printf("neuro index %d\n",*neuroindex);
    printf("output\n");
    output(start, end, neuroindex, amount, neuroListOri);
    printf("output end\n");
    /*printf("convert neuro index to name start\n");
    outtable_converter(amount, 1, start, end);
    printf("convert neuro index to name end\n");*/
    /* Cytoscape腳本
    printf("CytoscapeScriptCreate start\n");
    CytoscapeScriptCreater(amount, neuroindex, neuroListOri);
    printf("CytoscapeScriptCreate end\n");*/
    //free(pData);
    free(neuroListCustom);
    free(neuroindex);
    system("pause");
    return 0;
}
Beispiel #4
0
void allocSetup(int filenum,
		int *mallocCar,
		int *mallocMod,
		int *mallocPD,
		int *mallocD,
		int *mallocAmp,
		int *mallocT,
		int *mallocA,
		int *mallocPan)
{
	char file_name[64];

	sprintf(file_name, "%dCarrier", filenum);
	printf("\tLine counting file %s...", file_name);
	*mallocCar = filecount(file_name);
	printf("%d\n",*mallocCar);
	
	sprintf(file_name, "%dModulator", filenum);
	printf("\tLine counting file %s...", file_name);
	*mallocMod = filecount(file_name);
	printf("%d\n",*mallocMod);

	sprintf(file_name, "%dPD", filenum);
	printf("\tLine counting file %s...", file_name);
	*mallocPD = filecount(file_name);
	printf("%d\n",*mallocPD);

	sprintf(file_name, "%dD", filenum);
	printf("\tLine counting file %s...", file_name);
	*mallocD = filecount(file_name);
	printf("%d\n",*mallocD);
	
	sprintf(file_name, "%dAmp", filenum);
	printf("\tLine counting file %s...", file_name);
	*mallocAmp = filecount(file_name);
	printf("%d\n",*mallocAmp);
	
	sprintf(file_name, "%dD", filenum);
	double* D;
	D = (double *)Malloc(*mallocD * sizeof(double));
	file2array(file_name, D);

	sprintf(file_name, "%dT", filenum);
	printf("\tLine counting file %s...", file_name);
	*mallocT = filecount(file_name);
	printf("%d\n",*mallocT);

	sprintf(file_name, "%dA", filenum);
	printf("\tLine counting file %s...", file_name);
	*mallocA = filecount(file_name);
	printf("%d\n",*mallocA);


	int i;
	double toneLength = 1;
	for(i = 0;i<*mallocD;i++) 
		toneLength = toneLength + D[i];

	*mallocPan = toneLength * 44100.0;
	printf("\tD[0] = %f\n", D[0]);
	printf("\ttoneLength = %f\n", toneLength);
	printf("\tmallocPan = %d\n", *mallocPan);
	
	Free(D);
}
Beispiel #5
0
void loadarray(int filenum,
		double Carrier[],
		double Modulator[],
		double PD[],
		double D[],
		double Amp[],
		int *nFMTones,
		double T[],
		double A[],
		int *nPoints,
		double xpan[],
		double ypan[]){
	
	char file_name[64];
	
	sprintf(file_name, "%dCarrier", filenum);
	printf("\tfile2array file %s...\n", file_name);
	file2array(file_name, Carrier);
	
	sprintf(file_name, "%dModulator", filenum);
	printf("\tfile2array file %s...\n", file_name);
	file2array(file_name, Modulator);
	
	sprintf(file_name, "%dPD", filenum);
	printf("\tfile2array file %s...\n", file_name);
	file2array(file_name, PD);

	sprintf(file_name, "%dD", filenum);
	printf("\tfile2array file %s...\n", file_name);
	file2array(file_name, D);

	sprintf(file_name, "%dAmp", filenum);
	printf("\tfile2array file %s...\n", file_name);
	file2array(file_name, Amp);
	
	*nFMTones = filecount(file_name);
	
	int i;
	double toneLength = 0;
	printf("test\n");
	for(i =0;i<*nFMTones;i++)
		toneLength = toneLength + D[i];
	
	printf("test\n");
	//changes Modulator Multiplier to Molulating Frequency
	for(i=0;i<*nFMTones;i++)
		Modulator[i] = Modulator[i] * Carrier[i];

	sprintf(file_name, "%dT", filenum);
	printf("\tfile2array file %s...\n", file_name);
	file2array(file_name, T);

	sprintf(file_name, "%dA", filenum);
	printf("\tfile2array file %s...\n", file_name);
	file2array(file_name, A);
	
	*nPoints = filecount(file_name);
	
	//panning
	//TODO x and y panning for 8 chan
	char xpanTime[64];
	char xpanStep[64];
	sprintf(xpanTime, "%dxpantime", filenum);
	sprintf(xpanStep, "%dxpanstep", filenum);
	
	int xpanPoints = filecount(xpanTime);
	
	char ypanTime[64];
	char ypanStep[64];
	sprintf(ypanTime, "%dypantime", filenum);
	sprintf(ypanStep, "%dypanstep", filenum);
	
	int ypanPoints = filecount(ypanTime);
	
	double *xX;
	double *xY;
	double *yX;
	double *yY;
	xX = (double *)Malloc(xpanPoints * sizeof(double));
	xY = (double *)Malloc(xpanPoints * sizeof(double));
	yX = (double *)Malloc(ypanPoints * sizeof(double));
	yY = (double *)Malloc(ypanPoints * sizeof(double));
	file2array(xpanTime, xX);
	file2array(xpanStep, xY);
	file2array(ypanTime, yX);
	file2array(ypanStep, yY);
	
	int x, xIndx, xrange;
	double yrange, m, m_inc;
	double sr = 44100;
	int samples = toneLength * sr; 
	//linear panning
	double x1, y1, x2, y2;
	
	x1 = xX[0];
	y1 = xY[0];
	xIndx = 0;

	for(i = 1; i < xpanPoints; i++){
		x2 = xX[i];
		y2 = xY[i];

		xrange = (x2 - x1) * samples;
		yrange = (y2 - y1);

		m = 0;
		m_inc = 1.0 / (xrange - 1.0);

		for(x = xIndx ; x < xIndx+xrange; x++){
			xpan[x] = y1 +(m * yrange);
			m = m + m_inc;
			//printf("xpan[x] = %f\n", xpan[x]);
		}

		xIndx = xIndx + xrange;

		y1 = y2;
		x1 = x2;
	}
	
	x1 = yX[0];
	y1 = yY[0];
	xIndx = 0;
	
	for(i = 1; i < ypanPoints; i++){
		x2 = yX[i];
		y2 = yY[i];

		xrange = (x2 - x1) * samples;
		yrange = (y2 - y1);

		m = 0;
		m_inc = 1.0 / (xrange - 1.0);

		for(x = xIndx ; x < xIndx+xrange; x++){
			ypan[x] = y1 +(m * yrange);
			m = m + m_inc;
			//printf("ypan[x] = %f\n", ypan[x]);
		}

		xIndx = xIndx + xrange;

		y1 = y2;
		x1 = x2;
	}
	Free(xX);
	Free(xY);
	Free(yX);
	Free(yY);
}