00001 #include "afw.h"
00002 #include "ad7998.h"
00003 #include "osc.h"
00004
00005
00006
00007
00008
00009
00010
00011 namespace afw{
00012
00013
00014
00015
00016
00017 const int Hz = (int)(65536.0*65536.0/48000.0);
00018
00019
00020
00021
00022
00023
00024 shortfract * temp;
00025
00026
00027
00028
00029
00030
00031 int * deviation;
00032
00033
00034
00035
00036
00037 shortfract * lfotemp;
00038
00039
00040
00041
00042
00043 osc::COscillator * tone ;
00044
00045
00046
00047
00048
00049 osc::COscillator * lfo ;
00050
00051
00052
00053
00054
00055 void initProcessData(int count)
00056 {
00057 temp = new shortfract[count];
00058 deviation = new int[count];
00059 tone = new osc::CTableLookup( 440*Hz );
00060 lfo = new osc::CTableLookup( 440*Hz );
00061 }
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090 void processData(
00091 const shortfract leftIn[],
00092 const shortfract rightIn[],
00093 shortfract leftOut[],
00094 shortfract rightOut[],
00095 int count
00096 )
00097 {
00098 shortfract gain, freq;
00099
00100 gain = ad7998::getValue(ad7998::Vin1);
00101 freq = ad7998::getValue(ad7998::Vin2);
00102
00103 lfo->setFreq( (freq.v >> 12) * Hz );
00104 lfo->run( lfotemp, count );
00105
00106 for ( int i=0; i<count; i++ ){
00107 deviation[i] = (lfotemp[i]*gain >> (short)8 ).v * Hz;
00108 }
00109
00110 tone->run( temp, deviation, count );
00111 for ( int i=0; i<count; i++ ){
00112 leftOut[i] = temp[i] >> (short)2;
00113 rightOut[i]= temp[i] >> (short)2;
00114 }
00115
00116 }
00117
00118 };
00119
00120