// Returns true if adding the node was successful // Returns false if the Note in the NoteNode being added is already connected public bool AddConnection(NoteNode note, double weight) { if (!IsConnected(note.GetNote())) { connections[NoteUtil.NoteHash(note.GetNote())] = new Edge(note, weight); return(true); } return(false); }
public NoteGraph() { double initial_weight = 1.00 / 22.00; for (int i = 0; i < NoteUtil.NOTE_COUNT; ++i) { nodes[i] = new NoteNode(NoteUtil.GetNoteAtIndex(i)); } for (int i = 0; i < NoteUtil.NOTE_COUNT; ++i) { for (int k = 0; k < NoteUtil.NOTE_COUNT; ++k) { nodes[i].AddConnection(nodes[k], initial_weight); } } }
public List <NoteNode> GetNoteSequenceAsList(Random gen) { List <NoteNode> sequence = new List <NoteNode>(); NoteNode current = nodes[gen.Next(NoteUtil.NOTE_COUNT)]; // eliminate initial behavior for (int i = 0; i < 50; ++i) { current = current.GetNextNode(gen); } for (int i = 0; i < 8; ++i) { sequence.Add(current); current = current.GetNextNode(gen); } return(sequence); }
public Edge(NoteNode n, double w) { this.n = n; this.weight = w; }
// Returns true if adding the node was successful // Returns false if the Note in the NoteNode being added is already connected public bool AddConnection(NoteNode note, double weight) { if (!IsConnected(note.GetNote())) { connections[NoteUtil.NoteHash(note.GetNote())] = new Edge(note,weight); return true; } return false; }