From 23a5f9888e4c28ff5273b16e984caff32caeac69 Mon Sep 17 00:00:00 2001 From: John Glover Date: Tue, 3 Jul 2012 17:27:12 +0100 Subject: [synthesis] Fix SMSSynthesis (was using Peak data instead of tracked Partials). Add test for harmonic synthesis using sum of sines. --- src/simpl/synthesis.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/simpl/synthesis.cpp b/src/simpl/synthesis.cpp index 9dd1131..221e60e 100644 --- a/src/simpl/synthesis.cpp +++ b/src/simpl/synthesis.cpp @@ -125,10 +125,15 @@ void SMSSynthesis::det_synthesis_type(int new_det_synthesis_type) { } void SMSSynthesis::synth_frame(Frame* frame) { - for(int i = 0; i < _data.nTracks; i++) { - _data.pFSinAmp[i] = frame->peak(i)->amplitude; - _data.pFSinFreq[i] = frame->peak(i)->frequency; - _data.pFSinPha[i] = frame->peak(i)->phase; + int num_partials = _data.nTracks; + if(num_partials > frame->num_partials()) { + num_partials = frame->num_partials(); + } + + for(int i = 0; i < num_partials; i++) { + _data.pFSinAmp[i] = frame->partial(i)->amplitude; + _data.pFSinFreq[i] = frame->partial(i)->frequency; + _data.pFSinPha[i] = frame->partial(i)->phase; } sms_synthesize(&_data, frame->synth(), &_synth_params); -- cgit v1.2.3