OSCtoCV Library
Diff: OSCtoCV.h
- Revision:
- 4:fe335dc8d53d
- Parent:
- 1:981b62bb5c87
--- a/OSCtoCV.h Sun Jan 31 12:55:17 2016 +0000 +++ b/OSCtoCV.h Tue Feb 16 11:31:12 2016 +0000 @@ -34,7 +34,7 @@ #define SETUP_INTERNAL_REF 0x08 #define SPI_RATE 20000000 // 20Mbps SPI Clock -#define POLLING_INTERVAL 22 // Polling Interval (us) +#define POLLING_INTERVAL 19 // Polling Interval (us) //------------------------------------------------------------- // OSCtoCV Converter Macros @@ -49,9 +49,9 @@ #define S5th 7 // 5th #define Wht 8 // Wholetone -#define SCALE_NUM 9 // Scales total +#define SCALE_TOTAL 9 // Scales total -#define SCALE_AOUT (65535 / SCALE_NUM - 1) +#define SCALE_AOUT (65535 / SCALE_TOTAL - 1) #define QUAN_RES1 116 // Quantize voltage Steps #define QUAN_RES2 68 @@ -67,7 +67,7 @@ //------------------------------------------------------------- // Ethernet Setting -#define DHCP // address assigned by DHCP +#define DHCP // address assigned by DHCP #define INPUT_PORT 12345 // Input Port Number #define TOSC_PORT 9000 // touchOSC Port Number @@ -321,6 +321,23 @@ return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min; } +// Check current quantize scale +extern inline uint8_t CheckQuantizeMode(void) +{ + static uint8_t _qmode; + uint8_t qmode; + + qmode = gCtrl[1] * (SCALE_TOTAL - 1); // Sequencer Quantize Mode (gCtrl[1]) + + if (_qmode != qmode) + { + gAOUT.write_u16(SCALE_AOUT * qmode); // write Analog out for send current scale + _qmode = qmode; + } + + return qmode; +} + // Fast strlen function http://www.strchr.com/optimized_strlen_function extern inline size_t strlength(const char *s) {