Skip to content

Commit

Permalink
improve ChucK::run() comments; make input const argument
Browse files Browse the repository at this point in the history
  • Loading branch information
gewang committed Jul 7, 2023
1 parent a7ba409 commit 59bef1d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
8 changes: 6 additions & 2 deletions src/core/chuck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1218,9 +1218,12 @@ t_CKBOOL ChucK::start()

//-----------------------------------------------------------------------------
// name: run()
// desc: run engine (call from host callback)
// desc: run ChucK and synthesize audio for `numFrames`
// `input`: the incoming input array of audio samples
// `output`: the outgoing output array of audio samples
// `numFrames` : the number of audio frames to run
//-----------------------------------------------------------------------------
void ChucK::run( SAMPLE * input, SAMPLE * output, t_CKINT numFrames )
void ChucK::run( const SAMPLE * input, SAMPLE * output, t_CKINT numFrames )
{
// make sure we started...
if( !m_started ) this->start();
Expand All @@ -1231,6 +1234,7 @@ void ChucK::run( SAMPLE * input, SAMPLE * output, t_CKINT numFrames )




//-----------------------------------------------------------------------------
// name: globals()
// desc: returns VM Globals Manager
Expand Down
11 changes: 9 additions & 2 deletions src/core/chuck.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,15 @@ class ChucK
t_CKBOOL start();

public:
// run engine (call from callback)
void run( SAMPLE * input, SAMPLE * output, t_CKINT numFrames );
// run ChucK and synthesize audio for `numFrames`...
// (NOTE this function is often called from audio callback)
// `input`: the incoming input array of audio samples
// input array size expected to == `numFrames` * number-of-input-chanels, as initialized in setParam(CHUCK_PARAM_INPUT_CHANNELS, ...)
// `output`: the outgoing output array of audio samples
// output array size expected to == `numFrames` * number-of-output-chanels, as initialized in setParam(CHUCK_PARAM_OUTPUT_CHANNELS, ...)
// `numFrames` : the number of audio frames to run
// each audio frame corresponds to one point in time, and contains values for every audio channel
void run( const SAMPLE * input, SAMPLE * output, t_CKINT numFrames );

public:
// is initialized
Expand Down
5 changes: 4 additions & 1 deletion src/core/chuck_vm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,10 @@ t_CKBOOL Chuck_VM::compute()

//-----------------------------------------------------------------------------
// name: run()
// desc: ...
// desc: run VM and compute the next N frames of audio
// `N` : the number of audio frames to run
// `input`: the incoming input array of audio samples
// `output`: the outgoing output array of audio samples
//-----------------------------------------------------------------------------
t_CKBOOL Chuck_VM::run( t_CKINT N, const SAMPLE * input, SAMPLE * output )
{
Expand Down

0 comments on commit 59bef1d

Please sign in to comment.