update @sampler/@postman
This commit is contained in:
parent
5816f4d62a
commit
3f63314172
3 changed files with 30 additions and 58 deletions
|
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
//============<identities>============
|
//============<identities>============
|
||||||
//
|
//
|
||||||
#define MY_GROUP_ID (5000)
|
#define MY_GROUP_ID (10000)
|
||||||
#define MY_ID (MY_GROUP_ID + 1)
|
#define MY_ID (MY_GROUP_ID + 1)
|
||||||
#define MY_SIGN ("@POSTMAN|@SAMPLER")
|
#define MY_SIGN ("@POSTMAN|@SAMPLER")
|
||||||
//
|
//
|
||||||
|
|
|
||||||
|
|
@ -12,14 +12,6 @@
|
||||||
// (part-3) teensy35 : 'client:sampler' (mesh post --> play sounds)
|
// (part-3) teensy35 : 'client:sampler' (mesh post --> play sounds)
|
||||||
//
|
//
|
||||||
|
|
||||||
//============<sampler>============
|
|
||||||
//optionally pin3 will go HIGH/LOW in sync w/ sound PLAY/STOP
|
|
||||||
#define MOTOR_PIN 3
|
|
||||||
// #define FAN_ACTION // this is noisy.... ==> not so recommendable..
|
|
||||||
#define NOTE_MIN 24
|
|
||||||
#define NOTE_MAX 84
|
|
||||||
//============</sampler>===========
|
|
||||||
|
|
||||||
//HACK: let auto-poweroff speakers stay turned ON! - (creative muvo mini)
|
//HACK: let auto-poweroff speakers stay turned ON! - (creative muvo mini)
|
||||||
#define IDLE_FREQ 22000
|
#define IDLE_FREQ 22000
|
||||||
#define IDLE_AMP 0 // --> creative muvo 2 doesn't need this. they just stay on!
|
#define IDLE_AMP 0 // --> creative muvo 2 doesn't need this. they just stay on!
|
||||||
|
|
@ -32,11 +24,6 @@
|
||||||
SdFatSdioEX SD;
|
SdFatSdioEX SD;
|
||||||
#include <SerialFlash.h>
|
#include <SerialFlash.h>
|
||||||
|
|
||||||
//teensy 3.5 with SD card
|
|
||||||
#define SDCARD_CS_PIN BUILTIN_SDCARD
|
|
||||||
#define SDCARD_MOSI_PIN 11 // not actually used
|
|
||||||
#define SDCARD_SCK_PIN 13 // not actually used
|
|
||||||
|
|
||||||
// GUItool: begin automatically generated code
|
// GUItool: begin automatically generated code
|
||||||
AudioPlaySdWav playSdWav1; //xy=224,265
|
AudioPlaySdWav playSdWav1; //xy=224,265
|
||||||
AudioSynthWaveformSine sine1; //xy=236,361
|
AudioSynthWaveformSine sine1; //xy=236,361
|
||||||
|
|
@ -81,14 +68,7 @@ void sample_player_start()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//start the player!
|
//start the player!
|
||||||
//NOTE: block out 're-triggering'
|
|
||||||
// if (playSdWav1.isPlaying() == false) {
|
|
||||||
playSdWav1.play(filename);
|
playSdWav1.play(filename);
|
||||||
// }
|
|
||||||
#if defined(FAN_ACTION)
|
|
||||||
//fan action
|
|
||||||
digitalWrite(MOTOR_PIN, HIGH);
|
|
||||||
#endif
|
|
||||||
//mark the indicator : HIGH: ON
|
//mark the indicator : HIGH: ON
|
||||||
digitalWrite(13, HIGH);
|
digitalWrite(13, HIGH);
|
||||||
//to wait a bit for updating isPlaying()
|
//to wait a bit for updating isPlaying()
|
||||||
|
|
@ -116,10 +96,6 @@ void sample_player_stop() {
|
||||||
//stop the player.
|
//stop the player.
|
||||||
if (playSdWav1.isPlaying() == true) {
|
if (playSdWav1.isPlaying() == true) {
|
||||||
playSdWav1.stop();
|
playSdWav1.stop();
|
||||||
#if defined(FAN_ACTION)
|
|
||||||
//fan stop
|
|
||||||
digitalWrite(MOTOR_PIN, LOW);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void sample_player_check() {
|
void sample_player_check() {
|
||||||
|
|
@ -135,8 +111,8 @@ void sample_player_check() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
Task sample_player_start_task(0, TASK_ONCE, sample_player_start);
|
Task sample_player_start_task(0, TASK_ONCE, sample_player_start, &runner, false);
|
||||||
Task sample_player_stop_task(0, TASK_ONCE, sample_player_stop);
|
Task sample_player_stop_task(0, TASK_ONCE, sample_player_stop, &runner, false);
|
||||||
Task sample_player_check_task(0, TASK_FOREVER, sample_player_check, &runner, true);
|
Task sample_player_check_task(0, TASK_FOREVER, sample_player_check, &runner, true);
|
||||||
|
|
||||||
//i2c
|
//i2c
|
||||||
|
|
@ -183,22 +159,23 @@ void receiveEvent(int numBytes) {
|
||||||
|
|
||||||
//
|
//
|
||||||
int key = str_key.toInt();
|
int key = str_key.toInt();
|
||||||
if (key >= NOTE_MIN && key <= NOTE_MAX) {
|
sample_now = key;
|
||||||
sample_now = key;
|
//
|
||||||
//
|
int velocity = str_velocity.toInt(); // 0 ~ 127
|
||||||
int velocity = str_velocity.toInt(); // 0 ~ 127
|
float amp_gain = (float)velocity / 127.0;
|
||||||
float amp_gain = (float)velocity / 127.0;
|
//
|
||||||
amp1.gain(amp_gain);
|
amp_gain = amp_gain * 0.7; // additional amp down. * 70%
|
||||||
amp2.gain(amp_gain);
|
//
|
||||||
//
|
amp1.gain(amp_gain);
|
||||||
int gate = str_gate.toInt();
|
amp2.gain(amp_gain);
|
||||||
if (gate == 0) {
|
//
|
||||||
sample_player_stop_task.restart();
|
int gate = str_gate.toInt();
|
||||||
Serial.println("sample_player_stop_task");
|
if (gate == 0) {
|
||||||
} else {
|
sample_player_stop_task.restart();
|
||||||
sample_player_start_task.restart();
|
Serial.println("sample_player_stop_task");
|
||||||
Serial.println("sample_player_start_task");
|
} else {
|
||||||
}
|
sample_player_start_task.restart();
|
||||||
|
Serial.println("sample_player_start_task");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -242,13 +219,7 @@ void setup() {
|
||||||
// w/o ==> get killed by watchdog.. :(
|
// w/o ==> get killed by watchdog.. :(
|
||||||
//
|
//
|
||||||
// while (!Serial) {}
|
// while (!Serial) {}
|
||||||
// --> use this.. to capture start-up messages, properly. very handy.
|
// --> enable this.. to use Serial. otherwise, very jerky/unstable..
|
||||||
|
|
||||||
//motor
|
|
||||||
#if defined(FAN_ACTION)
|
|
||||||
pinMode(MOTOR_PIN, OUTPUT);
|
|
||||||
digitalWrite(MOTOR_PIN, LOW);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//i2c
|
//i2c
|
||||||
Wire.begin(I2C_ADDR);
|
Wire.begin(I2C_ADDR);
|
||||||
|
|
@ -269,10 +240,13 @@ void setup() {
|
||||||
|
|
||||||
//audio
|
//audio
|
||||||
AudioMemory(20);
|
AudioMemory(20);
|
||||||
#if !defined(TEENSY36)
|
|
||||||
//NOTE!! teensy36 board.. output broken? .. so disable this for teensy36.. this is the cause??
|
// dacs1.analogReference(EXTERNAL);
|
||||||
dacs1.analogReference(EXTERNAL);
|
// <-- this was used probably to make output swing greater Vpp == 3.3v
|
||||||
#endif
|
// but, with this + small headphones, i cannot hear anything.
|
||||||
|
// and, this might be dangerous in some case -> this is suspicous of 1 broken teensy 3.6
|
||||||
|
// so, unless you are so sure, don't enable this.
|
||||||
|
|
||||||
mixer1.gain(0,1.0);
|
mixer1.gain(0,1.0);
|
||||||
mixer1.gain(1,1.0);
|
mixer1.gain(1,1.0);
|
||||||
mixer1.gain(2,0);
|
mixer1.gain(2,0);
|
||||||
|
|
@ -291,10 +265,6 @@ void setup() {
|
||||||
pinMode(13, OUTPUT);
|
pinMode(13, OUTPUT);
|
||||||
digitalWrite(13, LOW); // LOW: OFF
|
digitalWrite(13, LOW); // LOW: OFF
|
||||||
|
|
||||||
//player task
|
|
||||||
runner.addTask(sample_player_start_task);
|
|
||||||
runner.addTask(sample_player_stop_task);
|
|
||||||
|
|
||||||
//
|
//
|
||||||
Serial.println("[setup] done.");
|
Serial.println("[setup] done.");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
2
post.h
2
post.h
|
|
@ -117,6 +117,8 @@ struct AddressLibrary {
|
||||||
book.add(Address(0xAC, 0x67, 0xB2, 0x0B, 0xAD, 0xB0, "audioooo #2")); //WROOM
|
book.add(Address(0xAC, 0x67, 0xB2, 0x0B, 0xAD, 0xB0, "audioooo #2")); //WROOM
|
||||||
book.add(Address(0xA8, 0x03, 0x2A, 0x6C, 0x88, 0x78, "audioooo #3")); //WROVER
|
book.add(Address(0xA8, 0x03, 0x2A, 0x6C, 0x88, 0x78, "audioooo #3")); //WROVER
|
||||||
//
|
//
|
||||||
|
book.add(Address(0x98, 0xF4, 0xAB, 0xB3, 0xB4, 0xDD, "sampler #1")); //TEENSY+ESP8266
|
||||||
|
//
|
||||||
lib.push_back(book);
|
lib.push_back(book);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue