Gamma  0.9.5
Generic Synthesis Library
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator
Player< T, Si, St > Class Template Reference

Sample buffer player. More...

#include <Player.h>

Inheritance diagram for Player< T, Si, St >:
Synced Array< T > Node2< Synced > ArrayBase< T, SizeArray, gam::Allocator< T > >

List of all members.

Public Member Functions

 Player (Player< T > &src, double rate=1)
 Player (Array< T > &src, double smpRate, double rate=1)
template<class Char >
 Player (const Char *pathToSoundFile, double rate=1)
template<class Char >
bool load (const Char *pathToSoundFile)
 Load a sound file into internal buffer.
void advance ()
 Increment read tap.
operator() (int channel=0)
 Returns sample at current position on specified channel and increments phase.
read (int channel) const
 Returns sample at current position on specified channel (without incrementing phase)
void buffer (Array< T > &src, double smpRate, int channels)
 Set sample buffer.
void free ()
 Free sample buffer (if owner)
void max (double v)
 Set interval max, in frames.
void min (double v)
 Set interval min, in frames.
void pos (double v)
 Set current read position, in frames.
void phase (double v)
 Set current read position [0, 1)
void rate (double v)
 Set playback rate scalar.
void range (double phs, double period)
 Set interval start phase and period.
void reset ()
 Reset playback head.
double max () const
 Get interval max.
double min () const
 Get interval min.
double period () const
 Get total period of sample data.
double pos () const
 Get current read position, in frames.
double posInInterval (double frac) const
 Get position from fraction within interval.
double rate () const
 Get playback rate.
double sampleRate () const
 Get sample rate of sample buffer.
int channels () const
 Get number of channels.
virtual void onResync (double r)
 Called by my Sync reference after it changes its value.
double scaleSPU () const
 Returns ratio of my SPU to my Sync's SPU.
void scaleSPU (double v)
 Scales samples/unit by factor.
double spu () const
 Returns local samples/unit.
void spu (double v)
 Set local samples/unit.
double ups () const
 Returns local units/sample.
void ups (double v)
 Set local units/sample.
const Syncsync () const
 Returns reference to my Sync.
void sync (Sync &src)
 Set absolute Sync source.
void scaleUPS (double v)
 Scales units/sample by factor.
void nodeInsertL (Synced &node)
 Insert myself to left of node.
void nodeInsertR (Synced &node)
 Insert myself to right of node.
void nodeRemove ()
 Remove myself from linked list.
T & operator[] (uint32_t i)
 Get write reference to element.
const T & operator[] (uint32_t i) const
 Get read-only reference to element.
ArrayBaseassign (const T &v)
 Sets all elements to value.
ArrayBaseassign (const T &v, uint32_t end, uint32_t stride=1, uint32_t start=0)
 Sets linear slice of elements to value.
T * elems ()
 Get writable pointer to elements.
const T * elems () const
 Get read-only pointer to elements.
uint32_t size () const
 Returns number of elements in array.
void clear ()
 Destroys all elements and frees memory.
void own ()
 Ensures ownership of elements.
bool isSoleOwner () const
 Returns true if we are the sole owner of data internally allocated.
void resize (uint32_t newSize, const T &c=T())
 Resizes number of elements in array.
void source (ArrayBase< T, SizeArray, gam::Allocator< T > > &src)
 Sets source of array elements to another array.
void source (T *src, uint32_t size)
 Sets source of array elements to another array.

Static Public Member Functions

static int references (T *m)
 Returns number of pointers to memory address being managed.

Public Attributes

SyncednodeL
 Pointer to left node.
SyncednodeR
 Pointer to right node.

Protected Member Functions

void initSynced ()
 To be called from the constructor(s) of derived classes.

Detailed Description

template<class T = real, template< class > class Si = ipl::Trunc, class St = tap::Clip>
class gam::Player< T, Si, St >

Sample buffer player.

The number of frames in the sample should not exceed 2^32. This equates to 27 hours at 44.1 kHz.

Template Parameters:
Tvalue (sample) type
Siinterpolation strategy
Stread tap strategy

Constructor & Destructor Documentation

Player ( Player< T > &  src,
double  rate = 1 
) [explicit]
Parameters:
[in]srcAnother Player to read data from
[in]ratePlayback rate
Player ( Array< T > &  src,
double  smpRate,
double  rate = 1 
)
Parameters:
[in]srcSample array to reference
[in]smpRateSample rate of samples
[in]ratePlayback rate
Player ( const Char *  pathToSoundFile,
double  rate = 1 
) [explicit]
Parameters:
[in]pathToSoundFilePath to sound file
[in]ratePlayback rate

Member Function Documentation

ArrayBase& assign ( const T &  v,
uint32_t  end,
uint32_t  stride = 1,
uint32_t  start = 0 
) [inherited]

Sets linear slice of elements to value.

Parameters:
[in]vvalue to be copied as new content
[in]endend index (exclusive)
[in]strideindex stride amount
[in]startstart index (inclusive)
void buffer ( Array< T > &  src,
double  smpRate,
int  channels 
)

Set sample buffer.

Parameters:
[in]srcSample buffer (if multichannel, must be deinterleaved)
[in]smpRateSample rate of samples
[in]channelsNumber of channels in sample buffer
virtual void onResync ( double  ratioSPU) [virtual]

Called by my Sync reference after it changes its value.

Any instance state that depends on the sampling length should be updated here.

Reimplemented from Synced.

void own ( ) [inherited]

Ensures ownership of elements.

If the array is not already the sole owner, new memory is allocated and the previously referenced array elements are copied.

void resize ( uint32_t  newSize,
const T &  c = T() 
) [inherited]

Resizes number of elements in array.

If the new size is less than the old size, then elements are truncated. If the new size is greater than the old size, then the argument value is copied into the additional elements.


The documentation for this class was generated from the following file: