faker 1968
/
Effector_110613
Revision 0:adfbd02222d4, committed 2011-06-13
- Comitter:
- faker
- Date:
- Mon Jun 13 15:20:17 2011 +0000
- Commit message:
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Delay_Unit.cpp Mon Jun 13 15:20:17 2011 +0000 @@ -0,0 +1,34 @@ +/*****************************************************/ +/* Delay_Unit.cpp */ +/* */ +/*****************************************************/ + +#define DELAY_MAIN +#include "Delay_Unit.h" + +#define LIMIT_P (32767) +#define LIMIT_N (-32768) + +int delay(int iEffectIn) { + + int iSignal; + + // Bypass ? + if(g_iDelayBypass == 0)return iEffectIn; + + // Delay + iSignal = (int)g_sDelayBuff[g_usDelayPoint] * g_iDelayFeedBackLevel / 100 + iEffectIn; + + // Output Gain + if (iSignal >= LIMIT_P)iSignal = LIMIT_P; + if (iSignal <= LIMIT_N)iSignal = LIMIT_N; + + g_sDelayBuff[g_usDelayPoint] = iSignal; + + g_usDelayPoint = (g_usDelayPoint + 1) % (MAX_DELAY_POINT * g_iDelayTime / MAX_DELAY_TIME); + + return iSignal; + +} + +#undef DELAY_MAIN \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Delay_Unit.h Mon Jun 13 15:20:17 2011 +0000 @@ -0,0 +1,47 @@ +/*****************************************************/ +/* Delay_Unit.h */ +/* */ +/*****************************************************/ + +#ifndef _DELAY_UNIT_INCLUDE +#define _DELAY_UNIT_INCLUDE + +#undef EXTERN +#ifdef DELAY_MAIN +#define EXTERN +#else +#define EXTERN extern +#endif + +#define MAX_DELAY_TIME (300) // 300msec +#define MAX_DELAY_POINT (MAX_DELAY_TIME * 40) + +// Gloval Valinat + +EXTERN short g_sDelayBuff[MAX_DELAY_POINT]; +EXTERN unsigned short g_usDelayPoint; + +EXTERN int g_iDelayTime +#ifdef DELAY_MAIN + = 150 /* 150msec */ +#endif + ; + +EXTERN int g_iDelayFeedBackLevel +#ifdef DELAY_MAIN + = 50 /* 50% */ +#endif + ; + +EXTERN int g_iDelayBypass +#ifdef DELAY_MAIN + = 1 /* BYPASS */ +#endif + ; + +// Function + +EXTERN int delay(int); + +#undef EXTERN +#endif \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Distotion_Unit.cpp Mon Jun 13 15:20:17 2011 +0000 @@ -0,0 +1,48 @@ +/*****************************************************/ +/* Distotion_Unit.cpp */ +/* */ +/*****************************************************/ + +#define DIST_MAIN +#include "Distotion_Unit.h" + +#define LIMIT_P (32767) +#define LIMIT_N (-32768) + +int distotion(int iEffectIn) { + + int iSignal; + int iClip; + + // Bypass ? + if(g_iDistBypass == 0)return iEffectIn; + + // Input Gain + iSignal = iEffectIn * g_iDistInputGain / 10; + + iClip = 32767 * g_iDistClipLevel / 100; + + // Clip + switch(g_iDistMode){ + case 1: if (iSignal < 0)iSignal *= (-1); + if (iSignal >= iClip)iSignal = iClip; + break; + case 2: if (iSignal >= iClip)iSignal = iClip; + if (iSignal <= -iClip)iSignal = -iClip; + break; + case 3: if (iSignal >= iClip)iSignal = iClip; + if (iSignal <= (-iClip / 2))iSignal = (-iClip / 2); + break; + default:break; + } + + // Output Gain + iSignal = iSignal * g_iDistOutputGain / 10; + if (iSignal >= LIMIT_P)iSignal = LIMIT_P; + if (iSignal <= LIMIT_N)iSignal = LIMIT_N; + + return iSignal; + +} + +#undef DIST_MAIN \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Distotion_Unit.h Mon Jun 13 15:20:17 2011 +0000 @@ -0,0 +1,53 @@ +/*****************************************************/ +/* Distotion_Unit.h */ +/* */ +/*****************************************************/ + +#ifndef _DISTOTIN_UNIT_INCLUDE +#define _DISTOTIN_UNIT_INCLUDE + +#undef EXTERN +#ifdef DIST_MAIN +#define EXTERN +#else +#define EXTERN extern +#endif + +// Gloval Valinat + +EXTERN int g_iDistInputGain +#ifdef DIST_MAIN + = 10 +#endif + ; + +EXTERN int g_iDistClipLevel +#ifdef DIST_MAIN + = 50 +#endif + ; + +EXTERN int g_iDistOutputGain +#ifdef DIST_MAIN + = 10 +#endif + ; + +EXTERN int g_iDistMode +#ifdef DIST_MAIN + = 1 +#endif + ; + +EXTERN int g_iDistBypass +#ifdef DIST_MAIN + = 1 +#endif + ; + +// Function + +EXTERN int distotion(int); + +#undef EXTERN +#endif \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/EffectParam.h Mon Jun 13 15:20:17 2011 +0000 @@ -0,0 +1,73 @@ +/*****************************************************/ +/* EffectParam.h */ +/* */ +/*****************************************************/ + +// MODE (Rotary SW1) +enum{ + MODE_PLAY, + MODE_EDIT, + MODE_PROGWRITE, + + MODE_MAX_NUM +}; + +// PLAY & PrgWrtie MODE - MAX Bank & MAX Prog No. +const int BANK_MAX_NUM = 10; +const int PROGNO_MAX_NUM = 10; + +// EDIT MODE - EFFECT (Rotary SW2) +enum{ + EFFECT_DIST, + EFFECT_DELAY, + + EFFECT_MAX_NUM +}; + +// EDIT MODE - EFFECT_DIST - PARAM (Rotary SW3) +enum{ + DIST_PARAM_BYPASS, + DIST_PARAM_MODE, + DIST_PARAM_INPUTGAIN, + DIST_PARAM_CLIPLEVEL, + DIST_PARAM_OUTPUTGAIN, + + DIST_PARAM_MAX_NUM +}; + +// EDIT MODE - EFFECT_DIST - VALUE (Rotary SW4) +#define DIST_VALUE_BYPASS_MAX (2) +#define DIST_VALUE_MODE_MAX (3) +#define DIST_VALUE_INPUTGAIN_MAX (100) +#define DIST_VALUE_CLIPLEVEL_MAX (100) +#define DIST_VALUE_OUTPUTGAIN_MAX (100) + + +// EDIT MODE - EFFECT_DELAY - PARAM (Rotary SW3) +enum{ + DLY_PARAM_BYPASS, + DLY_PARAM_DELAYTIME, + DLY_PARAM_FBGAIN, + + DLY_PARAM_MAX_NUM +}; + +// EDIT MODE - EFFECT_DELAY - VALUE (Rotary SW4) +#define DLY_VALUE_BYPASS_MAX (2) +#define DLY_VALUE_DELAYTIME_MAX (300) +#define DLY_VALUE_FBGAIN_MAX (100) + + +// Program patch pointer +enum{ + PP_DIST_PARAM_BYPASS, + PP_DIST_PARAM_MODE, + PP_DIST_PARAM_INPUTGAIN, + PP_DIST_PARAM_CLIPLEVEL, + PP_DIST_PARAM_OUTPUTGAIN, + PP_DLY_PARAM_BYPASS, + PP_DLY_PARAM_DELAYTIME, + PP_DLY_PARAM_FBGAIN, + + PP_MAX_NUM +}; \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/R_Sw_Check.cpp Mon Jun 13 15:20:17 2011 +0000 @@ -0,0 +1,69 @@ +/*****************************************************/ +/* Rotary Switch Check.cpp */ +/* */ +/* */ +/*****************************************************/ + +#define SW_CHECK_MAIN +#include "R_Sw_Check.h" + +unsigned char ucRotarySwPol(char swA_0, char swB_0, + char swA_1, char swB_1, + char swA_2, char swB_2, + char swA_3, char swB_3, + int *pol){ + + unsigned char ucRet = 0xFF; + +// Rotary SW0 + *pol = 0; + if((swA_0 == 0) && (g_sw0_0 == 1) && (swB_0 == 1)){ + *pol = -1; + ucRet = 0; + } + if((swA_0 == 1) && (g_sw0_0 == 0) && (swB_0 == 1)){ + *pol = 1; + ucRet = 0; + } + g_sw0_0 = swA_0; + +// Rotary SW1 + *(pol+1) = 0; + if((swA_1 == 0) && (g_sw1_0 == 1) && (swB_1 == 1)){ + *(pol+1) = -1; + ucRet = 1; + } + if((swA_1 == 1) && (g_sw1_0 == 0) && (swB_1 == 1)){ + *(pol+1) = 1; + ucRet = 1; + } + g_sw1_0 = swA_1; + +// Rotary SW2 + *(pol+2) = 0; + if((swA_2 == 0) && (g_sw2_0 == 1) && (swB_2 == 1)){ + *(pol+2) = -1; + ucRet = 2; + } + if((swA_2 == 1) && (g_sw2_0 == 0) && (swB_2 == 1)){ + *(pol+2) = 1; + ucRet = 2; + } + g_sw2_0 = swA_2; + +// Rotary SW3 + *(pol+3) = 0; + if((swA_3 == 0) && (g_sw3_0 == 1) && (swB_3 == 1)){ + *(pol+3) = -1; + ucRet = 3; + } + if((swA_3 == 1) && (g_sw3_0 == 0) && (swB_3 == 1)){ + *(pol+3) = 1; + ucRet = 3; + } + g_sw3_0 = swA_3; + + return ucRet; +} + +#undef SW_CHECK_MAIN \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/R_Sw_Check.h Mon Jun 13 15:20:17 2011 +0000 @@ -0,0 +1,30 @@ +/*****************************************************/ +/* Rotary Switch Check.h */ +/* */ +/* */ +/*****************************************************/ + +#ifndef _SW_CHECK_INCLUDE +#define _SW_CHECK_INCLUDE + +#undef EXTERN +#ifdef SW_CHECK_MAIN +#define EXTERN +#else +#define EXTERN extern +#endif + +// Gloval Valinat + +EXTERN char +#ifdef SW_CHECK_MAIN + g_sw0_0 = 1, g_sw1_0 = 1, g_sw2_0 = 1, g_sw3_0 = 1; +#else + g_sw0_0, g_sw1_0, g_sw2_0, g_sw3_0; +#endif + +// Function + +EXTERN unsigned char ucRotarySwPol(char, char, char, char, char, char, char, char, int*); +#undef EXTERN +#endif \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TextLCD.cpp Mon Jun 13 15:20:17 2011 +0000 @@ -0,0 +1,180 @@ +/* draft mbed TextLCD + * (c) 2007/8, sford + */ + +#include "TextLCD.h" + +#include "mbed.h" + +using namespace mbed; + +/* + * useful info found at http://www.a-netz.de/lcd.en.php + * + * + * Initialisation + * ============== + * + * After attaching the supply voltage/after a reset, the display needs to be brought in to a defined state + * + * - wait approximately 15 ms so the display is ready to execute commands + * - Execute the command 0x30 ("Display Settings") three times (wait 1,64ms after each command, the busy flag cannot be queried now). + * - The display is in 8 bit mode, so if you have only connected 4 data pins you should only transmit the higher nibble of each command. + * - If you want to use the 4 bit mode, now you can execute the command to switch over to this mode now. + * - Execute the "clear display" command + * + * Timing + * ====== + * + * Nearly all commands transmitted to the display need 40us for execution. + * Exceptions are the commands "Clear Display and Reset" and "Set Cursor to Start Position" + * These commands need 1.64ms for execution. These timings are valid for all displays working with an + * internal clock of 250kHz. But I do not know any displays that use other frequencies. Any time you + * can use the busy flag to test if the display is ready to accept the next command. + * + * _e is kept high apart from calling clock + * _rw is kept 0 (write) apart from actions that uyse it differently + * _rs is set by the data/command writes + */ + +TextLCD::TextLCD(PinName rs, PinName rw, PinName e, PinName d0, PinName d1, + PinName d2, PinName d3) : _rw(rw), _rs(rs), + _e(e), _d(d0, d1, d2, d3){ + + _rows = 4; + _columns = 20; + + _rw = 0; + _e = 1; + _rs = 0; // command mode + + // Should theoretically wait 15ms, but most things will be powered up pre-reset + // so i'll disable that for the minute. If implemented, could wait 15ms post reset + // instead + // wait(0.015); + + // send "Display Settings" 3 times (Only top nibble of 0x30 as we've got 4-bit bus) + for(int i=0; i<3; i++) { + writeNibble(0x3); + wait(0.00164); // this command takes 1.64ms, so wait for it + } + writeNibble(0x2); // 4-bit mode + + writeCommand(0x28); // Function set 001 BW N F - - + writeCommand(0x0C); + writeCommand(0x6); // Cursor Direction and Display Shift : 0000 01 CD S (CD 0-left, 1-right S(hift) 0-no, 1-yes + + cls(); +} + +int TextLCD::_putc(int value) { + if(value == '\n') { + newline(); + } else { + writeData(value); + } + return value; +} + +int TextLCD::_getc() { + return 0; +} + +void TextLCD::newline() { + _column = 0; + _row++; + if(_row >= _rows) { + _row = 0; + } + locate(_column, _row); +} + +void TextLCD::locate(int column, int row) { + if(column < 0 || column >= _columns || row < 0 || row >= _rows) { + error("locate(%d,%d) out of range on %dx%d display", column, row, _columns, _rows); + return; + } + + _row = row; + _column = column; + int address=0; + // row 0 : 0x0->0x13 + // row 1 : 0x40->0x53 + // row 2 : 0x14->0x27 + // row 3 : 0x54->0x67 + + switch (_row) { + case (0) : address = 0x00 + _column; + break; + case (1) : address = 0x40 + _column; + break; + case (2) : address = 0x14 + _column; + break; + case (3) : address = 0x54 + _column; + break; + } + + address += 0x80; + +// } +// else { + // memory starts at 0x80, and is 40 chars long per row +// address = 0x80 + (_row * 40) + _column; +// } + + writeCommand(address); +} + + +void TextLCD::rows(int rows) { + _rows = rows; +} + + +void TextLCD::columns(int columns) { + _columns = columns; +} + + + + +void TextLCD::cls() { + writeCommand(0x01); // Clear Display + wait(0.00164f); // This command takes 1.64 ms + locate(0, 0); +} + +void TextLCD::reset() { + cls(); +} + +void TextLCD::clock() { + wait(0.000040f); + _e = 0; + wait(0.000040f); // most instructions take 40us + _e = 1; +} + +void TextLCD::writeNibble(int value) { + _d = value; + clock(); +} + +void TextLCD::writeByte(int value) { + writeNibble(value >> 4); + writeNibble(value >> 0); +} + +void TextLCD::writeCommand(int command) { + _rs = 0; + writeByte(command); +} + +void TextLCD::writeData(int data) { + _rs = 1; + writeByte(data); + _column++; + if(_column >= _columns) { + newline(); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TextLCD.h Mon Jun 13 15:20:17 2011 +0000 @@ -0,0 +1,51 @@ +/* draft mbed TextLCD + * (c) 2007/8, sford + */ + +#ifndef MBED_TEXTLCD_H +#define MBED_TEXTLCD_H + +#include "Stream.h" +#include "DigitalOut.h" +#include "BusOut.h" +#include "mbed.h" + +namespace mbed { + +class TextLCD : public Stream { + +public: + + TextLCD(PinName rs, PinName rw, PinName e, PinName d0, PinName d1, + PinName d2, PinName d3); + + void rows(int rows); + void columns(int columns); + + virtual void locate(int row, int column); + virtual void cls(); + virtual void reset(); + +protected: + + void clock(); + void writeData(int data); + void writeCommand(int command); + void writeByte(int value); + void writeNibble(int value); + virtual int _putc(int c); + virtual int _getc(); + virtual void newline(); + + int _rows; + int _columns; + int _row; + int _column; + DigitalOut _rw, _rs, _e; + BusOut _d; + +}; + +} + +#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Mon Jun 13 15:20:17 2011 +0000 @@ -0,0 +1,566 @@ +/*****************************************************/ +/* MBED MULTI EFFECTOR */ +/* */ +/* */ +/*****************************************************/ + +#include "mbed.h" +#include "EffectParam.h" +#include "TextLCD.h" +#include "R_Sw_Check.h" +#include "Distotion_Unit.h" +#include "Delay_Unit.h" + +//Serial debug(USBTX, USBRX); // tx, rx + +LocalFileSystem local("local"); +Ticker sampling; + +AnalogIn Ain(p17); // Audio Input +AnalogOut Aout(p18); // Audio Output +TextLCD lcd(p24, p25, p26, p27, p28, p29, p30); // rs, rw, e, d0, d1, d2, d3) +DigitalIn Rsw0A(p5); // Rotary SW 0 +DigitalIn Rsw0B(p6); +DigitalIn Rsw1A(p7); // Rotary SW 1 +DigitalIn Rsw1B(p8); +DigitalIn Rsw2A(p9); // Rotary SW 2 +DigitalIn Rsw2B(p10); +DigitalIn Rsw3A(p11); // Rotary SW 3 +DigitalIn Rsw3B(p12); +DigitalOut busyFlag(p13); // Effect Proc Busy Flag + +/*******************************/ +/* For Test Signal */ +/*******************************/ +#define TEST_SIGNAL_ENABLE (0) // 1 : Internal SinWave for Debug +#define TEST_SIGNAL_FREQ (1000.0) // Frequency [Hz] +#define TEST_SIGNAL_AMP (30000.0) // Amplitude +#define PAI (3.14159) + +/*******************************/ +/* For ADC & DAC Setting */ +/*******************************/ +#define SAMPLING_TIME (25.0) // ADC Sampling Rate [us] +volatile unsigned int *g_usiAd0cr, *g_usiAd0dr2; // ADC Reg +unsigned int *g_usiDacr; // DAC Reg + +/*******************************/ +/* Gloval Valinat */ +/*******************************/ +unsigned int g_usiFinalOut; // DAC Out Final Data +int g_ssBuff[10]; // Audio Data Buff +float g_fTestWaveT; // Test Sin Wave Phase +int g_iBankNo = 0; // Parameter Patch Bank No +int g_iProgNo = 0; // Parameter Patch Program No +int g_iFlag = 0; // Pacth Write Flag +int g_iProgPatch[BANK_MAX_NUM][PROGNO_MAX_NUM][PP_MAX_NUM]; // Parameter Data + + +/*******************************/ +/* Function */ +/*******************************/ +int main(void); +void effectProcess(void); // Effect Process Function +void paramCheck(int*, int*); // Paramter Range Check +void param1Change(int*, int*, int*, int*); // Process for Changed Rotary SW1 +void param2Change(int*, int*, int*, int*); // Process for Changed Rotary SW2 +void param3Change(int*, int*, int*, int*); // Process for Changed Rotary SW3 +void param4Change(int*, int*, int*, int*); // Process for Changed Rotary SW4 + +void progWrite(int*); // +void distParamChange(int*, int*); // Change Parameter for Ditotion +void delayParamChange(int*, int*); // Change PArameter for Delay + +void progPatchWite(int); // Paramter Write for Flash ROM +void ProgramPatchChange(int, int); // + +/*******************************/ +/* Effect Process */ +/*******************************/ +void effectProcess() { + busyFlag = 1; + // Line Out + *g_usiDacr = g_usiFinalOut; + // ADC Start + *g_usiAd0cr = 0x01200204; + +#if (TEST_SIGNAL_ENABLE == 1) // Test Signal Sin Wave + g_ssBuff[0] = TEST_SIGNAL_AMP * sin(g_fTestWaveT); + g_fTestWaveT = g_fTestWaveT + 2.0 * PAI * SAMPLING_TIME * TEST_SIGNAL_FREQ / 1e6; + if (g_fTestWaveT >= (2.0 * PAI))g_fTestWaveT = 0; +#endif + + // + // Effect Func + // + + g_ssBuff[1] = distotion(g_ssBuff[0]); // Call Distotion Function + g_ssBuff[2] = delay(g_ssBuff[1]); // CAll Delay Function + + // + // Effect Func + // + +#if (TEST_SIGNAL_ENABLE == 0) + while (1) { + if ((*g_usiAd0dr2 & 0x80000000) != 0)break; // ADC Done ? + } + g_ssBuff[0] = (int)(*g_usiAd0dr2 & 0x0000FFF0) - 32768; +#endif + + g_usiFinalOut = 0x00010000 | (g_ssBuff[2] + 32768); + + busyFlag = 0; +} + + + + +/*******************************/ +/* MAIN */ +/*******************************/ +int main() { + + int i ,j ,k; + int iTemp1, iTemp2; + int iParamSwPol[4]; + int iRsw1Num, iRsw2Num, iRsw3Num, iRsw4Num; + char str1[256], str2[256]; + + iRsw1Num = iRsw2Num = iRsw3Num = iRsw4Num = 0; + + // LCD INIT + lcd.cls(); + lcd.locate(0,0); + lcd.printf("Multi Effector"); + lcd.locate(1,1); + lcd.printf("Mode:"); + param1Change(&iRsw1Num, &iRsw2Num, &iRsw3Num, &iRsw4Num); + + // Program Patch File Open + FILE *fp = fopen("/local/prm.txt", "r"); + if(!fp) { + progPatchWite(1); // No File + }else{ + // Read Patch from File + fgets(str1, 256, fp); + fgets(str2, 256, fp); + for(i=0;i<BANK_MAX_NUM;i++){ + for(j=0;j<PROGNO_MAX_NUM;j++){ + fscanf(fp, "%5d%5d", &iTemp1, &iTemp2); + for(k=0;k<PP_MAX_NUM;k++){ + fscanf(fp, "%5d", &g_iProgPatch[i][j][k]); + } + } + } + fclose(fp); + } + + // ADC & DAC SETTING + g_usiAd0cr = (unsigned int*)0x40034000; + g_usiAd0dr2 = (unsigned int*)0x40034018; + g_usiDacr = (unsigned int*)0x4008C000; + + // SAMPLING TIMER START + sampling.attach_us(&effectProcess, SAMPLING_TIME); + + // Rotary SW State Check + while (1) { + switch (ucRotarySwPol(Rsw0A, Rsw0B, Rsw1A, Rsw1B, Rsw2A, Rsw2B, Rsw3A, Rsw3B, iParamSwPol)) { + case 0: + iRsw1Num += iParamSwPol[0]; + param1Change(&iRsw1Num, &iRsw2Num, &iRsw3Num, &iRsw4Num); + break; + case 1: + iRsw2Num += iParamSwPol[1]; + param2Change(&iRsw1Num, &iRsw2Num, &iRsw3Num, &iRsw4Num); + break; + case 2: + iRsw3Num += iParamSwPol[2]; + param3Change(&iRsw1Num, &iRsw2Num, &iRsw3Num, &iRsw4Num); + break; + case 3: + iRsw4Num += iParamSwPol[3]; + param4Change(&iRsw1Num, &iRsw2Num, &iRsw3Num, &iRsw4Num); + break; + default: + break; + } + } +} + + +/*******************************/ +/* Param Check */ +/*******************************/ +void paramCheck(int* iParam, int iMaxValue) { + + if(*iParam >= iMaxValue)*iParam = 0; + if(*iParam < 0)*iParam = iMaxValue - 1; + +} + + +/*******************************/ +/* Param1 Change */ +/*******************************/ +void param1Change(int* iParam1, int* iParam2, int* iParam3, int* iParam4) { + + paramCheck(iParam1, MODE_MAX_NUM); + + lcd.locate(6,1); + lcd.printf(" "); + lcd.locate(0,2); + lcd.printf(" "); + lcd.locate(0,3); + lcd.printf(" "); + + switch (*iParam1) { + case MODE_PLAY: + lcd.locate(6,1); + lcd.printf("PLAY"); + lcd.locate(2,2); + lcd.printf(" Bank PrgNo"); + *iParam2 = g_iBankNo; + *iParam3 = g_iProgNo; + break; + case MODE_EDIT: + lcd.locate(6,1); + lcd.printf("EDIT"); + lcd.locate(2,2); + lcd.printf("Effct Param Value"); + *iParam2 = *iParam3 = 0; + break; + case MODE_PROGWRITE: + lcd.locate(6,1); + lcd.printf("Prog Write"); + lcd.locate(2,2); + lcd.printf(" Bank PrgNo Write"); + *iParam2 = g_iBankNo; + *iParam3 = g_iProgNo; + break; + default: + break; + } + + param2Change(iParam1, iParam2, iParam3, iParam4); + +} + + +/*******************************/ +/* Param2 Change */ +/*******************************/ +void param2Change(int* iParam1, int* iParam2, int* iParam3, int* iParam4) { + + lcd.locate(0,3); + lcd.printf(" "); + + switch (*iParam1) { + case MODE_PLAY: + paramCheck(iParam2, BANK_MAX_NUM); + g_iBankNo = *iParam2; + *iParam3 = g_iProgNo; + break; + case MODE_EDIT: + paramCheck(iParam2, EFFECT_MAX_NUM); + *iParam3 = 0; + break; + case MODE_PROGWRITE: + paramCheck(iParam2, BANK_MAX_NUM); + g_iBankNo = *iParam2; + *iParam3 = g_iProgNo; + *iParam4 = 0; + g_iFlag = 0; + default: + break; + } + + if ((*iParam1 == MODE_PLAY) || (*iParam1 == MODE_PROGWRITE)) { + lcd.locate(6,3); + lcd.printf("%d",*iParam2); + } + + if (*iParam1 == MODE_EDIT) { + switch (*iParam2) { + case EFFECT_DIST: + lcd.locate(2,3); + lcd.printf(" DIST"); + break; + case EFFECT_DELAY: + lcd.locate(2,3); + lcd.printf("DELAY"); + break; + default: + break; + } + } + + param3Change(iParam1, iParam2, iParam3, iParam4); + +} + + +/*******************************/ +/* Param3 Change */ +/*******************************/ +void param3Change(int* iParam1, int* iParam2, int* iParam3, int* iParam4) { + + lcd.locate(8,3); + lcd.printf(" "); + + switch (*iParam1) { + case MODE_PLAY: + paramCheck(iParam3, PROGNO_MAX_NUM); + g_iProgNo = *iParam3; + break; + case MODE_EDIT: + switch (*iParam2) { + case EFFECT_DIST: + paramCheck(iParam3, DIST_PARAM_MAX_NUM); + switch (*iParam3) { + case DIST_PARAM_BYPASS: *iParam4 = g_iProgPatch[g_iBankNo][g_iProgNo][PP_DIST_PARAM_BYPASS]; + break; + case DIST_PARAM_MODE: *iParam4 = g_iProgPatch[g_iBankNo][g_iProgNo][PP_DIST_PARAM_MODE]; + break; + case DIST_PARAM_INPUTGAIN: *iParam4 = g_iProgPatch[g_iBankNo][g_iProgNo][PP_DIST_PARAM_INPUTGAIN]; + break; + case DIST_PARAM_CLIPLEVEL: *iParam4 = g_iProgPatch[g_iBankNo][g_iProgNo][PP_DIST_PARAM_CLIPLEVEL]; + break; + case DIST_PARAM_OUTPUTGAIN: *iParam4 = g_iProgPatch[g_iBankNo][g_iProgNo][PP_DIST_PARAM_OUTPUTGAIN]; + break; + default: break; + } + distParamChange(iParam3, iParam4); + break; + case EFFECT_DELAY: + paramCheck(iParam3, DLY_PARAM_MAX_NUM); + switch (*iParam3) { + case DLY_PARAM_BYPASS: *iParam4 = g_iProgPatch[g_iBankNo][g_iProgNo][PP_DLY_PARAM_BYPASS]; + break; + case DLY_PARAM_DELAYTIME: *iParam4 = g_iProgPatch[g_iBankNo][g_iProgNo][PP_DLY_PARAM_DELAYTIME]; + break; + case DLY_PARAM_FBGAIN: *iParam4 = g_iProgPatch[g_iBankNo][g_iProgNo][PP_DLY_PARAM_FBGAIN]; + break; + default: break; + } + delayParamChange(iParam3, iParam4); + break; + default: + break; + } + break; + case MODE_PROGWRITE: + paramCheck(iParam3, PROGNO_MAX_NUM); + g_iProgNo = *iParam3; + *iParam4 = 0; + g_iFlag = 0; + progWrite(iParam4); + break; + default: + break; + } + + if ((*iParam1 == MODE_PLAY) || (*iParam1 == MODE_PROGWRITE)) { + lcd.locate(12,3); + lcd.printf("%d",*iParam3); + } + +} + + +/*******************************/ +/* Param4 Change */ +/*******************************/ +void param4Change(int* iParam1, int* iParam2, int* iParam3, int* iParam4) { + + lcd.locate(14,3); + lcd.printf(" "); + + switch (*iParam1) { + case MODE_EDIT: + switch (*iParam2) { + case EFFECT_DIST: + distParamChange(iParam3, iParam4); + break; + case EFFECT_DELAY: + delayParamChange(iParam3, iParam4); + break; + default: + break; + } + break; + case MODE_PROGWRITE: + progWrite(iParam4); + break; + default: + break; + } + +} + + +/*******************************/ +/* Distotion Param Change */ +/*******************************/ +void distParamChange(int* iParam3, int* iParam4) { + + lcd.locate(8,3); + lcd.printf(" "); + lcd.locate(8,3); + + switch (*iParam3) { + case DIST_PARAM_BYPASS: + paramCheck(iParam4, DIST_VALUE_BYPASS_MAX); + g_iDistBypass = *iParam4; + //g_iProgPatch[g_iBankNo][g_iProgNo][PP_DIST_PARAM_BYPASS] = *iParam4; + if(g_iDistBypass == 0){ + lcd.printf("BYPSS OFF"); + }else{ + lcd.printf("BYPSS ON"); + } + break; + case DIST_PARAM_MODE: + paramCheck(iParam4, DIST_VALUE_MODE_MAX); + g_iDistMode = *iParam4; + //g_iProgPatch[g_iBankNo][g_iProgNo][PP_DIST_PARAM_MODE] = *iParam4; + lcd.printf(" MODE %d", *iParam4); + break; + case DIST_PARAM_INPUTGAIN: + paramCheck(iParam4, DIST_VALUE_INPUTGAIN_MAX); + g_iDistInputGain = *iParam4; + //g_iProgPatch[g_iBankNo][g_iProgNo][PP_DIST_PARAM_INPUTGAIN] = *iParam4; + lcd.printf("INP.G %d", *iParam4); + break; + case DIST_PARAM_CLIPLEVEL: + paramCheck(iParam4, DIST_VALUE_CLIPLEVEL_MAX); + g_iDistClipLevel = *iParam4; + //g_iProgPatch[g_iBankNo][g_iProgNo][PP_DIST_PARAM_CLIPLEVEL] = *iParam4; + lcd.printf("CLP.L %d", *iParam4); + break; + case DIST_PARAM_OUTPUTGAIN: + paramCheck(iParam4, DIST_VALUE_OUTPUTGAIN_MAX); + g_iDistOutputGain = *iParam4; + //g_iProgPatch[g_iBankNo][g_iProgNo][PP_DIST_PARAM_OUTPUTGAIN] = *iParam4; + lcd.printf("OUT.G %d", *iParam4); + break; + default: + break; + + } +} + +/*******************************/ +/* Delay Param Change */ +/*******************************/ +void delayParamChange(int* iParam3, int* iParam4) { + + lcd.locate(8,3); + lcd.printf(" "); + lcd.locate(8,3); + + switch (*iParam3) { + case DLY_PARAM_BYPASS: + paramCheck(iParam4, DLY_VALUE_BYPASS_MAX); + g_iDelayBypass = *iParam4; + //g_iProgPatch[g_iBankNo][g_iProgNo][PP_DLY_PARAM_BYPASS] = *iParam4; + if(g_iDelayBypass == 0){ + lcd.printf("BYPSS OFF"); + }else{ + lcd.printf("BYPSS ON"); + } + break; + case DLY_PARAM_DELAYTIME: + paramCheck(iParam4, DLY_VALUE_DELAYTIME_MAX); + g_iDelayTime = *iParam4; + //g_iProgPatch[g_iBankNo][g_iProgNo][PP_DLY_PARAM_DELAYTIME] = *iParam4; + lcd.printf("DLY.T %d", *iParam4); + break; + case DLY_PARAM_FBGAIN: + paramCheck(iParam4, DLY_VALUE_FBGAIN_MAX); + g_iDelayFeedBackLevel = *iParam4; + //g_iProgPatch[g_iBankNo][g_iProgNo][PP_DLY_PARAM_FBGAIN] = *iParam4; + lcd.printf(" FB.G %d", *iParam4); + break; + default: + break; + + } +} + +/*******************************/ +/* Program Patch Write */ +/*******************************/ +void progWrite(int* param){ + + if(g_iFlag == 0){ + if((*param > 24) || (*param < -24)){ + lcd.locate(14,3); + lcd.printf(" Done"); + ProgramPatchChange(g_iBankNo, g_iProgNo); + progPatchWite(0); + g_iFlag = 1; + }else{ + lcd.locate(14,3); + lcd.printf("Unexe"); + } + }else{ + lcd.locate(14,3); + lcd.printf(" Done"); + } +} + + +/*******************************/ +/* Program Patch Wite */ +/*******************************/ +void progPatchWite(int iFlag){ + + int i, j, k; + + FILE *fp = fopen("/local/prm.txt", "w"); + if(!fp) { + while(1){ + lcd.cls(); + wait(0.5); + lcd.locate(1,1); + lcd.printf("SYSTEM ERROR #2000"); + wait(0.5); + } + } + + fprintf(fp, " BANK PROG ---- DISTOTION --- ----- DELAY ------\n"); + fprintf(fp, " BYP MODE ING C.Lv OUTG BYP TIME FB\n"); + for(i=0;i<BANK_MAX_NUM;i++){ + for(j=0;j<PROGNO_MAX_NUM;j++){ + if(iFlag == 1)ProgramPatchChange(i, j); + fprintf(fp, "%5d%5d", i, j); + for(k=0;k<PP_MAX_NUM;k++){ + fprintf(fp, "%5d\0", g_iProgPatch[i][j][k]); + } + fprintf(fp, "\n"); + } + } + + fclose(fp); +} + + +/*******************************/ +/* Program Patch Chanege */ +/*******************************/ +void ProgramPatchChange(int iBank, int iProg){ + + // Distotion Param + g_iProgPatch[iBank][iProg][PP_DIST_PARAM_BYPASS] = g_iDistBypass; + g_iProgPatch[iBank][iProg][PP_DIST_PARAM_MODE] = g_iDistMode; + g_iProgPatch[iBank][iProg][PP_DIST_PARAM_INPUTGAIN] = g_iDistInputGain; + g_iProgPatch[iBank][iProg][PP_DIST_PARAM_CLIPLEVEL] = g_iDistClipLevel; + g_iProgPatch[iBank][iProg][PP_DIST_PARAM_OUTPUTGAIN] = g_iDistOutputGain; + + // Delay Param + g_iProgPatch[iBank][iProg][PP_DLY_PARAM_BYPASS] = g_iDelayBypass; + g_iProgPatch[iBank][iProg][PP_DLY_PARAM_DELAYTIME] = g_iDelayTime; + g_iProgPatch[iBank][iProg][PP_DLY_PARAM_FBGAIN] = g_iDelayFeedBackLevel; + +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Mon Jun 13 15:20:17 2011 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/e2ac27c8e93e