Stuck in the mud

Well, here’s part of my documentation on this emotive bleep project. I am *trying* to write code that has a vocabulary of bleeps with a few “phrases”…

I tried working out logically… that I need an array of phrases, each of which is an array of sequences. Beyond that, I am stuck, and after hours of circling the drain, I was wondering if one of you guys reading might be able to give me a few hints 🙂

———————————————————————————————————————————

//emotive bleeps

//static values
int speakerPin = 9;
int length = 10; // the number of notes
int tempo = 500;
//tone variables
String phrases[] = {“hi”,”bye”,”yes”,”no”,”alert”,”dying”, “hot” };
char notes[] = “qrstuvwxyz”; // a space represents a rest
int beats[] = {1,1,1,1,1,1,1,1,1,1};

//func to play each tone, regardless of sequence
void playTone(int tone, int duration) {
for (long i = 0; i < duration * 1000L; i += tone * 2) {
digitalWrite(speakerPin, HIGH);
delayMicroseconds(tone);
digitalWrite(speakerPin, LOW);
delayMicroseconds(tone);
}
}
void playPhrase(String phrase){
//get input from keyboard (processing sketch) and interpret that as a “phrase” string
String phrase = ‘bye’;
switch(phrase) {
//each phrase has the same 10 notes, but I am just going to have each phrase have different values for the wavelengths
case’hi’:
char names[] = {‘q’, ‘r’, ‘s’, ‘t’, ‘u’, ‘v’, ‘w’, ‘x’, ‘y’, ‘z’ };
int tones[] = {  0, 600, 1800, 1000, 400, 1000, 0,  0, 500, 3000}; //wavelengths
case’bye’:
char names[] = {‘q’, ‘r’, ‘s’, ‘t’, ‘u’, ‘v’, ‘w’, ‘x’, ‘y’, ‘z’ };
int tones[] = {  400, 800, 800, 0, 0, 0, 0,  0, 2500, 3000}; //wavelengths
default”:
char names[] = {‘q’, ‘r’, ‘s’, ‘t’, ‘u’, ‘v’, ‘w’, ‘x’, ‘y’, ‘z’ };
int tones[] = {  400, 600, 800, 1000, 1200, 1550, 1750,  2000, 2500, 3000}; //wavelengths
break;
}
}

/*
void playNote (char note, int duration){
char names[] = {‘q’, ‘r’, ‘s’, ‘t’, ‘u’, ‘v’, ‘w’, ‘x’, ‘y’, ‘z’ };
int tones[] = {  400, 600, 800, 1000, 1200, 1550, 1750,  2000, 2500, 3000}; //wavelengths
}*/

void setup() {
pinMode(speakerPin, OUTPUT);
}

void loop() {
for (int i = 0; i < length; i++) {
if (notes[i] == ‘ ‘) {
delay(beats[i] * tempo); // rest
} else {
playPhrase(notes[i], beats[i] * tempo);
}

// pause between notes
delay(tempo / 2);
}
}

——————————————————————————————————————————————-