## SwamiguiSampleEditor SwamiguiSampleEditor |

## Synopsis

    enum                SwamiguiSampleEditorStatus;
    gboolean            (*SwamiguiSampleEditorHandler)      (SwamiguiSampleEditor *editor);
                        SwamiguiSampleEditor;
    enum                SwamiguiSampleEditorMarkerFlags;
    enum                SwamiguiSampleEditorMarkerId;
    GtkWidget *         swamigui_sample_editor_new          (void);
    void                swamigui_sample_editor_zoom_ofs     (SwamiguiSampleEditor *editor,
                                                             double zoom_amt,
                                                             double zoom_xpos);
    void                swamigui_sample_editor_scroll_ofs   (SwamiguiSampleEditor *editor,
                                                             int sample_ofs);
    void                swamigui_sample_editor_loop_zoom    (SwamiguiSampleEditor *editor,
                                                             double zoom_amt);
    void                swamigui_sample_editor_set_selection
                                                            (SwamiguiSampleEditor *editor,
                                                             IpatchList *items);
    IpatchList *        swamigui_sample_editor_get_selection
                                                            (SwamiguiSampleEditor *editor);
    void                swamigui_sample_editor_register_handler
                                                            (SwamiguiSampleEditorHandler handler,
                                                             SwamiguiPanelCheckFunc check_func);
    void                swamigui_sample_editor_unregister_handler
                                                            (SwamiguiSampleEditorHandler handler);
    void                swamigui_sample_editor_reset        (SwamiguiSampleEditor *editor);
    void                swamigui_sample_editor_get_loop_controls
                                                            (SwamiguiSampleEditor *editor,
                                                             SwamiControl **loop_start,
                                                             SwamiControl **loop_end);
    int                 swamigui_sample_editor_add_track    (SwamiguiSampleEditor *editor,
                                                             IpatchSampleData *sample,
                                                             gboolean right_chan);
    gboolean            swamigui_sample_editor_get_track_info
                                                            (SwamiguiSampleEditor *editor,
                                                             guint track,
                                                             IpatchSampleData **sample,
                                                             SwamiguiSampleCanvas **sample_view,
                                                             SwamiguiSampleCanvas **loop_view);
    void                swamigui_sample_editor_remove_track (SwamiguiSampleEditor *editor,
                                                             guint track);
    void                swamigui_sample_editor_remove_all_tracks
                                                            (SwamiguiSampleEditor *editor);
    guint               swamigui_sample_editor_add_marker   (SwamiguiSampleEditor *editor,
                                                             guint flags,
                                                             SwamiControl **start,
                                                             SwamiControl **end);
    gboolean            swamigui_sample_editor_get_marker_info
                                                            (SwamiguiSampleEditor *editor,
                                                             guint marker,
                                                             guint *flags,
                                                             GnomeCanvasItem **start_line,
                                                             GnomeCanvasItem **end_line,
                                                             SwamiControl **start_ctrl,
                                                             SwamiControl **end_ctrl);
    void                swamigui_sample_editor_set_marker   (SwamiguiSampleEditor *editor,
                                                             guint marker,
                                                             guint start,
                                                             guint end);
    void                swamigui_sample_editor_remove_marker
                                                            (SwamiguiSampleEditor *editor,
                                                             guint marker);
    void                swamigui_sample_editor_remove_all_markers
                                                            (SwamiguiSampleEditor *editor);
    void                swamigui_sample_editor_show_marker  (SwamiguiSampleEditor *editor,
                                                             guint marker,
                                                             gboolean show_marker);
    void                swamigui_sample_editor_set_loop_types
                                                            (SwamiguiSampleEditor *editor,
                                                             int *types,
                                                             gboolean loop_play_btn);
    void                swamigui_sample_editor_set_active_loop_type
                                                            (SwamiguiSampleEditor *editor,
                                                             int type);

## Object Hierarchy

      GObject
       +----GInitiallyUnowned
             +----GtkObject
                   +----GtkWidget
                         +----GtkContainer
                               +----GtkBox
                                     +----GtkHBox
                                           +----SwamiguiSampleEditor

## Implemented Interfaces

SwamiguiSampleEditor implements AtkImplementorIface, GtkBuildable, GtkOrientable and SwamiguiPanel.

## Properties

      "marker-bar-height"        gint                  : Read / Write

## Description

## Details

### enum SwamiguiSampleEditorStatus

    typedef enum
    {
      SWAMIGUI_SAMPLE_EDITOR_NORMAL,	/* no particular status */
      SWAMIGUI_SAMPLE_EDITOR_INIT,		/* check selection and initialize */
      SWAMIGUI_SAMPLE_EDITOR_UPDATE		/* selection changed */
    } SwamiguiSampleEditorStatus;

### SwamiguiSampleEditorHandler ()

    gboolean            (*SwamiguiSampleEditorHandler)      (SwamiguiSampleEditor *editor);

This function type is used to handle specific patch item types with sample data and loop info. The `editor` object `status` field indicates the current operation which is one of:

`SWAMIGUI_SAMPLE_EDITOR_INIT` - Check selection and initialize the sample editor if the selection can be handled. Return `TRUE` if selection was handled, which will activate this handler, `FALSE` otherwise.

`SWAMIGUI_SAMPLE_EDITOR_UPDATE` - Item selection has changed, update sample editor. Return `TRUE` if selection change was handled, `FALSE` otherwise which will de-activate this handler.

Other useful fields of a SwamiguiSplits object include `selection` which defines the current item selection.

`editor` : | Sample editor widget
Returns : | Should return `TRUE` if operation was handled, `FALSE` otherwise.

### SwamiguiSampleEditor

    typedef struct _SwamiguiSampleEditor SwamiguiSampleEditor;

### enum SwamiguiSampleEditorMarkerFlags

    typedef enum
    {
      SWAMIGUI_SAMPLE_EDITOR_MARKER_SINGLE	= 1 << 0,  /* Single value (not range) */
      SWAMIGUI_SAMPLE_EDITOR_MARKER_VIEW	= 1 << 1,  /* view only marker */
      SWAMIGUI_SAMPLE_EDITOR_MARKER_SIZE	= 1 << 2   /* a start/size marker */
    } SwamiguiSampleEditorMarkerFlags;

### enum SwamiguiSampleEditorMarkerId

    typedef enum
    {
      SWAMIGUI_SAMPLE_EDITOR_MARKER_ID_SELECTION,		/* selection marker */
      SWAMIGUI_SAMPLE_EDITOR_MARKER_ID_LOOP_FIND_START,	/* loop find start window */
      SWAMIGUI_SAMPLE_EDITOR_MARKER_ID_LOOP_FIND_END	/* loop find end window */
    } SwamiguiSampleEditorMarkerId;

### swamigui_sample_editor_new ()

    GtkWidget *         swamigui_sample_editor_new          (void);

Create a new sample view object

Returns : | new widget of type SwamiguiSampleEditor

### swamigui_sample_editor_zoom_ofs ()

    void                swamigui_sample_editor_zoom_ofs     (SwamiguiSampleEditor *editor,
                                                             double zoom_amt,
                                                             double zoom_xpos);

Zoom the sample canvas the specified scale amount and modify the start sample position to keep the given X coordinate stationary.

`editor` : | Sample editor object
`zoom_amt` : | Zoom multiplier (> 1 = zoom in, < 1 = zoom out)
`zoom_xpos` : | X coordinate position to keep stationary

### swamigui_sample_editor_scroll_ofs ()

    void                swamigui_sample_editor_scroll_ofs   (SwamiguiSampleEditor *editor,
                                                             int sample_ofs);

Scroll the sample canvas by a given offset.

`editor` : | Sample editor object
`sample_ofs` : | Offset amount in samples

### swamigui_sample_editor_loop_zoom ()

    void                swamigui_sample_editor_loop_zoom    (SwamiguiSampleEditor *editor,
                                                             double zoom_amt);

Zoom the loop viewer canvas the specified scale amount. Zoom always occurs around center of loop cross overlap.

`editor` : | Sample editor object
`zoom_amt` : | Zoom multiplier (> 1 = zoom in, < 1 = zoom out)

### swamigui_sample_editor_set_selection ()

    void                swamigui_sample_editor_set_selection
                                                            (SwamiguiSampleEditor *editor,
                                                             IpatchList *items);

Set the items of a sample editor widget. The `items` list will usually contain a single patch item that has sample data associated with it, although sometimes multiple items will be handled as in the case of stereo pairs.

`editor` : | Sample editor object
`items` : | List of selected items or `NULL` to unset selection

### swamigui_sample_editor_get_selection ()

    IpatchList *        swamigui_sample_editor_get_selection
                                                            (SwamiguiSampleEditor *editor);

Get the list of active items in a sample editor widget.

`editor` : | Sample editor widget
Returns : | New list containing selected items which has a ref count of one which the caller owns or `NULL` if no items selected. Remove the reference when finished with it.

### swamigui_sample_editor_register_handler ()

    void                swamigui_sample_editor_register_handler
                                                            (SwamiguiSampleEditorHandler handler,
                                                             SwamiguiPanelCheckFunc check_func);

Registers a new handler for sample editor widgets. Sample editor handlers interface patch item's of particular types with sample data and related parameters (such as looping params).

MT: This function should only be called within GUI thread.

`handler` : | Sample editor handler function to register
`check_func` : | Function used to check if an item selection is valid for this handler

### swamigui_sample_editor_unregister_handler ()

    void                swamigui_sample_editor_unregister_handler
                                                            (SwamiguiSampleEditorHandler handler);

Unregisters a handler previously registered with `swamigui_sample_editor_register_handler()`.

MT: This function should only be called in GUI thread.

`handler` : | Handler function to unregister

### swamigui_sample_editor_reset ()

    void                swamigui_sample_editor_reset        (SwamiguiSampleEditor *editor);

Resets a sample editor by removing all tracks and markers and disconnecting loop view controls. Usually only used by sample editor handlers.

`editor` : | Sample editor widget

### swamigui_sample_editor_get_loop_controls ()

    void                swamigui_sample_editor_get_loop_controls
                                                            (SwamiguiSampleEditor *editor,
                                                             SwamiControl **loop_start,
                                                             SwamiControl **loop_end);

Get the loop start and end controls that are connected to all loop view start and end properties. Essentially controls for the loop view start and end points.

`editor` : | Sample editor object
`loop_start` : | Output - Loop view start point control (`NULL` to ignore)
`loop_end` : | Output - Loop view end point control (`NULL` to ignore)

### swamigui_sample_editor_add_track ()

    int                 swamigui_sample_editor_add_track    (SwamiguiSampleEditor *editor,
                                                             IpatchSampleData *sample,
                                                             gboolean right_chan);

Add a sample track to a sample editor. Usually only done by sample editor handlers. This function can be used to add multiple samples for stereo or multi-track audio.

`editor` : | Sample editor object
`sample` : | Object with an IpatchSample interface to add
`right_chan` : | Only used if `sample` is stereo. If `TRUE` the right channel will be used, `FALSE` will use the left channel.
Returns : | The index of the new track in the sample editor object (starting from 0).

### swamigui_sample_editor_get_track_info ()

    gboolean            swamigui_sample_editor_get_track_info
                                                            (SwamiguiSampleEditor *editor,
                                                             guint track,
                                                             IpatchSampleData **sample,
                                                             SwamiguiSampleCanvas **sample_view,
                                                             SwamiguiSampleCanvas **loop_view);

Get info for a sample track. No reference counting is done, since track will not get removed unless the sample editor handler does so. Returned object pointers should only be used within editor callback or references should be added.

`editor` : | Sample editor object
`track` : | Track index to get info from (starting from 0)
`sample` : | Output - Sample object (`NULL` to ignore)
`sample_view` : | Output - The sample view canvas (`NULL` to ignore)
`loop_view` : | Output - The loop view canvas (`NULL` to ignore)
Returns : | `TRUE` if `index` is a valid sample index, `FALSE` otherwise in which case the returned pointers are undefined.

### swamigui_sample_editor_remove_track ()

    void                swamigui_sample_editor_remove_track (SwamiguiSampleEditor *editor,
                                                             guint track);

Remove a track from a sample editor by its index (starts from 0).

`editor` : | Sample editor object
`track` : | Index of track to remove

### swamigui_sample_editor_remove_all_tracks ()

    void                swamigui_sample_editor_remove_all_tracks
                                                            (SwamiguiSampleEditor *editor);

Remove all tracks from a sample editor.

`editor` : | Sample editor object

### swamigui_sample_editor_add_marker ()

    guint               swamigui_sample_editor_add_marker   (SwamiguiSampleEditor *editor,
                                                             guint flags,
                                                             SwamiControl **start,
                                                             SwamiControl **end);

Add a new marker to a sample editor. Markers can be used for loop points, sample start/end points, selections and other position indicators/controls. Marker 0 is the sample selection marker and it is always present although it may be hidden.

`editor` : | Sample editor object
`flags` : | SwamiguiSampleEditorMarkerFlags - SWAMIGUI_SAMPLE_EDITOR_MARKER_SINGLE is used for markers which define a single value. - SWAMIGUI_SAMPLE_EDITOR_MARKER_VIEW is used for markers which are view only and not controllable by user. - SWAMIGUI_SAMPLE_EDITOR_MARKER_SIZE is used to define a start/size marker instead of a start/end marker. This causes the second control to be the current size of the marker instead of the end position. Note that passing 0 defines a interactive range marker.
`start` : | Output - New control for start of marker or `NULL` to ignore
`end` : | Output - New control for end/size of marker (ranges only) or `NULL` to ignore
Returns : | New marker index

### swamigui_sample_editor_get_marker_info ()

    gboolean            swamigui_sample_editor_get_marker_info
                                                            (SwamiguiSampleEditor *editor,
                                                             guint marker,
                                                             guint *flags,
                                                             GnomeCanvasItem **start_line,
                                                             GnomeCanvasItem **end_line,
                                                             SwamiControl **start_ctrl,
                                                             SwamiControl **end_ctrl);

Get info for the given `marker` index. No reference counting is done, since marker will not get removed unless the sample editor handler does so. Returned object pointers should only be used within editor callback or references should be added.

`editor` : | Sample editor object
`marker` : | Marker index to get info on (starts at 0 - the selection marker)
`flags` : | SwamiguiSampleEditorMarkerFlags
`start_line` : | Output - Gnome canvas line for the start marker (`NULL` to ignore)
`end_line` : | Output - Gnome canvas line for the end marker (`NULL` to ignore), will be `NULL` for single markers (non ranges)
`start_ctrl` : | Output - Control for the start marker (`NULL` to ignore)
`end_ctrl` : | Output - Control for the end/size marker (`NULL` to ignore), will be `NULL` for single markers (non ranges)
Returns : | `TRUE` if a marker with the given index exists, `FALSE` otherwise.

### swamigui_sample_editor_set_marker ()

    void                swamigui_sample_editor_set_marker   (SwamiguiSampleEditor *editor,
                                                             guint marker,
                                                             guint start,
                                                             guint end);

Set the marker start and end positions.

`editor` : | Sample editor widget
`marker` : | Marker number
`start` : | Marker start position
`end` : | Marker end position

### swamigui_sample_editor_remove_marker ()

    void                swamigui_sample_editor_remove_marker
                                                            (SwamiguiSampleEditor *editor,
                                                             guint marker);

Remove a marker.

`editor` : | Sample editor object
`marker` : | Index of marker to remove (builtin markers are hidden rather than removed)

### swamigui_sample_editor_remove_all_markers ()

    void                swamigui_sample_editor_remove_all_markers
                                                            (SwamiguiSampleEditor *editor);

Remove all markers (except selection marker 0, which is always present).

`editor` : | Sample editor object

### swamigui_sample_editor_show_marker ()

    void                swamigui_sample_editor_show_marker  (SwamiguiSampleEditor *editor,
                                                             guint marker,
                                                             gboolean show_marker);

Set the visibility of a marker.

`editor` : | Sample editor widget
`marker` : | Marker number to set visibility of
`show_marker` : | `TRUE` to show marker, `FALSE` to hide

### swamigui_sample_editor_set_loop_types ()

    void                swamigui_sample_editor_set_loop_types
                                                            (SwamiguiSampleEditor *editor,
                                                             int *types,
                                                             gboolean loop_play_btn);

Usually only used by sample editor handlers. Sets the available loop types in the loop selector menu.

`editor` : | Sample editor object
`types` : | -1 terminated array of IpatchSampleLoopType values to show in loop selector (`NULL` to hide loop selector)
`loop_play_btn` : | If `types` is `NULL`, setting this to `TRUE` will cause a play loop toggle button to be shown (for items that dont have a loop type property, but it is desirable for the user to be able to listen to the loop).

### swamigui_sample_editor_set_active_loop_type ()

    void                swamigui_sample_editor_set_active_loop_type
                                                            (SwamiguiSampleEditor *editor,
                                                             int type);

Set the active loop type in the loop type selector or loop play button. Usually only used by sample editor handlers.

`editor` : | Sample editor widget
`type` : | IpatchSampleLoopType or TRUE/FALSE if using loop play button.

## Property Details

### The `"marker-bar-height"` property

      "marker-bar-height"        gint                  : Read / Write

Height of marker and loop meter bar.

Allowed values: [0,100]

Default value: 24