github.com/256dpi/max-go@v0.7.0/lib/msp/buffer.h (about)

     1  #ifndef _BUFFER_H_
     2  #define _BUFFER_H_
     3  
     4  #include "ext_obex.h"
     5  #include "ext_systhread.h"
     6  #include "ext_critical.h"
     7  #include "ext_atomic.h"
     8  #include "ext_buffer.h"
     9  #include "ext_maxtypes.h"
    10  
    11  #if C74_PRAGMA_STRUCT_PACKPUSH
    12      #pragma pack(push, 2)
    13  #elif C74_PRAGMA_STRUCT_PACK
    14      #pragma pack(2)
    15  #endif
    16  
    17  enum {
    18  	MAXCHAN = 4
    19  };
    20  
    21  enum {
    22  	bi_basefreq = 0,
    23  	bi_detune,
    24  	bi_lowfreq,
    25  	bi_hifreq,
    26  	bi_lowvel,
    27  	bi_hivel,
    28  	bi_gain,
    29  	bi_numparams
    30  };
    31  
    32  
    33  /**	Data structure for the buffer~ object.
    34  	Deprectated.
    35  	Use #t_buffer_ref and #t_buffer_obj instead.
    36  */
    37  struct _buffer
    38  {
    39  	t_object b_obj;		///< doesn't have any signals so it doesn't need to be pxobject
    40  	long b_valid;		///< flag is off during read replacement or editing operation
    41  	float *b_samples;	///< stored with interleaved channels if multi-channel
    42  	long b_frames;		///< number of sample frames (each one is sizeof(float) * b_nchans bytes)
    43  	long b_nchans;		///< number of channels
    44  	long b_size;		///< size of buffer in floats
    45  	float b_sr;			///< sampling rate of the buffer
    46  	float b_1oversr;	///< 1 / sr
    47  	float b_msr;		///< sr * .001
    48  	// Mac-specific stuff
    49  	float *b_memory;	///< pointer to where memory starts (initial padding for interp)
    50  	t_symbol *b_name;	///< name of the buffer
    51  	short b_vol;
    52  	short b_space;
    53  	// looping info (from AIFF file)
    54  	long b_susloopstart;	///< looping info (from AIFF file) in samples
    55  	long b_susloopend;		///< looping info (from AIFF file) in samples
    56  	long b_relloopstart;	///< looping info (from AIFF file) in samples
    57  	long b_relloopend;		///< looping info (from AIFF file) in samples
    58  	// instrument info (from AIFF file)
    59  	short b_inst[bi_numparams];
    60  	// window stuff
    61  	void *b_wind;
    62  	double b_pixperfr;
    63  	double b_frperpix;
    64  	long b_imagesize;
    65  	short b_unusedshort1;		// was Point b_scroll
    66  	short b_unusedshort2;		// could chop if struct compatibility wasn't important
    67  	long b_scrollscale;
    68  	long b_selbegin[MAXCHAN];	// unused - do NOT USE - MAXCHAN is retired
    69  	long b_selend[MAXCHAN];		// unused - do NOT USE - MAXCHAN is retired
    70  	long b_zoom;
    71  	long b_zim[11];
    72  	void *b_mouseout;
    73  	long b_format;			///< 'AIFF' or 'Sd2f'
    74  	t_symbol *b_filename;	///< last file read (not written) for info~
    75  	long b_oldnchans;		///< used for resizing window in case of # of channels change
    76  	void *b_doneout;
    77  	long b_outputbytes;		///< number of bytes used for output sample (1-4)
    78  	long b_modtime;			///< last modified time ("dirty" method)
    79  	struct _buffer *b_peer;	///< objects that share this symbol (used as a link in the peers)
    80  	t_bool b_owner;		///< b_memory/b_samples "owned" by this object
    81  	long b_outputfmt;		///< sample type (A_LONG, A_FLOAT, etc.)
    82  	t_int32_atomic b_inuse;	///< objects that use buffer should ATOMIC_INCREMENT / ATOMIC_DECREMENT this in their perform
    83  	void *b_dspchain;		///< dspchain used for this instance
    84  	long b_padding;			///< amount of padding (number of samples) in b_memory before b_samples starts
    85  	long b_paddingchanged;	///< flag indicating that b_padding has changed and needs to be allocated
    86  	t_object *b_jsoundfile;	///< internal instance for reading/writing FLAC format
    87  	t_systhread_mutex b_mutex; ///< mutex to use when locking and performing operations anywhere except perform method
    88  	long b_wasvalid;		///< internal flag used by replacement or editing operation
    89  	method b_custom_error_handler_fn;	/// used to return error numbers to a caller if this object is embedded inside of another object (e.g. playlist~)
    90  	t_object *b_custom_error_handler;	/// used to return error numbers to a caller if this object is embedded inside of another object (e.g. playlist~)
    91  	t_clock *b_dirty_clock;				///< used to move buffer dirty notifications to the main thread
    92  	t_qelem *b_dirty_qelem;				///< used to move buffer dirty notifications to the main thread
    93  	t_bool b_dirty_done;				///< a buffer is not only dirty, but needs the 'done' message sent out its b_doneout outlet
    94  	t_filepath b_filevol;	///< path of last file read (not written)
    95  };
    96  
    97  // Direct access to a t_buffer struct is deprecated and will no longer be supported in the future.
    98  // Instead, use t_buffer_ref and t_buffer_obj as defined in the 'ext_buffer.h' header file.
    99  
   100  #ifdef C74_BUFFER_INTERNAL
   101  typedef struct _buffer t_buffer;
   102  #else
   103  C74_DEPRECATED( typedef struct _buffer t_buffer );
   104  #endif // C74_BUFFER_INTERNAL
   105  
   106  
   107  #define BUFWIND(x) ((t_wind *)(x->b_wind))
   108  
   109  
   110  #if C74_PRAGMA_STRUCT_PACKPUSH
   111      #pragma pack(pop)
   112  #elif C74_PRAGMA_STRUCT_PACK
   113      #pragma pack()
   114  #endif
   115  
   116  #endif // #ifndef _BUFFER_H_