mirror of
https://github.com/thestk/stk
synced 2026-05-03 12:28:11 +00:00
Compare commits
3 Commits
d7d6079f6b
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6aacd357d7 | ||
|
|
0d4bb84732 | ||
|
|
270edc855f |
@@ -12,7 +12,6 @@ SET_PROPERTY(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Release" "Debug" "RelWithD
|
|||||||
message("Build type: " ${CMAKE_BUILD_TYPE})
|
message("Build type: " ${CMAKE_BUILD_TYPE})
|
||||||
|
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /clr")
|
|
||||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /O2 /DNDEBUG")
|
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /O2 /DNDEBUG")
|
||||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /Z7 /Ob0 /Od /RTC1 /D_ITERATOR_DEBUG_LEVEL=2 /D_STK_DEBUG_ /D__RTAUDIO_DEBUG__ /D__RTMIDI_DEBUG__")
|
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /Z7 /Ob0 /Od /RTC1 /D_ITERATOR_DEBUG_LEVEL=2 /D_STK_DEBUG_ /D__RTAUDIO_DEBUG__ /D__RTMIDI_DEBUG__")
|
||||||
else()
|
else()
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ namespace stk {
|
|||||||
*/
|
*/
|
||||||
/***************************************************/
|
/***************************************************/
|
||||||
|
|
||||||
const int maxDelay = 5024;
|
const int maxDelay = 5000; //5024;
|
||||||
|
|
||||||
class PitShift : public Effect
|
class PitShift : public Effect
|
||||||
{
|
{
|
||||||
@@ -64,6 +64,7 @@ class PitShift : public Effect
|
|||||||
DelayL delayLine_;
|
DelayL delayLine_;
|
||||||
StkFloat delay_[2];
|
StkFloat delay_[2];
|
||||||
StkFloat env_[2];
|
StkFloat env_[2];
|
||||||
|
StkFrames window_;
|
||||||
StkFloat rate_;
|
StkFloat rate_;
|
||||||
unsigned long delayLength_;
|
unsigned long delayLength_;
|
||||||
unsigned long halfLength_;
|
unsigned long halfLength_;
|
||||||
@@ -73,25 +74,29 @@ class PitShift : public Effect
|
|||||||
inline StkFloat PitShift :: tick( StkFloat input )
|
inline StkFloat PitShift :: tick( StkFloat input )
|
||||||
{
|
{
|
||||||
// Calculate the two delay length values, keeping them within the
|
// Calculate the two delay length values, keeping them within the
|
||||||
// range 12 to maxDelay-12.
|
// range 0 to delayLength.
|
||||||
delay_[0] += rate_;
|
delay_[0] += rate_;
|
||||||
while ( delay_[0] > maxDelay-12 ) delay_[0] -= delayLength_;
|
while ( delay_[0] >= delayLength_ ) delay_[0] -= delayLength_;
|
||||||
while ( delay_[0] < 12 ) delay_[0] += delayLength_;
|
while ( delay_[0] < 0 ) delay_[0] += delayLength_;
|
||||||
|
|
||||||
delay_[1] = delay_[0] + halfLength_;
|
delay_[1] = delay_[0] + halfLength_;
|
||||||
while ( delay_[1] > maxDelay-12 ) delay_[1] -= delayLength_;
|
while ( delay_[1] >= delayLength_ ) delay_[1] -= delayLength_;
|
||||||
while ( delay_[1] < 12 ) delay_[1] += delayLength_;
|
while ( delay_[1] < 0 ) delay_[1] += delayLength_;
|
||||||
|
|
||||||
// Set the new delay line lengths.
|
// Set the new delay line lengths.
|
||||||
delayLine_.setDelay( delay_[0] );
|
delayLine_.setDelay( delay_[0] );
|
||||||
|
|
||||||
// Calculate a triangular envelope.
|
// Calculate a triangular envelope.
|
||||||
env_[1] = fabs( ( delay_[0] - halfLength_ + 12 ) * ( 1.0 / (halfLength_ + 12 ) ) );
|
//env_[1] = fabs( ( delay_[0] - halfLength_ ) * ( 1.0 / (halfLength_ ) ) );
|
||||||
env_[0] = 1.0 - env_[1];
|
//env_[0] = 1.0 - env_[1];
|
||||||
|
|
||||||
|
// Or use the precomputed hanning window.
|
||||||
|
env_[1] = window_[delay_[0]];
|
||||||
|
env_[0] = window_[delay_[1]];
|
||||||
|
|
||||||
// Delay input and apply envelope.
|
// Delay input and apply envelope.
|
||||||
lastFrame_[0] = env_[1] * delayLine_.tapOut( delay_[1] );
|
lastFrame_[0] = env_[1] * delayLine_.tapOut( delay_[1] );
|
||||||
lastFrame_[0] = +env_[0] * delayLine_.tick( input );
|
lastFrame_[0] += env_[0] * delayLine_.tick( input );
|
||||||
|
|
||||||
// Compute effect mix and output.
|
// Compute effect mix and output.
|
||||||
lastFrame_[0] *= effectMix_;
|
lastFrame_[0] *= effectMix_;
|
||||||
|
|||||||
@@ -219,17 +219,17 @@ int tick( void *outputBuffer, void *inputBuffer, unsigned int nBufferFrames,
|
|||||||
|
|
||||||
int main( int argc, char *argv[] )
|
int main( int argc, char *argv[] )
|
||||||
{
|
{
|
||||||
|
// If you want to change the default sample rate (set in Stk.h), do
|
||||||
|
// it before instantiating any objects! If the sample rate is
|
||||||
|
// specified in the command line, it will override this setting.
|
||||||
|
Stk::setSampleRate( 48000.0 );
|
||||||
|
|
||||||
TickData data;
|
TickData data;
|
||||||
RtAudio adac;
|
RtAudio adac;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if ( argc < 2 || argc > 6 ) usage();
|
if ( argc < 2 || argc > 6 ) usage();
|
||||||
|
|
||||||
// If you want to change the default sample rate (set in Stk.h), do
|
|
||||||
// it before instantiating any objects! If the sample rate is
|
|
||||||
// specified in the command line, it will override this setting.
|
|
||||||
Stk::setSampleRate( 48000.0 );
|
|
||||||
|
|
||||||
// Parse the command-line arguments.
|
// Parse the command-line arguments.
|
||||||
unsigned int port = 2001;
|
unsigned int port = 2001;
|
||||||
for ( i=1; i<argc; i++ ) {
|
for ( i=1; i<argc; i++ ) {
|
||||||
|
|||||||
@@ -16,15 +16,20 @@ namespace stk {
|
|||||||
|
|
||||||
PitShift :: PitShift( void )
|
PitShift :: PitShift( void )
|
||||||
{
|
{
|
||||||
delayLength_ = maxDelay - 24;
|
delayLength_ = maxDelay;
|
||||||
halfLength_ = delayLength_ / 2;
|
halfLength_ = delayLength_ / 2;
|
||||||
delay_[0] = 12;
|
delay_[0] = 0;
|
||||||
delay_[1] = maxDelay / 2;
|
delay_[1] = delayLength_ / 2;
|
||||||
|
|
||||||
delayLine_.setMaximumDelay( maxDelay );
|
delayLine_.setMaximumDelay( maxDelay );
|
||||||
delayLine_.setDelay( delay_[0] );
|
delayLine_.setDelay( delay_[0] );
|
||||||
effectMix_ = 0.5;
|
effectMix_ = 0.5;
|
||||||
rate_ = 1.0;
|
rate_ = 1.0;
|
||||||
|
|
||||||
|
window_.resize( delayLength_, 1 );
|
||||||
|
StkFloat temp = TWO_PI / delayLength_;
|
||||||
|
for ( unsigned long i=0; i<=window_.size(); i++ )
|
||||||
|
window_[i] = (cos( i * temp ) + 1.0) / 2.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PitShift :: clear()
|
void PitShift :: clear()
|
||||||
|
|||||||
Reference in New Issue
Block a user