public StochasticGenerator(MelodySequence[] seqs)
{
if(seqs != null && seqs.Length > 0)
this.base_seq = seqs[0];
int count = seqs.Length;
List<int[]> notes = new List<int[]>();
List<int[]> bayesInputs = new List<int[]>();
List<int> bayesOutputs = new List<int>();
notes_map = new Dictionary<int, int>();
int max_notes = 0;
int note = 0;
foreach (MelodySequence m in seqs)
{
Note[] song = m.ToArray();
int[] _notes = new int[song.Length];
int[] _durations = new int[20];
for (int i = 0; i < song.Length; i++)
{
var unote = song[i].Pitch + song[i].Duration*128;
if (notes_map.ContainsKey(unote))
_notes[i] = notes_map[unote];
else
{
notes_map[unote] = note++;
_notes[i] = notes_map[unote];
}
}
notes.Add(_notes);
}
max_notes = note;
Console.WriteLine("Training Pitches");
pitch_hmm = new HiddenMarkovModel(50, max_notes);
var teacher = new BaumWelchLearning(pitch_hmm) { Tolerance = 0.0001, Iterations = 0 };
var __pitches = notes.ToArray();
teacher.Run(__pitches);
teacher.Run(__pitches);
Console.WriteLine("Done training");
this.MaxGenerations = 2000;
}