diff options
author | John Glover <j@johnglover.net> | 2013-06-15 23:38:39 +0200 |
---|---|---|
committer | John Glover <j@johnglover.net> | 2013-06-15 23:38:39 +0200 |
commit | c357d6caf3eb64d3fc2604868b696c1e34e8d16e (patch) | |
tree | b1b595dfa7790a8a9520413ce133850e79713ec0 /src | |
parent | 60ed1e8252e6e4f0cbc8c0a5c9aea124bdd2a01b (diff) | |
download | simpl-c357d6caf3eb64d3fc2604868b696c1e34e8d16e.tar.gz simpl-c357d6caf3eb64d3fc2604868b696c1e34e8d16e.tar.bz2 simpl-c357d6caf3eb64d3fc2604868b696c1e34e8d16e.zip |
Add basic tests for SndObjPartialTracking.
Fix reading invalid memory address when looping over partials.
Diffstat (limited to 'src')
-rw-r--r-- | src/sndobj/SinAnal.cpp | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/sndobj/SinAnal.cpp b/src/sndobj/SinAnal.cpp index d8e53cf..d6a07a2 100644 --- a/src/sndobj/SinAnal.cpp +++ b/src/sndobj/SinAnal.cpp @@ -112,8 +112,10 @@ SinAnal::SinAnal(SndObj* input, double threshold, int maxtracks, AddMsg("max tracks", 21); AddMsg("threshold", 22); - for(i = 0; i < m_maxtracks; i++) - m_pkmags[m_prev][i] = m_bndx[m_prev][i] = m_adthresh[m_prev][i] = 0.f; + for(i = 0; i < m_maxtracks; i++) { + m_pkmags[0][i] = m_bndx[0][i] = m_adthresh[0][i] = 0.f; + m_pkmags[1][i] = m_bndx[1][i] = m_adthresh[1][i] = 0.f; + } } SinAnal::SinAnal(SndObj* input, int numbins, double threshold, int maxtracks, @@ -184,8 +186,10 @@ SinAnal::SinAnal(SndObj* input, int numbins, double threshold, int maxtracks, AddMsg("max tracks", 21); AddMsg("threshold", 22); - for(i = 0; i < m_maxtracks; i++) - m_pkmags[m_prev][i] = m_bndx[m_prev][i] = m_adthresh[m_prev][i] = 0.f; + for(i = 0; i < m_maxtracks; i++) { + m_pkmags[0][i] = m_bndx[0][i] = m_adthresh[0][i] = 0.f; + m_pkmags[1][i] = m_bndx[1][i] = m_adthresh[1][i] = 0.f; + } } SinAnal::~SinAnal(){ @@ -483,7 +487,7 @@ SinAnal::PartialTracking(){ // loop to the end of tracks (indicate by the 0'd bins) // find continuation tracks - for(j=0; m_bndx[m_prev][j] != 0.f && j < m_maxtracks; j++){ + for(j=0; j < m_maxtracks && m_bndx[m_prev][j] != 0.f; j++){ int foundcont = 0; if(m_numpeaks > 0){ // check for peaks; m_numpeaks will be > 0 |