Nsound
0.9.4
|
#include <Nsound/AudioStream.h>
Public Member Functions | |
AudioStream () | |
Create an AudioStream. More... | |
AudioStream (float64 sample_rate, uint32 n_channels=1, uint32 n_samples_pre_allocate=4096) | |
AudioStream (const std::string &filename) | |
~AudioStream () | |
Destructor. More... | |
AudioStream (const AudioStream &rhs) | |
Copy Constructor. More... | |
void | abs () |
This method calls abs on all buffers held in the stream. More... | |
AudioStream | getAbs () const |
Modifies the AudioStream by making any negative value positive. More... | |
void | add (const AudioStream &as, uint32 offset, uint32 n_samples=0) |
This method adds the passed AudioStream to this AudioStream. More... | |
void | add (const AudioStream &as, float64 offset_seconds, float64 duration_seconds=0.0) |
This method adds the passed AudioStream to this AudioStream. More... | |
void | convolve (const Buffer &b) |
Convolves every channel in the AudioStream with the Buffer. More... | |
AudioStream | getConvolve (const Buffer &b) const |
Convolves every channel in the AudioStream with the Buffer. More... | |
void | dB () |
Modifies the AudioStream so each sample is converted to dB, 20 * log10(sample). More... | |
AudioStream | getdB () const |
Returns the AudioStream in dB. More... | |
void | derivative (uint32 n) |
Calculates the nth derivative of the AudioStream. More... | |
AudioStream | getDerivative (uint32 n) const |
Returns the nth derivative of the Buffer. More... | |
void | downSample (uint32 n) |
Downsample by a integral factor. N must be > 1. More... | |
AudioStream | getDownSample (uint32 n) const |
Downsample by a integral factor. N must be > 1. More... | |
float64 | getDuration () const |
Returns the number of seconds of audio data in the stream. More... | |
uint32 | getLength () const |
Returns the number of samples of audio data in the stream. More... | |
void | limit (float64 min, float64 max) |
Limits the AudioStream the min and max values. More... | |
void | limit (const Buffer &min, const Buffer &max) |
Limits the AudioStream the min and max values. More... | |
AudioStream | getLimit (float64 min, float64 max) const |
Limits the AudioStream the min and max values. More... | |
AudioStream | getLimit (const Buffer &min, const Buffer &max) const |
Limits the AudioStream the min and max values. More... | |
float64 | getMax () const |
Returns the maximum sample value in the Audiostream. More... | |
float64 | getMaxMagnitude () const |
Returns the maximum sample magnitude value in the AudioStream, i.e. max(abs(samples)).. More... | |
float64 | getMin () const |
Returns the minimum sample value in the AudioStream. More... | |
void | mono () |
Collapses all channels into one Buffer making it mono. More... | |
AudioStream | getMono () const |
Collapses all channels into one Buffer making it mono. More... | |
uint32 | getNChannels (void) const |
Returns the number of audio channels in the stream. More... | |
float64 | getSampleRate () const |
Returns the sample rate of the stream. More... | |
void | normalize () |
Multiplies the AudioStream by a constant gain so the peak sample has magnitude 1.0. More... | |
AudioStream | getNormalize () const |
Returns the normalized AudioStream. More... | |
AudioStreamSelection | operator() (const BooleanVectorVector &bv) |
Returns an AudioStreamSelection object used for manipulation of a selected region of samples. More... | |
const Buffer & | operator[] (uint32 index) const |
These methods provide a reference to the Buffer object held in the channel. More... | |
Buffer & | operator[] (uint32 index) |
float64 | operator() (uint32 channel, uint32 index) const |
Returns one sample from the specified channel and index. More... | |
AudioStream & | operator= (const AudioStream &rhs) |
Assignment operator. More... | |
AudioStream & | operator= (const Buffer &rhs) |
Assignment operator, deletes any existing data and sets one channels to rhs. More... | |
boolean | operator== (const AudioStream &rhs) const |
Boolean == operator. More... | |
boolean | operator!= (const AudioStream &rhs) const |
Boolean != operator. More... | |
AudioStream & | operator<< (const AudioStream &rhs) |
Concatenates or appends rhs to the AudioStream. More... | |
AudioStream & | operator<< (const Buffer &rhs) |
Concatenates or appends rhs to all the channels in the AudioStream. More... | |
AudioStream & | operator<< (float64 d) |
Concatenates or appends rhs to all the channels in the AudioStream. More... | |
BooleanVectorVector | operator> (float64 rhs) |
BooleanVectorVector | operator>= (float64 rhs) |
BooleanVectorVector | operator< (float64 rhs) |
BooleanVectorVector | operator<= (float64 rhs) |
BooleanVectorVector | operator== (float64 rhs) |
BooleanVectorVector | operator!= (float64 rhs) |
AudioStream & | operator+= (const AudioStream &rhs) |
AudioStream & | operator-= (const AudioStream &rhs) |
AudioStream & | operator*= (const AudioStream &rhs) |
AudioStream & | operator/= (const AudioStream &rhs) |
AudioStream & | operator^= (const AudioStream &rhs) |
AudioStream & | operator+= (const Buffer &rhs) |
AudioStream & | operator-= (const Buffer &rhs) |
AudioStream & | operator*= (const Buffer &rhs) |
AudioStream & | operator/= (const Buffer &rhs) |
AudioStream & | operator^= (const Buffer &rhs) |
AudioStream & | operator+= (float64 d) |
AudioStream & | operator-= (float64 d) |
AudioStream & | operator*= (float64 d) |
AudioStream & | operator/= (float64 d) |
AudioStream & | operator^= (float64 d) |
void | pad (float64 fill=0.0) |
Pads the AudioStream so that each channel has exactly the same number of samples. More... | |
AudioStream | getPad (float64 fill=0.0) const |
void | pan (float64 pan) |
Sets the amplitude level left vs right. More... | |
AudioStream | getPan (float64 pan) const |
Sets the amplitude level left vs right. More... | |
void | pan (const Buffer &pan) |
Sets the amplitude level left vs right. More... | |
AudioStream | getPan (const Buffer &pan) const |
Sets the amplitude level left vs right. More... | |
void | plot (const std::string &title="AudioStream") const |
void | readWavefile (const char *filename) |
Read a Wavefile. More... | |
void | resample (float64 factor) |
Resample by a non-integer factor. More... | |
void | resample (const Buffer &factor) |
Resample by a dynamic non-integer factor. More... | |
AudioStream | getResample (float64 factor) const |
Resample by a non-integer factor. More... | |
AudioStream | getResample (const Buffer &factor) const |
Resample by a dynamic non-integer factor. More... | |
void | resample2 (float64 new_sample_rate) |
Resample to the specified sample rate. More... | |
AudioStream | getResample2 (float64 new_sample_rate) const |
Resample to the specified sample rate. More... | |
void | reverse () |
Reverses the AudioStream. More... | |
AudioStream | getReverse () const |
Reverses the samples in the AudioStream. More... | |
AudioStreamSelection | select (const uint32 start_index, const uint32 stop_index) |
Returns an AudioStreamSelection for the range of indicies. More... | |
std::ostream & | write (std::ostream &out) const |
Serializes the AudioStream to output stream, no endian checks. More... | |
std::string | write () const |
std::istream & | read (std::istream &stream_in) |
Constructs an AudioStream from seralized data in the inputstream. More... | |
void | read (const std::string &string_in) |
void | setNChannels (uint32 channels) |
void | setSampleRate (uint32 sample_rate) |
void | smooth (uint32 n_passes, uint32 n_samples_per_average) |
Implements a standard moving average filter to smooth the waveform. More... | |
AudioStream | getSmooth (uint32 n_passes, uint32 n_samples_per_average) const |
Implements a standard moving average filter to smooth the waveform. More... | |
void | speedUp (float32 step_size) |
Resamples the AudioStream by the step_size, no interpolation. More... | |
AudioStream | getSpeedUp (float32 step_size) const |
Resamples the AudioStream by the step_size, no interpolation. More... | |
void | speedUp (const Buffer &step_size) |
Resamples the AudioStream by a variable step_size, no interpolation. More... | |
AudioStream | getSpeedUp (const Buffer &step_size) const |
Resamples the AudioStream by a variable step_size, no interpolation. More... | |
void | sqrt () |
Takes the square root of each sample in the AudioStream. More... | |
AudioStream | getSqrt () const |
Returns an AudioStream after taking the square root of each sample. More... | |
AudioStream | substream (uint32 start_index, uint32 n_samples=0) const |
AudioStream | substream (int32 start_index, int32 n_samples=0) const |
AudioStream | substream (float64 start_time, float64 duration=0) const |
void | transpose () |
Treating the AudioStream as a matrix, this peforms a matrix transpose. More... | |
AudioStream | getTranspose () const |
Retuns a copy of the AudioStream transposed. More... | |
void | upSample (uint32 n) |
Upsample by a integral factor. N must be > 1. More... | |
AudioStream | getUpSample (uint32 n) const |
Upsample by a integral factor. N must be > 1. More... | |
void | writeWavefile (const char *filename) const |
Write the AudioStream to a Wavefile. More... | |
void | _set_at_index (int32 i, const Buffer &) |
SWIG helper function. More... | |
void | _swig_shadow () |
SWIG helper function function to shadow. More... | |
Static Public Member Functions | |
static AudioStream | ones (float64 sample_rate, const uint32 n_channels, float64 duration) |
Returns an AudioStream full of ones of duration seconds. More... | |
static AudioStream | rand (float64 sample_rate, const uint32 n_channels, float64 duration) |
Returns a Buffer full of random values of length n_samples. More... | |
static AudioStream | zeros (float64 sample_rate, const uint32 n_channels, float64 duration) |
Returns a Buffer full of zeros of length n_samples. More... | |
Private Attributes | |
float64 | sample_rate_ |
uint32 | channels_ |
std::vector< Buffer * > | buffers_ |
Friends | |
std::ostream & | operator<< (std::ostream &out, const AudioStream &rhs) |
Definition at line 52 of file AudioStream.h.
AudioStream::AudioStream | ( | ) |
Create an AudioStream.
Definition at line 52 of file AudioStream.cc.
References channels_, and M_ASSERT_VALUE.
AudioStream::AudioStream | ( | float64 | sample_rate, |
uint32 | n_channels = 1 , |
||
uint32 | n_samples_pre_allocate = 4096 |
||
) |
AudioStream::AudioStream | ( | const std::string & | filename | ) |
Definition at line 82 of file AudioStream.cc.
AudioStream::~AudioStream | ( | ) |
AudioStream::AudioStream | ( | const AudioStream & | rhs | ) |
void AudioStream::abs | ( | ) |
This method calls abs on all buffers held in the stream.
Definition at line 114 of file AudioStream.cc.
References buffers_.
Referenced by getAbs(), and Wavefile_UnitTest().
|
inline |
Modifies the AudioStream by making any negative value positive.
Definition at line 81 of file AudioStream.h.
References abs().
Referenced by FilterDelay_UnitTest().
void AudioStream::add | ( | const AudioStream & | as, |
uint32 | offset, | ||
uint32 | n_samples = 0 |
||
) |
This method adds the passed AudioStream to this AudioStream.
This method adds the passed AudioStream to this AudioStream. If the length of as is longer than this AudioStream, this AudioStream will be extended. If n_samples is 0, the whole length of as will get added, otherwise, only n_samples will get added.
offset | - The index into this AudioStream to start adding |
as | - The AudioStream to add data from |
n_samples | - The number of samples from as to add |
Definition at line 121 of file AudioStream.cc.
References buffers_, channels_, and M_ASSERT_VALUE.
Referenced by Nsound::Mixer::getStream(), main(), Nsound::OrganPipe::play(), and Nsound::Hat::play().
void AudioStream::add | ( | const AudioStream & | as, |
float64 | offset_seconds, | ||
float64 | duration_seconds = 0.0 |
||
) |
This method adds the passed AudioStream to this AudioStream.
This method adds the passed AudioStream to this AudioStream. If the length of as is longer than this AudioStream, this AudioStream will be extended. If duration_seconds is 0, the whole length of as will get added, otherwise, only duration_seconds will get added.
offset_seconds | - The offset in seconds into this AudioStream to start adding or appending |
as | - The source AudioStream to add |
duration_seconds | - The number of seconds from the source AudioStream to add or append. |
Definition at line 136 of file AudioStream.cc.
References buffers_, channels_, M_ASSERT_VALUE, and sample_rate_.
void AudioStream::convolve | ( | const Buffer & | b | ) |
Convolves every channel in the AudioStream with the Buffer.
Definition at line 154 of file AudioStream.cc.
References buffers_.
Referenced by getConvolve().
|
inline |
Convolves every channel in the AudioStream with the Buffer.
Definition at line 133 of file AudioStream.h.
References convolve().
Referenced by main().
void AudioStream::dB | ( | ) |
Modifies the AudioStream so each sample is converted to dB, 20 * log10(sample).
Definition at line 161 of file AudioStream.cc.
References buffers_.
Referenced by getdB(), and Nsound::Spectrogram::plot().
|
inline |
void AudioStream::derivative | ( | uint32 | n | ) |
Calculates the nth derivative of the AudioStream.
Definition at line 168 of file AudioStream.cc.
References buffers_.
Referenced by getDerivative().
|
inline |
Returns the nth derivative of the Buffer.
Definition at line 151 of file AudioStream.h.
References derivative().
void AudioStream::downSample | ( | uint32 | n | ) |
Downsample by a integral factor. N must be > 1.
Definition at line 176 of file AudioStream.cc.
References buffers_.
Referenced by getDownSample().
|
inline |
Downsample by a integral factor. N must be > 1.
Definition at line 160 of file AudioStream.h.
References downSample().
float64 AudioStream::getDuration | ( | ) | const |
Returns the number of seconds of audio data in the stream.
Definition at line 183 of file AudioStream.cc.
References buffers_, and sample_rate_.
Referenced by main(), my_main(), plot(), and stretch_to().
uint32 AudioStream::getLength | ( | ) | const |
Returns the number of samples of audio data in the stream.
Definition at line 197 of file AudioStream.cc.
References buffers_.
Referenced by Nsound::ReverberationRoom::filter(), Nsound::Mixer::getStream(), Nsound::Plotter::imagesc(), main(), my_main(), operator==(), pan(), Nsound::DrumKickBass::play(), play_int(), select(), substream(), testAutioStream(), transpose(), and Nsound::Wavefile::write().
Limits the AudioStream the min and max values.
Definition at line 211 of file AudioStream.cc.
References buffers_.
Referenced by getLimit().
Limits the AudioStream the min and max values.
Definition at line 218 of file AudioStream.cc.
References buffers_.
|
inline |
Limits the AudioStream the min and max values.
Definition at line 181 of file AudioStream.h.
References limit().
|
inline |
Limits the AudioStream the min and max values.
Definition at line 186 of file AudioStream.h.
References limit().
float64 AudioStream::getMax | ( | ) | const |
Returns the maximum sample value in the Audiostream.
Definition at line 225 of file AudioStream.cc.
References buffers_.
Referenced by FilterDelay_UnitTest().
float64 AudioStream::getMaxMagnitude | ( | ) | const |
Returns the maximum sample magnitude value in the AudioStream, i.e. max(abs(samples))..
Definition at line 236 of file AudioStream.cc.
References buffers_.
Referenced by normalize().
float64 AudioStream::getMin | ( | ) | const |
Returns the minimum sample value in the AudioStream.
Definition at line 247 of file AudioStream.cc.
References buffers_.
void AudioStream::mono | ( | ) |
Collapses all channels into one Buffer making it mono.
Definition at line 258 of file AudioStream.cc.
References getMono().
Referenced by main().
AudioStream AudioStream::getMono | ( | ) | const |
Collapses all channels into one Buffer making it mono.
Definition at line 265 of file AudioStream.cc.
References buffers_, channels_, and sample_rate_.
Referenced by mono(), Nsound::Buffer::operator<<(), Nsound::Stretcher::pitchShift(), Nsound::Stretcher::timeShift(), and Nsound::CircularBuffer::write().
|
inline |
Returns the number of audio channels in the stream.
Definition at line 212 of file AudioStream.h.
References channels_.
Referenced by _set_at_index(), Nsound::Mixer::add(), Nsound::FilterDC::filter(), Nsound::Filter::filter(), Nsound::FilterSlinky::filter(), Nsound::FilterBandPassVocoder::filter(), Nsound::FilterFlanger::filter(), Nsound::FilterBandRejectFIR::filter(), Nsound::ReverberationRoom::filter(), Nsound::FilterParametricEqualizer::filter(), Nsound::Plotter::imagesc(), main(), my_main(), operator+=(), Nsound::operator/(), Nsound::Stretcher::pitchShift(), play_int(), Nsound::EnvelopeAdsr::shape(), Nsound::Stretcher::timeShift(), Nsound::Wavefile::write(), and write().
|
inline |
Returns the sample rate of the stream.
Definition at line 217 of file AudioStream.h.
References sample_rate_.
Referenced by Nsound::FilterDC::filter(), Nsound::Filter::filter(), Nsound::FilterSlinky::filter(), Nsound::FilterBandPassVocoder::filter(), Nsound::FilterFlanger::filter(), Nsound::FilterBandRejectFIR::filter(), Nsound::FilterParametricEqualizer::filter(), main(), my_main(), Nsound::operator/(), Nsound::Stretcher::pitchShift(), Nsound::EnvelopeAdsr::shape(), stretch_to(), Nsound::Stretcher::timeShift(), transpose(), Nsound::Wavefile::write(), and write().
void AudioStream::normalize | ( | ) |
Multiplies the AudioStream by a constant gain so the peak sample has magnitude 1.0.
Definition at line 285 of file AudioStream.cc.
References getMaxMagnitude().
Referenced by getNormalize(), main(), Nsound::Clarinet::play(), Nsound::FluteSlide::play(), and Nsound::OrganPipe::play().
|
inline |
Returns the normalized AudioStream.
Definition at line 225 of file AudioStream.h.
References normalize().
AudioStreamSelection AudioStream::operator() | ( | const BooleanVectorVector & | bv | ) |
Returns an AudioStreamSelection object used for manipulation of a selected region of samples.
Definition at line 376 of file AudioStream.cc.
These methods provide a reference to the Buffer object held in the channel.
Definition at line 297 of file AudioStream.cc.
References buffers_, channels_, and M_ASSERT_VALUE.
Returns one sample from the specified channel and index.
Definition at line 368 of file AudioStream.cc.
References buffers_, channels_, and M_ASSERT_VALUE.
AudioStream & AudioStream::operator= | ( | const AudioStream & | rhs | ) |
Assignment operator.
Definition at line 313 of file AudioStream.cc.
References buffers_, channels_, sample_rate_, and setNChannels().
AudioStream & AudioStream::operator= | ( | const Buffer & | rhs | ) |
Assignment operator, deletes any existing data and sets one channels to rhs.
Definition at line 331 of file AudioStream.cc.
References buffers_.
boolean AudioStream::operator== | ( | const AudioStream & | rhs | ) | const |
Boolean == operator.
Definition at line 343 of file AudioStream.cc.
References buffers_, channels_, and getLength().
|
inline |
AudioStream & AudioStream::operator<< | ( | const AudioStream & | rhs | ) |
Concatenates or appends rhs to the AudioStream.
Definition at line 383 of file AudioStream.cc.
References channels_, and M_ASSERT_VALUE.
AudioStream & AudioStream::operator<< | ( | const Buffer & | rhs | ) |
Concatenates or appends rhs to all the channels in the AudioStream.
Definition at line 399 of file AudioStream.cc.
References buffers_.
AudioStream & AudioStream::operator<< | ( | float64 | d | ) |
Concatenates or appends rhs to all the channels in the AudioStream.
Definition at line 527 of file AudioStream.cc.
References buffers_.
BooleanVectorVector Nsound::AudioStream::operator> | ( | float64 | rhs | ) |
Definition at line 970 of file AudioStream.cc.
BooleanVectorVector Nsound::AudioStream::operator>= | ( | float64 | rhs | ) |
Definition at line 982 of file AudioStream.cc.
BooleanVectorVector Nsound::AudioStream::operator< | ( | float64 | rhs | ) |
Definition at line 994 of file AudioStream.cc.
BooleanVectorVector Nsound::AudioStream::operator<= | ( | float64 | rhs | ) |
Definition at line 1006 of file AudioStream.cc.
BooleanVectorVector Nsound::AudioStream::operator== | ( | float64 | rhs | ) |
Definition at line 1018 of file AudioStream.cc.
BooleanVectorVector Nsound::AudioStream::operator!= | ( | float64 | rhs | ) |
Definition at line 1030 of file AudioStream.cc.
AudioStream & AudioStream::operator+= | ( | const AudioStream & | rhs | ) |
Definition at line 407 of file AudioStream.cc.
References channels_, getNChannels(), and M_ASSERT_VALUE.
AudioStream & AudioStream::operator-= | ( | const AudioStream & | rhs | ) |
AudioStream & AudioStream::operator*= | ( | const AudioStream & | rhs | ) |
AudioStream & AudioStream::operator/= | ( | const AudioStream & | rhs | ) |
AudioStream & AudioStream::operator^= | ( | const AudioStream & | rhs | ) |
AudioStream & AudioStream::operator+= | ( | const Buffer & | rhs | ) |
AudioStream & AudioStream::operator-= | ( | const Buffer & | rhs | ) |
AudioStream & AudioStream::operator*= | ( | const Buffer & | rhs | ) |
AudioStream & AudioStream::operator/= | ( | const Buffer & | rhs | ) |
AudioStream & AudioStream::operator^= | ( | const Buffer & | rhs | ) |
AudioStream & AudioStream::operator+= | ( | float64 | d | ) |
AudioStream & AudioStream::operator-= | ( | float64 | d | ) |
AudioStream & AudioStream::operator*= | ( | float64 | d | ) |
AudioStream & AudioStream::operator/= | ( | float64 | d | ) |
AudioStream & AudioStream::operator^= | ( | float64 | d | ) |
void AudioStream::pad | ( | float64 | fill = 0.0 | ) |
Pads the AudioStream so that each channel has exactly the same number of samples.
Definition at line 602 of file AudioStream.cc.
References buffers_, and Nsound::Buffer::ones().
Referenced by getPad(), and transpose().
|
inline |
void AudioStream::pan | ( | float64 | pan | ) |
Sets the amplitude level left vs right.
Sets the amplitude level between left and right channels.
pre> 1 = 100% left volume, 0% right volume 0 = 50% left volume, 50% right volume -1 = 0% left volume, 100% right volume /pre>
pan | - Static levels between channels accross all samples |
Definition at line 627 of file AudioStream.cc.
References buffers_, channels_, and M_ASSERT_VALUE.
Referenced by getPan(), main(), and testAutioStream().
|
inline |
Sets the amplitude level left vs right.
Sets the amplitude level between left and right channels.
pre> 1 = 100% left volume, 0% right volume 0 = 50% left volume, 50% right volume -1 = 0% left volume, 100% right volume /pre>
pan | - Static levels between channels accross all samples |
Definition at line 353 of file AudioStream.h.
References pan().
Referenced by main().
void AudioStream::pan | ( | const Buffer & | pan | ) |
Sets the amplitude level left vs right.
Sets the amplitude level between left and right channels.
pre> 1 = 100% left volume, 0% right volume 0 = 50% left volume, 50% right volume -1 = 0% left volume, 100% right volume /pre>
pan | - Dynamic levels between channels |
Definition at line 640 of file AudioStream.cc.
References buffers_, channels_, getLength(), Nsound::Buffer::getLength(), and M_ASSERT_VALUE.
|
inline |
Sets the amplitude level left vs right.
Sets the amplitude level between left and right channels.
pre> 1 = 100% left volume, 0% right volume 0 = 50% left volume, 50% right volume -1 = 0% left volume, 100% right volume /pre>
pan | - Dynamic levels between channels |
Definition at line 384 of file AudioStream.h.
References pan().
void AudioStream::plot | ( | const std::string & | title = "AudioStream" | ) | const |
Definition at line 661 of file AudioStream.cc.
References buffers_, channels_, Nsound::Generator::drawLine(), Nsound::Plotter::figure(), getDuration(), Nsound::Plotter::plot(), sample_rate_, Nsound::Plotter::subplot(), Nsound::Plotter::title(), Nsound::Plotter::xlabel(), and Nsound::Plotter::ylabel().
Referenced by FilterDelay_UnitTest(), main(), and Wavefile_UnitTest().
void AudioStream::readWavefile | ( | const char * | filename | ) |
void AudioStream::resample | ( | float64 | factor | ) |
Resample by a non-integer factor.
Definition at line 706 of file AudioStream.cc.
References buffers_.
Referenced by getResample(), my_main(), and resample2().
void AudioStream::resample | ( | const Buffer & | factor | ) |
Resample by a dynamic non-integer factor.
Definition at line 713 of file AudioStream.cc.
References buffers_.
|
inline |
Resample by a non-integer factor.
Definition at line 405 of file AudioStream.h.
References resample().
|
inline |
Resample by a dynamic non-integer factor.
Definition at line 410 of file AudioStream.h.
References resample().
void AudioStream::resample2 | ( | float64 | new_sample_rate | ) |
Resample to the specified sample rate.
Definition at line 720 of file AudioStream.cc.
References M_ASSERT_VALUE, resample(), and sample_rate_.
Referenced by getResample2(), and main().
|
inline |
Resample to the specified sample rate.
Definition at line 419 of file AudioStream.h.
References resample2().
void AudioStream::reverse | ( | ) |
Reverses the AudioStream.
Definition at line 733 of file AudioStream.cc.
References buffers_.
Referenced by getReverse(), and testAutioStream().
|
inline |
Reverses the samples in the AudioStream.
Definition at line 433 of file AudioStream.h.
References reverse().
Referenced by main().
AudioStreamSelection AudioStream::select | ( | const uint32 | start_index, |
const uint32 | stop_index | ||
) |
Returns an AudioStreamSelection for the range of indicies.
start_index | the start of the selection |
stop_index | the stop of the selection |
Definition at line 740 of file AudioStream.cc.
References getLength().
std::ostream & AudioStream::write | ( | std::ostream & | out | ) | const |
Serializes the AudioStream to output stream, no endian checks.
out | the std::ostream to write bytes to |
Definition at line 902 of file AudioStream.cc.
References buffers_, getNChannels(), and getSampleRate().
std::string AudioStream::write | ( | ) | const |
Definition at line 915 of file AudioStream.cc.
std::istream & AudioStream::read | ( | std::istream & | stream_in | ) |
Constructs an AudioStream from seralized data in the inputstream.
in | the std::istream to read bytes from |
Definition at line 924 of file AudioStream.cc.
References buffers_, M_THROW, sample_rate_, setNChannels(), and sr.
Referenced by read().
void AudioStream::read | ( | const std::string & | string_in | ) |
Definition at line 952 of file AudioStream.cc.
References read().
void AudioStream::setNChannels | ( | uint32 | channels | ) |
Definition at line 781 of file AudioStream.cc.
References buffers_, and channels_.
Referenced by operator=(), and read().
|
inline |
Implements a standard moving average filter to smooth the waveform.
n_passes = the number of times to calculate the moving average n_samples_per_average = the number of samples to average to create one sample in the output.
Definition at line 797 of file AudioStream.cc.
References buffers_.
Referenced by getSmooth().
|
inline |
Implements a standard moving average filter to smooth the waveform.
Definition at line 495 of file AudioStream.h.
References smooth().
void AudioStream::speedUp | ( | float32 | step_size | ) |
Resamples the AudioStream by the step_size, no interpolation.
Definition at line 804 of file AudioStream.cc.
References buffers_.
Referenced by getSpeedUp().
|
inline |
Resamples the AudioStream by the step_size, no interpolation.
Definition at line 504 of file AudioStream.h.
References speedUp().
void AudioStream::speedUp | ( | const Buffer & | step_size | ) |
Resamples the AudioStream by a variable step_size, no interpolation.
Definition at line 811 of file AudioStream.cc.
References buffers_.
|
inline |
Resamples the AudioStream by a variable step_size, no interpolation.
Definition at line 513 of file AudioStream.h.
References speedUp().
void AudioStream::sqrt | ( | ) |
Takes the square root of each sample in the AudioStream.
Definition at line 818 of file AudioStream.cc.
References buffers_.
Referenced by getSqrt().
|
inline |
Returns an AudioStream after taking the square root of each sample.
Definition at line 522 of file AudioStream.h.
References sqrt().
AudioStream AudioStream::substream | ( | uint32 | start_index, |
uint32 | n_samples = 0 |
||
) | const |
Definition at line 825 of file AudioStream.cc.
References channels_, and sample_rate_.
Referenced by Nsound::Mixer::getStream(), main(), Nsound::Clarinet::play(), substream(), and testAutioStream().
AudioStream AudioStream::substream | ( | int32 | start_index, |
int32 | n_samples = 0 |
||
) | const |
Definition at line 840 of file AudioStream.cc.
References M_ASSERT_VALUE, and substream().
AudioStream AudioStream::substream | ( | float64 | start_time, |
float64 | duration = 0 |
||
) | const |
Definition at line 853 of file AudioStream.cc.
References buffers_, channels_, getLength(), and sample_rate_.
void AudioStream::transpose | ( | ) |
Treating the AudioStream as a matrix, this peforms a matrix transpose.
Treat the AudioStream like a 2D matrix where the number of channels is the first dimension, or the rows, and the length of each Buffer in the AudioStream is the number of columns.
Transposing the matrix swaps the rows with the columns. For example, the first row (or AudioStream channel) becomes the first column, etc.
| 0 1 |^T | 0 2 4 | | 2 3 | = | 1 3 5 | | 4 5 |
Definition at line 875 of file AudioStream.cc.
References channels_, getLength(), getSampleRate(), and pad().
Referenced by getTranspose(), my_main(), and Nsound::Spectrogram::plot().
|
inline |
Retuns a copy of the AudioStream transposed.
Definition at line 554 of file AudioStream.h.
References transpose().
Referenced by my_main().
void AudioStream::upSample | ( | uint32 | n | ) |
Upsample by a integral factor. N must be > 1.
Definition at line 895 of file AudioStream.cc.
References buffers_.
Referenced by getUpSample().
|
inline |
Upsample by a integral factor. N must be > 1.
Definition at line 563 of file AudioStream.h.
References upSample().
void AudioStream::writeWavefile | ( | const char * | filename | ) | const |
Write the AudioStream to a Wavefile.
Definition at line 960 of file AudioStream.cc.
References M_CHECK_PTR.
SWIG helper function.
Definition at line 759 of file AudioStream.cc.
References buffers_, getNChannels(), and M_THROW.
|
inline |
|
static |
Returns an AudioStream full of ones of duration seconds.
Definition at line 1041 of file AudioStream.cc.
References Nsound::Generator::drawLine().
|
static |
Returns a Buffer full of random values of length n_samples.
Definition at line 1057 of file AudioStream.cc.
References Nsound::Generator::whiteNoise().
|
static |
Returns a Buffer full of zeros of length n_samples.
Definition at line 1073 of file AudioStream.cc.
References Nsound::Generator::drawLine().
|
friend |
|
private |
Definition at line 619 of file AudioStream.h.
Referenced by add(), getDuration(), getMono(), getSampleRate(), operator=(), plot(), read(), resample2(), setSampleRate(), and substream().
|
private |
Definition at line 620 of file AudioStream.h.
Referenced by add(), AudioStream(), getMono(), getNChannels(), operator()(), operator*=(), operator+=(), operator-=(), operator/=(), operator<<(), operator=(), operator==(), operator[](), operator^=(), pan(), plot(), setNChannels(), substream(), and transpose().
|
private |
Definition at line 622 of file AudioStream.h.
Referenced by _set_at_index(), abs(), add(), AudioStream(), convolve(), dB(), derivative(), downSample(), getDuration(), getLength(), getMax(), getMaxMagnitude(), getMin(), getMono(), limit(), operator()(), operator*=(), operator+=(), operator-=(), operator/=(), operator<<(), operator=(), operator==(), operator[](), operator^=(), pad(), pan(), plot(), read(), resample(), reverse(), setNChannels(), smooth(), speedUp(), sqrt(), substream(), upSample(), write(), and ~AudioStream().