switching the frequency between 440 and 880 every second
This commit is contained in:
@ -10,6 +10,9 @@ I2S i2s(OUTPUT);
|
|||||||
#define BLOCKSIZE 64 // Heavy block size
|
#define BLOCKSIZE 64 // Heavy block size
|
||||||
#define BUFFERSIZE (2 * BLOCKSIZE) // Stereo interleaved
|
#define BUFFERSIZE (2 * BLOCKSIZE) // Stereo interleaved
|
||||||
|
|
||||||
|
bool state;
|
||||||
|
int delta;
|
||||||
|
|
||||||
int16_t buffer[BUFFERSIZE];
|
int16_t buffer[BUFFERSIZE];
|
||||||
|
|
||||||
inline int16_t float_to_i16(float x) {
|
inline int16_t float_to_i16(float x) {
|
||||||
@ -75,5 +78,12 @@ void setup() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
|
if (millis() - delta > 1000) {
|
||||||
|
int freq;
|
||||||
|
if (state) freq = 440;
|
||||||
|
else freq = 880;
|
||||||
|
hv->sendFloatToReceiver(hv_string_to_hash("osc_freq_input"), freq);
|
||||||
|
state = !state;
|
||||||
|
delta = millis();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user