// VLSI 1053 codec chaos music generator II // /* Based Logistic equation Pot0 = chain note A Pot1 = chain note B Pot2 = chain instrument Pot3 = chaos constant Pot4 = tempo/speed 45 - 350 BPM 16th note Channel 1-3 voices Channel 10 drums Created by JLS 2019 */ #include #include #define MAXTEMPO 14 // 350 BPM 16th note #define MINTEMPO 111 // 45 BPM 16th note MIDI_CREATE_DEFAULT_INSTANCE(); float r; float x = 0.2; int xout = 0; int delay_ms = 0; //SCI_MODE register defines #define SM_DIFF 0 #define SM_LAYER12 1 #define SM_RESET 2 #define SM_CANCEL 3 #define SM_EARSPEAKER_LO 4 #define SM_TESTS 5 #define SM_STREAM 6 #define SM_EARSPEAKER_HI 7 #define SM_DACT 8 #define SM_SDIORD 9 #define SM_SDISHARE 10 #define SM_SDINEW 11 #define SM_ADPCM 12 #define SM_ADPCM_HP 13 #define SM_LINE1 14 #define SM_CLK_RANGE 15 void cs_low() { digitalWrite(9, LOW); // CS low delayMicroseconds(250); } void cs_high() { digitalWrite(9, HIGH); // CS high delayMicroseconds(250); } void sci_write(char address, int data) { cs_low(); SPI.transfer(0x02); //send write command SPI.transfer(address); //send address we are going to write to SPI.transfer((data >> 8) & 0xFF); //send the first 8 MSBs of the data SPI.transfer(data & 0xFF); //send the LSBs cs_high(); } void sci_volume (char volleft, char volright) { cs_low(); SPI.transfer(0x02); SPI.transfer(0x0B); SPI.transfer(volleft); SPI.transfer(volright); cs_high(); } void sci_bass (char treble, char bass) { cs_low(); SPI.transfer(0x02); SPI.transfer(0x02); SPI.transfer(treble); SPI.transfer(bass); cs_high(); } void setup() { MIDI.begin (); pinMode (9,OUTPUT); // pin9 = CS SPI.begin(); SPI.setDataMode(SPI_MODE1); SPI.setClockDivider(SPI_CLOCK_DIV2); SPCR = (1<