本文整理汇总了C++中outputChannels函数的典型用法代码示例。如果您正苦于以下问题:C++ outputChannels函数的具体用法?C++ outputChannels怎么用?C++ outputChannels使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了outputChannels函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: die
int STEREO::init(double p[], int n_args)
{
nargs = n_args;
outslots = n_args - MATRIX_PFIELD_OFFSET;
const float outskip = p[0];
const float inskip = p[1];
float dur = p[2];
if (dur < 0.0)
dur = -dur - inskip;
if (n_args <= MATRIX_PFIELD_OFFSET)
return die("STEREO", "You need at least one channel assignment.");
if (rtsetoutput(outskip, dur, this) == -1)
return DONT_SCHEDULE;
if (rtsetinput(inskip, this) == -1)
return DONT_SCHEDULE; // no input
if (outputChannels() != 2)
return die("STEREO", "Output must be stereo.");
initamp(dur, p, 3, 1);
if (fastUpdate)
updatePans(p);
return nSamps();
}
示例2: framesToRun
int WAVETABLE::run()
{
const int nframes = framesToRun();
for (int i = 0; i < nframes; i++) {
if (--branch <= 0) {
if (fastUpdate) {
if (amptable)
amp = ampmult * tablei(currentFrame(), amptable, amptabs);
}
else
doupdate();
branch = getSkip();
}
float out[2];
out[0] = osc->next() * amp;
if (outputChannels() == 2) {
out[1] = (1.0 - spread) * out[0];
out[0] *= spread;
}
rtaddout(out);
increment();
}
return framesToRun();
}
示例3: framesToRun
int GRANSYNTH::run()
{
const int frames = framesToRun();
const int outchans = outputChannels();
int i;
for (i = 0; i < frames; i++) {
if (--_branch <= 0) {
doupdate();
_branch = getSkip();
}
_stream->prepare();
float out[outchans];
if (outchans == 2) {
out[0] = _stream->lastL() * _amp;
out[1] = _stream->lastR() * _amp;
}
else
out[0] = _stream->lastL() * _amp;
rtaddout(out);
increment();
}
return i;
}
示例4: doupdate
int WAVESHAPE::run()
{
for (int i = 0; i < framesToRun(); i++) {
if (--branch <= 0) {
doupdate();
branch = skip;
}
float sig = osc->next();
float wsig = wshape(sig * index, xferfunc, lenxfer);
// dc blocking filter
float osig = a1 * z1;
z1 = b1 * z1 + wsig;
osig += a0 * z1;
float out[2];
out[0] = osig * amp;
if (outputChannels() == 2) {
out[1] = (1.0 - spread) * out[0];
out[0] *= spread;
}
rtaddout(out);
increment();
}
return framesToRun();
}
示例5: run
int MMESH2D :: run()
{
int i;
float out[2];
for (i = 0; i < framesToRun(); i++) {
if (--branch <= 0) {
double p[10];
update (p, 10, kAmp | kPan);
amp = p[2];
if (amptable)
amp *= theEnv->next(currentFrame());
branch = getSkip();
}
out[0] = dcblocker->next(theMesh->tick()) * amp;
if (outputChannels() == 2) {
out[1] = out[0] * (1.0 - pctleft);
out[0] *= pctleft;
}
rtaddout(out);
increment();
}
return framesToRun();
}
示例6: run
int MBOWED :: run()
{
int i;
float out[2];
for (i = 0; i < framesToRun(); i++) {
if (--branch <= 0) {
doupdate();
branch = getSkip();
}
if (--vibupdate < 0) { // reset the vibrato freq after each cycle
float vibfreq = theRand->range(viblo, vibhi);
theVib->setfreq(vibfreq);
vibupdate = (int)(SR/vibfreq);
}
out[0] = theBow->tick(bowvel) * amp;
theBow->setFrequency(freqbase + (freqamp * ( (theVib->next()+2.0) * 0.5 )));
if (outputChannels() == 2) {
out[1] = out[0] * (1.0 - pctleft);
out[0] *= pctleft;
}
rtaddout(out);
increment();
}
return framesToRun();
}
示例7: run
int FREEVERB :: run()
{
float *inL, *inR, *outL, *outR;
inL = in;
inR = inputChannels() > 1 ? in + 1 : in;
outL = outbuf;
outR = outputChannels() > 1 ? outbuf + 1 : outbuf;
int samps = framesToRun() * inputChannels();
if (currentFrame() < insamps)
rtgetin(in, this, samps);
// Scale input signal by amplitude multiplier and setline curve.
for (int i = 0; i < samps; i += inputChannels()) {
if (--branch <= 0) {
double p[11];
update(p, 11, kRoomSize | kPreDelay | kDamp | kDry | kWet | kWidth);
if (currentFrame() < insamps) { // amp is pre-effect
amp = update(3, insamps);
if (amparray)
amp *= tablei(currentFrame(), amparray, amptabs);
}
updateRvb(p);
branch = getSkip();
}
if (currentFrame() < insamps) { // still taking input from file
in[i] *= amp;
if (inputChannels() == 2)
in[i + 1] *= amp;
}
else { // in ringdown phase
in[i] = 0.0;
if (inputChannels() == 2)
in[i + 1] = 0.0;
}
increment();
}
// Hand off to Freeverb to do the actual work.
rvb->processreplace(inL, inR, outL, outR, framesToRun(), inputChannels(),
outputChannels());
return framesToRun();
}
示例8: init
int FMINST::init(double p[], int n_args)
{
nargs = n_args;
float outskip = p[0];
float dur = p[1];
if (rtsetoutput(outskip, dur, this) == -1)
return DONT_SCHEDULE;
if (outputChannels() > 2)
return die("FMINST", "Can't handle more than 2 output channels.");
carfreqraw = p[3];
if (carfreqraw < 15.0)
carfreq = cpspch(carfreqraw);
else
carfreq = carfreqraw;
modfreqraw = p[4];
if (modfreqraw < 15.0)
modfreq = cpspch(modfreqraw);
else
modfreq = modfreqraw;
double *wavetable = NULL;
int tablelen = 0;
if (n_args > 8) { // handle table coming in as optional p8 TablePField
wavetable = (double *) getPFieldTable(8, &tablelen);
}
if (wavetable == NULL) {
wavetable = floc(WAVET_GEN_SLOT);
if (wavetable == NULL)
return die("FMINST", "Either use the wavetable pfield (p8) or make "
"an old-style gen function in slot %d.", WAVET_GEN_SLOT);
tablelen = fsize(WAVET_GEN_SLOT);
}
carosc = new Ooscili(SR, carfreq, wavetable, tablelen);
modosc = new Ooscili(SR, modfreq, wavetable, tablelen);
if (n_args < 10) { // no p9 guide PField, must use gen table
indexenv = floc(INDEX_GEN_SLOT);
if (indexenv == NULL)
return die("FMINST", "Either use the index guide pfield (p9) or make "
"an old-style gen function in slot %d.", INDEX_GEN_SLOT);
int len = fsize(INDEX_GEN_SLOT);
tableset(SR, dur, len, indtabs);
}
initamp(dur, p, 2, 1);
if (fastUpdate) {
minindex = p[5];
indexdiff = p[6] - minindex;
pan = p[7];
}
return nSamps();
}
示例9: framesToRun
int MYINST::run()
{
// framesToRun() gives the number of sample frames -- 1 sample for each
// channel -- that we have to write during this scheduler time slice.
const int samps = framesToRun() * inputChannels();
// Read <samps> samples from the input file (or audio input device).
rtgetin(_in, this, samps);
// Each loop iteration processes 1 sample frame. */
for (int i = 0; i < samps; i += inputChannels()) {
// This block updates certain parameters at the control rate -- the
// rate set by the user with the control_rate() or reset() script
// functions. The Instrument base class holds this value as a number
// of sample frames to skip between updates. Get this value using
// getSkip() to reset the <_branch> counter.
if (--_branch <= 0) {
doupdate();
_branch = getSkip();
}
// Grab the current input sample, scaled by the amplitude multiplier.
float insig = _in[i + _inchan] * _amp;
float out[2]; // Space for only 2 output chans!
// Just copy it to the output array with no processing.
out[0] = insig;
// If we have stereo output, use the pan pfield.
if (outputChannels() == 2) {
out[1] = out[0] * (1.0f - _pan);
out[0] *= _pan;
}
// Write this sample frame to the output buffer.
rtaddout(out);
// Increment the count of sample frames this instrument has written.
increment();
}
// Return the number of frames we processed.
return framesToRun();
}
示例10: doupdate
int MYINST::init(double p[], int n_args)
{
_nargs = n_args; // store this for use in doupdate()
// Store pfields in variables, to allow for easy pfield renumbering.
// You should retain the RTcmix numbering convention for the first
// 4 pfields: outskip, inskip, dur, amp; or, for instruments that
// take no input: outskip, dur, amp.
const float outskip = p[0];
const float inskip = p[1];
const float dur = p[2];
// Here's how to handle an optional pfield.
_inchan = (n_args > 4) ? int(p[4]) : 0; // default is chan 0
// no need to retrieve amp or pan here, because these will be set
// before their first use inside of doupdate().
// Tell scheduler when to start this inst. If rtsetoutput returns -1 to
// indicate an error, then return DONT_SCHEDULE.
if (rtsetoutput(outskip, dur, this) == -1)
return DONT_SCHEDULE;
// Test whether the requested number of output channels is right for your
// instrument. The die function reports the error; the system decides
// whether this should exit the program or keep going.
if (outputChannels() > 2)
return die("MYINST", "Use mono or stereo output only.");
// Set file pointer on audio input. If the input source is real-time or
// an aux bus, then <inskip> must be zero. The system will return an
// an error in this case, which we must pass along.
if (rtsetinput(inskip, this) == -1)
return DONT_SCHEDULE;
// Make sure requested input channel number is valid for this input source.
// inputChannels() gives the total number of input channels, initialized
// in rtsetinput.
if (_inchan >= inputChannels())
return die("MYINST", "You asked for channel %d of a %d-channel input.",
_inchan, inputChannels());
// Return the number of sample frames that we'll write to output, which
// the base class has already computed in response to our rtsetoutput call
// above. nSamps() equals the duration passed to rtsetoutput multiplied
// by the sampling rate and then rounded to the nearest integer.
return nSamps();
}
示例11: init
int MULTEQ :: init(double p[], int n_args)
{
nargs = n_args;
const float ringdur = 0.1;
float outskip = p[0];
float inskip = p[1];
float dur = p[2];
if (rtsetinput(inskip, this) == -1)
return DONT_SCHEDULE;
insamps = (int) (dur * SR + 0.5);
if (rtsetoutput(outskip, dur + ringdur, this) == -1)
return DONT_SCHEDULE;
if (inputChannels() > MAXCHAN)
return die("MULTEQ",
"Input and output must have no more than %d channels.", MAXCHAN);
if (outputChannels() != inputChannels())
return die("MULTEQ", "Input and output must have same number of "
"channels, no more than %d.", MAXCHAN);
if ((nargs - FIRST_BAND_PF) % BAND_PFS)
return die("MULTEQ",
"For each band, need type, freq, Q, gain and bypass.");
numbands = 0;
int band = 0;
for (int i = FIRST_BAND_PF; i < nargs; i += BAND_PFS, band += MAXCHAN) {
if (numbands == MAXBAND) {
warn("MULTEQ", "You can only have %d EQ bands.", MAXBAND);
break;
}
OeqType type = getEQType(true, i);
if (type == OeqInvalid)
return die("MULTEQ", "Invalid EQ type string or code.");
float freq = p[i + 1];
float Q = p[i + 2];
float gain = p[i + 3];
bool bypass = (bool) p[i + 4];
for (int c = 0; c < inputChannels(); c++) {
eq[band + c] = new EQBand(SR, type, freq, Q, gain, bypass);
if (eq[band + c] == NULL)
return die("MULTEQ", "Can't allocate EQ band.");
}
numbands++;
}
skip = (int) (SR / (float) resetval);
return nSamps();
}
示例12: init
int BROWN::init(double p[], int n_args)
{
_nargs = n_args;
const float outskip = p[0];
const float dur = p[1];
if (rtsetoutput(outskip, dur, this) == -1)
return DONT_SCHEDULE;
if (outputChannels() > 2)
return die("BROWN", "Use mono or stereo output only.");
return nSamps();
}
示例13: doupdate
int PINK::init(double p[], int n_args)
{
_nargs = n_args; // store this for use in doupdate()
const float outskip = p[0];
const float dur = p[1];
if (rtsetoutput(outskip, dur, this) == -1)
return DONT_SCHEDULE;
if (outputChannels() > 2)
return die("PINK", "Use mono or stereo output only.");
return nSamps();
}
示例14: die
int HOLO::init(double p[], int n_args)
{
/* HOLO: stereo FIR filter to perform crosstalk cancellation
*
* p0 = outsk
* p1 = insk
* p2 = dur
* p3 = amp
* p4 = xtalk amp mult
*
*/
int i, rvin;
if (inputChannels() != 2) {
return die("HOLO", "Input must be stereo.");
}
if (outputChannels() != 2) {
return die("HOLO", "Output must be stereo.");
}
rvin = rtsetinput(p[1], this);
if (rvin == -1) { // no input
return(DONT_SCHEDULE);
}
rvin = rtsetoutput(p[0], p[2], this);
if (rvin == -1) { // no output
return(DONT_SCHEDULE);
}
ncoefs = nCoeffs;
for (int n = 0; n < 2; n++) {
pastsamps[n] = new float[ncoefs + 1];
pastsamps2[n] = new float[ncoefs + 1];
for (i = 0; i < ncoefs; i++) {
pastsamps[n][i] = 0.0;
pastsamps2[n][i] = 0.0;
}
}
amp = p[3];
xtalkAmp = (p[4] != 0.0) ? p[4] : 1.0;
intap = 0;
skip = (int)(SR / (float) resetval);
return 0;
}
示例15: die
int GRANSYNTH::init(double p[], int n_args)
{
_nargs = n_args;
if (_nargs < 11 || _nargs > 17)
return die("GRANSYNTH", USAGE_MESSAGE);
const double outskip = p[0];
const double dur = p[1];
const int seed = _nargs > 14 ? int(p[14]) : 0;
if (rtsetoutput(outskip, dur, this) == -1)
return DONT_SCHEDULE;
if (outputChannels() > 2)
return die("GRANSYNTH", "You can have only mono or stereo output.");
_stereoOut = (outputChannels() == 2);
int length;
double *table = (double *) getPFieldTable(3, &length);
if (table == NULL)
return die("GRANSYNTH", "You must create a table containing the "
"oscillator waveform.");
_stream = new SynthGrainStream(SR, table, length, outputChannels(), seed);
table = (double *) getPFieldTable(4, &length);
if (table == NULL)
return die("GRANSYNTH", "You must create a table containing the grain "
"envelope.");
_stream->setGrainEnvelopeTable(table, length);
if (_nargs > 12) {
table = (double *) getPFieldTable(12, &length);
if (table != NULL)
_stream->setGrainTranspositionCollection(table, length);
}
return nSamps();
}