Dicto

Dicto — Audio dictation gobject

Stability Level

Unstable, unless otherwise indicated

Synopsis

#define             DICTO_TYPE
#define             DICTO                               (obj)
#define             DICTO_CLASS                         (klass)
#define             IS_DICTO                            (obj)
#define             IS_DICTO_CLASS                      (klass)
#define             DICTO_GET_CLASS                     (obj)
                    DictoFormat;
struct              dicto;
typedef             Dicto;
GType               dicto_get_type                      (void);
Dicto *             dicto_new                           (gchar *basedir);
Dicto *             dicto_new_full                      (gchar *basedir,
                                                         DictoFormats f,
                                                         gchar *sink,
                                                         gchar *source);
gboolean            dicto_set_basedir                   (Dicto *d,
                                                         const gchar *basedir);
gboolean            dicto_record                        (Dicto *d,
                                                         const gchar *file);
gboolean            dicto_play                          (Dicto *d,
                                                         const gchar *file);
gboolean            dicto_prepare                       (Dicto *d,
                                                         const gchar *file);
gboolean            dicto_stop                          (Dicto *d);
gboolean            dicto_seek                          (Dicto *d,
                                                         gdouble pos);
gboolean            dicto_delete                        (Dicto *d,
                                                         const gchar *file);
gboolean            dicto_toggle_record                 (Dicto *d,
                                                         const gchar *file);
gchar *             dicto_filename_time_new             (Dicto *d,
                                                         time_t t);
gboolean            dicto_refresh_list                  (Dicto *d);
GHashTable *        dicto_notes_get_list                (Dicto *d);
gboolean            dicto_remove                        (Dicto *d,
                                                         const gchar *file);
gboolean            dicto_get_position                  (Dicto *d,
                                                         gdouble *length,
                                                         gdouble *position);

Object Hierarchy

  GObject
   +----Dicto

Properties

  "basedir"                  gchar*                : Read / Write / Construct
  "current-file"             gchar*                : Read
  "format"                   guint                 : Read / Write / Construct Only
  "pos-int"                  guint                 : Read / Write
  "prefix"                   gchar*                : Read / Write / Construct
  "sink"                     gchar*                : Read / Write / Construct Only
  "source"                   gchar*                : Read / Write / Construct Only
  "state"                    guint                 : Read
  "suffix"                   gchar*                : Read / Write / Construct
  "time-format"              gchar*                : Read / Write

Signals

  "error"                                          : Run First
  "level"                                          : Run First
  "playing"                                        : Run First
  "position"                                       : Run First
  "ready"                                          : Run First
  "recording"                                      : Run First
  "refresh"                                        : Run First
  "seeked"                                         : Run First
  "stopped-play"                                   : Run First
  "stopped-record"                                 : Run First

Description

Dicto is object that simplifies creating audio dictations in applications, it can be combined with DictoWidget to create a simple and automatic UI.

It uses a predefined list of some common formats, suitable for both speech and music.

The object takes care of a list of notes in the given base directory. Signals are emited when playing, recording, stopping, seeking and note list changes.

Details

DICTO_TYPE

#define DICTO_TYPE				(dicto_get_type ())


DICTO()

#define DICTO(obj)				(G_TYPE_CHECK_INSTANCE_CAST ((obj), DICTO_TYPE, Dicto))

obj :


DICTO_CLASS()

#define DICTO_CLASS(klass)		(G_TYPE_CHECK_CLASS_CAST ((klass), DICTO_TYPE, DictoClass))

klass :


IS_DICTO()

#define IS_DICTO(obj)			(G_TYPE_CHECK_INSTANCE_TYPE ((obj), DICTO_TYPE))

obj :


IS_DICTO_CLASS()

#define IS_DICTO_CLASS(klass)	(G_TYPE_CHECK_CLASS_TYPE ((klass), DICTO_TYPE))

klass :


DICTO_GET_CLASS()

#define DICTO_GET_CLASS(obj)		(G_TYPE_INSTANCE_GET_CLASS ((obj), DICTO_TYPE, DictoClass))

obj :


DictoFormat

typedef struct {
	gint id;
	const gchar *desc;
	const gchar *ext;
	const gchar *filter;
	const gchar *muxer;
	const gchar *encoder;
	const gchar *mime;
	guint channels;
	guint rate;
	guint bits;
} DictoFormat;


struct dicto

struct dicto {
	GObject parent;

	/* Private */
	gpointer priv;
};


Dicto

typedef struct _dicto Dicto;


dicto_get_type ()

GType               dicto_get_type                      (void);

Returns :


dicto_new ()

Dicto *             dicto_new                           (gchar *basedir);

Creates a new Dicto object ready for use with default format and audio sink/source, determined at ./configure time.

Default for desktop gtk build uses alsasink and alsasrc. Default for hildon 2.2 build uses pulsesink and pulsesrc. Default for hildon 2.0 build uses dsppcmsink and dsppcmsrc.

basedir :

Directory to use for file lists and new recordings

Returns :

See dicto_new_full()

dicto_new_full ()

Dicto *             dicto_new_full                      (gchar *basedir,
                                                         DictoFormats f,
                                                         gchar *sink,
                                                         gchar *source);

Creates a new Dicto object ready for use.

basedir :

Directory to use for file lists and new recordings

f :

Audio format to use

sink :

GstElement audio sink element

source :

GstElement audio source element

Returns :

The new Dicto object.

dicto_set_basedir ()

gboolean            dicto_set_basedir                   (Dicto *d,
                                                         const gchar *basedir);

Set base directory to use to for recordings. d: A Dicto object. basedir: A UNIX path to notes, it will be created if it does not exists.

d :

basedir :

Returns :


dicto_record ()

gboolean            dicto_record                        (Dicto *d,
                                                         const gchar *file);

Records to given file without a limit. Emits "recording" when recording starts.

d :

A Dicto object

file :

Returns :

TRUE if recording started, FALSE on error.

dicto_play ()

gboolean            dicto_play                          (Dicto *d,
                                                         const gchar *file);

Plays given audio note file. Does nothing if already playing. Clears current note on error.

d :

A Dicto object

file :

A file to play

Returns :

TRUE if playback started, FALSE on error and if recording.

dicto_prepare ()

gboolean            dicto_prepare                       (Dicto *d,
                                                         const gchar *file);

Prepares given file for playback but does not start playback. Use dicto_play() with same filename to start playback. Does nothing if we are already playing. Clears current file if error happens.

d :

A Dicto object

file :

A file to prepare for playback

Returns :

TRUE if preparation was successfull, FALSE otherwise.

dicto_stop ()

gboolean            dicto_stop                          (Dicto *d);

Stop recording or playback. Emits signals "stopped_play" or "stopped_record" if pipelines where stopped.

d :

A Dicto object

Returns :

TRUE if a pipeline was stopped.

dicto_seek ()

gboolean            dicto_seek                          (Dicto *d,
                                                         gdouble pos);

Seeks to given position in the current playback note. The note must have been prepared with dicto_prepare() or beeing played back by dicto_play().

d :

A Dicto object

pos :

Position to seek to

Returns :

TRUE if seeking was successfull.

dicto_delete ()

gboolean            dicto_delete                        (Dicto *d,
                                                         const gchar *file);

Simple version of dicto_delete_full

d :

A Dicto object

file :

A note to delete, must be an existing note file name

Returns :

FALSE on error, TRUE otherwise.

dicto_toggle_record ()

gboolean            dicto_toggle_record                 (Dicto *d,
                                                         const gchar *file);

Toggles recording: stops if recording, records if stopped.

d :

A Dicto object

file :

Filename to use for new recording.

Returns :

TRUE if successfull, FALSE if playing or other error.

dicto_filename_time_new ()

gchar *             dicto_filename_time_new             (Dicto *d,
                                                         time_t t);

d :

A Dicto object

t :

A unix timestamp, or 0 for current time.

Returns :

A string containg a filename with the given or current timestamp using given format or the default "Y-m-d-H-M-S".

dicto_refresh_list ()

gboolean            dicto_refresh_list                  (Dicto *d);

d :

Returns :


dicto_notes_get_list ()

GHashTable *        dicto_notes_get_list                (Dicto *d);

d :

Returns :


dicto_remove ()

gboolean            dicto_remove                        (Dicto *d,
                                                         const gchar *file);

d :

file :

Returns :


dicto_get_position ()

gboolean            dicto_get_position                  (Dicto *d,
                                                         gdouble *length,
                                                         gdouble *position);

Get the current playback/recording position and stream length. If any of two arguments are null the queries will be skipped.

d :

A Dicto object

length :

Pointer to a gdouble, to store length of the currently playing recording, dummy if recording.

position :

Pointer to a gdouble, to store the current position of playing recording or length to current recording.

Returns :

TRUE if any of the two queries was ok.

Property Details

The "basedir" property

  "basedir"                  gchar*                : Read / Write / Construct

Default value: "/tmp"


The "current-file" property

  "current-file"             gchar*                : Read

Default value: ""


The "format" property

  "format"                   guint                 : Read / Write / Construct Only

Allowed values: <= 16

Default value: 0


The "pos-int" property

  "pos-int"                  guint                 : Read / Write

Report position this often, in ms.

Allowed values: [50,1000]

Default value: 250


The "prefix" property

  "prefix"                   gchar*                : Read / Write / Construct

Default value: "an-"


The "sink" property

  "sink"                     gchar*                : Read / Write / Construct Only

gstreamer sink element used for playback.

Default value: "alsasrc"


The "source" property

  "source"                   gchar*                : Read / Write / Construct Only

gstreamer source element used for recording.

Default value: "alsasink"


The "state" property

  "state"                    guint                 : Read

The current DictoState state of Dicto,

Allowed values: <= 8

Default value: 0


The "suffix" property

  "suffix"                   gchar*                : Read / Write / Construct

Default value: ""


The "time-format" property

  "time-format"              gchar*                : Read / Write

Default value: "%Y-%m-%d-%H-%M-%S"

Signal Details

The "error" signal

void                user_function                      (Dicto   *dicto,
                                                        gpointer arg1,
                                                        gpointer user_data)      : Run First

dicto :

the object which received the signal.

arg1 :

user_data :

user data set when the signal handler was connected.

The "level" signal

void                user_function                      (Dicto   *dicto,
                                                        gdouble  arg1,
                                                        gdouble  arg2,
                                                        gdouble  arg3,
                                                        gpointer user_data)      : Run First

dicto :

the object which received the signal.

arg1 :

Param3 :

Param4 :

user_data :

user data set when the signal handler was connected.

The "playing" signal

void                user_function                      (Dicto   *dicto,
                                                        gpointer user_data)      : Run First

dicto :

the object which received the signal.

user_data :

user data set when the signal handler was connected.

The "position" signal

void                user_function                      (Dicto   *dicto,
                                                        gdouble  arg1,
                                                        gpointer user_data)      : Run First

dicto :

the object which received the signal.

arg1 :

user_data :

user data set when the signal handler was connected.

The "ready" signal

void                user_function                      (Dicto   *dicto,
                                                        gpointer user_data)      : Run First

dicto :

the object which received the signal.

user_data :

user data set when the signal handler was connected.

The "recording" signal

void                user_function                      (Dicto   *dicto,
                                                        gpointer user_data)      : Run First

dicto :

the object which received the signal.

user_data :

user data set when the signal handler was connected.

The "refresh" signal

void                user_function                      (Dicto   *dicto,
                                                        gpointer user_data)      : Run First

dicto :

the object which received the signal.

user_data :

user data set when the signal handler was connected.

The "seeked" signal

void                user_function                      (Dicto   *dicto,
                                                        gdouble  arg1,
                                                        gpointer user_data)      : Run First

dicto :

the object which received the signal.

arg1 :

user_data :

user data set when the signal handler was connected.

The "stopped-play" signal

void                user_function                      (Dicto   *dicto,
                                                        gpointer user_data)      : Run First

dicto :

the object which received the signal.

user_data :

user data set when the signal handler was connected.

The "stopped-record" signal

void                user_function                      (Dicto   *dicto,
                                                        gpointer user_data)      : Run First

dicto :

the object which received the signal.

user_data :

user data set when the signal handler was connected.

See Also

#DictoWidget