svapp  1.9
ClipMixer Class Reference

Mix in synthetic notes produced by resampling a prerecorded clip. More...

#include <ClipMixer.h>

List of all members.

Classes

struct  NoteEnd
struct  NoteStart

Public Member Functions

 ClipMixer (int channels, int sampleRate, int blockSize)
 ~ClipMixer ()
void setChannelCount (int channels)
bool loadClipData (QString clipFilePath, float clipF0, float level)
 Load a sample clip from a wav file.
void reset ()
void mix (float **toBuffers, float gain, std::vector< NoteStart > newNotes, std::vector< NoteEnd > endingNotes)

Private Member Functions

float getResampleRatioFor (float frequency)
int getResampledClipDuration (float frequency)
void mixNote (float **toBuffers, float *levels, float frequency, int sourceOffset, int targetOffset, int sampleCount, bool isEnd)

Private Attributes

int m_channels
int m_sampleRate
int m_blockSize
QString m_clipPath
float * m_clipData
int m_clipLength
float m_clipF0
float m_clipRate
std::vector< NoteStartm_playing

Detailed Description

Mix in synthetic notes produced by resampling a prerecorded clip.

(i.e. this is an implementation of a digital sampler in the musician's sense.) This can mix any number of notes of arbitrary frequency, so long as they all use the same sample clip.

Definition at line 29 of file ClipMixer.h.


Constructor & Destructor Documentation

ClipMixer::ClipMixer ( int  channels,
int  sampleRate,
int  blockSize 
)

Definition at line 23 of file ClipMixer.cpp.

Definition at line 34 of file ClipMixer.cpp.

References m_clipData.


Member Function Documentation

void ClipMixer::setChannelCount ( int  channels)

Definition at line 40 of file ClipMixer.cpp.

References m_channels.

bool ClipMixer::loadClipData ( QString  clipFilePath,
float  clipF0,
float  level 
)

Load a sample clip from a wav file.

This can only happen once: construct a new ClipMixer if you want a different clip. The clip was recorded at a pitch with fundamental frequency clipF0, and should be scaled by level (in the range 0-1) when playing back.

Definition at line 46 of file ClipMixer.cpp.

References m_clipData, m_clipF0, m_clipLength, and m_clipRate.

Referenced by AudioGenerator::makeClipMixerFor().

void ClipMixer::reset ( )

Definition at line 100 of file ClipMixer.cpp.

References m_playing.

float ClipMixer::getResampleRatioFor ( float  frequency) [private]

Definition at line 106 of file ClipMixer.cpp.

References m_clipData, m_clipF0, m_clipRate, and m_sampleRate.

Referenced by getResampledClipDuration(), and mixNote().

int ClipMixer::getResampledClipDuration ( float  frequency) [private]

Definition at line 115 of file ClipMixer.cpp.

References getResampleRatioFor(), and m_clipLength.

Referenced by mix().

void ClipMixer::mixNote ( float **  toBuffers,
float *  levels,
float  frequency,
int  sourceOffset,
int  targetOffset,
int  sampleCount,
bool  isEnd 
) [private]

!! just linear interpolation for now (same as SV's sample !! player). a small sinc kernel would be better and !! probably "good enough"

Definition at line 199 of file ClipMixer.cpp.

References getResampleRatioFor(), m_channels, m_clipData, m_clipLength, and m_sampleRate.

Referenced by mix().


Member Data Documentation

int ClipMixer::m_channels [private]

Definition at line 66 of file ClipMixer.h.

Referenced by mix(), mixNote(), and setChannelCount().

int ClipMixer::m_sampleRate [private]

Definition at line 67 of file ClipMixer.h.

Referenced by getResampleRatioFor(), and mixNote().

int ClipMixer::m_blockSize [private]

Definition at line 68 of file ClipMixer.h.

Referenced by mix().

QString ClipMixer::m_clipPath [private]

Definition at line 70 of file ClipMixer.h.

float* ClipMixer::m_clipData [private]

Definition at line 72 of file ClipMixer.h.

Referenced by getResampleRatioFor(), loadClipData(), mixNote(), and ~ClipMixer().

int ClipMixer::m_clipLength [private]

Definition at line 73 of file ClipMixer.h.

Referenced by getResampledClipDuration(), loadClipData(), and mixNote().

float ClipMixer::m_clipF0 [private]

Definition at line 74 of file ClipMixer.h.

Referenced by getResampleRatioFor(), and loadClipData().

float ClipMixer::m_clipRate [private]

Definition at line 75 of file ClipMixer.h.

Referenced by getResampleRatioFor(), and loadClipData().

std::vector<NoteStart> ClipMixer::m_playing [private]

Definition at line 77 of file ClipMixer.h.

Referenced by mix(), and reset().


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