AudioBlock Class Reference

#include <AudioBlock.h>

Description

A generalized structure representing an audio waveform.

An audio waveform is defined in Dynacoe as a stream of samples, where samples are typically 2 to 4 bytes of information representing the amplitude of the waveform at that point. In Dynacoe, samples are 16-bit signed integers. Though, it is important to note that AudioBlocks represent stereo waveforms, where per sample, there exist two datum values, one for each channel. As such, data for the waveform is interleaved to qualify both channels, where the subsequent sample corresponds to the channel opposite of the current one.

Functions

void Define (AudioSample *data, uint32_t numSamples)
 
void SetVolume (float fraction)
 
void SetPanning (float fraction)
 
float GetVolume ()
 
float GetPanning ()
 
uint32_t NumBytes ()
 
uint32_t NumSamples ()
 
AudioBlockGetSubBlock (uint32_t firstSample, uint32_t endSample)
 
void AppendBlock (AudioBlock *block)
 
void RemoveBlock (uint32_t beginSample, uint32_t endSample)
 
void InsertBlock (uint32_t beginSample, AudioBlock *block)
 
float GetSecondsFromSamples (uint32_t i)
 
uint32_t GetSampleFromSeconds (float f)
 
void EditSample (uint32_t sample, AudioSample sampleValue)
 
AudioSample GetSample (uint32_t sample)
 
void Append (AudioSample *data, uint32_t size)
 

Static Functions

static AudioBlockCreateSine (float pitch, float roughness, uint8_t volume, float duration, int compound)
 
static AudioBlockCreateHit (float pitch, float impact, float roughness, uint8_t volume, int compound)
 

Member Function Documentation

void Define ( AudioSample data,
uint32_t  numSamples 
)

Clears the current data store of the AudioBlock and replaces it with the given data.

Parameters
dataThe audio samples that the AudioBlock will now consist of.
numSamplesThe number of samples contained by data.
void SetVolume ( float  fraction)

Sets volume according to a fraction.

0 corresponds to silence and 1.0 correspond to maximum volume. Values outside this range are clamped.

Parameters
fractionThe fraction of volume that AudioBlock will use. Clamped to the range 0.f - 1.f, where 0.f is no sound and 1.f is original sample's volume.
void SetPanning ( float  fraction)

Sets panning according to a fraction.

0 corresponds to left output channel only and 1.0 denotes right output channel only. Values outside this range are clamped.

Parameters
fractionThe fraction of panning to use. Clamped to the range 0 to 1, where .5 is even splitting between both channels.
float GetVolume ( )

Returns the current volume.

float GetPanning ( )

Returns the current panning.

uint32_t NumBytes ( )

Returns the size in bytes stored in the AudioBlock.

uint32_t NumSamples ( )

Similar to numBytes; returns the number of samples that the AudioBlock consists of.

AudioBlock* GetSubBlock ( uint32_t  firstSample,
uint32_t  endSample 
)

Returns a subsection of the AudioBlock as an independent AudioBlock.

The new AudioBlock consists of all samples from firstSample to endSample.

Parameters
firstSampleThe first sample of the new block.
sendSampleThe last sample of the new block.
void AppendBlock ( AudioBlock block)

Appends the specified AudioBlock to the end of this one.

Parameters
blockThe block to have appended at the end of this block.
void RemoveBlock ( uint32_t  beginSample,
uint32_t  endSample 
)

Removes a section of samples.

Parameters
beginSampleThe first sample to begin removal.
endSampleThe last sample to remove. All in between will be removed.
void InsertBlock ( uint32_t  beginSample,
AudioBlock block 
)

Inserts the collection of samples at the specified sample.

Parameters
beginSampleThe sample of this AudioBlock to begin insertion at.
blockThe AudioBlock to copy data from.
float GetSecondsFromSamples ( uint32_t  i)

Convert to seconds of the sample.

If the queried sample is beyond the extent of the AudioBlock, -1 is returned.

Parameters
iThe sample index to retreive the time from.
uint32_t GetSampleFromSeconds ( float  f)

Same as GetSecondsFromSamples, but the other way.

Parameters
fThe time in seconds to ask about.
void EditSample ( uint32_t  sample,
AudioSample  sampleValue 
)

Changes the value of the specified sample.

If the sample index given is invalid, no change to the waveform is made.

Parameters
sampleThe sample to edit.
sampleValueThe new value of the sample.
AudioSample GetSample ( uint32_t  sample)

Retrieves the current value of the waveform at the given sample index.

If the sample is invalid, no error is returned, but the value returned will always be 0 for this case.

Parameters
sampleThe sample to ask about.
void Append ( AudioSample data,
uint32_t  size 
)

Adds the specified samples to the wave form.

Parameters
dataThe raw data to append.
sizeThe number of samples to append.
static AudioBlock* CreateSine ( float  pitch,
float  roughness,
uint8_t  volume,
float  duration,
int  compound 
)
static

Creates a new AudioBlock as a basic sine wave with the given parameters. Refer to PitchReference for hertz values.

Parameters
pitchThe pitch of the sine wave to add in hertz.
roughnessThe roughness of the sine wave.
volumeThe volume of the size wave.
durationThe duration of the AdioBlock in seconds.
compoundThe compounding of the sine wave.
static AudioBlock* CreateHit ( float  pitch,
float  impact,
float  roughness,
uint8_t  volume,
int  compound 
)
static

Creates a new AudioBlock as a basic noise distribution with the given parameters.

Parameters
pitchThe pitch of the sine wave to add in hertz.
roughnessThe roughness of the sine wave.
volumeThe volume of the size wave.
durationThe duration of the AdioBlock in seconds.
compoundThe compounding of the sine wave.

The documentation for this class was generated from the following file:
  • /home/jc/git/Dynacoe/DynacoeSrc/includes/Dynacoe/AudioBlock.h