/**
* Generates a random progression and attempts to voice it
*/
public synchronized void generateAndVoiceProgression() {
SymbolList progression = new SymbolList();
ArrayList<String> identifiers = new ArrayList<String>();
//add the root as the last chord
identifiers.add("I");
//add the dominant as the second to last
identifiers.add("7V");
//get the current vertex (for the cadence)
Vertex currentVertex = graph.getVertex("7V");
for (int i = 0; i < 9; i++) {
//get the adjacent edges to the current vertex
LinkedList<Edge> currentEdges = currentVertex.getAdjacent();
int numToChoose = currentEdges.size();
int randomNumber = (int) (Math.random() * numToChoose + 0);
//get a random edge
Edge randomEdge = currentEdges.get(randomNumber);
//get the destination of the random edge
currentVertex = randomEdge.getDestination();
String identifier = currentVertex.getName();
identifiers.add(identifier);
//returnVector.add(current.name);
}
//create a progression using the given identifiers
for (int i = identifiers.size() - 1; i >= 0; i--) {
//get the symbol for the current identifier
String id = identifiers.get(i);
Symbol symbol = availableSymbols.getSymbolByIdentifier(id);
//add this symbol to the current progression
progression.add(symbol);
}
//pass this progression to be voiced
this.voiceProgression(progression);