~ubuntu-branches/ubuntu/utopic/glame/utopic

« back to all changes in this revision

Viewing changes to src/gui/libgtkwaveform/gwavefile.h

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Kobras
  • Date: 2002-04-09 17:14:12 UTC
  • Revision ID: james.westby@ubuntu.com-20020409171412-jzpnov7mbz2w6zsr
Tags: upstream-0.6.2
ImportĀ upstreamĀ versionĀ 0.6.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * gwavefile.h: wave utilities
 
3
 *
 
4
 * Copyright (c) 2000, 2001 David A. Bartold, Richard Guenther
 
5
 *
 
6
 * This library is free software; you can redistribute it and/or
 
7
 * modify it under the terms of the GNU Library General Public
 
8
 * License as published by the Free Software Foundation; either
 
9
 * version 2 of the License, or (at your option) any later version.
 
10
 *
 
11
 * This library is distributed in the hope that it will be useful,
 
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
14
 * Library General Public License for more details.
 
15
 *
 
16
 * You should have received a copy of the GNU Library General Public
 
17
 * License along with this library; if not, write to the
 
18
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 
19
 * Boston, MA 02111-1307, USA.
 
20
 */
 
21
 
 
22
#ifndef __G_WAVEFILE_H__
 
23
#define __G_WAVEFILE_H__
 
24
 
 
25
#include <glib.h>
 
26
 
 
27
 
 
28
typedef struct _GWavefile GWavefile;
 
29
typedef enum   _GWavefileType         GWavefileType;
 
30
 
 
31
enum _GWavefileType
 
32
{
 
33
  G_WAVEFILE_TYPE_NULL,
 
34
  G_WAVEFILE_TYPE_S32, G_WAVEFILE_TYPE_U32,
 
35
  G_WAVEFILE_TYPE_S16, G_WAVEFILE_TYPE_U16,
 
36
  G_WAVEFILE_TYPE_S8, G_WAVEFILE_TYPE_U8,
 
37
  G_WAVEFILE_TYPE_F4, G_WAVEFILE_TYPE_F8,
 
38
  G_WAVEFILE_TYPE_F4NI, G_WAVEFILE_TYPE_F8NI
 
39
};
 
40
 
 
41
 
 
42
/* Utility functions. */
 
43
static inline gint16
 
44
double_to_s16 (gdouble d)
 
45
{
 
46
  if (d >= 1.0)
 
47
    return 32767;
 
48
  else if (d <= -1.0)
 
49
    return -32768;
 
50
 
 
51
  return (gint16) ((d + 1.0) * 32767.5 - 32768.0);
 
52
}
 
53
 
 
54
static inline gint32
 
55
double_to_s32 (gdouble d)
 
56
{
 
57
  if (d >= 1.0)
 
58
    return 0x7fffffff /* 2147483647 */;
 
59
  else if (d <= -1.0)
 
60
    return 0x80000000 /* -2147483648 */;
 
61
 
 
62
  return (gint32) ((d + 1.0) * 2147483647.5 - 2147483648.0);
 
63
}
 
64
 
 
65
static inline gdouble
 
66
s32_to_double (gint32 i)
 
67
{
 
68
  return (((double) i) + 2147483648.0) / 2147483647.5 - 1.0;
 
69
}
 
70
 
 
71
static inline gdouble
 
72
s16_to_double (gint16 i)
 
73
{
 
74
  return (((double) i) + 32768.0) / 32767.5 - 1.0;
 
75
}
 
76
 
 
77
 
 
78
 
 
79
#ifdef __cplusplus
 
80
extern "C" {
 
81
#endif
 
82
 
 
83
guint32 g_wavefile_type_width   (GWavefileType dtype);
 
84
void    g_wavefile_type_convert (guint32       n_channels,
 
85
                                 guint32       length,
 
86
                                 GWavefileType out_type,
 
87
                                 gpointer      out,
 
88
                                 GWavefileType in_type,
 
89
                                 gpointer      in);
 
90
void    g_wavefile_type_clear   (guint32       n_channels,
 
91
                                 guint32       length,
 
92
                                 GWavefileType type,
 
93
                                 gpointer      out);
 
94
 
 
95
#ifdef __cplusplus
 
96
}
 
97
#endif
 
98
 
 
99
 
 
100
#endif /* __G_WAVEFILE_H__ */