IpatchBase

IpatchBase — Toplevel object for patch files (SoundFont, DLS, etc)

Synopsis




enum                IpatchBaseFlags;
#define             IPATCH_BASE_UNUSED_FLAG_SHIFT
#define             IPATCH_BASE_DEFAULT_NAME
                    IpatchBase;
                    IpatchBaseClass;
void                ipatch_base_set_file                (IpatchBase *base,
                                                         IpatchFile *file);
IpatchFile*         ipatch_base_ref_file                (IpatchBase *base);
void                ipatch_base_set_file_name           (IpatchBase *base,
                                                         const char *file_name);
char*               ipatch_base_get_file_name           (IpatchBase *base);
void                ipatch_base_find_unused_midi_locale (IpatchBase *base,
                                                         int *bank,
                                                         int *program,
                                                         const IpatchItem *exclude,
                                                         gboolean percussion);

Object Hierarchy


  GObject
   +----IpatchItem
         +----IpatchContainer
               +----IpatchBase
                     +----IpatchDLS2
                     +----IpatchSF2

Properties


  "changed"                  gboolean              : Read / Write
  "file"                     IpatchFile            : Read / Write
  "file-name"                gchararray            : Read / Write
  "saved"                    gboolean              : Read / Write

Description

A base object to derive toplevel patch objects from, like a SoundFont or DLS patch.

Details

enum IpatchBaseFlags

typedef enum /*< flags >*/
{
  /* patch changed flag */
  IPATCH_BASE_CHANGED = 1 << IPATCH_ITEM_UNUSED_FLAG_SHIFT,
  /* patch been saved ever? */
  IPATCH_BASE_SAVED   = 1 << (IPATCH_ITEM_UNUSED_FLAG_SHIFT + 1)
} IpatchBaseFlags;

IpatchItem flags for base objects.

IPATCH_BASE_CHANGED A flag indicating if the base object or its children have unsaved changes.
IPATCH_BASE_SAVED A flag indicating if the base object has ever been saved.

IPATCH_BASE_UNUSED_FLAG_SHIFT

#define IPATCH_BASE_UNUSED_FLAG_SHIFT (IPATCH_ITEM_UNUSED_FLAG_SHIFT + 4)

IpatchItem flag shift value for next unused flag. Useful for derived types to define their own flags.


IPATCH_BASE_DEFAULT_NAME

#define IPATCH_BASE_DEFAULT_NAME "Untitled"


IpatchBase

typedef struct _IpatchBase IpatchBase;


IpatchBaseClass

typedef struct {
  IpatchContainerClass parent_class;

  /* methods */
  void (*find_unused_locale)(IpatchBase *base, int *bank, int *program,
			     const IpatchItem *exclude, gboolean percussion);
  IpatchItem * (*find_item_by_locale_ref)(IpatchBase *base, int bank,
					  int program);
} IpatchBaseClass;


ipatch_base_set_file ()

void                ipatch_base_set_file                (IpatchBase *base,
                                                         IpatchFile *file);

Sets the file object associated with a patch.

base : Patch base object to set file object of
file : File object

ipatch_base_ref_file ()

IpatchFile*         ipatch_base_ref_file                (IpatchBase *base);

Get the file object associated with a patch base object. Caller owns a reference to the returned file object and it should be unrefed when done with it.

base : Patch base object to get file object from
Returns : File object or NULL if not set. Remember to unref it when done with it.

ipatch_base_set_file_name ()

void                ipatch_base_set_file_name           (IpatchBase *base,
                                                         const char *file_name);

Sets the file name of the file object in a patch base object. File object should have been set before calling this function (otherwise request is silently ignored). A convenience function as one could get the file object and set it directly.

base : Patch base object to set file name of
file_name : Path and name to set filename to

ipatch_base_get_file_name ()

char*               ipatch_base_get_file_name           (IpatchBase *base);

Get the file name of the file object in a base patch item. A convenience function.

base : Base patch item to get file name from.
Returns : New allocated file name or NULL if not set or file object not set. String should be freed when finished with it.

ipatch_base_find_unused_midi_locale ()

void                ipatch_base_find_unused_midi_locale (IpatchBase *base,
                                                         int *bank,
                                                         int *program,
                                                         const IpatchItem *exclude,
                                                         gboolean percussion);

Finds an unused MIDI locale (bank:program number pair) in a patch base object. The way in which MIDI bank and program numbers are used is implementation dependent. Percussion instruments often affect the bank parameter (for example SoundFont uses bank 128 for percussion presets). On input the bank and program parameters set the initial locale to start from (set to 0:0 to find the first free value). If the percussion parameter is set it may affect bank, if its not set, bank will not be modified (e.g., if bank is a percussion value it will be used). The exclude parameter can be set to a child item of base to exclude from the list of "used" locales (useful when making an item unique that is already parented to base). On return bank and program will be set to an unused MIDI locale based on the input criteria.

base : Patch base object
bank : MIDI bank number (input and output parameter)
program : MIDI program number (input and output parameter)
exclude : Child of base with MIDI locale to exclude or NULL
percussion : Set to TRUE to find a free percussion MIDI locale

Property Details

The "changed" property

  "changed"                  gboolean              : Read / Write

A flag indicating if base object, or its children, have changed.

Default value: TRUE


The "file" property

  "file"                     IpatchFile            : Read / Write

Set the file object associated with a base object.


The "file-name" property

  "file-name"                gchararray            : Read / Write

Name of file associated with a base object.

Default value: "untitled"


The "saved" property

  "saved"                    gboolean              : Read / Write

A flag indicating if a base object has ever been saved.

Default value: FALSE

See Also

IpatchSF2