if (elm->sclnotenum) elm->sclnote = (int16 *) memdup( elm->sclnote, elm->sclnotenum * sizeof(int16)); if (elm->scltunenum) elm->scltune = (int16 *) memdup( elm->scltune, elm->scltunenum * sizeof(int16));
void dup_tone_bank_element(int dr, int bk, int prog){	ToneBank **bank = ((dr) ? drumset : tonebank);	ToneBankElement *elm = &bank[bk]->tone[prog];	int i;		if (elm->name)		elm->name = safe_strdup(elm->name);	if (elm->comment)		elm->comment = safe_strdup(elm->comment);	if (elm->tunenum)		elm->tune = (float *) memdup(				elm->tune, elm->tunenum * sizeof(float));	if (elm->fcnum)		elm->fc = (int16 *) memdup(				elm->fc, elm->fcnum * sizeof(int16));	if (elm->resonum)		elm->reso = (int16 *) memdup(				elm->reso, elm->resonum * sizeof(int16));	if (elm->trempitchnum)		elm->trempitch = (int16 *) memdup(				elm->trempitch, elm->trempitchnum * sizeof(int16));	if (elm->tremfcnum)		elm->tremfc = (int16 *) memdup(				elm->tremfc, elm->tremfcnum * sizeof(int16));	if (elm->modpitchnum)		elm->modpitch = (int16 *) memdup(				elm->modpitch, elm->modpitchnum * sizeof(int16));	if (elm->modfcnum)		elm->modfc = (int16 *) memdup(				elm->modfc, elm->modfcnum * sizeof(int16));	if (elm->envratenum) {		elm->envrate = (int **) memdup(				elm->envrate, elm->envratenum * sizeof(int *));		for (i = 0; i < elm->envratenum; i++)			elm->envrate[i] = (int *) memdup(elm->envrate[i], 6 * sizeof(int));	}	if (elm->envofsnum) {		elm->envofs = (int **) memdup(				elm->envofs, elm->envofsnum * sizeof(int *));		for (i = 0; i < elm->envofsnum; i++)			elm->envofs[i] = (int *) memdup(elm->envofs[i], 6 * sizeof(int));	}	if (elm->modenvratenum) {		elm->modenvrate = (int **) memdup(				elm->modenvrate, elm->modenvratenum * sizeof(int *));		for (i = 0; i < elm->modenvratenum; i++)			elm->modenvrate[i] = (int *) memdup(elm->modenvrate[i], 6 * sizeof(int));	}	if (elm->modenvofsnum) {		elm->modenvofs = (int **) memdup(				elm->modenvofs, elm->modenvofsnum * sizeof(int *));		for (i = 0; i < elm->modenvofsnum; i++)			elm->modenvofs[i] = (int *) memdup(elm->modenvofs[i], 6 * sizeof(int));	}	if (elm->tremnum) {		elm->trem = (Quantity **) memdup(elm->trem, elm->tremnum * sizeof(Quantity *));		for (i = 0; i < elm->tremnum; i++)			elm->trem[i] = (Quantity *) memdup(elm->trem[i], 3 * sizeof(Quantity));	}	if (elm->vibnum) {		elm->vib = (Quantity **) memdup(elm->vib, elm->vibnum * sizeof(Quantity *));		for (i = 0; i < elm->vibnum; i++)			elm->vib[i] = (Quantity *) memdup(elm->vib[i], 3 * sizeof(Quantity));	}}