mirror of
https://github.com/thestk/stk
synced 2026-02-07 09:46:16 +00:00
Version 4.4.0
This commit is contained in:
committed by
Stephen Sinclair
parent
d199342e86
commit
eccd8c9981
@@ -13,15 +13,17 @@
|
||||
Stanford, bearing the names of Karplus and/or
|
||||
Strong.
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2009.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#include "Drone.h"
|
||||
|
||||
namespace stk {
|
||||
|
||||
Drone :: Drone( StkFloat lowestFrequency )
|
||||
{
|
||||
length_ = (unsigned long) (Stk::sampleRate() / lowestFrequency + 1);
|
||||
length_ = (unsigned long) ( Stk::sampleRate() / lowestFrequency + 1 );
|
||||
loopGain_ = 0.999;
|
||||
delayLine_.setMaximumDelay( length_ );
|
||||
delayLine_.setDelay( 0.5 * length_ );
|
||||
@@ -29,11 +31,11 @@ Drone :: Drone( StkFloat lowestFrequency )
|
||||
this->clear();
|
||||
}
|
||||
|
||||
Drone :: ~Drone()
|
||||
Drone :: ~Drone( void )
|
||||
{
|
||||
}
|
||||
|
||||
void Drone :: clear()
|
||||
void Drone :: clear( void )
|
||||
{
|
||||
delayLine_.clear();
|
||||
loopFilter_.clear();
|
||||
@@ -95,11 +97,4 @@ void Drone :: noteOff( StkFloat amplitude )
|
||||
#endif
|
||||
}
|
||||
|
||||
StkFloat Drone :: computeSample()
|
||||
{
|
||||
// Here's the whole inner loop of the instrument!!
|
||||
lastOutput_ = delayLine_.tick( loopFilter_.tick( delayLine_.lastOut() * loopGain_ )
|
||||
+ (0.005 * envelope_.tick() * noise_.tick()));
|
||||
return lastOutput_;
|
||||
}
|
||||
|
||||
} // stk namespace
|
||||
|
||||
@@ -1,3 +1,14 @@
|
||||
#ifndef STK_DRONE_H
|
||||
#define STK_DRONE_H
|
||||
|
||||
#include "Instrmnt.h"
|
||||
#include "DelayA.h"
|
||||
#include "OneZero.h"
|
||||
#include "ADSR.h"
|
||||
#include "Noise.h"
|
||||
|
||||
namespace stk {
|
||||
|
||||
/***************************************************/
|
||||
/*! \class Drone
|
||||
\brief STK "drone" plucked string model.
|
||||
@@ -13,19 +24,10 @@
|
||||
Stanford, bearing the names of Karplus and/or
|
||||
Strong.
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2009.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#ifndef STK_DRONE_H
|
||||
#define STK_DRONE_H
|
||||
|
||||
#include "Instrmnt.h"
|
||||
#include "DelayA.h"
|
||||
#include "OneZero.h"
|
||||
#include "ADSR.h"
|
||||
#include "Noise.h"
|
||||
|
||||
class Drone : public Instrmnt
|
||||
{
|
||||
public:
|
||||
@@ -33,27 +35,28 @@ class Drone : public Instrmnt
|
||||
Drone( StkFloat lowestFrequency = 20 );
|
||||
|
||||
//! Class destructor.
|
||||
~Drone();
|
||||
~Drone( void );
|
||||
|
||||
//! Reset and clear all internal state.
|
||||
void clear();
|
||||
void clear( void );
|
||||
|
||||
//! Set instrument parameters for a particular frequency.
|
||||
virtual void setFrequency(StkFloat frequency);
|
||||
void setFrequency( StkFloat frequency );
|
||||
|
||||
//! Pluck the string with the given amplitude using the current frequency.
|
||||
void pluck(StkFloat amplitude);
|
||||
void pluck( StkFloat amplitude );
|
||||
|
||||
//! Start a note with the given frequency and amplitude.
|
||||
virtual void noteOn(StkFloat frequency, StkFloat amplitude);
|
||||
void noteOn( StkFloat frequency, StkFloat amplitude );
|
||||
|
||||
//! Stop a note with the given amplitude (speed of decay).
|
||||
virtual void noteOff(StkFloat amplitude);
|
||||
void noteOff( StkFloat amplitude );
|
||||
|
||||
//! Compute and return one output sample.
|
||||
StkFloat tick( unsigned int channel = 0 );
|
||||
|
||||
protected:
|
||||
|
||||
StkFloat computeSample( void );
|
||||
|
||||
DelayA delayLine_;
|
||||
OneZero loopFilter_;
|
||||
ADSR envelope_;
|
||||
@@ -63,5 +66,15 @@ class Drone : public Instrmnt
|
||||
|
||||
};
|
||||
|
||||
inline StkFloat Drone :: tick( unsigned int )
|
||||
{
|
||||
// Here's the whole inner loop of the instrument!!
|
||||
lastFrame_[0] = delayLine_.tick( loopFilter_.tick( delayLine_.lastOut() * loopGain_ )
|
||||
+ ( 0.005 * envelope_.tick() * noise_.tick() ) );
|
||||
return lastFrame_[0];
|
||||
}
|
||||
|
||||
} // stk namespace
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -7,12 +7,12 @@ SRC_PATH = ../../src
|
||||
OBJECT_PATH = @object_path@
|
||||
vpath %.o $(OBJECT_PATH)
|
||||
|
||||
OBJECTS = Stk.o Generator.o Noise.o Envelope.o ADSR.o \
|
||||
Filter.o DelayA.o Delay.o \
|
||||
OBJECTS = Stk.o Noise.o ADSR.o \
|
||||
DelayA.o Delay.o \
|
||||
OnePole.o OneZero.o Skini.o \
|
||||
Tabla.o Instrmnt.o Sitar.o \
|
||||
Drone.o VoicDrum.o FileRead.o WvOut.o WvIn.o FileWvIn.o \
|
||||
Effect.o JCRev.o Messager.o
|
||||
Tabla.o Sitar.o \
|
||||
Drone.o VoicDrum.o FileRead.o FileWvIn.o \
|
||||
JCRev.o Messager.o
|
||||
|
||||
INCLUDE = @include@
|
||||
ifeq ($(strip $(INCLUDE)), )
|
||||
@@ -21,18 +21,16 @@ endif
|
||||
vpath %.h $(INCLUDE)
|
||||
|
||||
CC = @CXX@
|
||||
DEFS = @byte_order@
|
||||
DEFS += @debug@
|
||||
CFLAGS = @cflags@
|
||||
CFLAGS += @warn@ -I$(INCLUDE) -I../../src/include
|
||||
DEFS = @CPPFLAGS@
|
||||
DEFS += @byte_order@
|
||||
CFLAGS = @CXXFLAGS@
|
||||
CFLAGS += -I$(INCLUDE) -I$(INCLUDE)/../src/include
|
||||
LIBRARY = @LIBS@
|
||||
LIBRARY += @frameworks@
|
||||
|
||||
REALTIME = @realtime@
|
||||
ifeq ($(REALTIME),yes)
|
||||
PROGRAMS = ragamat
|
||||
OBJECTS += RtMidi.o RtAudio.o RtWvOut.o Thread.o Mutex.o Socket.o TcpServer.o @objects@
|
||||
DEFS += @audio_apis@
|
||||
endif
|
||||
|
||||
RAWWAVES = @rawwaves@
|
||||
@@ -60,6 +58,7 @@ $(OBJECTS) : Stk.h
|
||||
clean :
|
||||
-rm $(OBJECT_PATH)/*.o
|
||||
-rm $(PROGRAMS) *.exe
|
||||
-rm -fR *.dSYM
|
||||
|
||||
strip :
|
||||
strip $(PROGRAMS)
|
||||
|
||||
@@ -8,14 +8,16 @@
|
||||
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 - 2007.
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2009.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#include "Tabla.h"
|
||||
#include <cmath>
|
||||
|
||||
Tabla :: Tabla() : Instrmnt()
|
||||
namespace stk {
|
||||
|
||||
Tabla :: Tabla( void ) : Instrmnt()
|
||||
{
|
||||
// This counts the number of sounding voices.
|
||||
nSounding_ = 0;
|
||||
@@ -23,7 +25,7 @@ Tabla :: Tabla() : Instrmnt()
|
||||
soundNumber_ = std::vector<int> (TABLA_POLYPHONY, -1);
|
||||
}
|
||||
|
||||
Tabla :: ~Tabla()
|
||||
Tabla :: ~Tabla( void )
|
||||
{
|
||||
}
|
||||
|
||||
@@ -45,7 +47,7 @@ static char tablaWaves[TABLA_NUMWAVES][16] =
|
||||
"DrTak2.raw"
|
||||
};
|
||||
|
||||
void Tabla :: noteOn(StkFloat instrument, StkFloat amplitude)
|
||||
void Tabla :: noteOn( StkFloat instrument, StkFloat amplitude )
|
||||
{
|
||||
#if defined(_STK_DEBUG_)
|
||||
errorString_ << "Tabla::noteOn: instrument = " << instrument << ", amplitude = " << amplitude << '.';
|
||||
@@ -117,34 +119,11 @@ void Tabla :: noteOn(StkFloat instrument, StkFloat amplitude)
|
||||
#endif
|
||||
}
|
||||
|
||||
void Tabla :: noteOff(StkFloat amplitude)
|
||||
void Tabla :: noteOff( StkFloat amplitude )
|
||||
{
|
||||
// Set all sounding wave filter gains low.
|
||||
int i = 0;
|
||||
while ( i < nSounding_ ) filters_[i++].setGain( amplitude * 0.01 );
|
||||
}
|
||||
|
||||
StkFloat Tabla :: computeSample()
|
||||
{
|
||||
lastOutput_ = 0.0;
|
||||
if ( nSounding_ == 0 ) return lastOutput_;
|
||||
|
||||
for ( int i=0; i<TABLA_POLYPHONY; i++ ) {
|
||||
if ( soundOrder_[i] >= 0 ) {
|
||||
if ( waves_[i].isFinished() ) {
|
||||
// Re-order the list.
|
||||
for ( int j=0; j<TABLA_POLYPHONY; j++ ) {
|
||||
if ( soundOrder_[j] > soundOrder_[i] )
|
||||
soundOrder_[j] -= 1;
|
||||
}
|
||||
soundOrder_[i] = -1;
|
||||
nSounding_--;
|
||||
}
|
||||
else
|
||||
lastOutput_ += filters_[i].tick( waves_[i].tick() );
|
||||
}
|
||||
}
|
||||
|
||||
return lastOutput_;
|
||||
}
|
||||
|
||||
} // stk namespace
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
#ifndef STK_TABLA_H
|
||||
#define STK_TABLA_H
|
||||
|
||||
#include "Instrmnt.h"
|
||||
#include "FileWvIn.h"
|
||||
#include "OnePole.h"
|
||||
|
||||
namespace stk {
|
||||
|
||||
/***************************************************/
|
||||
/*! \class Tabla
|
||||
\brief STK tabla drum class.
|
||||
@@ -8,17 +17,10 @@
|
||||
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 - 2007.
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2009.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#ifndef STK_TABLA_H
|
||||
#define STK_TABLA_H
|
||||
|
||||
#include "Instrmnt.h"
|
||||
#include "FileWvIn.h"
|
||||
#include "OnePole.h"
|
||||
|
||||
const int TABLA_NUMWAVES = 15;
|
||||
const int TABLA_POLYPHONY = 4;
|
||||
|
||||
@@ -26,27 +28,54 @@ class Tabla : public Instrmnt
|
||||
{
|
||||
public:
|
||||
//! Class constructor.
|
||||
Tabla();
|
||||
Tabla( void );
|
||||
|
||||
//! Class destructor.
|
||||
~Tabla();
|
||||
~Tabla( void );
|
||||
|
||||
//! Start a note with the given drum type and amplitude.
|
||||
void noteOn(StkFloat instrument, StkFloat amplitude);
|
||||
void noteOn( StkFloat instrument, StkFloat amplitude );
|
||||
|
||||
//! Stop a note with the given amplitude (speed of decay).
|
||||
void noteOff(StkFloat amplitude);
|
||||
void noteOff( StkFloat amplitude );
|
||||
|
||||
//! Compute and return one output sample.
|
||||
StkFloat tick( unsigned int channel = 0 );
|
||||
|
||||
protected:
|
||||
|
||||
StkFloat computeSample( void );
|
||||
|
||||
FileWvIn waves_[TABLA_POLYPHONY];
|
||||
OnePole filters_[TABLA_POLYPHONY];
|
||||
std::vector<int> soundOrder_;
|
||||
std::vector<int> soundNumber_;
|
||||
int nSounding_;
|
||||
int nSounding_;
|
||||
|
||||
};
|
||||
|
||||
inline StkFloat Tabla :: tick( unsigned int )
|
||||
{
|
||||
lastFrame_[0] = 0.0;
|
||||
if ( nSounding_ == 0 ) return lastFrame_[0];
|
||||
|
||||
for ( int i=0; i<TABLA_POLYPHONY; i++ ) {
|
||||
if ( soundOrder_[i] >= 0 ) {
|
||||
if ( waves_[i].isFinished() ) {
|
||||
// Re-order the list.
|
||||
for ( int j=0; j<TABLA_POLYPHONY; j++ ) {
|
||||
if ( soundOrder_[j] > soundOrder_[i] )
|
||||
soundOrder_[j] -= 1;
|
||||
}
|
||||
soundOrder_[i] = -1;
|
||||
nSounding_--;
|
||||
}
|
||||
else
|
||||
lastFrame_[0] += filters_[i].tick( waves_[i].tick() );
|
||||
}
|
||||
}
|
||||
|
||||
return lastFrame_[0];
|
||||
}
|
||||
|
||||
} // stk namespace
|
||||
|
||||
#endif
|
||||
|
||||
@@ -8,14 +8,16 @@
|
||||
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 - 2007.
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2009.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#include "VoicDrum.h"
|
||||
#include <cmath>
|
||||
|
||||
VoicDrum :: VoicDrum() : Instrmnt()
|
||||
namespace stk {
|
||||
|
||||
VoicDrum :: VoicDrum( void ) : Instrmnt()
|
||||
{
|
||||
// This counts the number of sounding voices.
|
||||
nSounding_ = 0;
|
||||
@@ -23,7 +25,7 @@ VoicDrum :: VoicDrum() : Instrmnt()
|
||||
soundNumber_ = std::vector<int> (VOICE_POLYPHONY, -1);
|
||||
}
|
||||
|
||||
VoicDrum :: ~VoicDrum()
|
||||
VoicDrum :: ~VoicDrum( void )
|
||||
{
|
||||
}
|
||||
|
||||
@@ -114,33 +116,11 @@ void VoicDrum :: noteOn( StkFloat instrument, StkFloat amplitude )
|
||||
#endif
|
||||
}
|
||||
|
||||
void VoicDrum :: noteOff(StkFloat amplitude)
|
||||
void VoicDrum :: noteOff( StkFloat amplitude )
|
||||
{
|
||||
// Set all sounding wave filter gains low.
|
||||
int i = 0;
|
||||
while ( i < nSounding_ ) filters_[i++].setGain( amplitude * 0.01 );
|
||||
}
|
||||
|
||||
StkFloat VoicDrum :: computeSample()
|
||||
{
|
||||
lastOutput_ = 0.0;
|
||||
if ( nSounding_ == 0 ) return lastOutput_;
|
||||
|
||||
for ( int i=0; i<VOICE_POLYPHONY; i++ ) {
|
||||
if ( soundOrder_[i] >= 0 ) {
|
||||
if ( waves_[i].isFinished() ) {
|
||||
// Re-order the list.
|
||||
for ( int j=0; j<VOICE_POLYPHONY; j++ ) {
|
||||
if ( soundOrder_[j] > soundOrder_[i] )
|
||||
soundOrder_[j] -= 1;
|
||||
}
|
||||
soundOrder_[i] = -1;
|
||||
nSounding_--;
|
||||
}
|
||||
else
|
||||
lastOutput_ += filters_[i].tick( waves_[i].tick() );
|
||||
}
|
||||
}
|
||||
|
||||
return lastOutput_;
|
||||
}
|
||||
} // stk namespace
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
#ifndef STK_VOICDRUM_H
|
||||
#define STK_VOICDRUM_H
|
||||
|
||||
#include "Instrmnt.h"
|
||||
#include "FileWvIn.h"
|
||||
#include "OnePole.h"
|
||||
|
||||
namespace stk {
|
||||
|
||||
/***************************************************/
|
||||
/*! \class VoicDrum
|
||||
\brief STK vocal drum sample player class.
|
||||
@@ -8,17 +17,10 @@
|
||||
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 - 2007.
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2009.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#ifndef STK_VOICDRUM_H
|
||||
#define STK_VOICDRUM_H
|
||||
|
||||
#include "Instrmnt.h"
|
||||
#include "FileWvIn.h"
|
||||
#include "OnePole.h"
|
||||
|
||||
const int VOICE_NUMWAVES = 11;
|
||||
const int VOICE_POLYPHONY = 4;
|
||||
|
||||
@@ -26,21 +28,22 @@ class VoicDrum : public Instrmnt
|
||||
{
|
||||
public:
|
||||
//! Class constructor.
|
||||
VoicDrum();
|
||||
VoicDrum( void );
|
||||
|
||||
//! Class destructor.
|
||||
~VoicDrum();
|
||||
~VoicDrum( void );
|
||||
|
||||
//! Start a note with the given drum type and amplitude.
|
||||
void noteOn(StkFloat instrument, StkFloat amplitude);
|
||||
void noteOn( StkFloat instrument, StkFloat amplitude );
|
||||
|
||||
//! Stop a note with the given amplitude (speed of decay).
|
||||
void noteOff(StkFloat amplitude);
|
||||
void noteOff( StkFloat amplitude );
|
||||
|
||||
//! Compute and return one output sample.
|
||||
StkFloat tick( unsigned int channel = 0 );
|
||||
|
||||
protected:
|
||||
|
||||
StkFloat computeSample( void );
|
||||
|
||||
FileWvIn waves_[VOICE_POLYPHONY];
|
||||
OnePole filters_[VOICE_POLYPHONY];
|
||||
std::vector<int> soundOrder_;
|
||||
@@ -49,4 +52,30 @@ class VoicDrum : public Instrmnt
|
||||
|
||||
};
|
||||
|
||||
inline StkFloat VoicDrum :: tick( unsigned int )
|
||||
{
|
||||
lastFrame_[0] = 0.0;
|
||||
if ( nSounding_ == 0 ) return lastFrame_[0];
|
||||
|
||||
for ( int i=0; i<VOICE_POLYPHONY; i++ ) {
|
||||
if ( soundOrder_[i] >= 0 ) {
|
||||
if ( waves_[i].isFinished() ) {
|
||||
// Re-order the list.
|
||||
for ( int j=0; j<VOICE_POLYPHONY; j++ ) {
|
||||
if ( soundOrder_[j] > soundOrder_[i] )
|
||||
soundOrder_[j] -= 1;
|
||||
}
|
||||
soundOrder_[i] = -1;
|
||||
nSounding_--;
|
||||
}
|
||||
else
|
||||
lastFrame_[0] += filters_[i].tick( waves_[i].tick() );
|
||||
}
|
||||
}
|
||||
|
||||
return lastFrame_[0];
|
||||
}
|
||||
|
||||
} // stk namespace
|
||||
|
||||
#endif
|
||||
|
||||
@@ -11,9 +11,11 @@
|
||||
#include "RtAudio.h"
|
||||
|
||||
#include <signal.h>
|
||||
#include <string.h>
|
||||
#include <iostream>
|
||||
#include <algorithm>
|
||||
using std::min;
|
||||
using namespace stk;
|
||||
|
||||
StkFloat float_random(StkFloat max) // Return random float between 0.0 and max
|
||||
{
|
||||
|
||||
@@ -124,10 +124,6 @@ SOURCE=.\Drone.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\src\Effect.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\include\Effect.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@@ -156,26 +152,14 @@ SOURCE=..\..\include\FileWvIn.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\src\Filter.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\include\Filter.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\src\Generator.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\include\Generator.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\src\Instrmnt.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\include\Instrmnt.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@@ -312,15 +296,11 @@ SOURCE=.\VoicDrum.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\src\WaveLoop.cpp
|
||||
SOURCE=..\..\src\FileLoop.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\include\WaveLoop.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\src\WvIn.cpp
|
||||
SOURCE=..\..\include\FileLoop.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
@@ -328,10 +308,6 @@ SOURCE=..\..\include\WvIn.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\src\WvOut.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\include\WvOut.h
|
||||
# End Source File
|
||||
# End Target
|
||||
|
||||
Reference in New Issue
Block a user