Nsound  0.9.4
Classes | Typedefs | Enumerations | Functions | Variables
Nsound Namespace Reference

Classes

class  AudioBackend
 
class  AudioBackendLibao
 
class  AudioBackendLibportaudio
 
class  AudioPlayback
 
struct  AudioPlaybackRtDebug
 
class  AudioPlaybackRt
 
class  AudioStream
 
class  AudioStreamSelection
 A helper class for advance operators. More...
 
class  Buffer
 A Buffer for storing audio samples. More...
 
class  BufferSelection
 A helper class for advance operators. More...
 
class  BufferWindowSearch
 Searches the target Buffer for zero crossings at or after the window_size position. More...
 
class  CircularBuffer
 
class  circular_iterator
 A circulator iterator for class Buffer. More...
 
class  const_circular_iterator
 
class  Clarinet
 Class Drum. More...
 
class  Cosine
 DOXME. More...
 
struct  Context
 
class  DelayLine
 
class  DrumBD01
 Class DrumBD01. More...
 
class  DrumKickBass
 Class Drum. More...
 
class  EnvelopeAdsr
 
class  FFTChunk
 Results of performing an FFT are stored in this class. More...
 
class  FFTransform
 A Class that performes the Fast Fouier Transfrom on a Buffer. More...
 
class  Filter
 Base class for IIR Filters, defines the interface. More...
 
class  FilterAllPass
 
class  FilterBandPassFIR
 
class  FilterBandPassIIR
 
class  FilterBandPassVocoder
 
class  FilterBandRejectFIR
 
class  FilterBandRejectIIR
 
class  FilterCombLowPassFeedback
 A class for filtering audio in the frequecy domain. More...
 
class  FilterDC
 
class  FilterDelay
 A class for filtering audio in the frequecy domain. More...
 
class  FilterFlanger
 A class for filtering audio in the frequecy domain. More...
 
class  FilterHighPassFIR
 
class  FilterHighPassIIR
 A class for filtering audio in the frequecy domain. More...
 
class  FilterIIR
 
class  FilterLeastSquaresFIR
 A FIR filter that is defined as the least square error to the desired requency response. More...
 
class  FilterLowPassFIR
 
class  FilterLowPassIIR
 A class for filtering audio in the frequecy domain. More...
 
class  FilterLowPassMoogVcf
 
class  FilterMovingAverage
 
class  FilterParametricEqualizer
 Implementation of Zoelzer's parametric equalizer filters, with some modifications by the author. More...
 
class  FilterPhaser
 A class for filtering audio in the frequecy domain. More...
 
class  FilterSlinky
 Base class for IIR Filters, defines the interface. More...
 
class  FilterStageIIR
 A class for filtering audio in the frequecy domain. More...
 
class  FilterTone
 
class  FluteSlide
 Class Drum. More...
 
class  Generator
 A class the provides draw utilities and a wavetable oscillator. More...
 
class  GeneratorDecay
 A class tha generates decay curves. More...
 
class  Granulator
 
class  GuitarBass
 Class Drum. More...
 
class  Hat
 Class Hat. More...
 
class  Instrument
 The Nsound Instrument baseclass. All Nsound instruments extend this class. More...
 
class  Kernel
 
class  Mesh2D
 
class  MeshJunction
 
class  Mixer
 This class enables easy scheduling and mixing of multiple AudioStreams. More...
 
class  MixerNode
 This class holds the nodes for use with the Mixer class. More...
 
struct  Exception
 
class  OrganPipe
 Class OrganPipe. More...
 
class  Axes
 A wrapper around a Matplotlib Axes object. More...
 
class  Plotter
 
class  Pluck
 Implements a simple Karplus-Strong String Synthesis algorithim. More...
 
class  Pulse
 A Pulse Generator. More...
 
class  RandomNumberGenerator
 Base class for random number generators. More...
 
class  ReverberationRoom
 
class  RngTausworthe
 
class  Sawtooth
 DOXME. More...
 
class  Sine
 DOXME. More...
 
class  Spectrogram
 The result from an STFT. More...
 
class  Square
 Square generator. More...
 
class  Stretcher
 WSOLA. More...
 
class  Triangle
 Triangle generator. More...
 
class  Vocoder
 
class  Wavefile
 Very simple Wavefile reading class. More...
 
class  ID3v1Tag
 

Typedefs

typedef std::vector
< std::vector< boolean > > 
BooleanVectorVector
 
typedef std::vector< BufferBufferVector
 
typedef std::vector< Buffer * > BufferPointerVector
 
typedef std::vector< booleanBooleanVector
 
typedef std::vector< uint32Uint32Vector
 
typedef std::vector< float64FloatVector
 
typedef std::vector< FFTChunkFFTChunkVector
 
typedef std::set< KernelKernelCache
 
typedef std::set< MixerNodeMixerSet
 
typedef bool boolean
 
typedef signed char byte
 
typedef signed char int8
 
typedef signed short int16
 
typedef signed int int32
 
typedef signed long long int64
 
typedef float float32
 
typedef double float64
 
typedef unsigned char ubyte
 
typedef unsigned char uint8
 
typedef unsigned short uint16
 
typedef unsigned int uint32
 
typedef unsigned long long uint64
 
typedef signed long long raw_int64
 
typedef unsigned long long raw_uint64
 
typedef double raw_float64
 
typedef void PyObject
 

Enumerations

enum  AudioBackendType { BACKEND_TYPE_NONE, BACKEND_TYPE_LIBAO, BACKEND_TYPE_LIBPORTAUDIO }
 
enum  BufferUnderrunMode { BUM_SILENCE, BUM_NOISE, BUM_TONE }
 
enum  WindowType {
  BARTLETT, BLACKMAN, BLACKMAN_HARRIS, GAUSSIAN,
  GAUSSIAN_05, GAUSSIAN_10, GAUSSIAN_15, GAUSSIAN_20,
  GAUSSIAN_25, GAUSSIAN_30, GAUSSIAN_33, GAUSSIAN_35,
  GAUSSIAN_40, GAUSSIAN_45, GAUSSIAN_50, GAUSSIAN_55,
  GAUSSIAN_60, GAUSSIAN_65, GAUSSIAN_66, GAUSSIAN_70,
  GAUSSIAN_75, GAUSSIAN_80, GAUSSIAN_85, GAUSSIAN_90,
  GAUSSIAN_95, GAUSSIAN_99, HAMMING, HANNING,
  KAISER, NUTTALL, PARZEN, RECTANGULAR
}
 

Functions

void operator>> (const AudioStream &lhs, AudioPlayback &rhs)
 
void operator>> (const Buffer &lhs, AudioPlayback &rhs)
 
void use (const std::string &backend)
 Selects the AudioBackend to use by name. More...
 
void use (const AudioBackendType &type)
 
std::vector< std::string > getBackends ()
 Returns a list of the available audio backends by name. More...
 
std::vector< AudioBackendTypegetBackendTypes ()
 Returns a list of the available audio backends types. More...
 
void operator>> (const AudioStream &lhs, AudioPlaybackRt &rhs)
 
void operator>> (const Buffer &lhs, AudioPlaybackRt &rhs)
 
void operator>> (float64 sample, AudioPlaybackRt &rhs)
 
AudioStream operator+ (const AudioStream &lhs, const AudioStream &rhs)
 
AudioStream operator- (const AudioStream &lhs, const AudioStream &rhs)
 
AudioStream operator* (const AudioStream &lhs, const AudioStream &rhs)
 
AudioStream operator/ (const AudioStream &lhs, const AudioStream &rhs)
 
AudioStream operator^ (const AudioStream &lhs, const AudioStream &rhs)
 
AudioStream operator+ (const AudioStream &lhs, const Buffer &rhs)
 
AudioStream operator- (const AudioStream &lhs, const Buffer &rhs)
 
AudioStream operator* (const AudioStream &lhs, const Buffer &rhs)
 
AudioStream operator/ (const AudioStream &lhs, const Buffer &rhs)
 
AudioStream operator^ (const AudioStream &lhs, const Buffer &rhs)
 
AudioStream operator+ (const AudioStream &lhs, float64 d)
 
AudioStream operator- (const AudioStream &lhs, float64 d)
 
AudioStream operator* (const AudioStream &lhs, float64 d)
 
AudioStream operator/ (const AudioStream &lhs, float64 d)
 
AudioStream operator^ (const AudioStream &lhs, float64 d)
 
AudioStream operator+ (float64 d, const AudioStream &rhs)
 
AudioStream operator- (float64 d, const AudioStream &rhs)
 
AudioStream operator* (float64 d, const AudioStream &rhs)
 
AudioStream operator/ (float64 d, const AudioStream &rhs)
 
std::ostream & operator<< (std::ostream &out, const Buffer &rhs_buffer)
 
void find_fraction (float64 fraction, float64 gamma, uint32 &a, uint32 &b)
 
Buffer operator+ (const Buffer &lhs, const Buffer &rhs)
 Add the Buffers together on a sample by sample basis. More...
 
Buffer operator- (const Buffer &lhs, const Buffer &rhs)
 Subtract the Buffers together on a sample by sample basis. More...
 
Buffer operator* (const Buffer &lhs, const Buffer &rhs)
 Multiply the Buffers together on a sample by sample basis. More...
 
Buffer operator/ (const Buffer &lhs, const Buffer &rhs)
 Divide the samples in the Buffers sample by sample basis. More...
 
Buffer operator^ (const Buffer &lhs, const Buffer &rhs)
 Raise the left hand side (lhs) samples to the power in the of the samples in the right hand side (rhs). More...
 
Buffer operator+ (const Buffer &lhs, float64 d)
 Add the scalar d to every sample in the Buffer. More...
 
Buffer operator- (const Buffer &lhs, float64 d)
 Subtract the scalar d to every sample in the Buffer. More...
 
Buffer operator* (const Buffer &lhs, float64 d)
 Multiply the scalar d to every sample in the Buffer. More...
 
Buffer operator/ (const Buffer &lhs, float64 d)
 Divide every sample in the Buffer by d. More...
 
Buffer operator^ (const Buffer &lhs, float64 d)
 Each sample in the Buffer becomes the power x^n. More...
 
Buffer operator+ (float64 d, const Buffer &rhs)
 Add every sample in the Buffer to the scalar d. More...
 
Buffer operator- (float64 d, const Buffer &rhs)
 Subtract every sample in the Buffer from the scalar d. More...
 
Buffer operator* (float64 d, const Buffer &rhs)
 Multiply the scalar d by every sample in the Buffer. More...
 
Buffer operator/ (float64 d, const Buffer &rhs)
 Divide the scalar d by every sample in the Buffer. More...
 
Buffer operator^ (float64 d, const Buffer &rhs)
 Raise the scalar d to the power of every sample in the Buffer. More...
 
circular_iterator operator+ (const circular_iterator &lhs, int32 rhs)
 
circular_iterator operator- (const circular_iterator &lhs, int32 rhs)
 
const_circular_iterator operator+ (const const_circular_iterator &lhs, int32 rhs)
 
const_circular_iterator operator- (const const_circular_iterator &lhs, int32 rhs)
 
std::ostream & operator<< (std::ostream &out, const FilterIIR &rhs)
 
std::ostream & operator<< (std::ostream &out, const Kernel &rhs)
 
void __throw__ (const std::string &message)
 
template<class T >
std::ostream & _write (std::ostream &out, T value)
 
std::ostream & operator& (std::ostream &out, char value)
 
std::ostream & operator& (std::ostream &out, uint32 value)
 
std::ostream & operator& (std::ostream &out, uint64 value)
 
std::ostream & operator& (std::ostream &out, float32 value)
 
std::ostream & operator& (std::ostream &out, float64 value)
 
template<class T >
std::istream & _read (std::istream &in, T &value)
 
std::istream & operator& (std::istream &in, char &value)
 
std::istream & operator& (std::istream &in, uint32 &value)
 
std::istream & operator& (std::istream &in, uint64 &value)
 
std::istream & operator& (std::istream &in, float32 &value)
 
std::istream & operator& (std::istream &in, float64 &value)
 
template<class T >
peek (std::istream &in)
 
void searchForBestMatch_f64 (double *rss, const double *source, const unsigned int source_index, const unsigned int search_index, const unsigned int window_length, const unsigned int max_delta)
 
void searchForBestMatch_f32 (float *rss, const float *source, const unsigned int source_index, const unsigned int search_index, const unsigned int window_length, const unsigned int max_delta)
 
void Tic ()
 
Nsound::float64 Toc ()
 
float64 getFrequencyOffset (const float64 &f1, const float64 &octaves, const float64 &cents)
 
Bufferoperator<< (Buffer &lhs, const char *rhs)
 
void operator>> (const Buffer &lhs, const char *rhs)
 
AudioStreamoperator<< (AudioStream &lhs, const char *rhs)
 
void operator>> (const AudioStream &lhs, const char *rhs)
 
std::ostream & operator<< (std::ostream &out, const ID3v1Tag &rhs)
 

Variables

static double start_time = 0.0
 

Typedef Documentation

typedef std::vector< std::vector< boolean > > Nsound::BooleanVectorVector

Definition at line 44 of file AudioStreamSelection.h.

typedef std::vector<Buffer> Nsound::BufferVector

Definition at line 2039 of file Buffer.h.

typedef std::vector<Buffer *> Nsound::BufferPointerVector

Definition at line 2040 of file Buffer.h.

typedef std::vector< boolean > Nsound::BooleanVector

Definition at line 44 of file BufferSelection.h.

typedef std::vector< uint32 > Nsound::Uint32Vector

Definition at line 44 of file CircularIterators.h.

typedef std::vector< float64 > Nsound::FloatVector

Definition at line 45 of file CircularIterators.h.

typedef std::vector< FFTChunk > Nsound::FFTChunkVector

Definition at line 119 of file FFTChunk.h.

typedef std::set<Kernel> Nsound::KernelCache

Definition at line 180 of file Kernel.h.

typedef std::set<MixerNode> Nsound::MixerSet

Definition at line 48 of file Mixer.h.

typedef bool Nsound::boolean

Definition at line 135 of file Nsound.h.

typedef signed char Nsound::byte

Definition at line 139 of file Nsound.h.

typedef signed char Nsound::int8

Definition at line 140 of file Nsound.h.

typedef signed short Nsound::int16

Definition at line 141 of file Nsound.h.

typedef signed int Nsound::int32

Definition at line 142 of file Nsound.h.

typedef signed long long Nsound::int64

Definition at line 143 of file Nsound.h.

typedef float Nsound::float32

Definition at line 145 of file Nsound.h.

typedef double Nsound::float64

Definition at line 146 of file Nsound.h.

typedef unsigned char Nsound::ubyte

Definition at line 150 of file Nsound.h.

typedef unsigned char Nsound::uint8

Definition at line 151 of file Nsound.h.

typedef unsigned short Nsound::uint16

Definition at line 152 of file Nsound.h.

typedef unsigned int Nsound::uint32

Definition at line 153 of file Nsound.h.

typedef unsigned long long Nsound::uint64

Definition at line 154 of file Nsound.h.

typedef signed long long Nsound::raw_int64

Definition at line 157 of file Nsound.h.

typedef unsigned long long Nsound::raw_uint64

Definition at line 158 of file Nsound.h.

typedef double Nsound::raw_float64

Definition at line 159 of file Nsound.h.

typedef void Nsound::PyObject

Definition at line 46 of file Plotter.h.

Enumeration Type Documentation

Enumerator
BACKEND_TYPE_NONE 
BACKEND_TYPE_LIBAO 
BACKEND_TYPE_LIBPORTAUDIO 

Definition at line 38 of file AudioBackendType.h.

Enumerator
BUM_SILENCE 
BUM_NOISE 
BUM_TONE 

Definition at line 61 of file AudioPlaybackRt.h.

62 {
63  // BUM = Buffer Underrun Mode
65  BUM_NOISE,
66  BUM_TONE
67 };
Enumerator
BARTLETT 
BLACKMAN 
BLACKMAN_HARRIS 
GAUSSIAN 
GAUSSIAN_05 
GAUSSIAN_10 
GAUSSIAN_15 
GAUSSIAN_20 
GAUSSIAN_25 
GAUSSIAN_30 
GAUSSIAN_33 
GAUSSIAN_35 
GAUSSIAN_40 
GAUSSIAN_45 
GAUSSIAN_50 
GAUSSIAN_55 
GAUSSIAN_60 
GAUSSIAN_65 
GAUSSIAN_66 
GAUSSIAN_70 
GAUSSIAN_75 
GAUSSIAN_80 
GAUSSIAN_85 
GAUSSIAN_90 
GAUSSIAN_95 
GAUSSIAN_99 
HAMMING 
HANNING 
KAISER 
NUTTALL 
PARZEN 
RECTANGULAR 

Definition at line 39 of file WindowType.h.

40  {
41  BARTLETT,
42  BLACKMAN,
44  GAUSSIAN,
67  HAMMING,
68  HANNING,
69  KAISER,
70  NUTTALL,
71  PARZEN,
73  };

Function Documentation

void Nsound::operator>> ( const AudioStream lhs,
AudioPlayback rhs 
)

Definition at line 542 of file AudioPlayback.cc.

References Nsound::AudioPlayback::play().

Referenced by Nsound::Buffer::writeWavefile().

543 {
544  ap.play(lhs);
545 }
void Nsound::operator>> ( const Buffer lhs,
AudioPlayback rhs 
)

Definition at line 549 of file AudioPlayback.cc.

References Nsound::AudioPlayback::play().

550 {
551  ap.play(lhs);
552 }
void Nsound::use ( const std::string &  backend)

Selects the AudioBackend to use by name.

Parameters
backendthe common name for the backend to use
Example:
// C++
Nsound::use("portaudio");
// Python
Nsound.use("portaudio");
Nsound.use("ao");

Definition at line 564 of file AudioPlayback.cc.

References BACKEND_TYPE_LIBAO, BACKEND_TYPE_LIBPORTAUDIO, getBackends(), M_THROW, mylower(), and Nsound::AudioPlayback::setBackendType().

Referenced by use().

565 {
566  std::string be = mylower(backend);
567 
568  if(be == "ao" || be == "libao")
569  {
570  AudioPlayback::setBackendType(BACKEND_TYPE_LIBAO);
571  }
572  else
573  if(be == "portaudio" || be == "libportaudio")
574  {
575  AudioPlayback::setBackendType(BACKEND_TYPE_LIBPORTAUDIO);
576  }
577  else
578  {
579  std::stringstream ss_buffer;
580  ss_buffer << "Nsound::use(): "
581  << "Unrecognized AudioBackend '"
582  << backend
583  << "'"
584  << endl;
585 
586  std::vector< std::string > vec = getBackends();
587 
588  ss_buffer << "Available backends are:" << endl;
589 
590  for(uint32 i = 0; i < vec.size(); ++i)
591  {
592  ss_buffer << " "
593  << vec[i]
594  << endl;
595  }
596 
597  M_THROW(ss_buffer.str());
598  }
599 }
unsigned int uint32
Definition: Nsound.h:153
std::string mylower(const std::string &x)
#define M_THROW(message)
Definition: Macros.h:108
std::vector< std::string > getBackends()
Returns a list of the available audio backends by name.
void Nsound::use ( const AudioBackendType type)

Definition at line 603 of file AudioPlayback.cc.

References BACKEND_TYPE_LIBAO, BACKEND_TYPE_LIBPORTAUDIO, M_THROW, and use().

604 {
605  switch(type)
606  {
607  case BACKEND_TYPE_LIBAO:
608  use("ao");
609  break;
610 
612  use("portaudio");
613  break;
614 
615  default:
616  M_THROW("Nsound::use(): "
617  << "Unrecognized AudioBackendType "
618  << static_cast<uint32>(type));
619  }
620 }
void use(const std::string &backend)
Selects the AudioBackend to use by name.
#define M_THROW(message)
Definition: Macros.h:108
std::vector< std::string > Nsound::getBackends ( )

Returns a list of the available audio backends by name.

Example:
// C++
// Python
Nsound.getBackends();

Definition at line 624 of file AudioPlayback.cc.

Referenced by Nsound::AudioPlayback::scanDevices(), and use().

625 {
626  std::vector< std::string > vec;
627 
628  #if defined(NSOUND_LIBPORTAUDIO)
629  vec.push_back("portaudio");
630  #endif
631 
632  #if defined(NSOUND_LIBAO)
633  vec.push_back("ao");
634  #endif
635 
636  return vec;
637 }
std::vector< AudioBackendType > Nsound::getBackendTypes ( )

Returns a list of the available audio backends types.

Example:
// C++
Nsound::getBackendsTypes();
// Python
Nsound.getBackendsTypes();

Definition at line 641 of file AudioPlayback.cc.

References BACKEND_TYPE_LIBAO, and BACKEND_TYPE_LIBPORTAUDIO.

Referenced by Nsound::AudioPlayback::scanDevices().

642 {
643  std::vector< AudioBackendType > vec;
644 
645  #if defined(NSOUND_LIBPORTAUDIO)
646  vec.push_back(BACKEND_TYPE_LIBPORTAUDIO);
647  #endif
648 
649  #if defined(NSOUND_LIBAO)
650  vec.push_back(BACKEND_TYPE_LIBAO);
651  #endif
652 
653  return vec;
654 }
void Nsound::operator>> ( const AudioStream &  lhs,
AudioPlaybackRt &  rhs 
)

Definition at line 872 of file AudioPlaybackRt.cc.

References Nsound::AudioPlaybackRt::play().

873 {
874  rhs.play(lhs);
875 }
void Nsound::operator>> ( const Buffer &  lhs,
AudioPlaybackRt &  rhs 
)

Definition at line 878 of file AudioPlaybackRt.cc.

References Nsound::AudioPlaybackRt::play().

879 {
880  rhs.play(lhs);
881 }
void Nsound::operator>> ( float64  sample,
AudioPlaybackRt &  rhs 
)

Definition at line 884 of file AudioPlaybackRt.cc.

References Nsound::AudioPlaybackRt::play().

885 {
886  rhs.play(sample);
887 }
AudioStream Nsound::operator+ ( const AudioStream &  lhs,
const AudioStream &  rhs 
)
inline

Definition at line 629 of file AudioStream.h.

630 {
631  AudioStream temp(lhs);
632  return temp += rhs;
633 }
AudioStream Nsound::operator- ( const AudioStream &  lhs,
const AudioStream &  rhs 
)
inline

Definition at line 635 of file AudioStream.h.

636 {
637  AudioStream temp(lhs);
638  return temp -= rhs;
639 }
AudioStream Nsound::operator* ( const AudioStream &  lhs,
const AudioStream &  rhs 
)
inline

Definition at line 641 of file AudioStream.h.

642 {
643  AudioStream temp(lhs);
644  return temp *= rhs;
645 }
AudioStream Nsound::operator/ ( const AudioStream &  lhs,
const AudioStream &  rhs 
)
inline

Definition at line 647 of file AudioStream.h.

648 {
649  AudioStream temp(lhs);
650  return temp /= rhs;
651 }
AudioStream Nsound::operator^ ( const AudioStream &  lhs,
const AudioStream &  rhs 
)
inline

Definition at line 653 of file AudioStream.h.

654 {
655  AudioStream temp(lhs);
656  return temp ^= rhs;
657 }
AudioStream Nsound::operator+ ( const AudioStream &  lhs,
const Buffer &  rhs 
)
inline

Definition at line 659 of file AudioStream.h.

660 {
661  AudioStream temp(lhs);
662  return temp += rhs;
663 }
AudioStream Nsound::operator- ( const AudioStream &  lhs,
const Buffer &  rhs 
)
inline

Definition at line 665 of file AudioStream.h.

666 {
667  AudioStream temp(lhs);
668  return temp -= rhs;
669 }
AudioStream Nsound::operator* ( const AudioStream &  lhs,
const Buffer &  rhs 
)
inline

Definition at line 671 of file AudioStream.h.

672 {
673  AudioStream temp(lhs);
674  return temp *= rhs;
675 }
AudioStream Nsound::operator/ ( const AudioStream &  lhs,
const Buffer &  rhs 
)
inline

Definition at line 677 of file AudioStream.h.

678 {
679  AudioStream temp(lhs);
680  return temp /= rhs;
681 }
AudioStream Nsound::operator^ ( const AudioStream &  lhs,
const Buffer &  rhs 
)
inline

Definition at line 683 of file AudioStream.h.

684 {
685  AudioStream temp(lhs);
686  return temp ^= rhs;
687 }
AudioStream Nsound::operator+ ( const AudioStream &  lhs,
float64  d 
)
inline

Definition at line 689 of file AudioStream.h.

690 {
691  AudioStream temp(lhs);
692  return temp += d;
693 }
AudioStream Nsound::operator- ( const AudioStream &  lhs,
float64  d 
)
inline

Definition at line 695 of file AudioStream.h.

696 {
697  AudioStream temp(lhs);
698  return temp -= d;
699 }
AudioStream Nsound::operator* ( const AudioStream &  lhs,
float64  d 
)
inline

Definition at line 701 of file AudioStream.h.

702 {
703  AudioStream temp(lhs);
704  return temp *= d;
705 }
AudioStream Nsound::operator/ ( const AudioStream &  lhs,
float64  d 
)
inline

Definition at line 707 of file AudioStream.h.

708 {
709  AudioStream temp(lhs);
710  return temp /= d;
711 }
AudioStream Nsound::operator^ ( const AudioStream &  lhs,
float64  d 
)
inline

Definition at line 713 of file AudioStream.h.

714 {
715  AudioStream temp(lhs);
716  return temp ^= d;
717 }
AudioStream Nsound::operator+ ( float64  d,
const AudioStream &  rhs 
)
inline

Definition at line 719 of file AudioStream.h.

720 {
721  AudioStream temp(rhs);
722  return temp += d;
723 }
AudioStream Nsound::operator- ( float64  d,
const AudioStream &  rhs 
)
inline

Definition at line 725 of file AudioStream.h.

726 {
727  AudioStream temp(rhs * -1.0);
728  return temp += d;
729 }
AudioStream Nsound::operator* ( float64  d,
const AudioStream &  rhs 
)
inline

Definition at line 731 of file AudioStream.h.

732 {
733  AudioStream temp(rhs);
734  return temp *= d;
735 }
AudioStream Nsound::operator/ ( float64  d,
const AudioStream &  rhs 
)
inline

Definition at line 737 of file AudioStream.h.

References Nsound::AudioStream::getNChannels(), and Nsound::AudioStream::getSampleRate().

738 {
739  AudioStream temp(rhs.getSampleRate(), rhs.getNChannels());
740 
741  for(uint32 i = 0; i < rhs.getNChannels(); ++i)
742  {
743  temp[i] = d / rhs[i];
744  }
745 
746  return temp;
747 }
unsigned int uint32
Definition: Nsound.h:153
std::ostream & Nsound::operator<< ( std::ostream &  out,
const Buffer &  rhs_buffer 
)

Definition at line 1338 of file Buffer.cc.

References Nsound::Buffer::data_.

1339 {
1340  std::vector<float64>::const_iterator rhs = rhs_buffer.data_.begin();
1341  std::vector<float64>::const_iterator end = rhs_buffer.data_.end();
1342 
1343  while(rhs != end)
1344  {
1345  out << *rhs << endl;
1346  ++rhs;
1347  }
1348 
1349  return out;
1350 }
void Nsound::find_fraction ( float64  fraction,
float64  gamma,
uint32 &  a,
uint32 &  b 
)

Definition at line 1570 of file Buffer.cc.

Referenced by Nsound::Buffer::getResample().

1575 {
1576  float64 num = 1.0;
1577  float64 den = 1.0;
1578 
1579  float64 f = 1.0;
1580 
1581  float64 diff = f - fraction;
1582 
1583  while( fabs(diff) > gamma )
1584  {
1585  if(f > fraction)
1586  {
1587  den += 1.0;
1588  }
1589  else
1590  {
1591  num += 1.0;
1592  }
1593 
1594  f = num / den;
1595  diff = f - fraction;
1596  }
1597 
1598  a = static_cast<uint32>(num);
1599  b = static_cast<uint32>(den);
1600 }
unsigned int uint32
Definition: Nsound.h:153
double float64
Definition: Nsound.h:146
Buffer Nsound::operator+ ( const Buffer &  lhs,
const Buffer &  rhs 
)
inline

Add the Buffers together on a sample by sample basis.

Definition at line 1887 of file Buffer.h.

1888 {
1889  Buffer temp(lhs);
1890  return temp += rhs;
1891 }
Buffer Nsound::operator- ( const Buffer &  lhs,
const Buffer &  rhs 
)
inline

Subtract the Buffers together on a sample by sample basis.

Definition at line 1894 of file Buffer.h.

1895 {
1896  Buffer temp(lhs);
1897  return temp -= rhs;
1898 }
Buffer Nsound::operator* ( const Buffer &  lhs,
const Buffer &  rhs 
)
inline

Multiply the Buffers together on a sample by sample basis.

Definition at line 1901 of file Buffer.h.

1902 {
1903  Buffer temp(lhs);
1904  return temp *= rhs;
1905 }
Buffer Nsound::operator/ ( const Buffer &  lhs,
const Buffer &  rhs 
)
inline

Divide the samples in the Buffers sample by sample basis.

Definition at line 1908 of file Buffer.h.

1909 {
1910  Buffer temp(lhs);
1911  return temp /= rhs;
1912 }
Buffer Nsound::operator^ ( const Buffer &  lhs,
const Buffer &  rhs 
)
inline

Raise the left hand side (lhs) samples to the power in the of the samples in the right hand side (rhs).

Definition at line 1915 of file Buffer.h.

1916 {
1917  Buffer temp(lhs);
1918  return temp ^= rhs;
1919 }
Buffer Nsound::operator+ ( const Buffer &  lhs,
float64  d 
)
inline

Add the scalar d to every sample in the Buffer.

Definition at line 1924 of file Buffer.h.

1925 {
1926  Buffer temp(lhs);
1927  return temp += d;
1928 }
Buffer Nsound::operator- ( const Buffer &  lhs,
float64  d 
)
inline

Subtract the scalar d to every sample in the Buffer.

Definition at line 1931 of file Buffer.h.

1932 {
1933  Buffer temp(lhs);
1934  return temp -= d;
1935 }
Buffer Nsound::operator* ( const Buffer &  lhs,
float64  d 
)
inline

Multiply the scalar d to every sample in the Buffer.

Definition at line 1938 of file Buffer.h.

1939 {
1940  Buffer temp(lhs);
1941  return temp *= d;
1942 }
Buffer Nsound::operator/ ( const Buffer &  lhs,
float64  d 
)
inline

Divide every sample in the Buffer by d.

Definition at line 1945 of file Buffer.h.

1946 {
1947  Buffer temp(lhs);
1948  return temp /= d;
1949 }
Buffer Nsound::operator^ ( const Buffer &  lhs,
float64  d 
)
inline

Each sample in the Buffer becomes the power x^n.

Each sample in the Buffer becomes the power x^n, where x is the Buffer sample and N is the power.

Example:
// C++
Buffer b1("california.wav");
Buffer b2 = b1 ^ 2.0;
// Python
b1 = Buffer("california.wav")
b2 = b1 ** 2.0
WARNING: sometimes one may want to do this:
// C++
mag = real ^ 2 + imag ^ 2;
But C++'s default operator precedence will actually compile this:
mag = (real ^ (2 + imag)) ^ 2;
because operator+ has high presedence. To avoid this, in C++ you must use parentheses.
mag = (real ^ 2) + (imag ^ 2);

Definition at line 1982 of file Buffer.h.

1983 {
1984  Buffer temp(lhs);
1985  return temp ^= d;
1986 }
Buffer Nsound::operator+ ( float64  d,
const Buffer &  rhs 
)
inline

Add every sample in the Buffer to the scalar d.

Definition at line 1991 of file Buffer.h.

1992 {
1993  return rhs + d;
1994 }
Buffer Nsound::operator- ( float64  d,
const Buffer &  rhs 
)
inline

Subtract every sample in the Buffer from the scalar d.

Definition at line 1997 of file Buffer.h.

1998 {
1999  return (rhs * -1.0) + d;
2000 }
Buffer Nsound::operator* ( float64  d,
const Buffer &  rhs 
)
inline

Multiply the scalar d by every sample in the Buffer.

Definition at line 2003 of file Buffer.h.

2004 {
2005  return rhs * d;
2006 }
Buffer Nsound::operator/ ( float64  d,
const Buffer &  rhs 
)
inline

Divide the scalar d by every sample in the Buffer.

Definition at line 2009 of file Buffer.h.

References Nsound::Buffer::getLength().

2010 {
2011  Buffer temp(rhs);
2012 
2013  uint32 size = rhs.getLength();
2014 
2015  for(uint32 i = 0; i < size; ++i)
2016  {
2017  temp[i] = d / rhs[i];
2018  }
2019 
2020  return temp;
2021 }
unsigned int uint32
Definition: Nsound.h:153
Buffer Nsound::operator^ ( float64  d,
const Buffer &  rhs 
)
inline

Raise the scalar d to the power of every sample in the Buffer.

Definition at line 2024 of file Buffer.h.

References Nsound::Buffer::getLength().

2025 {
2026  Buffer temp(rhs);
2027 
2028  uint32 size = rhs.getLength();
2029 
2030  for(uint32 i = 0; i < size; ++i)
2031  {
2032  temp[i] = ::pow(d ,rhs[i]);
2033  }
2034 
2035  return temp;
2036 }
unsigned int uint32
Definition: Nsound.h:153
circular_iterator Nsound::operator+ ( const circular_iterator &  lhs,
int32  rhs 
)
inline

Definition at line 188 of file CircularIterators.h.

189 {
190  circular_iterator tmp(lhs);
191 
192  tmp += rhs;
193 
194  return tmp;
195 }
circular_iterator Nsound::operator- ( const circular_iterator &  lhs,
int32  rhs 
)
inline

Definition at line 199 of file CircularIterators.h.

200 {
201  circular_iterator tmp(lhs);
202 
203  tmp -= rhs;
204 
205  return tmp;
206 }
const_circular_iterator Nsound::operator+ ( const const_circular_iterator &  lhs,
int32  rhs 
)
inline

Definition at line 319 of file CircularIterators.h.

320 {
321  const_circular_iterator tmp(lhs);
322 
323  tmp += rhs;
324 
325  return tmp;
326 }
const_circular_iterator Nsound::operator- ( const const_circular_iterator &  lhs,
int32  rhs 
)
inline

Definition at line 330 of file CircularIterators.h.

331 {
332  const_circular_iterator tmp(lhs);
333 
334  tmp -= rhs;
335 
336  return tmp;
337 }
std::ostream & Nsound::operator<< ( std::ostream &  out,
const FilterIIR rhs 
)

Definition at line 715 of file FilterIIR.cc.

References Nsound::Kernel::getALength(), Nsound::Kernel::getBLength(), and Nsound::FilterIIR::kernel_.

716 {
717  out << "kernel_.b_length_ = " << rhs.kernel_->getBLength() << endl
718  << "kernel_.a_length_ = " << rhs.kernel_->getALength() << endl;
719  return out << *rhs.kernel_;
720 }
Kernel * kernel_
Definition: FilterIIR.h:166
uint32 getALength() const
Definition: Kernel.h:101
uint32 getBLength() const
Definition: Kernel.h:104
std::ostream & Nsound::operator<< ( std::ostream &  out,
const Kernel rhs 
)

Definition at line 174 of file Kernel.cc.

References Nsound::Kernel::a_, Nsound::Kernel::a_length_, Nsound::Kernel::b_, Nsound::Kernel::b_length_, and FORMAT.

175 {
176  #define FORMAT setw(12) << setprecision(9) << std::setiosflags(std::ios::fixed)
177 
178  for(uint32 i = 0; i < rhs.b_length_; ++i)
179  {
180  out << "b[" << i << "] = " << FORMAT << rhs.b_[i];
181 
182  if(i < rhs.a_length_)
183  {
184  out << " a[" << i << "] = " << FORMAT << rhs.a_[i];
185  }
186  out << std::endl;
187  }
188 
189  return out;
190 }
uint32 b_length_
Definition: Kernel.h:164
unsigned int uint32
Definition: Nsound.h:153
#define FORMAT
float64 * a_
Definition: Kernel.h:173
uint32 a_length_
Definition: Kernel.h:165
float64 * b_
Definition: Kernel.h:172
void Nsound::__throw__ ( const std::string &  message)
inline

Definition at line 54 of file Macros.h.

55 {
56  std::cerr << message << std::endl;
57  std::cerr.flush();
58  throw Nsound::Exception(message);
59 }
template<class T >
std::ostream& Nsound::_write ( std::ostream &  out,
value 
)

Definition at line 36 of file StreamOperators.cc.

Referenced by operator&().

37 {
38  out.write(reinterpret_cast<char *>(&value), sizeof(T));
39  return out;
40 }
std::ostream & Nsound::operator& ( std::ostream &  out,
char  value 
)

Definition at line 43 of file StreamOperators.cc.

References _write().

43 { return _write(out, value); }
std::ostream & _write(std::ostream &out, T value)
std::ostream & Nsound::operator& ( std::ostream &  out,
uint32  value 
)

Definition at line 46 of file StreamOperators.cc.

References _write().

46 { return _write(out, value); }
std::ostream & _write(std::ostream &out, T value)
std::ostream & Nsound::operator& ( std::ostream &  out,
uint64  value 
)

Definition at line 49 of file StreamOperators.cc.

References _write().

49 { return _write(out, value); }
std::ostream & _write(std::ostream &out, T value)
std::ostream & Nsound::operator& ( std::ostream &  out,
float32  value 
)

Definition at line 52 of file StreamOperators.cc.

References _write().

52 { return _write(out, value); }
std::ostream & _write(std::ostream &out, T value)
std::ostream & Nsound::operator& ( std::ostream &  out,
float64  value 
)

Definition at line 55 of file StreamOperators.cc.

References _write().

55 { return _write(out, value); }
std::ostream & _write(std::ostream &out, T value)
template<class T >
std::istream& Nsound::_read ( std::istream &  in,
T &  value 
)

Definition at line 59 of file StreamOperators.cc.

Referenced by operator&().

60 {
61  in.read(reinterpret_cast<char *>(&value), sizeof(T));
62  return in;
63 }
std::istream & Nsound::operator& ( std::istream &  in,
char &  value 
)

Definition at line 66 of file StreamOperators.cc.

References _read().

66 { return _read(in, value); }
std::istream & _read(std::istream &in, T &value)
std::istream & Nsound::operator& ( std::istream &  in,
uint32 &  value 
)

Definition at line 69 of file StreamOperators.cc.

References _read().

69 { return _read(in, value); }
std::istream & _read(std::istream &in, T &value)
std::istream & Nsound::operator& ( std::istream &  in,
uint64 &  value 
)

Definition at line 72 of file StreamOperators.cc.

References _read().

72 { return _read(in, value); }
std::istream & _read(std::istream &in, T &value)
std::istream & Nsound::operator& ( std::istream &  in,
float32 &  value 
)

Definition at line 75 of file StreamOperators.cc.

References _read().

75 { return _read(in, value); }
std::istream & _read(std::istream &in, T &value)
std::istream & Nsound::operator& ( std::istream &  in,
float64 &  value 
)

Definition at line 78 of file StreamOperators.cc.

References _read().

78 { return _read(in, value); }
std::istream & _read(std::istream &in, T &value)
template<class T >
T Nsound::peek ( std::istream &  in)

Definition at line 59 of file StreamOperators.h.

60 {
61  T tmp = 0;
62 
63  std::streampos pos = in.tellg();
64 
65  in.read(static_cast<char *>(&tmp), sizeof(T));
66 
67  in.seekg(pos);
68 
69  return tmp;
70 }
void Nsound::searchForBestMatch_f64 ( double *  rss,
const double *  source,
const unsigned int  source_index,
const unsigned int  search_index,
const unsigned int  window_length,
const unsigned int  max_delta 
)
void Nsound::searchForBestMatch_f32 ( float *  rss,
const float *  source,
const unsigned int  source_index,
const unsigned int  search_index,
const unsigned int  window_length,
const unsigned int  max_delta 
)
void Nsound::Tic ( )

Definition at line 37 of file TicToc.cc.

References start_time.

Referenced by main(), and testAutioStream().

38  {
39  start_time = clock();
40  }
static double start_time
Definition: TicToc.cc:35
Nsound::float64 Nsound::Toc ( )

Definition at line 42 of file TicToc.cc.

References start_time.

Referenced by main(), and testAutioStream().

43  {
44  return ((clock() - start_time) / static_cast<float64>(CLOCKS_PER_SEC));
45  }
static double start_time
Definition: TicToc.cc:35
float64 Nsound::getFrequencyOffset ( const float64 f1,
const float64 octaves,
const float64 cents 
)

Definition at line 45 of file Utils.cc.

49 {
50  return f1 * pow(2.0, octaves + cents / 1200.0);
51 }
Buffer & Nsound::operator<< ( Buffer lhs,
const char *  rhs 
)

Definition at line 1475 of file Wavefile.cc.

References Nsound::Wavefile::read().

1476 {
1477  BufferPointerVector b_vector;
1478 
1479  b_vector.push_back(&lhs);
1480 
1481  Wavefile::read(rhs,&b_vector, NULL, NULL);
1482 
1483  return lhs;
1484 }
std::vector< Buffer * > BufferPointerVector
Definition: Buffer.h:2040
void Nsound::operator>> ( const Buffer lhs,
const char *  rhs 
)

Definition at line 1488 of file Wavefile.cc.

References Nsound::Wavefile::getDefaultSampleRate(), Nsound::Wavefile::getDefaultSampleSize(), and Nsound::Wavefile::write().

1489 {
1490  Wavefile::write(
1491  rhs,
1492  lhs,
1493  Wavefile::getDefaultSampleSize(),
1494  Wavefile::getDefaultSampleRate());
1495 }
AudioStream & Nsound::operator<< ( AudioStream lhs,
const char *  rhs 
)

Definition at line 1500 of file Wavefile.cc.

References Nsound::Wavefile::read().

1501 {
1502  Wavefile::read(rhs, NULL, &lhs, NULL);
1503 
1504  return lhs;
1505 }
void Nsound::operator>> ( const AudioStream lhs,
const char *  rhs 
)

Definition at line 1509 of file Wavefile.cc.

References Nsound::Wavefile::getDefaultSampleSize(), and Nsound::Wavefile::write().

1510 {
1511  Wavefile::write(
1512  rhs,
1513  lhs,
1514  Wavefile::getDefaultSampleSize());
1515 }
std::ostream & Nsound::operator<< ( std::ostream &  out,
const ID3v1Tag rhs 
)

Definition at line 1860 of file Wavefile.cc.

References Nsound::ID3v1Tag::album, Nsound::ID3v1Tag::artist, Nsound::ID3v1Tag::comment, Nsound::ID3v1Tag::genre, Nsound::ID3v1Tag::title, and Nsound::ID3v1Tag::year.

1861 {
1862  out << "header : TAG" << endl
1863  << "title : " << rhs.title << endl
1864  << "artist : " << rhs.artist << endl
1865  << "album : " << rhs.album << endl
1866  << "year : " << rhs.year << endl
1867  << "comment : " << rhs.comment << endl
1868  << "genre : " << rhs.genre;
1869 
1870  return out;
1871 }
std::string title
Definition: Wavefile.h:268
std::string artist
Definition: Wavefile.h:269
std::string comment
Definition: Wavefile.h:272
std::string year
Definition: Wavefile.h:271
std::string album
Definition: Wavefile.h:270

Variable Documentation

double Nsound::start_time = 0.0
static

Definition at line 35 of file TicToc.cc.

Referenced by Nsound::Mixer::getStream(), Tic(), and Toc().