Beatmup
Beatmup::Audio::AbstractPlayback::Mode Struct Reference

Playback configuration. More...

#include <abstract_playback.h>

Public Member Functions

 Mode (dtime sampleRate, AudioSampleFormat format, int numChannels, dtime bufferLength, int numBuffers)
 Sets playback configuration. More...
 
 Mode (dtime sampleRate, AudioSampleFormat format, int numChannels, dtime bufferLength)
 
 Mode ()
 
dtime getLatency () const
 

Public Attributes

dtime sampleRate
 samples per second / sample rate in Hz More...
 
AudioSampleFormat sampleFormat
 format of each sample More...
 
unsigned char numChannels
 number of channels More...
 
dtime bufferLength
 length of each atomic buffer in samples More...
 
unsigned char numBuffers
 number of atomic buffers More...
 

Detailed Description

Playback configuration.

Definition at line 39 of file abstract_playback.h.

Constructor & Destructor Documentation

◆ Mode() [1/3]

AbstractPlayback::Mode::Mode ( dtime  sampleRate,
AudioSampleFormat  format,
int  numChannels,
dtime  bufferLength,
int  numBuffers 
)

Sets playback configuration.

Parameters
sampleRatesampling frequency in Hz
formatsample format
numChannelsnumber of channels (e.g., 1 for mono, 2 for stereo)
bufferLengthlength of a single buffer
numBuffersnumber of buffers

Definition at line 36 of file abstract_playback.cpp.

37  :
40  numChannels((unsigned char) numChannels),
42  numBuffers((unsigned char) numBuffers)
43 {
44  // check that all the mode parameters are in their valid ranges
45  if (numBuffers < 2)
46  Insanity::insanity("Bad playback mode: less that 2 buffers");
47  if (numChannels < 1)
48  Insanity::insanity("Bad playback mode: no channels");
49  if (bufferLength < 1)
50  Insanity::insanity("Bad playback mode: non-positive buffer length");
51  switch (format) {
52  case Int8:
53  case Int16:
54  case Int32:
55  case Float32:
56  break;
57  default:
58  Insanity::insanity("Bad playback mode: invalid sample format");
59  }
60  // we accept zero/negative sample rate which signifies "not set"
61 }
static void insanity(const char *message)
Definition: exception.h:136
@ Int8
signed integer, 8 bit per sample
@ Int32
signed integer, 32 bit per sample
@ Float32
floating point, 32 bit per sample
@ Int16
signed integer, 16 bit per sample
AudioSampleFormat sampleFormat
format of each sample
dtime sampleRate
samples per second / sample rate in Hz
unsigned char numBuffers
number of atomic buffers
unsigned char numChannels
number of channels
dtime bufferLength
length of each atomic buffer in samples
JNIEnv jobject jint format

◆ Mode() [2/3]

AbstractPlayback::Mode::Mode ( dtime  sampleRate,
AudioSampleFormat  format,
int  numChannels,
dtime  bufferLength 
)

◆ Mode() [3/3]

AbstractPlayback::Mode::Mode ( )

Definition at line 68 of file abstract_playback.cpp.

68 : Mode(0, AudioSampleFormat::Int16, 1, 1024, 2) {}

Member Function Documentation

◆ getLatency()

dtime Beatmup::Audio::AbstractPlayback::Mode::getLatency ( ) const
inline
Returns
mode latency in samples.

Definition at line 61 of file abstract_playback.h.

61 { return bufferLength * numBuffers; }

Member Data Documentation

◆ sampleRate

dtime Beatmup::Audio::AbstractPlayback::Mode::sampleRate

samples per second / sample rate in Hz

Definition at line 40 of file abstract_playback.h.

◆ sampleFormat

AudioSampleFormat Beatmup::Audio::AbstractPlayback::Mode::sampleFormat

format of each sample

Definition at line 41 of file abstract_playback.h.

◆ numChannels

unsigned char Beatmup::Audio::AbstractPlayback::Mode::numChannels

number of channels

Definition at line 42 of file abstract_playback.h.

◆ bufferLength

dtime Beatmup::Audio::AbstractPlayback::Mode::bufferLength

length of each atomic buffer in samples

Definition at line 43 of file abstract_playback.h.

◆ numBuffers

unsigned char Beatmup::Audio::AbstractPlayback::Mode::numBuffers

number of atomic buffers

Definition at line 44 of file abstract_playback.h.


The documentation for this struct was generated from the following files: