update 109(beakgu) 5percent exhibition

This commit is contained in:
Dooho Yi 2021-08-24 18:24:21 +09:00
parent d4a217df11
commit b219e19eb4
2 changed files with 39 additions and 32 deletions

View file

@ -57,8 +57,9 @@
//
#define HAVE_CLIENT_I2C
#define DISABLE_AP
#define REPLICATE_NOTE_REQ
#define USE_ALTERNATIVE_ADDRESSES
// #define SERIAL_SWAP
// #define REPLICATE_NOTE_REQ
// #define USE_ALTERNATIVE_ADDRESSES
//============<parameters>============
//
@ -344,33 +345,37 @@ void setup() {
esp_now_register_send_cb(onDataSent);
esp_now_register_recv_cb(onDataReceive);
//
// Serial.println("- ! (esp_now_add_peer) ==> add a 'broadcast peer' (FF:FF:FF:FF:FF:FF).");
// uint8_t broadcastmac[6] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
//
// //
Serial.println("- ! (esp_now_add_peer) ==> add a 'broadcast peer' (FF:FF:FF:FF:FF:FF).");
uint8_t broadcastmac[6] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
// option 1-1)) broadcast to all. for ESP8266
esp_now_add_peer(broadcastmac, ESP_NOW_ROLE_COMBO, 1, NULL, 0);
// // option 1-2)) broadcast to all. for ESP32
// esp_now_peer_info_t peerInfo;
// memcpy(peerInfo.peer_addr, broadcastmac, 6);
// peerInfo.channel = 0;
// peerInfo.encrypt = false;
// esp_now_add_peer(&peerInfo);
#if defined(USE_ALTERNATIVE_ADDRESSES)
AddressBook * book = lib.getBookByTitle("audioooo alt");
#else
AddressBook * book = lib.getBookByTitle("audioooo");
#endif
for (int idx = 0; idx < book->list.size(); idx++) {
Serial.println("- ! (esp_now_add_peer) ==> add a '" + book->list[idx].name + "'.");
#if defined(ESP32)
esp_now_peer_info_t peerInfo;
memcpy(peerInfo.peer_addr, book->list[idx].mac, 6);
peerInfo.channel = 0;
peerInfo.encrypt = false;
esp_now_add_peer(&peerInfo);
#else
esp_now_add_peer(book->list[idx].mac, ESP_NOW_ROLE_COMBO, 1, NULL, 0);
#endif
}
// // option 2)) according to the addressbook.
// #if defined(USE_ALTERNATIVE_ADDRESSES)
// AddressBook * book = lib.getBookByTitle("audioooo alt");
// #else
// AddressBook * book = lib.getBookByTitle("audioooo");
// #endif
// for (int idx = 0; idx < book->list.size(); idx++) {
// Serial.println("- ! (esp_now_add_peer) ==> add a '" + book->list[idx].name + "'.");
// #if defined(ESP32)
// esp_now_peer_info_t peerInfo;
// memcpy(peerInfo.peer_addr, book->list[idx].mac, 6);
// peerInfo.channel = 0;
// peerInfo.encrypt = false;
// esp_now_add_peer(&peerInfo);
// #else
// esp_now_add_peer(book->list[idx].mac, ESP_NOW_ROLE_COMBO, 1, NULL, 0);
// #endif
// }
//
Serial.println("-");
Serial.println("\".-.-.-. :)\"");

View file

@ -16,6 +16,8 @@
#define IDLE_FREQ 22000
#define IDLE_AMP 0 // --> creative muvo 2 doesn't need this. they just stay on!
#define GAIN_MAX 1.0 // if 1.0 is too loud, give max. limit here.
//teensy audio
#include <Audio.h>
// #include <SPI.h>
@ -163,19 +165,19 @@ void receiveEvent(int numBytes) {
int velocity = str_velocity.toInt(); // 0 ~ 127
float amp_gain = (float)velocity / 127.0;
//
amp_gain = amp_gain * 0.3; // 1.0 was too loud. => 0.3 max.
amp_gain = amp_gain * GAIN_MAX;
//
amp1.gain(amp_gain);
amp2.gain(amp_gain);
//
int gate = str_gate.toInt();
if (gate == 0) {
// filter out re-triggering same note while it is playing.
if (!playSdWav1.isPlaying() || sample_now != key) {
sample_now = key;
sample_player_stop_task.restart();
Serial.println("sample_player_stop_task");
}
// filter out re-triggering same note while it is playing. <== ???? WORKS????
// if (!playSdWav1.isPlaying() || sample_now != key) { <== ???? WORKS????
sample_now = key;
sample_player_stop_task.restart();
Serial.println("sample_player_stop_task");
// }
} else {
sample_now = key;
sample_player_start_task.restart();
@ -259,8 +261,8 @@ void setup() {
mixer2.gain(1,1.0);
mixer2.gain(2,0);
mixer2.gain(3,0);
amp1.gain(0.3); // 1.0 was too loud. => 0.3
amp2.gain(0.3);
amp1.gain(GAIN_MAX);
amp2.gain(GAIN_MAX);
//let auto-poweroff speakers stay turned ON!
sine1.frequency(IDLE_FREQ);