mirror of
https://github.com/thestk/stk
synced 2026-01-11 12:01:52 +00:00
Version 4.4.3
This commit is contained in:
committed by
Stephen Sinclair
parent
baca57040b
commit
0aec39260a
@@ -10,11 +10,11 @@ vpath %.o $(OBJECT_PATH)
|
||||
OBJECTS = Stk.o Noise.o Envelope.o ADSR.o \
|
||||
Modulate.o SingWave.o SineWave.o FileRead.o FileWrite.o \
|
||||
FileWvIn.o FileLoop.o FileWvOut.o \
|
||||
OneZero.o OnePole.o PoleZero.o TwoZero.o \
|
||||
OneZero.o OnePole.o PoleZero.o TwoZero.o Fir.o \
|
||||
BiQuad.o FormSwep.o Delay.o DelayL.o DelayA.o \
|
||||
ReedTable.o JetTable.o BowTable.o \
|
||||
PRCRev.o \
|
||||
Voicer.o Vector3D.o Sphere.o \
|
||||
JCRev.o \
|
||||
Voicer.o Vector3D.o Sphere.o Twang.o \
|
||||
\
|
||||
Clarinet.o BlowHole.o Saxofony.o Flute.o Brass.o BlowBotl.o \
|
||||
Bowed.o Plucked.o StifKarp.o Sitar.o PluckTwo.o Mandolin.o Mesh2D.o \
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#include "SKINI.msg"
|
||||
#include "WvOut.h"
|
||||
#include "Instrmnt.h"
|
||||
#include "PRCRev.h"
|
||||
#include "JCRev.h"
|
||||
#include "Voicer.h"
|
||||
#include "Skini.h"
|
||||
#include "RtAudio.h"
|
||||
@@ -36,7 +36,7 @@ struct TickData {
|
||||
WvOut **wvout;
|
||||
Instrmnt **instrument;
|
||||
Voicer *voicer;
|
||||
PRCRev reverb;
|
||||
JCRev reverb;
|
||||
Messager messager;
|
||||
Skini::Message message;
|
||||
StkFloat volume;
|
||||
@@ -53,7 +53,7 @@ struct TickData {
|
||||
|
||||
// Default constructor.
|
||||
TickData()
|
||||
: wvout(0), instrument(0), voicer(0), volume(1.0), t60(1.0),
|
||||
: wvout(0), instrument(0), voicer(0), volume(1.0), t60(0.75),
|
||||
nWvOuts(0), nVoices(1), currentVoice(0), channels(2), counter(0),
|
||||
realtime( false ), settling( false ), haveMessage( false ) {}
|
||||
};
|
||||
@@ -120,10 +120,7 @@ void processMessage( TickData* data )
|
||||
break;
|
||||
|
||||
case __SK_PitchBend_:
|
||||
short temp;
|
||||
temp = data->message.intValues[1] << 7;
|
||||
temp += data->message.intValues[0];
|
||||
data->voicer->pitchBend( (StkFloat) temp );
|
||||
data->voicer->pitchBend( value1 );
|
||||
break;
|
||||
|
||||
case __SK_Volume_:
|
||||
|
||||
@@ -3,7 +3,7 @@ Suggested Score/Instrument Pairings:
|
||||
BeeThree bookert.ski, organs.ski
|
||||
Rhodey doogie.ski
|
||||
Mandolin duelingb.ski
|
||||
Bowed fiddle.ski
|
||||
Bowed muneira.ski, fiddle.ski
|
||||
PercFlut misacrio.ski
|
||||
ModalBar morazbel.ski
|
||||
Brass pictures.ski
|
||||
|
||||
12901
projects/demo/scores/muneira.ski
Normal file
12901
projects/demo/scores/muneira.ski
Normal file
File diff suppressed because it is too large
Load Diff
@@ -401,7 +401,7 @@ proc patchChange {value} {
|
||||
.right.cont1 config -state normal -label "Vibrato Amount"
|
||||
set cont1 4.0
|
||||
set cont2 64.0
|
||||
set cont4 64.0
|
||||
set cont4 24.0
|
||||
set cont11 64.0
|
||||
printWhatz "ControlChange 0.0 1 " 1 $cont1
|
||||
printWhatz "ControlChange 0.0 1 " 2 $cont2
|
||||
|
||||
@@ -300,7 +300,7 @@ proc patchChange {value} {
|
||||
.right.cont1 config -state normal -label "Vibrato Amount"
|
||||
set cont1 4.0
|
||||
set cont2 64.0
|
||||
set cont4 64.0
|
||||
set cont4 24.0
|
||||
set cont11 64.0
|
||||
printWhatz "ControlChange 0.0 1 " 1 $cont1
|
||||
printWhatz "ControlChange 0.0 1 " 2 $cont2
|
||||
|
||||
@@ -2,8 +2,7 @@
|
||||
//
|
||||
// Gary P. Scavone, 1999.
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <cstring>
|
||||
#include "utilities.h"
|
||||
|
||||
// STK Instrument Classes
|
||||
@@ -58,7 +57,7 @@ int voiceByNumber(int number, Instrmnt **instrument)
|
||||
else if (number==2) *instrument = new Saxofony(10.0);
|
||||
else if (number==3) *instrument = new Flute(10.0);
|
||||
else if (number==4) *instrument = new Brass(10.0);
|
||||
else if (number==5) *instrument = new BlowBotl();
|
||||
else if (number==5) *instrument = new BlowBotl;
|
||||
else if (number==6) *instrument = new Bowed(10.0);
|
||||
else if (number==7) *instrument = new Plucked(5.0);
|
||||
else if (number==8) *instrument = new StifKarp(5.0);
|
||||
@@ -68,21 +67,21 @@ int voiceByNumber(int number, Instrmnt **instrument)
|
||||
else if (number==11) *instrument = new Rhodey;
|
||||
else if (number==12) *instrument = new Wurley;
|
||||
else if (number==13) *instrument = new TubeBell;
|
||||
else if (number==14) *instrument = new HevyMetl();
|
||||
else if (number==15) *instrument = new PercFlut();
|
||||
else if (number==14) *instrument = new HevyMetl;
|
||||
else if (number==15) *instrument = new PercFlut;
|
||||
else if (number==16) *instrument = new BeeThree;
|
||||
else if (number==17) *instrument = new FMVoices;
|
||||
|
||||
else if (number==18) *instrument = new VoicForm();
|
||||
else if (number==19) *instrument = new Moog();
|
||||
else if (number==20) *instrument = new Simple();
|
||||
else if (number==21) *instrument = new Drummer();
|
||||
else if (number==22) *instrument = new BandedWG();
|
||||
else if (number==23) *instrument = new Shakers();
|
||||
else if (number==24) *instrument = new ModalBar();
|
||||
else if (number==18) *instrument = new VoicForm;
|
||||
else if (number==19) *instrument = new Moog;
|
||||
else if (number==20) *instrument = new Simple;
|
||||
else if (number==21) *instrument = new Drummer;
|
||||
else if (number==22) *instrument = new BandedWG;
|
||||
else if (number==23) *instrument = new Shakers;
|
||||
else if (number==24) *instrument = new ModalBar;
|
||||
else if (number==25) *instrument = new Mesh2D(10, 10);
|
||||
else if (number==26) *instrument = new Resonate();
|
||||
else if (number==27) *instrument = new Whistle();
|
||||
else if (number==26) *instrument = new Resonate;
|
||||
else if (number==27) *instrument = new Whistle;
|
||||
|
||||
else {
|
||||
printf("\nUnknown instrument or program change requested!\n");
|
||||
@@ -121,12 +120,12 @@ void usage(char *function) {
|
||||
printf(" -os <file name> for .snd audio output file,\n");
|
||||
printf(" -om <file name> for .mat audio output file,\n");
|
||||
printf(" -oa <file name> for .aif audio output file,\n");
|
||||
printf(" -if <file name> to read control input from SKINI file,\n");
|
||||
#if defined(__STK_REALTIME__)
|
||||
printf(" -or for realtime audio output,\n");
|
||||
#endif
|
||||
printf(" -if <file name> to read control input from SKINI file,\n");
|
||||
#if defined(__STK_REALTIME__)
|
||||
printf(" -ip for realtime control input by pipe,\n");
|
||||
printf(" (won't work under Win95/98),\n");
|
||||
printf(" -is <port> for realtime control input by socket,\n");
|
||||
printf(" -im <port> for realtime control input by MIDI (virtual port = 0, default = 1),\n");
|
||||
#endif
|
||||
printf(" and Instrument = one of these:\n");
|
||||
@@ -146,16 +145,16 @@ void usage(char *function) {
|
||||
exit(0);
|
||||
}
|
||||
|
||||
int checkArgs(int numArgs, char *args[])
|
||||
int checkArgs(int nArgs, char *args[])
|
||||
{
|
||||
int w, i = 2, j = 0;
|
||||
int nWvOuts = 0;
|
||||
char flags[2][50] = {""};
|
||||
bool realtime = false;
|
||||
|
||||
if (numArgs < 3 || numArgs > 22) usage(args[0]);
|
||||
if (nArgs < 3 || nArgs > 22) usage(args[0]);
|
||||
|
||||
while (i < numArgs) {
|
||||
while (i < nArgs) {
|
||||
if (args[i][0] == '-') {
|
||||
if (args[i][1] == 'o') {
|
||||
if ( args[i][2] == 'r' ) realtime = true;
|
||||
@@ -166,16 +165,16 @@ int checkArgs(int numArgs, char *args[])
|
||||
flags[1][j++] = args[i][2];
|
||||
}
|
||||
else if (args[i][1] == 'i') {
|
||||
if ( (args[i][2] != 's') && (args[i][2] != 'p') &&
|
||||
(args[i][2] != 'm') && (args[i][2] != 'f') ) usage(args[0]);
|
||||
if ( (args[i][2] != 'p') && (args[i][2] != 'm') &&
|
||||
(args[i][2] != 'f') ) usage(args[0]);
|
||||
flags[0][j] = 'i';
|
||||
flags[1][j++] = args[i][2];
|
||||
}
|
||||
else if (args[i][1] == 's' && (i+1 < numArgs) && args[i+1][0] != '-' ) {
|
||||
else if (args[i][1] == 's' && (i+1 < nArgs) && args[i+1][0] != '-' ) {
|
||||
Stk::setSampleRate( atoi(args[i+1]) );
|
||||
flags[0][j++] = 's';
|
||||
}
|
||||
else if (args[i][1] == 'n' && (i+1 < numArgs) && args[i+1][0] != '-' ) {
|
||||
else if (args[i][1] == 'n' && (i+1 < nArgs) && args[i+1][0] != '-' ) {
|
||||
flags[0][j++] = 'n';
|
||||
}
|
||||
else usage(args[0]);
|
||||
@@ -218,13 +217,13 @@ int countVoices(int nArgs, char *args[])
|
||||
return nInstruments;
|
||||
}
|
||||
|
||||
bool parseArgs(int numArgs, char *args[], WvOut **output, Messager& messager)
|
||||
bool parseArgs(int nArgs, char *args[], WvOut **output, Messager& messager)
|
||||
{
|
||||
int i = 2, j = 0, nWvIns = 0;
|
||||
bool realtime = false;
|
||||
char fileName[256];
|
||||
|
||||
while (i < numArgs) {
|
||||
while (i < nArgs) {
|
||||
if ( (args[i][0] == '-') && (args[i][1] == 'i') ) {
|
||||
switch(args[i][2]) {
|
||||
|
||||
@@ -243,24 +242,10 @@ bool parseArgs(int numArgs, char *args[], WvOut **output, Messager& messager)
|
||||
usage(args[0]);
|
||||
#endif
|
||||
|
||||
case 's':
|
||||
#if defined(__STK_REALTIME__)
|
||||
// Check for an optional socket port argument.
|
||||
if ((i+1 < numArgs) && args[i+1][0] != '-') {
|
||||
int port = atoi(args[++i]);
|
||||
if ( !messager.startSocketInput( port ) ) exit(0);
|
||||
}
|
||||
else if ( !messager.startSocketInput() ) exit(0);
|
||||
nWvIns++;
|
||||
break;
|
||||
#else
|
||||
usage(args[0]);
|
||||
#endif
|
||||
|
||||
case 'm':
|
||||
#if defined(__STK_REALTIME__)
|
||||
// Check for an optional MIDI port argument.
|
||||
if ((i+1 < numArgs) && args[i+1][0] != '-') {
|
||||
if ((i+1 < nArgs) && args[i+1][0] != '-') {
|
||||
int port = atoi(args[++i]);
|
||||
if ( !messager.startMidiInput( port-1 ) ) exit(0);
|
||||
}
|
||||
@@ -288,7 +273,7 @@ bool parseArgs(int numArgs, char *args[], WvOut **output, Messager& messager)
|
||||
#endif
|
||||
|
||||
case 'w':
|
||||
if ((i+1 < numArgs) && args[i+1][0] != '-') {
|
||||
if ((i+1 < nArgs) && args[i+1][0] != '-') {
|
||||
i++;
|
||||
strcpy(fileName,args[i]);
|
||||
}
|
||||
@@ -298,7 +283,7 @@ bool parseArgs(int numArgs, char *args[], WvOut **output, Messager& messager)
|
||||
break;
|
||||
|
||||
case 's':
|
||||
if ((i+1 < numArgs) && args[i+1][0] != '-') {
|
||||
if ((i+1 < nArgs) && args[i+1][0] != '-') {
|
||||
i++;
|
||||
strcpy(fileName,args[i]);
|
||||
}
|
||||
@@ -308,7 +293,7 @@ bool parseArgs(int numArgs, char *args[], WvOut **output, Messager& messager)
|
||||
break;
|
||||
|
||||
case 'm':
|
||||
if ((i+1 < numArgs) && args[i+1][0] != '-') {
|
||||
if ((i+1 < nArgs) && args[i+1][0] != '-') {
|
||||
i++;
|
||||
strcpy(fileName,args[i]);
|
||||
}
|
||||
@@ -318,7 +303,7 @@ bool parseArgs(int numArgs, char *args[], WvOut **output, Messager& messager)
|
||||
break;
|
||||
|
||||
case 'a':
|
||||
if ((i+1 < numArgs) && args[i+1][0] != '-') {
|
||||
if ((i+1 < nArgs) && args[i+1][0] != '-') {
|
||||
i++;
|
||||
strcpy(fileName,args[i]);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
The Synthesis ToolKit in C++ (STK)
|
||||
|
||||
By Perry R. Cook and Gary P. Scavone, 1995-2010.
|
||||
By Perry R. Cook and Gary P. Scavone, 1995-2011.
|
||||
|
||||
EFFECTS PROJECT:
|
||||
|
||||
|
||||
@@ -63,8 +63,8 @@ int main( int argc, char *argv[] )
|
||||
|
||||
// Open the soundfile for output. Other file format options
|
||||
// include: FILE_SND, FILE_AIF, FILE_MAT, and FILE_RAW. Other data
|
||||
// type options include: STK_SINT8, STK_SINT32, StkFloat32, and
|
||||
// StkFloat64.
|
||||
// type options include: STK_SINT8, STK_INT24, STK_SINT32,
|
||||
// STK_FLOAT32, and STK_FLOAT64.
|
||||
try {
|
||||
output.openFile( argv[2], channels, FileWrite::FILE_WAV, Stk::STK_SINT16 );
|
||||
}
|
||||
|
||||
@@ -13,20 +13,26 @@
|
||||
Stanford, bearing the names of Karplus and/or
|
||||
Strong.
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2010.
|
||||
by Perry R. Cook and Gary P. Scavone, 1995-2011.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#include "Drone.h"
|
||||
#include <sstream>
|
||||
|
||||
namespace stk {
|
||||
|
||||
Drone :: Drone( StkFloat lowestFrequency )
|
||||
{
|
||||
length_ = (unsigned long) ( Stk::sampleRate() / lowestFrequency + 1 );
|
||||
loopGain_ = 0.999;
|
||||
delayLine_.setMaximumDelay( length_ );
|
||||
delayLine_.setDelay( 0.5 * length_ );
|
||||
if ( lowestFrequency <= 0.0 ) {
|
||||
oStream_ << "Drone::Drone: argument is less than or equal to zero!";
|
||||
handleError( StkError::FUNCTION_ARGUMENT );
|
||||
}
|
||||
|
||||
unsigned long delays = (unsigned long) ( Stk::sampleRate() / lowestFrequency );
|
||||
delayLine_.setMaximumDelay( delays + 1 );
|
||||
|
||||
this->setFrequency( 220.0 );
|
||||
envelope_.setAllTimes( 2.0, 0.5, 0.0, 0.5 );
|
||||
this->clear();
|
||||
}
|
||||
@@ -43,21 +49,18 @@ void Drone :: clear( void )
|
||||
|
||||
void Drone :: setFrequency( StkFloat frequency )
|
||||
{
|
||||
StkFloat freakency = frequency;
|
||||
#if defined(_STK_DEBUG_)
|
||||
if ( frequency <= 0.0 ) {
|
||||
errorString_ << "Drone::setFrequency: parameter is less than or equal to zero!";
|
||||
handleError( StkError::WARNING );
|
||||
freakency = 220.0;
|
||||
oStream_ << "Drone::setFrequency: argument is less than or equal to zero!";
|
||||
handleError( StkError::WARNING ); return;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Delay = length - approximate filter delay.
|
||||
StkFloat delay = (Stk::sampleRate() / freakency) - 0.5;
|
||||
if ( delay <= 0.0 )
|
||||
delay = 0.3;
|
||||
else if (delay > length_)
|
||||
delay = length_;
|
||||
StkFloat delay = (Stk::sampleRate() / frequency) - 0.5;
|
||||
delayLine_.setDelay( delay );
|
||||
loopGain_ = 0.997 + (freakency * 0.000002);
|
||||
|
||||
loopGain_ = 0.997 + (frequency * 0.000002);
|
||||
if ( loopGain_ >= 1.0 ) loopGain_ = 0.99999;
|
||||
}
|
||||
|
||||
@@ -70,31 +73,16 @@ void Drone :: noteOn( StkFloat frequency, StkFloat amplitude )
|
||||
{
|
||||
this->setFrequency( frequency );
|
||||
this->pluck( amplitude );
|
||||
|
||||
#if defined(_STK_DEBUG_)
|
||||
errorString_ << "Drone::NoteOn: frequency = " << frequency << ", amplitude = " << amplitude << ".";
|
||||
handleError( StkError::DEBUG_WARNING );
|
||||
#endif
|
||||
}
|
||||
|
||||
void Drone :: noteOff( StkFloat amplitude )
|
||||
{
|
||||
loopGain_ = 1.0 - amplitude;
|
||||
if ( loopGain_ < 0.0 ) {
|
||||
errorString_ << "Drone::noteOff: amplitude is greater than 1.0 ... setting to 1.0!";
|
||||
handleError( StkError::WARNING );
|
||||
loopGain_ = 0.0;
|
||||
}
|
||||
else if ( loopGain_ > 1.0 ) {
|
||||
errorString_ << "Drone::noteOff: amplitude is < 0.0 ... setting to 0.0!";
|
||||
handleError( StkError::WARNING );
|
||||
loopGain_ = 0.99999;
|
||||
if ( amplitude < 0.0 || amplitude > 1.0 ) {
|
||||
oStream_ << "Plucked::noteOff: amplitude is out of range!";
|
||||
handleError( StkError::WARNING ); return;
|
||||
}
|
||||
|
||||
#if defined(_STK_DEBUG_)
|
||||
errorString_ << "Drone::noteOff: amplitude = " << amplitude << ".";
|
||||
handleError( StkError::DEBUG_WARNING );
|
||||
#endif
|
||||
loopGain_ = 1.0 - amplitude;
|
||||
}
|
||||
|
||||
} // stk namespace
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace stk {
|
||||
Stanford, bearing the names of Karplus and/or
|
||||
Strong.
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2010.
|
||||
by Perry R. Cook and Gary P. Scavone, 1995-2011.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
@@ -55,6 +55,16 @@ class Drone : public Instrmnt
|
||||
//! Compute and return one output sample.
|
||||
StkFloat tick( unsigned int channel = 0 );
|
||||
|
||||
//! Fill a channel of the StkFrames object with computed outputs.
|
||||
/*!
|
||||
The \c channel argument must be less than the number of
|
||||
channels in the StkFrames argument (the first channel is specified
|
||||
by 0). However, range checking is only performed if _STK_DEBUG_
|
||||
is defined during compilation, in which case an out-of-range value
|
||||
will trigger an StkError exception.
|
||||
*/
|
||||
StkFrames& tick( StkFrames& frames, unsigned int channel = 0 );
|
||||
|
||||
protected:
|
||||
|
||||
DelayA delayLine_;
|
||||
@@ -74,6 +84,33 @@ inline StkFloat Drone :: tick( unsigned int )
|
||||
return lastFrame_[0];
|
||||
}
|
||||
|
||||
inline StkFrames& Drone :: tick( StkFrames& frames, unsigned int channel )
|
||||
{
|
||||
unsigned int nChannels = lastFrame_.channels();
|
||||
#if defined(_STK_DEBUG_)
|
||||
if ( channel > frames.channels() - nChannels ) {
|
||||
oStream_ << "Drone::tick(): channel and StkFrames arguments are incompatible!";
|
||||
handleError( StkError::FUNCTION_ARGUMENT );
|
||||
}
|
||||
#endif
|
||||
|
||||
StkFloat *samples = &frames[channel];
|
||||
unsigned int j, hop = frames.channels() - nChannels;
|
||||
if ( nChannels == 1 ) {
|
||||
for ( unsigned int i=0; i<frames.frames(); i++, samples += hop )
|
||||
*samples++ = tick();
|
||||
}
|
||||
else {
|
||||
for ( unsigned int i=0; i<frames.frames(); i++, samples += hop ) {
|
||||
*samples++ = tick();
|
||||
for ( j=1; j<nChannels; j++ )
|
||||
*samples++ = lastFrame_[j];
|
||||
}
|
||||
}
|
||||
|
||||
return frames;
|
||||
}
|
||||
|
||||
} // stk namespace
|
||||
|
||||
#endif
|
||||
|
||||
@@ -30,7 +30,7 @@ LIBRARY = @LIBS@
|
||||
REALTIME = @realtime@
|
||||
ifeq ($(REALTIME),yes)
|
||||
PROGRAMS = ragamat
|
||||
OBJECTS += RtMidi.o RtAudio.o RtWvOut.o Thread.o Mutex.o Socket.o TcpServer.o @objects@
|
||||
OBJECTS += RtMidi.o RtAudio.o Thread.o Mutex.o Socket.o TcpServer.o @objects@
|
||||
endif
|
||||
|
||||
RAWWAVES = @rawwaves@
|
||||
@@ -51,7 +51,7 @@ ragamat: ragamat.cpp $(OBJECTS)
|
||||
$(CC) $(LDFLAGS) $(CFLAGS) $(DEFS) -o ragamat ragamat.cpp $(OBJECT_PATH)/*.o $(LIBRARY)
|
||||
|
||||
libragamat: ragamat.cpp Tabla.cpp Drone.cpp VoicDrum.cpp
|
||||
$(CC) $(LDFLAGS) $(CFLAGS) $(DEFS) -o ragamat Tabla.cpp Drone.cpp VoicDrum.cpp ragamat.cpp -L../../src $(LIBRARY) -lstk
|
||||
$(CC) $(LDFLAGS) $(CFLAGS) $(DEFS) -o ragamat Tabla.cpp Drone.cpp VoicDrum.cpp ragamat.cpp -L../../src -lstk $(LIBRARY)
|
||||
|
||||
$(OBJECTS) : Stk.h
|
||||
|
||||
|
||||
@@ -8,12 +8,13 @@
|
||||
sample rates. You can specify the maximum polyphony (maximum
|
||||
number of simultaneous voices) in Tabla.h.
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2010.
|
||||
by Perry R. Cook and Gary P. Scavone, 1995-2011.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#include "Tabla.h"
|
||||
#include <cmath>
|
||||
#include <sstream>
|
||||
|
||||
namespace stk {
|
||||
|
||||
@@ -49,21 +50,9 @@ static char tablaWaves[TABLA_NUMWAVES][16] =
|
||||
|
||||
void Tabla :: noteOn( StkFloat instrument, StkFloat amplitude )
|
||||
{
|
||||
#if defined(_STK_DEBUG_)
|
||||
errorString_ << "Tabla::noteOn: instrument = " << instrument << ", amplitude = " << amplitude << '.';
|
||||
handleError( StkError::DEBUG_WARNING );
|
||||
#endif
|
||||
|
||||
StkFloat gain = amplitude;
|
||||
if ( amplitude > 1.0 ) {
|
||||
errorString_ << "Tabla::noteOn: amplitude parameter is greater than 1.0 ... setting to 1.0.";
|
||||
handleError( StkError::WARNING );
|
||||
gain = 1.0;
|
||||
}
|
||||
else if ( amplitude < 0.0 ) {
|
||||
errorString_ << "Tabla::noteOn: amplitude parameter is less than 0.0 ... doing nothing.";
|
||||
handleError( StkError::WARNING );
|
||||
return;
|
||||
if ( amplitude < 0.0 || amplitude > 1.0 ) {
|
||||
oStream_ << "Tabla::noteOn: amplitude parameter is out of bounds!";
|
||||
handleError( StkError::WARNING ); return;
|
||||
}
|
||||
|
||||
int noteNumber = ( (int) instrument ) % 16;
|
||||
@@ -79,8 +68,8 @@ void Tabla :: noteOn( StkFloat instrument, StkFloat amplitude )
|
||||
nSounding_++;
|
||||
}
|
||||
waves_[iWave].reset();
|
||||
filters_[iWave].setPole( 0.999 - (gain * 0.6) );
|
||||
filters_[iWave].setGain( gain );
|
||||
filters_[iWave].setPole( 0.999 - (amplitude * 0.6) );
|
||||
filters_[iWave].setGain( amplitude );
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -107,16 +96,18 @@ void Tabla :: noteOn( StkFloat instrument, StkFloat amplitude )
|
||||
waves_[iWave].openFile( (std::string("rawwaves/") + tablaWaves[ noteNumber ]).c_str(), true );
|
||||
if ( Stk::sampleRate() != 22050.0 )
|
||||
waves_[iWave].setRate( 22050.0 / Stk::sampleRate() );
|
||||
filters_[iWave].setPole( 0.999 - (gain * 0.6) );
|
||||
filters_[iWave].setGain( gain );
|
||||
filters_[iWave].setPole( 0.999 - (amplitude * 0.6) );
|
||||
filters_[iWave].setGain( amplitude );
|
||||
}
|
||||
|
||||
/*
|
||||
#if defined(_STK_DEBUG_)
|
||||
errorString_ << "Tabla::noteOn: number sounding = " << nSounding_ << '\n';
|
||||
for (int i=0; i<nSounding_; i++) errorString_ << soundNumber_[i] << " ";
|
||||
errorString_ << '\n';
|
||||
oStream; errorStream << "Tabla::noteOn: number sounding = " << nSounding_ << '\n';
|
||||
for (int i=0; i<nSounding_; i++) oStream << soundNumber_[i] << " ";
|
||||
oStream << '\n'; errorString_ = oStream.str();
|
||||
handleError( StkError::DEBUG_WARNING );
|
||||
#endif
|
||||
*/
|
||||
}
|
||||
|
||||
void Tabla :: noteOff( StkFloat amplitude )
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace stk {
|
||||
sample rates. You can specify the maximum polyphony (maximum
|
||||
number of simultaneous voices) in Tabla.h.
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2010.
|
||||
by Perry R. Cook and Gary P. Scavone, 1995-2011.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
@@ -42,6 +42,16 @@ class Tabla : public Instrmnt
|
||||
//! Compute and return one output sample.
|
||||
StkFloat tick( unsigned int channel = 0 );
|
||||
|
||||
//! Fill a channel of the StkFrames object with computed outputs.
|
||||
/*!
|
||||
The \c channel argument must be less than the number of
|
||||
channels in the StkFrames argument (the first channel is specified
|
||||
by 0). However, range checking is only performed if _STK_DEBUG_
|
||||
is defined during compilation, in which case an out-of-range value
|
||||
will trigger an StkError exception.
|
||||
*/
|
||||
StkFrames& tick( StkFrames& frames, unsigned int channel = 0 );
|
||||
|
||||
protected:
|
||||
|
||||
FileWvIn waves_[TABLA_POLYPHONY];
|
||||
@@ -76,6 +86,33 @@ inline StkFloat Tabla :: tick( unsigned int )
|
||||
return lastFrame_[0];
|
||||
}
|
||||
|
||||
inline StkFrames& Tabla :: tick( StkFrames& frames, unsigned int channel )
|
||||
{
|
||||
unsigned int nChannels = lastFrame_.channels();
|
||||
#if defined(_STK_DEBUG_)
|
||||
if ( channel > frames.channels() - nChannels ) {
|
||||
oStream_ << "Tabla::tick(): channel and StkFrames arguments are incompatible!";
|
||||
handleError( StkError::FUNCTION_ARGUMENT );
|
||||
}
|
||||
#endif
|
||||
|
||||
StkFloat *samples = &frames[channel];
|
||||
unsigned int j, hop = frames.channels() - nChannels;
|
||||
if ( nChannels == 1 ) {
|
||||
for ( unsigned int i=0; i<frames.frames(); i++, samples += hop )
|
||||
*samples++ = tick();
|
||||
}
|
||||
else {
|
||||
for ( unsigned int i=0; i<frames.frames(); i++, samples += hop ) {
|
||||
*samples++ = tick();
|
||||
for ( j=1; j<nChannels; j++ )
|
||||
*samples++ = lastFrame_[j];
|
||||
}
|
||||
}
|
||||
|
||||
return frames;
|
||||
}
|
||||
|
||||
} // stk namespace
|
||||
|
||||
#endif
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
sample rates. You can specify the maximum polyphony (maximum
|
||||
number of simultaneous voices) in VoicDrum.h.
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2010.
|
||||
by Perry R. Cook and Gary P. Scavone, 1995-2011.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
@@ -46,21 +46,9 @@ char voiceNames[VOICE_NUMWAVES][11] =
|
||||
|
||||
void VoicDrum :: noteOn( StkFloat instrument, StkFloat amplitude )
|
||||
{
|
||||
#if defined(_STK_DEBUG_)
|
||||
errorString_ << "VoicDrum::noteOn: instrument = " << instrument << ", amplitude = " << amplitude << '.';
|
||||
handleError( StkError::DEBUG_WARNING );
|
||||
#endif
|
||||
|
||||
StkFloat gain = amplitude;
|
||||
if ( amplitude > 1.0 ) {
|
||||
errorString_ << "VoicDrum::noteOn: amplitude parameter is greater than 1.0 ... setting to 1.0.";
|
||||
handleError( StkError::WARNING );
|
||||
gain = 1.0;
|
||||
}
|
||||
else if ( amplitude < 0.0 ) {
|
||||
errorString_ << "VoicDrum::noteOn: amplitude parameter is less than 0.0 ... doing nothing.";
|
||||
handleError( StkError::WARNING );
|
||||
return;
|
||||
if ( amplitude < 0.0 || amplitude > 1.0 ) {
|
||||
oStream_ << "VoicDrum::noteOn: amplitude parameter is out of bounds!";
|
||||
handleError( StkError::WARNING ); return;
|
||||
}
|
||||
|
||||
int noteNumber = ( (int) instrument ) % 11;
|
||||
@@ -76,8 +64,8 @@ void VoicDrum :: noteOn( StkFloat instrument, StkFloat amplitude )
|
||||
nSounding_++;
|
||||
}
|
||||
waves_[iWave].reset();
|
||||
filters_[iWave].setPole( 0.999 - (gain * 0.6) );
|
||||
filters_[iWave].setGain( gain );
|
||||
filters_[iWave].setPole( 0.999 - (amplitude * 0.6) );
|
||||
filters_[iWave].setGain( amplitude );
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -104,16 +92,18 @@ void VoicDrum :: noteOn( StkFloat instrument, StkFloat amplitude )
|
||||
waves_[iWave].openFile( (std::string("rawwaves/") + voiceNames[ noteNumber ]).c_str(), true );
|
||||
if ( Stk::sampleRate() != 22050.0 )
|
||||
waves_[iWave].setRate( 22050.0 / Stk::sampleRate() );
|
||||
filters_[iWave].setPole( 0.999 - (gain * 0.6) );
|
||||
filters_[iWave].setGain( gain );
|
||||
filters_[iWave].setPole( 0.999 - (amplitude * 0.6) );
|
||||
filters_[iWave].setGain( amplitude );
|
||||
}
|
||||
|
||||
/*
|
||||
#if defined(_STK_DEBUG_)
|
||||
errorString_ << "VoicDrum::noteOn: number sounding = " << nSounding_ << '\n';
|
||||
for (int i=0; i<nSounding_; i++) errorString_ << soundNumber_[i] << " ";
|
||||
errorString_ << '\n';
|
||||
handleError( StkError::DEBUG_WARNING );
|
||||
oStream << "VoicDrum::noteOn: number sounding = " << nSounding_ << '\n';
|
||||
for (int i=0; i<nSounding_; i++) oStream << soundNumber_[i] << " ";
|
||||
oStream << '\n';
|
||||
handleError( StkError::WARNING );
|
||||
#endif
|
||||
*/
|
||||
}
|
||||
|
||||
void VoicDrum :: noteOff( StkFloat amplitude )
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace stk {
|
||||
sample rates. You can specify the maximum polyphony (maximum
|
||||
number of simultaneous voices) in VoicDrum.h.
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2010.
|
||||
by Perry R. Cook and Gary P. Scavone, 1995-2011.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
@@ -42,6 +42,16 @@ class VoicDrum : public Instrmnt
|
||||
//! Compute and return one output sample.
|
||||
StkFloat tick( unsigned int channel = 0 );
|
||||
|
||||
//! Fill a channel of the StkFrames object with computed outputs.
|
||||
/*!
|
||||
The \c channel argument must be less than the number of
|
||||
channels in the StkFrames argument (the first channel is specified
|
||||
by 0). However, range checking is only performed if _STK_DEBUG_
|
||||
is defined during compilation, in which case an out-of-range value
|
||||
will trigger an StkError exception.
|
||||
*/
|
||||
StkFrames& tick( StkFrames& frames, unsigned int channel = 0 );
|
||||
|
||||
protected:
|
||||
|
||||
FileWvIn waves_[VOICE_POLYPHONY];
|
||||
@@ -76,6 +86,33 @@ inline StkFloat VoicDrum :: tick( unsigned int )
|
||||
return lastFrame_[0];
|
||||
}
|
||||
|
||||
inline StkFrames& VoicDrum :: tick( StkFrames& frames, unsigned int channel )
|
||||
{
|
||||
unsigned int nChannels = lastFrame_.channels();
|
||||
#if defined(_STK_DEBUG_)
|
||||
if ( channel > frames.channels() - nChannels ) {
|
||||
oStream_ << "VoicDrum::tick(): channel and StkFrames arguments are incompatible!";
|
||||
handleError( StkError::FUNCTION_ARGUMENT );
|
||||
}
|
||||
#endif
|
||||
|
||||
StkFloat *samples = &frames[channel];
|
||||
unsigned int j, hop = frames.channels() - nChannels;
|
||||
if ( nChannels == 1 ) {
|
||||
for ( unsigned int i=0; i<frames.frames(); i++, samples += hop )
|
||||
*samples++ = tick();
|
||||
}
|
||||
else {
|
||||
for ( unsigned int i=0; i<frames.frames(); i++, samples += hop ) {
|
||||
*samples++ = tick();
|
||||
for ( j=1; j<nChannels; j++ )
|
||||
*samples++ = lastFrame_[j];
|
||||
}
|
||||
}
|
||||
|
||||
return frames;
|
||||
}
|
||||
|
||||
} // stk namespace
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user