Exemple #1
0
static int READW(uint16_t *vp, struct timidity_file *tf)
{
	if (tf_read(vp, 2, 1, tf) != 1)
		return -1;
	*vp = LE_SHORT(*vp);
	return 1;
}
Exemple #2
0
static int READDW(uint32_t *vp, struct timidity_file *tf)
{
	if (tf_read(vp, 4, 1, tf) != 1)
		return -1;
	*vp = LE_LONG(*vp);
	return 1;
}
Exemple #3
0
static int READCHUNK(SFChunk *vp, struct timidity_file *tf)
{
	if (tf_read(vp, 8, 1, tf) != 1)
		return -1;
	vp->size = LE_LONG(vp->size);
	return 1;
}
 static void png_read_func(png_structp png_ptr, char *buff, size_t n)
 {
     struct timidity_file *tf;
-    tf = (struct timidity_file *)png_ptr->io_ptr;
+    tf = (struct timidity_file *)png_get_io_ptr(png_ptr);
     tf_read(buff, 1, n, tf);
 }
Exemple #5
0
void DocWndReadDoc(int num)
{
	struct timidity_file *tf;
	if(DocWndInfoLock()==FALSE)
		return;
	if(num<1)
		num = 1;
	if(num>DocWndInfo.DocFileMax)
		num = DocWndInfo.DocFileMax;
	if(num==DocWndInfo.DocFileCur)
		goto end;
	DocWndInfo.DocFileCur = num;
	tf = open_file(DocWndInfo.DocFile[DocWndInfo.DocFileCur-1],1,10);
	if(tf==NULL)
		goto end;
	if(DocWndInfo.Text!=NULL){
		free(DocWndInfo.Text);
		DocWndInfo.Text = NULL;
	}
	DocWndInfo.Text = (char *)safe_malloc(sizeof(char)*DOCWNDDOCSIZEMAX);
	DocWndInfo.Text[0] = '\0';
	DocWndInfo.TextSize = tf_read(DocWndInfo.Text,1,DOCWNDDOCSIZEMAX-1,tf);
	DocWndInfo.Text[DocWndInfo.TextSize] = '\0';
	close_file(tf);
	{
		char info[1024];
		char *filename;
		char *p1, *p2, *p3;
		p1 = DocWndInfo.DocFile[DocWndInfo.DocFileCur-1];
		p2 = pathsep_strrchr(p1);
		p3 = strrchr(p1,'#');
		if(p3!=NULL){
			sprintf(info,"(%02d/%02d) %s",DocWndInfo.DocFileCur,DocWndInfo.DocFileMax,p3+1);
			filename = p2 + 1;
		} else if(p2!=NULL){
			sprintf(info,"(%02d/%02d) %s",DocWndInfo.DocFileCur,DocWndInfo.DocFileMax,p2+1);
			filename = p2 + 1;
		} else {
			sprintf(info,"(%02d/%02d) %s",DocWndInfo.DocFileCur,DocWndInfo.DocFileMax,p1+1);
			filename = p1;
		}
		DocWndSetInfo(info,filename);
	}
	DocWndSetText(DocWndInfo.Text,DocWndInfo.TextSize);
end:
	if(DocWndInfo.DocFileCur==1)
		EnableWindow(GetDlgItem(hDocWnd,IDC_BUTTON_PREV),FALSE);
	else
		EnableWindow(GetDlgItem(hDocWnd,IDC_BUTTON_PREV),TRUE);
	if(DocWndInfo.DocFileCur==DocWndInfo.DocFileMax)
		EnableWindow(GetDlgItem(hDocWnd,IDC_BUTTON_NEXT),FALSE);
	else
		EnableWindow(GetDlgItem(hDocWnd,IDC_BUTTON_NEXT),TRUE);
	DocWndInfoUnLock();
}
Exemple #6
0
static int READSTR(char *str, struct timidity_file *tf)
{
	int n;

	if (tf_read(str, 20, 1, tf) != 1)
		return -1;
	str[19] = '\0';
	n = (int)strlen(str);
	while (n > 0 && str[n - 1] == ' ')
		n--;
	str[n] = '\0';
	return n;
}
Exemple #7
0
int Instruments::process_info(int size, SFInfo *sf, struct timidity_file *fd)
{
	sf->infopos = tf_tell(fd);
	sf->infosize = size;

	/* parse the buffer */
	while (size > 0) {
		SFChunk chunk;

		/* read a sub chunk */
		if (READCHUNK(&chunk, fd) <= 0)
			return -1;
		size -= 8;

		ctl_cmsg(CMSG_INFO, VERB_DEBUG, " %c%c%c%c:",
			chunk.id[0], chunk.id[1], chunk.id[2], chunk.id[3]);
		switch (chunkid(chunk.id)) {
		case IFIL_ID:
			/* soundfont file version */
			READW(&sf->version, fd);
			READW(&sf->minorversion, fd);
			ctl_cmsg(CMSG_INFO, VERB_DEBUG,
				"  version %d, minor %d",
				sf->version, sf->minorversion);
			break;
		case INAM_ID:
			/* name of the font */
			sf->sf_name = (char*)safe_malloc(chunk.size + 1);
			tf_read(sf->sf_name, 1, chunk.size, fd);
			sf->sf_name[chunk.size] = 0;
			ctl_cmsg(CMSG_INFO, VERB_DEBUG,
				"  name %s", sf->sf_name);
			break;

		default:
			FSKIP(chunk.size, fd);
			break;
		}
		size -= chunk.size;
	}
	return 0;
}