Mercurial > hg > silvet
diff src/EM.cpp @ 35:461d94ed3816
More on EM
author | Chris Cannam |
---|---|
date | Fri, 04 Apr 2014 14:38:40 +0100 |
parents | 7d81407a2fd8 |
children | 74b77a4d6552 |
line wrap: on
line diff
--- a/src/EM.cpp Fri Apr 04 14:28:41 2014 +0100 +++ b/src/EM.cpp Fri Apr 04 14:38:40 2014 +0100 @@ -17,3 +17,55 @@ #include "data/include/templates.h" +static double epsilon = 1e-16; + +EM::EM() : + m_notes(SILVET_TEMPLATE_NOTE_COUNT), + m_bins(SILVET_TEMPLATE_HEIGHT), + m_instruments(SILVET_TEMPLATE_COUNT) +{ + m_lowest = 0; + m_highest = m_notes - 1; + + for (int i = 0; i < m_instruments; ++i) { + if (i == 0 || silvet_templates[i].lowest < m_lowest) { + m_lowest = silvet_templates[i].lowest; + } + if (i == 0 || silvet_templates[i].highest > m_highest) { + m_highest = silvet_templates[i].highest; + } + } + + m_pitches = V(m_notes); + + for (int n = 0; n < m_notes; ++i) { + m_pitches[n] = drand48(); + } + + m_sources = Grid(m_instruments); + + for (int i = 0; i < m_instruments; ++i) { + m_sources[i] = V(m_notes); + for (int n = 0; n < m_notes; ++n) { + m_sources[i][n] = (inRange(i, n) ? 1.0 : 0.0); + } + } + + m_q = V(m_bins); + + for (int w = 0; w < m_bins; ++w) { + m_q[w] = epsilon; + } +} + +EM::~EM() +{ +} + +bool +EM::inRange(int instrument, int note) +{ + return (note >= silvet_templates[instrument].lowest && + note <= silvet_templates[instrument].highest); +} +