#ifdef WIN32 #include "windows.h" #define DLGCLASS CGainDialog #define GUICLASS gain_gui #include "ospguiatl.h" #endif #define OSP_STD_CHANBUF_SIZE 4 // Support maximum 4 channels #include "osputil.h" #include class gain_dsp : public osp_std_plugin { public: OSP_INFO_BEGIN OSP_RATE_MINMAX(4000,192000) // these sample rates // Supported transforms // SUGGESTED IN/OUT OSP_SUGGEST OSP_TRANSFORM_AUD(1,1) // mono to mono OSP_SUGGEST OSP_TRANSFORM_AUD(2,2) // stereo to stereo OSP_SUGGEST OSP_TRANSFORM_AUD(4,4) // quadro to quadro OSP_INFO_END // Parameters osp_param_volume gain,clip; // Plugin information static const char *getstr(int idx) { static const char *data[]= { // 12345678901234567890 "4front-gain-1", // uniqueid "4Front Gain Adjuster", "1.0a", // name and version "Gain", // short name "4Front", // vendor "http://www.yohng.com/ospi/", // support URL "Adjusts gain of sound, works as volume control", // description // copyrights "Copyright(C)2002 4Front Technologies. All rights reserved." }; return (((unsigned int)idx)>7)?NULL:data[idx]; } // constructor and parameter initialization // // note, that order of initialization should be the same // as the order of declaration. // // this example's GUI has parameter numbers hardcoded, so // changing order of these parameters may result in // unpredictable failures gain_dsp() : gain(this,"Gain",1.0f), // name, default value clip(this,"Clip at",1.0f) { gain.automation(ORDER2); OSP_ALIAS(gain) OSP_ALIAS(clip) // if you ever will want to assign parameter inside filter, // use paramvalue/paramint(param.id, newvalue) or // param.setfloat/setint // // do not use param = value, since that is not going to work // // normally, parameters should be only changed from GUI using // paramvalue and paramint // defaults osp_init_info(); // should be called BEFORE we want to set defaults nports(AUD_IN,2); nports(AUD_OUT,2); rate(44100); } // UNCOMMEND IF NEEDED // // void rateupdated() // { // osp_std_plugin::rateupdated(); // // // TODO: add code when rate is updated? // } // UNCOMMEND IF NEEDED // // void nportsupdated(int type,int n) // { // osp_std_plugin::nportsupdated(type,n); // // // TODO: add code when number of ports changed? // } void reset() { // TODO: add code for resetting plugin } // processing function // // osp_std_plugin::processf() function parses events, splits // audio to blocks (between events) and calls this function // // // NOTE! Due to osp_std_plugin implementation, this function // is REQUIRED to update in[cn]/out[ch] pointers to point // right past the end of the buffer. This example (gain) modifies // pointers correctly. Default implementation of // osp_std_plugin::processBLOCK() updates pointers correctly // as well. void processBLOCK(int64 stamp,float **in, int instep, float **out, int outstep, int sz) { float fgain=gain; // cache param values float fgain_v=gain.velocity, // automation order1 fgain_a=gain.accel; // automation order2 int t,k; int nch=nports(AUD_IN); if (bypass()) // if bypassed, then pass along default implementation { osp_std_plugin::processBLOCK(stamp,in,instep,out,outstep,sz); return; } for(k=0;k