## SwamiWavetbl SwamiWavetbl |

## Synopsis

                        SwamiWavetbl;
    IpatchVBank *       swami_wavetbl_get_virtual_bank      (SwamiWavetbl *wavetbl);
    void                swami_wavetbl_set_active_item_locale
                                                            (SwamiWavetbl *wavetbl,
                                                             int bank,
                                                             int program);
    void                swami_wavetbl_get_active_item_locale
                                                            (SwamiWavetbl *wavetbl,
                                                             int *bank,
                                                             int *program);
    gboolean            swami_wavetbl_open                  (SwamiWavetbl *wavetbl,
                                                             GError **err);
    void                swami_wavetbl_close                 (SwamiWavetbl *wavetbl);
    SwamiControlMidi *  swami_wavetbl_get_control           (SwamiWavetbl *wavetbl,
                                                             int index);
    gboolean            swami_wavetbl_load_patch            (SwamiWavetbl *wavetbl,
                                                             IpatchItem *patch,
                                                             GError **err);
    gboolean            swami_wavetbl_load_active_item      (SwamiWavetbl *wavetbl,
                                                             IpatchItem *item,
                                                             GError **err);
    gboolean            swami_wavetbl_check_update_item     (SwamiWavetbl *wavetbl,
                                                             IpatchItem *item,
                                                             GParamSpec *prop);
    void                swami_wavetbl_update_item           (SwamiWavetbl *wavetbl,
                                                             IpatchItem *item);

## Object Hierarchy

      GObject
       +----SwamiLock
             +----SwamiWavetbl

## Properties

      "active"                   gboolean              : Read
      "active-bank"              gint                  : Read / Write
      "active-program"           gint                  : Read / Write
      "vbank"                    IpatchVBank*          : Read

## Signals

      "active"                                         : Run First

## Description

## Details

### SwamiWavetbl

    typedef struct _SwamiWavetbl SwamiWavetbl;

### swami_wavetbl_get_virtual_bank ()

    IpatchVBank *       swami_wavetbl_get_virtual_bank      (SwamiWavetbl *wavetbl);

Retrieve the IpatchVBank object from a Wavetable instance. This bank is the main synthesis object for the Wavetable instance, which is used for mapping instruments to MIDI bank:program locales.

`wavetbl` : | Swami Wavetable object
Returns : | The virtual bank of the Wavetable instance with a reference count added for the caller.

### swami_wavetbl_set_active_item_locale ()

    void                swami_wavetbl_set_active_item_locale
                                                            (SwamiWavetbl *wavetbl,
                                                             int bank,
                                                             int program);

Sets the MIDI bank and program numbers (MIDI locale) of the active item. The active item is the currently focused item in the user interface, which doesn't necessarily have its own locale bank and program.

MT-NOTE: This function ensures bank and program number are set atomically, which is not assured if using the standard ``g_object_set()`` routine.

`wavetbl` : | Swami wave table object
`bank` : | MIDI bank number of active item
`program` : | MIDI program number of active item

### swami_wavetbl_get_active_item_locale ()

    void                swami_wavetbl_get_active_item_locale
                                                            (SwamiWavetbl *wavetbl,
                                                             int *bank,
                                                             int *program);

Gets the MIDI bank and program numbers (MIDI locale) of the active item. See `swami_wavetbl_set_active_item_locale()` for more info.

`wavetbl` : | Swami wave table object
`bank` : | Location to store MIDI bank number of active item or `NULL`
`program` : | Location to store MIDI program number of active item or `NULL`

### swami_wavetbl_open ()

    gboolean            swami_wavetbl_open                  (SwamiWavetbl *wavetbl,
                                                             GError **err);

Open Wavetbl driver.

`wavetbl` : | Swami Wavetable object
`err` : | Location to store error information or `NULL`.
Returns : | `TRUE` on success, `FALSE` otherwise

### swami_wavetbl_close ()

    void                swami_wavetbl_close                 (SwamiWavetbl *wavetbl);

Close driver, has no effect if already closed. Emits the "active" signal.

`wavetbl` : | Swami Wavetable object

### swami_wavetbl_get_control ()

    SwamiControlMidi *  swami_wavetbl_get_control           (SwamiWavetbl *wavetbl,
                                                             int index);

Get a MIDI control from a wavetable object. Calls the wavetable's "get_control" method. A control `index` is used to support multiple controls (for example if the wavetable device supports more than 16 MIDI channels).

`wavetbl` : | Swami Wavetable object
`index` : | Control index
Returns : | New MIDI control object linked to `wavetbl` or `NULL` if no control with the given `index`. The returned control's reference count has been incremented and is owned by the caller, remember to unref it when finished.

### swami_wavetbl_load_patch ()

    gboolean            swami_wavetbl_load_patch            (SwamiWavetbl *wavetbl,
                                                             IpatchItem *patch,
                                                             GError **err);

Load a patch into a wavetable object.

`wavetbl` : | Swami Wavetable object
`patch` : | Patch object to load
`err` : | Location to store error information or `NULL`.
Returns : | `TRUE` on success, `FALSE` otherwise

### swami_wavetbl_load_active_item ()

    gboolean            swami_wavetbl_load_active_item      (SwamiWavetbl *wavetbl,
                                                             IpatchItem *item,
                                                             GError **err);

Load an item as the active program item.

`wavetbl` : | Swami Wavetable object
`item` : | Patch item to load as active item.
`err` : | Location to store error information or `NULL`.
Returns : | `TRUE` on success, `FALSE` otherwise

### swami_wavetbl_check_update_item ()

    gboolean            swami_wavetbl_check_update_item     (SwamiWavetbl *wavetbl,
                                                             IpatchItem *item,
                                                             GParamSpec *prop);

Checks if a given `item` needs to be updated if the property `prop` has changed.

`wavetbl` : | Swami Wavetable object
`item` : | Patch item to check if an update is needed
`prop` : | GParamSpec of property that has changed
Returns : | `TRUE` if `item` should be updated, `FALSE` otherwise (`prop` is not a synthesis property or `item` is not currently loaded in `wavetbl`).

### swami_wavetbl_update_item ()

    void                swami_wavetbl_update_item           (SwamiWavetbl *wavetbl,
                                                             IpatchItem *item);

Refresh a given `item` object's synthesis cache. This should be called after a change affecting synthesis output occurs to `item`, which can be tested with `swami_wavetbl_check_update_item()`.

`wavetbl` : | Swami Wavetable object
`item` : | Patch item to force update on

## Property Details

### The `"active"` property

      "active"                   gboolean              : Read

State of driver.

Default value: FALSE

### The `"active-bank"` property

      "active-bank"              gint                  : Read / Write

Active (focused) MIDI bank number.

Allowed values: [0,128]

Default value: 127

### The `"active-program"` property

      "active-program"           gint                  : Read / Write

Active (focused) MIDI program number.

Allowed values: [0,127]

Default value: 127

### The `"vbank"` property

      "vbank"                    IpatchVBank*          : Read

Virtual bank.

## Signal Details

### The `"active"` signal

    void                user_function                      (SwamiWavetbl *swamiwavetbl,
                                                            gboolean      arg1,
                                                            gpointer      user_data)         : Run First