#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 () |
AudioBlock * | GetSubBlock (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 AudioBlock * | CreateSine (float pitch, float roughness, uint8_t volume, float duration, int compound) |
static AudioBlock * | CreateHit (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
-
data The audio samples that the AudioBlock will now consist of. numSamples The 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
-
fraction The 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
-
fraction The 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
-
firstSample The first sample of the new block. sendSample The last sample of the new block.
void AppendBlock | ( | AudioBlock * | block | ) |
Appends the specified AudioBlock to the end of this one.
- Parameters
-
block The block to have appended at the end of this block.
void RemoveBlock | ( | uint32_t | beginSample, |
uint32_t | endSample | ||
) |
Removes a section of samples.
- Parameters
-
beginSample The first sample to begin removal. endSample The 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
-
beginSample The sample of this AudioBlock to begin insertion at. block The 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
-
i The sample index to retreive the time from.
uint32_t GetSampleFromSeconds | ( | float | f | ) |
Same as GetSecondsFromSamples, but the other way.
- Parameters
-
f The 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
-
sample The sample to edit. sampleValue The 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
-
sample The sample to ask about.
void Append | ( | AudioSample * | data, |
uint32_t | size | ||
) |
Adds the specified samples to the wave form.
- Parameters
-
data The raw data to append. size The number of samples to append.
|
static |
Creates a new AudioBlock as a basic sine wave with the given parameters. Refer to PitchReference for hertz values.
- Parameters
-
pitch The pitch of the sine wave to add in hertz. roughness The roughness of the sine wave. volume The volume of the size wave. duration The duration of the AdioBlock in seconds. compound The compounding of the sine wave.
|
static |
Creates a new AudioBlock as a basic noise distribution with the given parameters.
- Parameters
-
pitch The pitch of the sine wave to add in hertz. roughness The roughness of the sine wave. volume The volume of the size wave. duration The duration of the AdioBlock in seconds. compound The 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