|
Post by saltatempo on Mar 23, 2024 13:53:14 GMT
Hi people I'm not sure about the analog pins used in this sketch...
A2 for POT1 A1 for POT2 A0 for POT3?
I'm beginner in writing code and there isn't "analogRead(A0)" in the code!
Thanks for helping.
|
|
|
Post by duddex on Mar 28, 2024 13:10:38 GMT
The BYTEBEAT-XFADE does not use analogRead(). The values of the potentiometers are read in the "ISR(TIMER2_OVF_vect)" function and stored in in1_pot1, in1_pot2, in3 and pot3. #define in1_pot1 gp->cv[2] #define in2_pot2 gp->cv[1] #define in3 gp->cv[3] #define pot3 gp->cv[0] Unfortunately I am not able to explain more details because I don't understand them (yet). I found this page: garretlab.web.fc2.com/en/arduino/inside/hardware/arduino/avr/cores/arduino/wiring_analog.c/analogRead.htmlBut I still don't understand all the details (yet).
|
|
|
Post by duddex on Mar 28, 2024 13:24:09 GMT
The "classic" (I don't know a better name) GRAINS modules use the class class GrainsIO. In theory the only difference between these classic GRAINS modules is the actual implementation of the audio processing in the "process" method
// Main processing "callback" - this is were all user-code for this framework should go if possible. static void GrainsIO::process(); I have never used this class. But I also have never written a GRAINS module which processes audio
|
|
|
Post by saltatempo on Mar 28, 2024 21:29:29 GMT
Hi, from your link int analogRead(uint8_t pin) { if (pin >= 14) pin -= 14; // allow for channel or pin numbers // set the analog reference (high two bits of ADMUX) and select the // channel (low 4 bits). this also sets ADLAR (left-adjust result) // to 0 (the default). ADMUX = (analog_reference << 6) | (pin & 0x07); // without a delay, we seem to read from the wrong channel //delay(1); // start the conversion sbi(ADCSRA, ADSC); // ADSC is cleared when the conversion finishes while (bit_is_set(ADCSRA, ADSC)); // ADC macro takes care of reading ADC register. // avr-gcc implements the proper reading order: ADCL is read first. return ADC; } compared with this part of bytebeatxfade sketch ISR(TIMER2_OVF_vect) { gp->div32 = !gp->div32; // divide timer2 frequency / 2 to 31.25kHz if(gp->div32) { gp->div16 = !gp->div16; // sample channel 0-3 (CV) and 4 (audio) alternately so each channel is sampled with 15.6kHz if(gp->div16) // Get CV-data now { gp->pot_cv=ADCH; // Store CV data detected for main-loop (will be processed with next sample from audio-in) cbi(ADMUX,MUX0); // Clear all CVs... cbi(ADMUX,MUX1); // ...on input-multiplexer sbi(ADMUX,MUX2); // set multiplexer to channel 4 for audio } else // Get audio-data in this round { gp->cv[gp->pot_selector] = gp->pot_cv; // store CV-data selected in last round for main loop gp->audio_data=ADCH; // get ADC channel 4 cbi(ADMUX,MUX2); // disable analogue input on channel 4 gp->pot_selector++; // select next Pot or CV input if(gp->pot_selector > 3 ) // Round-robin one of 4 possible CVs/pots gp->pot_selector = 0; ADMUX |= gp->pot_selector; // Set current CV or Pot selected for non-audio input (round-robin)
gp->new_sample=true; // We selected audio and CV data now in interupt to be processed in next main loop } sbi(ADCSRA,ADSC); // ADC start conversion once, will be reset by the Atmega8, we have to set it each round... } } I start understand, more or less, how the ATmega "take a measure" from its analog inputs. Thanks Here also section 23 from ATmega datasheet
|
|
|
Post by saltatempo on Apr 1, 2024 20:52:36 GMT
|
|