bbrrrrrrrrffffffffffffffffffff
FUNCION PRINCIPAL
---------------------------------------------------
#include
#include
#include "Module.h"
/* ESTI YE UNA LLAMADA Q VA EN ARCHIVO APARTE*/
#include "SEMod_struct.h"
#include "SEPin.h"
#define PN_X_IN 0
#define PN_Y_OUT 1
#define PN_FREQ_SCALE 2
#define TWO_PI 6.28318530718f
#define VOLT_PER_OCTAVE 0
#define VOLT_PER_KHZ 1
Module::Module(seaudioMasterCallback seaudioMaster) : SEModule_base(seaudioMaster)
{
}
Module::~Module()
{
}
// main process
void Module::sub_process(long buffer_offset, long sampleFrames )
{
float *x = buffer_offset + x_in;
float *y = buffer_offset + y_out;
float freq;
if( *x != prev_x )
{
prev_x = *x;
if( freq_scale == VOLT_PER_OCTAVE )
freq = 440.0f * (float) ( pow( 2.0f, ( ( *x * 10.0f ) - 5.0f ) ) );
else
freq = *x * 10000.0f; // 1 volt/kHz, 1.0 = 10 SE volts
delta_ramp = TWO_PI * freq * sampleRateRecip;
close_enough = TWO_PI - ( delta_ramp * 0.5f );
}
for( int s = sampleFrames; s > 0; --s )
{
ramp += delta_ramp;
if( ramp >= close_enough ) ramp -= TWO_PI;
*y++ = ( ( (float) sin( ramp ) ) * 0.5f );
}
}
void Module::open()
{
// this macro switches the active processing function
// e.g you may have several versions of your code, optimised for a certain situation
SET_PROCESS_FUNC(Module::sub_process);
SEModule_base::open(); // call the base class
sampleRateRecip = 1.0f / sampleRate;
ramp = 0.f;
prev_x = -20.0f;
getPin(PN_Y_OUT)->TransmitStatusChange( SampleClock(), ST_RUN );
}
// this routine is called whenever an input changes status.
// e.g when the user changes a module's parameters,
// or when audio stops/starts streaming into a pin
void Module::OnPlugStateChange(SEPin *pin)
{
}
// describe the module
bool Module::getModuleProperties (SEModuleProperties* properties)
{
properties->name = "SineOsc"; // this is the name the end-user will see
// return a unique string.
// if posible include manufacturer and plugin identity
// this is used internally by SE to identify the plug. No two plugs may have the same id.
properties->id = "dehauptSineOscV1.0";
// Info, may include Author, Web page whatever
properties->about = "SineOsc module V1.0\n©David Haupt, 2003\nAll Rights Reserved\nwww.dehaupt.com/SynthEdit\ndave@dehaupt.com";
return true;
}
// describe the pins (plugs)
bool Module::getPinProperties (long index, SEPinProperties* properties)
{
switch( index )
{
case PN_X_IN:
properties->name = "Pitch";
properties->variable_address = &x_in;
properties->direction = DR_IN;
properties->datatype = DT_FSAMPLE;
properties->default_value = "1";
break;
case PN_Y_OUT:
properties->name = "Signal Out";
properties->variable_address = &y_out;
properties->direction = DR_OUT;
properties->datatype = DT_FSAMPLE;
properties->default_value = "0";
break;
case PN_FREQ_SCALE:
properties->name = "Freq Scale";
properties->variable_address = &freq_scale;
properties->direction = DR_PARAMETER;
properties->datatype = DT_ENUM;
properties->datatype_extra = "1 Volt/Octave,1 Volt/kHz";
properties->default_value = "0";
break;
default:
return false; // host will ask for plugs 0,1,2,3 etc. return false to signal when done
};
return true;
}
EL ARCHIVO MODULE.H , QUE LLAMA EN LA CABECERA
------------------------------------------------------------------
#if !defined(_SEModule_INCL_)
#define _SEModule_INCL_
#include "SEModule_base.h"
class Module : public SEModule_base
{
public:
Module(seaudioMasterCallback seaudioMaster);
~Module();
virtual bool getModuleProperties (SEModuleProperties* properties);
virtual bool getPinProperties (long index, SEPinProperties* properties);
virtual void sub_process(long buffer_offset, long sampleFrames );
void OnPlugStateChange(SEPin *pin);
virtual void open();
private:
float *x_in; // frequency
short freq_scale;
float *y_out;
float ramp, prev_x, delta_ramp, close_enough;
float sampleRateRecip; // ( 1 / sampleRate )
};
#endif
Brrffffff, ahora preguntarme a cuento de que sale un sonido de todas estas operaciones, NPI

, entre esto y el disco de pizzicato five q estoy escuchando... vaya momento... estoy llegando al nirvana