Context Object
BKContext
is the base object and contains the channel sound buffers. The context is also responsible for running the attached clocks.
This initializes a BKContent
object with 2 channels (stereo) and a sample rate of 44100 Hz. The maximum number of channels is BK_MAX_CHANNELS
(8). The sample rate can range between BK_MIN_SAMPLE_RATE
(16000) and BK_MAX_SAMPLE_RATE
(96000). Lower or higher values are clamped.
Attributes
The following list contains attributes which can be set with with BKContextSetAttr
or read with BKContextGetAttr
. Some attributes use a more complex data type and can be set with BKContextSetPtr
or read with BKContextGetPtr
.
- BK_SAMPLE_RATE (read-only)
-
Data type: BKInt
The sample rate on which basis the note frequencies are calculated. This attribute is read-only and can only be set at initialization.
- BK_NUM_CHANNELS (read-only)
-
Data type: BKInt
Number of channels in which the sound data is rendered. Attributes and track effects which affect panning have only an effect when this number is exactly 2 (stereo). This attribute is read-only and can only be set at initialization.
- BK_CLOCK_PERIOD
-
Data type: BKTime
The master clock's tick period. This is a BKTime struct. The default value is a 1/240th second (240 Hz). Use this attribute if a finer time granularity is required.
- BK_TIME (read-only)
-
Data type: BKTime
This is the current absolute number of frames generated since initialization or the last reset of the context.
Functions (BKContext.h)
BKContextInit
BKInt BKContextInit (BKContext * ctx, BKInt numChannels, BKInt sampleRate)
Initializes a context object ctx
with numChannel
channels and a sample rate of sampleRate
. Returns 0
on success.
Possible return errors:
BK_ALLOCATION_ERROR
if memory allocation failed.
BKContextAlloc
BKInt BKContextAlloc (BKContext ** outCtx, BKInt numChannels, BKInt sampleRate)
Allocate and initializes a context object ctx
with numChannel
channels and a sample rate of sampleRate
. Returns 0
on success.
Possible return errors:
BK_ALLOCATION_ERROR
if memory allocation failed.