Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 82 additions & 6 deletions src/core/ugen_xxx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,16 @@ DLL_QUERY xxx_query( Chuck_DL_Query * QUERY )
func->add_arg( "float", "gain" );
if( !type_engine_import_mfun( env, func ) ) goto error;

// set gain in dB rather than linearly
func = make_new_mfun( "float", "db", gain_set_db );
func->add_arg( "float", "db" );
func->doc = "Set gain (in dB)";
if( !type_engine_import_mfun( env, func ) ) goto error;

func = make_new_mfun( "float", "db", gain_get_db );
func->doc = "Get gain (in dB)";
if( !type_engine_import_mfun( env, func ) ) goto error;

// end import
if( !type_engine_import_class_end( env ) )
return FALSE;
Expand All @@ -390,6 +400,21 @@ DLL_QUERY xxx_query( Chuck_DL_Query * QUERY )
while( true ) { 100::ms => now; }
*/

//! GainDB
doc = "The same as the Gain UGen, but the constructor sets the gain in deciBels rather than linear scaling.";
if( !type_engine_import_ugen_begin( env, "GainDB", "Gain", env->global(),
NULL, NULL, NULL, NULL, doc.c_str() ) )
return FALSE;

func = make_new_ctor( gainDB_ctor );
func->doc = "construct a GainDB with default value (in deciBels).";
func->add_arg( "float", "db" );
if( !type_engine_import_ctor( env, func ) ) goto error;

// end import
if( !type_engine_import_class_end( env ) )
return FALSE;

//! \section wave forms

// add noise
Expand Down Expand Up @@ -1366,16 +1391,16 @@ DLL_QUERY lisa_query( Chuck_DL_Query * QUERY )
func->doc = "For particular voice (arg 1), get panning value.";
func->add_arg( "int", "voice" );
if( !type_engine_import_mfun( env, func ) ) goto error;
func = make_new_mfun( "float", "pan", LiSaMulti_ctrl_voicepan0 );

func = make_new_mfun( "float", "pan", LiSaMulti_ctrl_voicepan0 );
func->doc = "For voice 0, set panning value [0.0, number of channels - 1.0].";
func->add_arg( "float", "val" );
if( !type_engine_import_mfun( env, func ) ) goto error;

func = make_new_mfun( "float", "pan", LiSaMulti_cget_voicepan0);
func->doc = "For voice 0, get panning value.";
if( !type_engine_import_mfun( env, func ) ) goto error;
if( !type_engine_import_mfun( env, func ) ) goto error;

// set record feedback coefficient
func = make_new_mfun( "float", "feedback", LiSaMulti_ctrl_coeff );
func->doc = "Set feedback amount when overdubbing (loop recording; how much to retain).";
Expand Down Expand Up @@ -1994,6 +2019,57 @@ CK_DLL_MFUN( gain_ctor_1 )



//-----------------------------------------------------------------------------
// name: Gain.db( float db )
// desc: Set Gain gain (in dB)
//-----------------------------------------------------------------------------
CK_DLL_MFUN( gain_set_db )
{
// get ugen
Chuck_UGen * ugen = (Chuck_UGen *)SELF;
// set from constructor arg
t_CKFLOAT gain = GET_NEXT_FLOAT(ARGS);
ugen->m_gain = pow(10.0, gain / 20.0); // dB power scaling

RETURN->v_float = gain;
}




//-----------------------------------------------------------------------------
// name: Gain.gain()
// desc: Get Gain gain (in dB)
//-----------------------------------------------------------------------------
CK_DLL_MFUN( gain_get_db )
{
// get ugen
Chuck_UGen * ugen = (Chuck_UGen *)SELF;
// set from constructor arg
t_CKFLOAT dB = 20 * log10(ugen->m_gain); // dB power scaling

RETURN->v_float = dB;
}




//-----------------------------------------------------------------------------
// name: GainDB( float gain )
// desc: GainDB constructor that takes a dB float
//-----------------------------------------------------------------------------
CK_DLL_CTOR( gainDB_ctor )
{
// get ugen
Chuck_UGen * ugen = (Chuck_UGen *)SELF;
// set from constructor arg
t_CKFLOAT gain = GET_NEXT_FLOAT(ARGS);
ugen->m_gain = pow(10.0, gain / 20.0); // dB power scaling
}




//-----------------------------------------------------------------------------
// name: pan2_ctor()
// desc: ...
Expand Down Expand Up @@ -2065,7 +2141,7 @@ class CNoise_Data
}
// CK_FPRINTF_STDERR( "random bits - %d", rand_bits );
setMode ( "pink" );
}
}
~CNoise_Data() {
// 1.5.0.1 (anthonyhawes) added
CK_SAFE_FREE( pink_array );
Expand Down Expand Up @@ -3592,7 +3668,7 @@ CK_DLL_CTRL( sndbuf_ctrl_read )

// log
EM_log( CK_LOG_INFO, "(sndbuf): reading '%s'...", filename );

// copy in the chunks size | 1.5.0.0 (ge)
d->chunks = d->chunks_on_next_load;

Expand Down
5 changes: 5 additions & 0 deletions src/core/ugen_xxx.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ CK_DLL_CGET( mix2_cget_value );
// Gain
CK_DLL_MFUN( gain_ctor_1 );

// GainDB
CK_DLL_CTOR( gainDB_ctor );
CK_DLL_MFUN( gain_set_db );
CK_DLL_MFUN( gain_get_db );

// noise
CK_DLL_TICK( noise_tick );

Expand Down
Loading