This is Envelope.h in view mode; [Download] [Up]
//
// Programmer: Craig Stuart Sapp <craig@ccrma.stanford.edu>
// Creation Date: Fri May 2 15:18:35 GMT-0800 1997
// Last Modified: Mon May 5 12:21:41 GMT-0800 1997
// Filename: .../sig/src/Generator/Envelope/Envelope.h
// Syntax: C++
// $Smake: cc -Wall -g -c %b.cc -I../../../include && rm -f %b.o
//
#ifndef _ENVELOPE_H_INCLUDED
#define _ENVELOPE_H_INCLUDED
#include "Generator.h"
class EnvPoint;
class Envelope : public Generator {
public:
Envelope (char *envelopeString = "(0 0; 1 0)",
long numSamplesDuration = 0);
~Envelope ();
void action (void);
int activeQ (void);
long getDurationSamples (void);
double getDurationSeconds (void);
char* getEnvelope (void);
sampleType output (int channel);
void printState (void);
void setDuration (long samples);
void setDuration (double seconds);
void setDurationSamples (long samples);
void setDurationSeconds (double seconds);
void setEnvelope (const char *envelopeString,
int timeQ = 1);
void trigger (int startPoint = 0);
protected:
double minDuration; // time in samples of envelope w/o stick
double srate; // in hertz;
long numPoints; // number of points in envelope
long currPoint; // current point
long currSample; // current sample
char *envelopeString; // string which contains envelope desc
EnvPoint *points; // points of envelope
char active; // true if generating envelope
sampleType outputValue; // value to be send out of the object
double linearIncrement;
double geometricIncrement;
// private functions:
int find (char* string, char aChar,
int start = 0, char stopChar = '\0');
double extractNumber (char* string, int& index);
int countOccurence (char* string, char aChar,
int start = 0, char stopChar = '\0');
void calculateNextSample (void);
void checkParentheses (void);
int skipSpaces (char* envelopeString, int index);
void fractionalizePoints (void);
};
class EnvPoint {
public:
EnvPoint(char defaultInterp = 'l') {interp = defaultInterp; x = y = 0.0; }
double x; // normalized time value
double y; // output value for time x
double samples; // sample equivalent of x value
char interp; // type of interpolation to do in the current interval
};
#endif _ENVELOPE_H_INCLUDED
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.