<< Utility functions >>

These are some utility functions that you might find useful. They are available in gwavefile.h.

static inline gint16 double_to_s16 (gdouble d);

Convert a double [-1.0, 1.0] to a signed 16 bit number.


static inline gint32 double_to_s32 (gdouble d);

Convert a double [-1.0, 1.0] to a signed 32 bit number.


static inline gdouble s16_to_double (gint16 i);

Convert a 16 bit number to a double [-1.0, 1.0].


static inline gdouble s32_to_double (gint32 i);

Convert a 32 bit number to a double [-1.0, 1.0].


guint32 g_wavefile_type_width   (GWavefileType dtype);

Returns the number of bytes required to allocate one item of the given type.


void    g_wavefile_type_convert (guint32       n_channels,
                                 guint32       length,
                                 GWavefileType out_type,
                                 gpointer      out,
                                 GWavefileType in_type,
                                 gpointer      in);

Convert a whole block of data from one data type to another. The output pointer must point to a preallocated block of data.


void    g_wavefile_type_clear   (guint32       n_channels,
                                 guint32       length,
                                 GWavefileType type,
                                 gpointer      out);

Clears out a block of data to the proper median sample value.

Utility functions