~siretart/ubuntu/utopic/blender/libav10

« back to all changes in this revision

Viewing changes to source/blender/python/api2_2x/Sound.c

  • Committer: Bazaar Package Importer
  • Author(s): Kevin Roy
  • Date: 2011-02-08 22:20:54 UTC
  • mfrom: (1.4.2 upstream)
  • mto: (14.2.6 sid) (1.5.1)
  • mto: This revision was merged to the branch mainline in revision 27.
  • Revision ID: james.westby@ubuntu.com-20110208222054-kk0gwa4bu8h5lyq4
Tags: upstream-2.56.1-beta-svn34076
ImportĀ upstreamĀ versionĀ 2.56.1-beta-svn34076

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* 
2
 
 * $Id: Sound.c 14444 2008-04-16 22:40:48Z hos $
3
 
 *
4
 
 * ***** BEGIN GPL LICENSE BLOCK *****
5
 
 *
6
 
 * This program is free software; you can redistribute it and/or
7
 
 * modify it under the terms of the GNU General Public License
8
 
 * as published by the Free Software Foundation; either version 2
9
 
 * of the License, or (at your option) any later version.
10
 
 *
11
 
 * This program 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
14
 
 * GNU General Public License for more details.
15
 
 *
16
 
 * You should have received a copy of the GNU General Public License
17
 
 * along with this program; if not, write to the Free Software Foundation,
18
 
 * Inc., 59 Temple Place - Suite 330, Boston, MA        02111-1307, USA.
19
 
 *
20
 
 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
21
 
 * All rights reserved.
22
 
 *
23
 
 * This is a new part of Blender.
24
 
 *
25
 
 * Contributor(s): Chris Keith
26
 
 *
27
 
 * ***** END GPL LICENSE BLOCK *****
28
 
*/
29
 
 
30
 
#include "Sound.h" /*This must come first*/
31
 
 
32
 
#include "BKE_global.h"
33
 
#include "BKE_main.h"
34
 
#include "BLI_blenlib.h"
35
 
#include "BKE_sound.h"
36
 
#include "BKE_library.h"
37
 
#include "BIF_editsound.h"
38
 
#include "BKE_packedFile.h"
39
 
#include "mydevice.h"           /* redraw defines */
40
 
#include "gen_utils.h"
41
 
#include "gen_library.h"
42
 
#include "DNA_space_types.h" /* for FILE_MAXDIR only */
43
 
 
44
 
/*****************************************************************************/
45
 
/* Python BPy_Sound defaults:                                   */
46
 
/*****************************************************************************/
47
 
 
48
 
#define EXPP_SND_volume_MIN   0.0
49
 
#define EXPP_SND_volume_MAX   1.0
50
 
#define EXPP_SND_pitch_MIN  -12.0
51
 
#define EXPP_SND_pitch_MAX   12.0
52
 
#define EXPP_SND_attenuation_MIN 0.0
53
 
#define EXPP_SND_attenuation_MAX 5.0
54
 
 
55
 
/*****************************************************************************/
56
 
/* Python API function prototypes for the Sound module.         */
57
 
/*****************************************************************************/
58
 
static PyObject *M_Sound_Get( PyObject * self, PyObject * args );
59
 
static PyObject *M_Sound_Load( PyObject * self, PyObject * value );
60
 
 
61
 
/************************************************************************/
62
 
/* The following string definitions are used for documentation strings. */
63
 
/* In Python these will be written to the console when doing a          */
64
 
/* Blender.Sound.__doc__                                                */
65
 
/************************************************************************/
66
 
static char M_Sound_doc[] = "The Blender Sound module\n\n";
67
 
 
68
 
static char M_Sound_Get_doc[] =
69
 
        "(name) - return the sound with the name 'name', \
70
 
returns None if not found.\n If 'name' is not specified, \
71
 
it returns a list of all sounds in the\ncurrent scene.";
72
 
 
73
 
static char M_Sound_Load_doc[] =
74
 
        "(filename) - return sound from file filename as a Sound Object,\n\
75
 
returns None if not found.";
76
 
 
77
 
/*****************************************************************************/
78
 
/* Python method structure definition for Blender.Sound module:                                                  */
79
 
/*****************************************************************************/
80
 
struct PyMethodDef M_Sound_methods[] = {
81
 
        {"Get", M_Sound_Get, METH_VARARGS, M_Sound_Get_doc},
82
 
        {"Load", M_Sound_Load, METH_O, M_Sound_Load_doc},
83
 
        {NULL, NULL, 0, NULL}
84
 
};
85
 
 
86
 
/*****************************************************************************/
87
 
/* Python Sound_Type callback function prototypes:                      */
88
 
/*****************************************************************************/
89
 
static int Sound_compare( BPy_Sound * a, BPy_Sound * b );
90
 
static PyObject *Sound_repr( BPy_Sound * self );
91
 
 
92
 
#define SOUND_FLOAT_METHODS(funcname, varname)                                  \
93
 
static PyObject *Sound_get ## funcname(BPy_Sound *self) {               \
94
 
    return PyFloat_FromDouble(self->sound->varname);                    \
95
 
}                                                                                                                               \
96
 
static PyObject *Sound_set ## funcname(BPy_Sound *self, PyObject *args) { \
97
 
    float       f = 0;                                                                                                  \
98
 
    if (!PyArg_ParseTuple(args, "f", &f))                                                       \
99
 
            return (EXPP_ReturnPyObjError (PyExc_TypeError,                             \
100
 
                    "expected float argument"));                                                        \
101
 
    self->sound->varname = EXPP_ClampFloat(f,                                           \
102
 
                        EXPP_SND_##varname##_MIN, EXPP_SND_##varname##_MAX);    \
103
 
    Py_RETURN_NONE;                                                                                                     \
104
 
}
105
 
 
106
 
#define SOUND_FLOAT_METHOD_FUNCS(varname)                                                       \
107
 
{"get"#varname, (PyCFunction)Sound_get ## varname, METH_NOARGS,         \
108
 
"() - Return Sound object "#varname},                                                           \
109
 
{"set"#varname, (PyCFunction)Sound_set ## varname, METH_VARARGS,        \
110
 
"(float) - Change Sound object "#varname},
111
 
 
112
 
 
113
 
/*****************************************************************************/
114
 
/* Python BPy_Sound methods declarations:                               */
115
 
/*****************************************************************************/
116
 
static PyObject *Sound_getName( BPy_Sound * self );
117
 
static PyObject *Sound_getFilename( BPy_Sound * self );
118
 
static PyObject *Sound_setName( BPy_Sound * self, PyObject * args );
119
 
static int               Sound_setFilename( BPy_Sound * self, PyObject * args );
120
 
static PyObject *Sound_oldsetFilename( BPy_Sound * self, PyObject * args );
121
 
static PyObject *Sound_setCurrent( BPy_Sound * self );
122
 
static PyObject *Sound_play( BPy_Sound * self );
123
 
static PyObject *Sound_unpack( BPy_Sound * self, PyObject * args);
124
 
static PyObject *Sound_pack( BPy_Sound * self );
125
 
/*static PyObject *Sound_reload ( BPy_Sound * self );*/
126
 
SOUND_FLOAT_METHODS( Volume, volume )
127
 
SOUND_FLOAT_METHODS( Attenuation, attenuation )
128
 
SOUND_FLOAT_METHODS( Pitch, pitch )
129
 
/* these can't be set via interface, removed for now */
130
 
/*
131
 
SOUND_FLOAT_METHODS( Panning, panning )
132
 
SOUND_FLOAT_METHODS( MinGain, min_gain )
133
 
SOUND_FLOAT_METHODS( MaxGain, max_gain )
134
 
SOUND_FLOAT_METHODS( Distance, distance )
135
 
*/
136
 
 
137
 
/*****************************************************************************/
138
 
/* Python BPy_Sound methods table:                                       */
139
 
/*****************************************************************************/
140
 
static PyMethodDef BPy_Sound_methods[] = {
141
 
        /* name, method, flags, doc */
142
 
        {"getName", ( PyCFunction ) Sound_getName, METH_NOARGS,
143
 
         "() - Return Sound object name"},
144
 
        {"getFilename", ( PyCFunction ) Sound_getFilename, METH_NOARGS,
145
 
         "() - Return Sound object filename"},
146
 
        {"setName", ( PyCFunction ) Sound_setName, METH_VARARGS,
147
 
         "(name) - Set Sound object name"},
148
 
        {"setFilename", ( PyCFunction ) Sound_oldsetFilename, METH_VARARGS,
149
 
         "(filename) - Set Sound object filename"},
150
 
        {"setCurrent", ( PyCFunction ) Sound_setCurrent, METH_NOARGS,
151
 
         "() - make this the active sound in the sound buttons win (also redraws)"},
152
 
        {"play", ( PyCFunction ) Sound_play, METH_NOARGS,
153
 
                                 "() - play this sound"},
154
 
        {"unpack", ( PyCFunction ) Sound_unpack, METH_VARARGS,
155
 
                         "(int) - Unpack sound. Uses one of the values defined in Blender.UnpackModes."},
156
 
        {"pack", ( PyCFunction ) Sound_pack, METH_NOARGS,
157
 
                         "() Pack the sound"},
158
 
/*
159
 
        {"reload", ( PyCFunction ) Sound_setCurrent, METH_NOARGS,
160
 
         "() - reload this Sound object's sample.\n\
161
 
    This is only useful if the original sound file has changed."},
162
 
*/
163
 
        SOUND_FLOAT_METHOD_FUNCS( Volume )
164
 
        SOUND_FLOAT_METHOD_FUNCS( Attenuation )
165
 
        SOUND_FLOAT_METHOD_FUNCS( Pitch )
166
 
        /*
167
 
        SOUND_FLOAT_METHOD_FUNCS( Panning )
168
 
        SOUND_FLOAT_METHOD_FUNCS( MinGain )
169
 
        SOUND_FLOAT_METHOD_FUNCS( MaxGain )
170
 
        SOUND_FLOAT_METHOD_FUNCS( Distance )
171
 
        */
172
 
        {NULL, NULL, 0, NULL}
173
 
};
174
 
 
175
 
/* NOTE: these were copied and modified from image.h.  To Be Done TBD:
176
 
 * macro-ize them, or C++ templates eventually?
177
 
 */
178
 
/****************************************************************************/
179
 
/* Function:            M_Sound_Get                             */
180
 
/* Python equivalent:   Blender.Sound.Get                        */
181
 
/* Description:         Receives a string and returns the Sound object   */
182
 
/*                      whose name matches the string.  If no argument is  */
183
 
/*                      passed in, a list of all Sound names in the      */
184
 
/*                      current scene is returned.                       */
185
 
/****************************************************************************/
186
 
static PyObject *M_Sound_Get( PyObject * self, PyObject * args )
187
 
{
188
 
        char *name = NULL;
189
 
        bSound *snd_iter;
190
 
 
191
 
        if( !PyArg_ParseTuple( args, "|s", &name ) )
192
 
                return ( EXPP_ReturnPyObjError( PyExc_TypeError,
193
 
                                                "expected string argument (or nothing)" ) );
194
 
 
195
 
        snd_iter = G.main->sound.first;
196
 
 
197
 
        if( name ) {            /* (name) - Search Sound by name */
198
 
 
199
 
                BPy_Sound *wanted_Sound = NULL;
200
 
 
201
 
                while( ( snd_iter ) && ( wanted_Sound == NULL ) ) {
202
 
                        if( strcmp( name, snd_iter->id.name + 2 ) == 0 ) {
203
 
                                wanted_Sound =
204
 
                                        ( BPy_Sound * )
205
 
                                        PyObject_NEW( BPy_Sound, &Sound_Type );
206
 
                                if( wanted_Sound ) {
207
 
                                        wanted_Sound->sound = snd_iter;
208
 
                                        break;
209
 
                                }
210
 
                        }
211
 
                        snd_iter = snd_iter->id.next;
212
 
                }
213
 
 
214
 
                if( wanted_Sound == NULL ) {    /* Requested Sound doesn't exist */
215
 
                        char error_msg[64];
216
 
                        PyOS_snprintf( error_msg, sizeof( error_msg ),
217
 
                                       "Sound \"%s\" not found", name );
218
 
                        return ( EXPP_ReturnPyObjError
219
 
                                 ( PyExc_NameError, error_msg ) );
220
 
                }
221
 
 
222
 
                return ( PyObject * ) wanted_Sound;
223
 
        }
224
 
 
225
 
        else {                  /* () - return a list of all Sounds in the scene */
226
 
                int index = 0;
227
 
                PyObject *snd_list, *pyobj;
228
 
 
229
 
                snd_list = PyList_New( BLI_countlist( &( G.main->sound ) ) );
230
 
 
231
 
                if( snd_list == NULL )
232
 
                        return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
233
 
                                                        "couldn't create PyList" ) );
234
 
 
235
 
                while( snd_iter ) {
236
 
                        pyobj = Sound_CreatePyObject( snd_iter );
237
 
 
238
 
                        if( !pyobj ) {
239
 
                                Py_DECREF(snd_list);
240
 
                                return ( EXPP_ReturnPyObjError
241
 
                                         ( PyExc_MemoryError,
242
 
                                           "couldn't create PyObject" ) );
243
 
                        }
244
 
                        PyList_SET_ITEM( snd_list, index, pyobj );
245
 
 
246
 
                        snd_iter = snd_iter->id.next;
247
 
                        index++;
248
 
                }
249
 
 
250
 
                return ( snd_list );
251
 
        }
252
 
}
253
 
 
254
 
/*****************************************************************************/
255
 
/* Function:    M_Sound_Load                                            */
256
 
/* Python equivalent:   Blender.Sound.Load                              */
257
 
/* Description:         Receives a string and returns the Sound object   */
258
 
/*                      whose filename matches the string.               */
259
 
/*****************************************************************************/
260
 
static PyObject *M_Sound_Load( PyObject * self, PyObject * value )
261
 
{
262
 
        char *fname = PyString_AsString(value);
263
 
        bSound *snd_ptr;
264
 
        BPy_Sound *snd;
265
 
 
266
 
        if( !fname )
267
 
                return ( EXPP_ReturnPyObjError( PyExc_TypeError,
268
 
                                                "expected string argument" ) );
269
 
 
270
 
        snd = ( BPy_Sound * ) PyObject_NEW( BPy_Sound, &Sound_Type );
271
 
 
272
 
        if( !snd )
273
 
                return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
274
 
                                                "couldn't create PyObject Sound_Type" ) );
275
 
 
276
 
        snd_ptr = sound_new_sound( fname );
277
 
 
278
 
        if( snd_ptr ) {
279
 
                if( G.ssound ) {
280
 
                        G.ssound->sound = snd_ptr;
281
 
                }
282
 
        }
283
 
 
284
 
        if( !snd_ptr )
285
 
                return ( EXPP_ReturnPyObjError( PyExc_IOError,
286
 
                                                "not a valid sound sample" ) );
287
 
 
288
 
        snd->sound = snd_ptr;
289
 
 
290
 
        return ( PyObject * ) snd;
291
 
}
292
 
 
293
 
/*****************************************************************************/
294
 
/* Function:    Sound_Init                                      */
295
 
/*****************************************************************************/
296
 
PyObject *Sound_Init( void )
297
 
{
298
 
        PyObject *submodule;
299
 
 
300
 
        if( PyType_Ready( &Sound_Type ) < 0 )
301
 
                return NULL;
302
 
 
303
 
        submodule =
304
 
                Py_InitModule3( "Blender.Sound", M_Sound_methods,
305
 
                                M_Sound_doc );
306
 
 
307
 
        return ( submodule );
308
 
}
309
 
 
310
 
/************************/
311
 
/*** The Sound PyType ***/
312
 
/************************/
313
 
 
314
 
 
315
 
/*****************************************************************************/
316
 
/* Function:    Sound_CreatePyObject                                    */
317
 
/* Description: This function will create a new BPy_Sound from an existing  */
318
 
/*              Blender Sound structure.                                */
319
 
/*****************************************************************************/
320
 
PyObject *Sound_CreatePyObject( bSound * snd )
321
 
{
322
 
        BPy_Sound *py_snd;
323
 
 
324
 
        py_snd = ( BPy_Sound * ) PyObject_NEW( BPy_Sound, &Sound_Type );
325
 
 
326
 
        if( !py_snd )
327
 
                return EXPP_ReturnPyObjError( PyExc_MemoryError,
328
 
                                              "couldn't create BPy_Sound object" );
329
 
 
330
 
        py_snd->sound = snd;
331
 
 
332
 
        return ( PyObject * ) py_snd;
333
 
}
334
 
 
335
 
/*****************************************************************************/
336
 
/* Function:    Sound_FromPyObject                              */
337
 
/* Description: Returns the Blender Sound associated with this object    */
338
 
/*****************************************************************************/
339
 
bSound *Sound_FromPyObject( PyObject * pyobj )
340
 
{
341
 
        return ( ( BPy_Sound * ) pyobj )->sound;
342
 
}
343
 
 
344
 
/*****************************************************************************/
345
 
/* Python BPy_Sound methods:    */
346
 
/*****************************************************************************/
347
 
static PyObject *Sound_getName( BPy_Sound * self )
348
 
{
349
 
        return PyString_FromString( self->sound->id.name + 2 );
350
 
}
351
 
 
352
 
static PyObject *Sound_getFilename( BPy_Sound * self )
353
 
{
354
 
        return PyString_FromString( self->sound->name );
355
 
}
356
 
 
357
 
static PyObject *Sound_getPacked( BPy_Sound * self )
358
 
{
359
 
        if (!sound_sample_is_null(self->sound)) {
360
 
                bSample *sample = sound_find_sample(self->sound);
361
 
                if (sample->packedfile)
362
 
                        Py_RETURN_TRUE;
363
 
        }
364
 
        Py_RETURN_FALSE;
365
 
}
366
 
 
367
 
static PyObject *Sound_setName( BPy_Sound * self, PyObject * args )
368
 
{
369
 
        char *name;
370
 
 
371
 
        if( !PyArg_ParseTuple( args, "s", &name ) ) {
372
 
                return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
373
 
                                                "expected a String as argument" ) );
374
 
        }
375
 
 
376
 
        rename_id( &self->sound->id, name );
377
 
 
378
 
        Py_RETURN_NONE;
379
 
}
380
 
 
381
 
static int Sound_setFilename( BPy_Sound * self, PyObject * value )
382
 
{
383
 
        char *name;
384
 
 
385
 
        /* max len is FILE_MAXDIR = 160 chars like in DNA_image_types.h */
386
 
        name = PyString_AsString(value);
387
 
        if (!name || strlen(name) > FILE_MAXDIR)
388
 
                return ( EXPP_ReturnIntError( PyExc_ValueError,
389
 
                                                "string argument is limited to 160 chars at most" ) );
390
 
 
391
 
        strcpy( self->sound->name, name );
392
 
        return 0;
393
 
}
394
 
 
395
 
static PyObject *Sound_oldsetFilename( BPy_Sound * self, PyObject * args )
396
 
{
397
 
        return EXPP_setterWrapper( (void *)self, args, (setter)Sound_setFilename );
398
 
}
399
 
 
400
 
 
401
 
static PyObject *Sound_play( BPy_Sound * self )
402
 
{
403
 
        sound_play_sound( self->sound );
404
 
 
405
 
        Py_RETURN_NONE;
406
 
}
407
 
 
408
 
static PyObject *Sound_setCurrent( BPy_Sound * self )
409
 
{
410
 
        bSound *snd_ptr = self->sound;
411
 
 
412
 
        if( snd_ptr ) {
413
 
                if( G.ssound ) {
414
 
                        G.ssound->sound = snd_ptr;
415
 
                }
416
 
        }
417
 
 
418
 
        EXPP_allqueue( REDRAWSOUND, 0 );
419
 
        EXPP_allqueue( REDRAWBUTSLOGIC, 0 );
420
 
 
421
 
        Py_RETURN_NONE;
422
 
}
423
 
 
424
 
/* unpack sound */
425
 
 
426
 
static PyObject *Sound_unpack( BPy_Sound * self, PyObject * args )
427
 
{
428
 
        bSound *sound = self->sound;
429
 
        int mode;
430
 
        if( !PyArg_ParseTuple( args, "i", &mode ) )
431
 
                        return EXPP_ReturnPyObjError( PyExc_TypeError,
432
 
                                                        "expected an integer from Blender.UnpackModes" );
433
 
 
434
 
        if (!sound_sample_is_null(sound)) {
435
 
            bSample *sample = sound_find_sample(sound);
436
 
                if (sample->packedfile) {
437
 
                        if (unpackSample(sample, mode) == RET_ERROR)
438
 
                                        return EXPP_ReturnPyObjError( PyExc_RuntimeError,
439
 
                                                                        "error unpacking sound");
440
 
                }
441
 
        } else {
442
 
                return EXPP_ReturnPyObjError( PyExc_RuntimeError, "sound has no samples" );
443
 
        }
444
 
        Py_RETURN_NONE;
445
 
}
446
 
 
447
 
/* pack sound */
448
 
 
449
 
static PyObject *Sound_pack( BPy_Sound * self )
450
 
{
451
 
        bSound *sound = self->sound;
452
 
        if (!sound_sample_is_null(sound))
453
 
        {
454
 
                bSample *sample = sound_find_sample(sound);
455
 
                if (sample->packedfile )
456
 
                        return EXPP_ReturnPyObjError( PyExc_RuntimeError,
457
 
                                        "sound alredy packed" );
458
 
                sound_set_packedfile(sample, newPackedFile(sample->name));
459
 
        }
460
 
        else
461
 
        {
462
 
                return EXPP_ReturnPyObjError( PyExc_RuntimeError,
463
 
                                "sound has no samples" );
464
 
        }
465
 
        Py_RETURN_NONE;
466
 
}
467
 
 
468
 
/*
469
 
static PyObject *Sound_reload( BPy_Sound * self)
470
 
{
471
 
        sound_free_sample();
472
 
 
473
 
        if (sound->snd_sound) {
474
 
                SND_RemoveSound(ghSoundScene, sound->snd_sound);
475
 
                sound->snd_sound = NULL;
476
 
        }
477
 
 
478
 
        Py_RETURN_NONE;
479
 
}
480
 
*/
481
 
 
482
 
 
483
 
 
484
 
/*****************************************************************************/
485
 
/* Function:    Sound_compare                                   */
486
 
/* Description: This is a callback function for the BPy_Sound type. It   */
487
 
/*              compares two Sound_Type objects. Only the "==" and "!="   */
488
 
/*              comparisons are meaninful. Returns 0 for equality and -1 if  */
489
 
/*              they don't point to the same Blender Sound struct.       */
490
 
/*              In Python it becomes 1 if they are equal, 0 otherwise.   */
491
 
/*****************************************************************************/
492
 
static int Sound_compare( BPy_Sound * a, BPy_Sound * b )
493
 
{
494
 
        return ( a->sound == b->sound ) ? 0 : -1;
495
 
}
496
 
 
497
 
/*****************************************************************************/
498
 
/* Function:    Sound_repr                                              */
499
 
/* Description: This is a callback function for the BPy_Sound type. It  */
500
 
/*              builds a meaninful string to represent Sound objects.    */
501
 
/*****************************************************************************/
502
 
static PyObject *Sound_repr( BPy_Sound * self )
503
 
{
504
 
        return PyString_FromFormat( "[Sound \"%s\"]",
505
 
                                    self->sound->id.name + 2 );
506
 
}
507
 
 
508
 
/*****************************************************************************/
509
 
/* Python attributes get/set structure:                                      */
510
 
/*****************************************************************************/
511
 
static PyGetSetDef BPy_Sound_getseters[] = {
512
 
        GENERIC_LIB_GETSETATTR,
513
 
        {"filename", (getter)Sound_getFilename, (setter)Sound_setFilename,
514
 
         "text filename", NULL},
515
 
        {"packed", (getter)Sound_getPacked, (setter)NULL,
516
 
         "text filename", NULL},
517
 
        {NULL,NULL,NULL,NULL,NULL}  /* Sentinel */
518
 
};
519
 
 
520
 
 
521
 
 
522
 
/*****************************************************************************/
523
 
/* Python Sound_Type structure definition:                              */
524
 
/*****************************************************************************/
525
 
PyTypeObject Sound_Type = {
526
 
        PyObject_HEAD_INIT( NULL )
527
 
        0,              /* ob_size */
528
 
        "Blender Sound",        /* tp_name */
529
 
        sizeof( BPy_Sound ),    /* tp_basicsize */
530
 
        0,                      /* tp_itemsize */
531
 
        /* methods */
532
 
        NULL,   /* tp_dealloc */
533
 
        0,              /* tp_print */
534
 
        NULL,   /* tp_getattr */
535
 
        NULL,   /* tp_setattr */
536
 
        ( cmpfunc ) Sound_compare,      /* tp_compare */
537
 
        ( reprfunc ) Sound_repr,        /* tp_repr */
538
 
 
539
 
        /* Method suites for standard classes */
540
 
 
541
 
        NULL,                       /* PyNumberMethods *tp_as_number; */
542
 
        NULL,                       /* PySequenceMethods *tp_as_sequence; */
543
 
        NULL,                       /* PyMappingMethods *tp_as_mapping; */
544
 
 
545
 
        /* More standard operations (here for binary compatibility) */
546
 
 
547
 
        ( hashfunc ) GenericLib_hash,   /* hashfunc tp_hash; */
548
 
        NULL,                       /* ternaryfunc tp_call; */
549
 
        NULL,                       /* reprfunc tp_str; */
550
 
        NULL,                       /* getattrofunc tp_getattro; */
551
 
        NULL,                       /* setattrofunc tp_setattro; */
552
 
 
553
 
        /* Functions to access object as input/output buffer */
554
 
        NULL,                       /* PyBufferProcs *tp_as_buffer; */
555
 
 
556
 
  /*** Flags to define presence of optional/expanded features ***/
557
 
        Py_TPFLAGS_DEFAULT,         /* long tp_flags; */
558
 
 
559
 
        NULL,                       /*  char *tp_doc;  Documentation string */
560
 
  /*** Assigned meaning in release 2.0 ***/
561
 
        /* call function for all accessible objects */
562
 
        NULL,                       /* traverseproc tp_traverse; */
563
 
 
564
 
        /* delete references to contained objects */
565
 
        NULL,                       /* inquiry tp_clear; */
566
 
 
567
 
  /***  Assigned meaning in release 2.1 ***/
568
 
  /*** rich comparisons ***/
569
 
        NULL,                       /* richcmpfunc tp_richcompare; */
570
 
 
571
 
  /***  weak reference enabler ***/
572
 
        0,                          /* long tp_weaklistoffset; */
573
 
 
574
 
  /*** Added in release 2.2 ***/
575
 
        /*   Iterators */
576
 
        NULL,                       /* getiterfunc tp_iter; */
577
 
        NULL,                       /* iternextfunc tp_iternext; */
578
 
 
579
 
  /*** Attribute descriptor and subclassing stuff ***/
580
 
        BPy_Sound_methods,           /* struct PyMethodDef *tp_methods; */
581
 
        NULL,                       /* struct PyMemberDef *tp_members; */
582
 
        BPy_Sound_getseters,         /* struct PyGetSetDef *tp_getset; */
583
 
        NULL,                       /* struct _typeobject *tp_base; */
584
 
        NULL,                       /* PyObject *tp_dict; */
585
 
        NULL,                       /* descrgetfunc tp_descr_get; */
586
 
        NULL,                       /* descrsetfunc tp_descr_set; */
587
 
        0,                          /* long tp_dictoffset; */
588
 
        NULL,                       /* initproc tp_init; */
589
 
        NULL,                       /* allocfunc tp_alloc; */
590
 
        NULL,                       /* newfunc tp_new; */
591
 
        /*  Low-level free-memory routine */
592
 
        NULL,                       /* freefunc tp_free;  */
593
 
        /* For PyObject_IS_GC */
594
 
        NULL,                       /* inquiry tp_is_gc;  */
595
 
        NULL,                       /* PyObject *tp_bases; */
596
 
        /* method resolution order */
597
 
        NULL,                       /* PyObject *tp_mro;  */
598
 
        NULL,                       /* PyObject *tp_cache; */
599
 
        NULL,                       /* PyObject *tp_subclasses; */
600
 
        NULL,                       /* PyObject *tp_weaklist; */
601
 
        NULL
602
 
};
603
 
 
604