⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 uif_selections.c

📁 A GTK sound font editor. Sound font files are used to synthesize instruments from audio samples for
💻 C
📖 第 1 页 / 共 3 页
字号:
  /* add ptr to this duplicated inst in inst hash to be used for all     references to the old duplicated inst */  g_hash_table_insert (inst_hash, linst, duplinst);  /* tell sfundo about our new item */  dofunc_noitem_save (SFTREE_NODE_REF (node)->itemid);  return (duplinst);}static GSList *uisel_clone_sample (GSList *lsam, UISFont *dstuisf, UISFont *srcuisf,		    gint mode){  GtkCTreeNode *node;  static SFSample *dup;  static GSList *duplsam;  if (mode == UISEL_START)    {      /* check if this sample has already been processed */      if ((duplsam = g_hash_table_lookup (sample_hash, lsam)))	return (duplsam);      dup = sfont_sample_dup ((SFSample *)(lsam->data), SFDUP_NORMAL, TRUE);    }  if (mode == UISEL_START || mode == UISEL_CHANGE)    /* check for duplicate sample (including itself) */    if ((duplsam = sfont_find_sample (dstuisf->sf, dup->name, NULL)))      {	if (sample_all_mode == UISEL_START || mode != UISEL_START)	  {			/* if no all mode or mode not UISEL_START */	    paste_item_type = NODE_SAMPLE;	    paste_item_data = dup;	    /* Duplicate sample dialog: Change, Replace, Keep, Cancel */	    uisel_dup_item_dialog (_("Type"), _("Sample"), NULL,				   _("Name"), dup->name, NULL,				   _("Sound font"),				   sfont_get_info (srcuisf->sf, INAM_ID),				   sfont_get_info (dstuisf->sf, INAM_ID),				   _("File name"),				   srcuisf->sf->fname,				   dstuisf->sf->fname,				   NULL);	    return (NULL);	/* return to wait for user input */	  }	else mode = sample_all_mode; /* user requested all mode */      }  switch (mode)    {    case UISEL_REPLACE:      return (NULL);    case UISEL_KEEP:      /* add ptr to sample hash of the destination sample to keep, it will be	 used for all references to this sample */      g_hash_table_insert (sample_hash, lsam, duplsam);      sfont_sample_destroy (dup, TRUE);      return (duplsam);    case UISEL_CANCEL:		/* Cancel paste operation */      sfont_sample_destroy (dup, TRUE);      return (NULL);    }  /* add the duplicated sample to the destination sound font and the sftree */  sfont_add_sample (dstuisf->sf, dup);  duplsam = g_slist_find (dstuisf->sf->sample, dup);  node = sftree_add_sample (duplsam, dstuisf->nodes, SFTREE_NODE_APPEND);  /* add ptr to this duplicated sample in sample hash to be used for all     references to the old duplicated sample */  g_hash_table_insert (sample_hash, lsam, duplsam);  /* tell sfundo about our new item */  dofunc_noitem_save (SFTREE_NODE_REF (node)->itemid);  return (duplsam);}static GSList *uisel_new_preset_from_inst (SFTreeRef *dstref, SFTreeRef *srcref,			    UISFont *dstuisf, UISFont *srcuisf, gint mode){  static GSList *instlp;  static SFPreset *pset;  static gboolean check;  SFInst *inst;  SFZone *zone;  GSList *psetlp, *p;  GtkCTreeNode *node;  if (mode == UISEL_START)    {      gint bank, prenum;      instlp = (GSList *)(srcref->dptr);      pset = sfont_preset_alloc ();      strcpy (pset->name, ((SFInst *)(instlp->data))->name);      /* find a free preset */      sfont_find_free_preset (dstuisf->sf, &bank, &prenum,			      dstref->type != NODE_PERCUSS);      pset->bank = bank;      pset->prenum = prenum;      check = FALSE;    }  inst = (SFInst *)(instlp->data);  if (!check)    {      if (mode == UISEL_START || mode == UISEL_CHANGE)	{		  /* check for duplicate preset */	  if ((psetlp = sfont_find_preset (dstuisf->sf, pset->name,					   pset->bank, pset->prenum, NULL)))	    {	      if (preset_all_mode == UISEL_START || mode == UISEL_CHANGE)		{		/* if no all mode or mode not UISEL_START */		  SFPreset *dup = (SFPreset *)(psetlp->data);		  gchar *s1, *s2, *s3, *s4;		  paste_item_type = NODE_PRESET;		  paste_item_data = pset;		  s1 = g_strdup_printf ("%d", pset->bank);		  s2 = g_strdup_printf ("%d", dup->bank);		  s3 = g_strdup_printf ("%d", pset->prenum);		  s4 = g_strdup_printf ("%d", dup->prenum);		  /* Duplicate preset dialog: Change, Replace, Keep, Cancel */		  uisel_dup_item_dialog (_("Type"), _("Preset"), NULL,					 _("Name"), pset->name, dup->name,					 _("Bank"), s1, s2,					 _("Preset"), s3, s4,					 _("Sound font"),					 sfont_get_info (srcuisf->sf, INAM_ID),					 sfont_get_info (dstuisf->sf, INAM_ID),					 _("File name"),					 srcuisf->sf->fname,					 dstuisf->sf->fname,					 NULL);		  g_free (s1); g_free (s2); g_free (s3); g_free (s4);		  return (NULL);	/* return to wait for user input */		}	      else mode = preset_all_mode; /* user requested all mode */	    }	}      switch (mode)	{	case UISEL_REPLACE:	/* Replace duplicate preset (not done yet) */	  break;	case UISEL_KEEP:	/* Keep existing duplicate preset */	  sfont_preset_destroy (pset);	  return (psetlp);	case UISEL_CANCEL:	/* Cancel paste operation */	  sfont_preset_destroy (pset);	  return (NULL);	}      check = TRUE;		/* flag duplicate check as done */      mode = UISEL_START;	/* Reset mode */    }  if (dstuisf != srcuisf)	/* not a global zone, same sound font? */    {				/* duplicate the instrument */      p = uisel_clone_inst (instlp, dstuisf, srcuisf, mode);      if (mode == UISEL_CANCEL)	sfont_preset_destroy (pset);      if (!p) return (NULL);	/* waiting for user input or cancel? */    }  else p = instlp;  /* add the preset to the destination sound font and the sftree */  sfont_add_preset (dstuisf->sf, pset);  psetlp = g_slist_find (dstuisf->sf->preset, pset);  node = sftree_add_preset_sorted (psetlp, dstuisf->nodes);  /* create new zone */  zone = sfont_zone_alloc ();  zone->instsamp = p;  /* add preset zone */  sfont_add_preset_zone (dstuisf->sf, pset, zone);  p = g_slist_find (pset->zone, zone);  sftree_add_pzone (p, node, -1);  /* tell sfundo about our new item */  dofunc_noitem_save (SFTREE_NODE_REF (node)->itemid);  return (psetlp);}static GSList *uisel_new_inst_from_sample (SFTreeRef *dstref, SFTreeRef *srcref,			    UISFont *dstuisf, UISFont *srcuisf, gint mode){  static GSList *samlp;  static SFInst *inst;  static gboolean check;  SFSample *sam;  SFZone *zone;  GSList *instlp, *p;  GtkCTreeNode *node;  if (mode == UISEL_START)    {      samlp = (GSList *)(srcref->dptr);      inst = sfont_inst_alloc ();      strcpy (inst->name, ((SFSample *)(samlp->data))->name);      check = FALSE;    }  sam = (SFSample *)(samlp->data);  if (!check)    {      if (mode == UISEL_START || mode == UISEL_CHANGE)	{		  /* check for duplicate instrument */	  if ((instlp = sfont_find_inst (dstuisf->sf, inst->name, NULL)))	    {	      if (inst_all_mode == UISEL_START || mode == UISEL_CHANGE)		{		/* if no all mode or mode not UISEL_START */		  paste_item_type = NODE_INST;		  paste_item_data = inst;		  /* Duplicate inst dialog: Change, Replace, Keep, Cancel */		  uisel_dup_item_dialog (_("Type"), _("Instrument"), NULL,					 _("Name"), inst->name, NULL,					 _("Sound font"),					 sfont_get_info (srcuisf->sf, INAM_ID),					 sfont_get_info (dstuisf->sf, INAM_ID),					 _("File name"),					 srcuisf->sf->fname,					 dstuisf->sf->fname,					 NULL);		  return (NULL);	/* return to wait for user input */		}	      else mode = preset_all_mode; /* user requested all mode */	    }	}      switch (mode)	{	case UISEL_REPLACE:	/* Replace duplicate inst (not done yet) */	  break;	case UISEL_KEEP:	/* Keep existing duplicate inst */	  sfont_inst_destroy (inst);	  return (instlp);	case UISEL_CANCEL:	/* Cancel paste operation */	  sfont_inst_destroy (inst);	  return (NULL);	}      check = TRUE;		/* flag duplicate check as done */      mode = UISEL_START;	/* Reset mode */    }  if (dstuisf != srcuisf)	/* not a global zone, same sound font? */    {				/* duplicate the sample */      p = uisel_clone_sample (samlp, dstuisf, srcuisf, mode);      if (mode == UISEL_CANCEL)	sfont_inst_destroy (inst);      if (!p) return (NULL);	/* waiting for user input or cancel? */    }  else p = samlp;  /* add the instrument to the destination sound font and the sftree */  sfont_add_inst (dstuisf->sf, inst);  instlp = g_slist_find (dstuisf->sf->inst, inst);  node = sftree_add_inst (instlp, dstuisf->nodes, -1);  /* create new zone */  zone = sfont_zone_alloc ();  zone->instsamp = p;  /* add instrument zone */  sfont_add_inst_zone (dstuisf->sf, inst, zone);  p = g_slist_find (inst->zone, zone);  sftree_add_izone (p, node, -1);  /* tell sfundo about our new item */  dofunc_noitem_save (SFTREE_NODE_REF (node)->itemid);  return (instlp);}static GSList *uisel_paste_pzone (GtkCTreeNode *pnode, SFTreeRef *srcref, UISFont *dstuisf,		   UISFont *srcuisf, gint mode){  SFPreset *pset;  GSList *p, *p2, *duplzone;  SFZone *z;  GtkCTreeNode *node;  GtkWidget *popdog;  /* get pointer to SFPreset from preset sftree node */  pset = (SFPreset *)(((GSList *)(SFTREE_NODE_REF (pnode)->dptr))->data);  /* pointer to instrument or preset zone list item */  p = (GSList *)(srcref->dptr);  if (srcref->type == NODE_INST) /* item is an instrument? */    {      if (dstuisf != srcuisf)	/* different sound font? */	{			/* duplicate the instrument */	  p = uisel_clone_inst (p, dstuisf, srcuisf, mode);	  if (!p) return (NULL); /* waiting for user input or cancel? */	}      if (mode == UISEL_CANCEL) return (NULL); /* catch cancel request */      z = sfont_new_preset_zone (dstuisf->sf, pset, p);    }  else if (srcref->type == NODE_PZONE) /* item is preset zone? */    {      z = (SFZone *) (p->data);	/* get preset zone */      p2 = NULL;      /* Global Zone? */      if (z->instsamp)	{	  if (dstuisf != srcuisf) /* not a global zone, same sound font? */	    {			/* duplicate the instrument */	      p2 = uisel_clone_inst (z->instsamp, dstuisf, srcuisf, mode);	      if (!p2) return (NULL); /* waiting for user input or cancel? */	    }	}      else			/* its a global zone */	{	  switch (mode)	    {	    case UISEL_START:	      /* preset already has Global Zone? */	      if (pset->zone && !((SFZone *)(pset->zone->data))->instsamp)		{		  /* Duplicate global zone dialog: Replace, Keep, Cancel */		  popdog = 		    util_quick_popup (_("Duplicate global preset zone"),				      _("Keep"), uisel_cb_dup_zone,				      GINT_TO_POINTER (UISEL_KEEP),				      _("Cancel"), uisel_cb_dup_zone,				      GINT_TO_POINTER (UISEL_CANCEL),				      NULL);		  gtk_signal_connect (GTK_OBJECT (popdog), "destroy",				      (GtkSignalFunc)uisel_cb_dup_zone_destroy,				      NULL);		  return (NULL); /* return to wait for user input */		}	      break;	    case UISEL_REPLACE:	/* not done yet (fall through) */	    case UISEL_KEEP:	      return (p);	    default:	      break;	    }	}      if (mode == UISEL_CANCEL) return (NULL); /* catch cancel request */      z = sfont_zone_dup (z, SFDUP_NORMAL); /* duplicate the pzone */      /* if dstuisf != srcuisf, point to the new instrument */      if (p2) z->instsamp = p2;      sfont_add_preset_zone (dstuisf->sf, pset, z);    }  /* add zone to sftree */  duplzone = g_slist_find (pset->zone, z);  node = sftree_add_pzone (duplzone, pnode, SFTREE_NODE_APPEND);  /* tell sfundo about our new zone */  dofunc_noitem_save (SFTREE_NODE_REF (node)->itemid);  if (pset == uisf_selected_elem)    pianospan_update ();	/* update key spans */  wtbl_sfitem_changed (pset->itemid, WTBL_ITEM_CHANGE);  return (duplzone);}/* Instrument zone paste */static GSList *uisel_paste_izone (GtkCTreeNode *pnode, SFTreeRef *srcref, UISFont *dstuisf,		   UISFont *srcuisf, gint mode){  SFInst *inst;  GSList *p, *p2, *duplzone;  SFZone *z;  GtkCTreeNode *node;  GtkWidget *popdog;  /* get pointer to SFInst from instrument sftree node */  inst = (SFInst *)(((GSList *)(SFTREE_NODE_REF (pnode)->dptr))->data);  /* pointer to sample or instrument zone list item */  p = (GSList *)(srcref->dptr);  if (srcref->type == NODE_SAMPLE) /* item is a sample? */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -