diff --git a/src/spect.cpp b/src/spect.cpp index 4cb29392..a0ae1261 100644 --- a/src/spect.cpp +++ b/src/spect.cpp @@ -31,12 +31,6 @@ #include "wx/datstrm.h" -#ifdef INCLUDE_KLATT -extern "C" void SetSynth_Klatt(int length, int modn, frame_t *fr1, frame_t *fr2, voice_t *v, int control); -#endif - -extern "C" void SetSynth(int length, int modn, frame_t *fr1, frame_t *fr2, voice_t *v); - extern "C" int PeaksToHarmspect(wavegen_peaks_t *peaks, int pitch, int *htab, int control); extern unsigned char pk_shape1[]; @@ -115,7 +109,6 @@ SpectFrame::SpectFrame(SpectFrame *copy) int ix; - selected = 0; keyframe = 0; spect = NULL; markers = 0; @@ -229,32 +222,6 @@ int SpectFrame::Load(wxInputStream& stream, int file_format_type) -void SpectFrame::ZeroPeaks() -{//========================= - int pk; - - for(pk=0; pkpeaks,sizeof(peaks)); - memcpy(klatt_param, sf->klatt_param, sizeof(klatt_param)); - keyframe = sf->keyframe; -} - - - -void SpectFrame::ToggleMarker(int n) -{//================================= - markers ^= 1< 600) - bw = 70; - if(peaks[1].pkfreq > 650) - bw = 80; - if(peaks[1].pkfreq > 750) - bw = 90; - peaks[1].pkwidth = bw; - - bw = 90; - bw3 = 150; - if(peaks[2].pkfreq < 1000) - { - bw = 80; - bw3 = 120; - } - if(peaks[2].pkfreq > 1600) - { - bw = 100; - bw3 = 200; - } - if(peaks[2].pkfreq > 2000) - { - bw = 110; - bw3 = 250; - } - peaks[2].pkwidth = bw; - peaks[3].pkwidth = bw3; - peaks[4].pkwidth = 200; - peaks[5].pkwidth = 200; - peaks[6].pkwidth = 500; - peaks[0].pkfreq = 280; // FNP - peaks[0].pkwidth = 280; // FNZ - - peaks[7].pkfreq = 7800; - peaks[7].pkwidth = 0; - peaks[8].pkfreq = 9000; - peaks[8].pkwidth = 0; - - for(pk=0; pk<=8; pk++) - { - peaks[pk].pkheight = peaks[pk].pkwidth << 6; - peaks[pk].pkright = 0; - } -} - - SpectSeq::SpectSeq(int n) {//====================== numframes = n; @@ -387,64 +286,6 @@ SpectSeq::~SpectSeq() } -void SpectSeq::SelectAll(int yes) -{//============================== - // select of deselect all frames in the sequence - int ix; - for(ix=0; ixselected = yes; -} - - -int SpectSeq::CountSelected() -{//========================== - int ix; - int count=0; - for(ix=0; ixselected) - count++; - } - return(count); -} // end of SpectSeq::CountSelected - - -void SpectSeq::DeleteSelected() -{//============================ - int ix; - int count=0; - - for(ix=0; ixselected) - { - count++; - } - else - if(count > 0) - { - *frames[ix-count] = *frames[ix]; - } - } - numframes = numframes - count; -} // end of SpectSeq::DeleteSelected - - -void SpectSeq::SetFrameLengths() -{//============================= - int frame; - - for(frame=0; framekeyframe) - frames[frame]->length = GetFrameLength(frame,1,NULL); - else - frames[frame]->length = 0; - } -} // end of SetFrameLengths - - - float SpectSeq::GetFrameLength(int frame, int plus, int *original) {//=============================================================== int ix; @@ -466,32 +307,6 @@ float SpectSeq::GetFrameLength(int frame, int plus, int *original) } -float SpectSeq::GetKeyedLength() -{//============================= - int ix; - int first; - int last=0; - float adjust=0; - - first = -1; - for(ix=0; ixkeyframe) - { - last = ix; - if(first == -1) first = ix; - } - } - if(first == -1) - return(0); // no keyframes - - for(ix=first; ixlength_adjust; - - return((frames[last]->time - frames[first]->time) * 1000 + adjust); -} - - void SpectSeq::Load2(wxInputStream& stream, int n) {//=========================================================== // continuation of load/import @@ -597,159 +412,3 @@ int SpectSeq::Load(wxInputStream & stream) } return(0); } // end of SpectSeq::Load - - -void SpectSeq::InterpolatePeak(int peak) -{//===================================== - int f, f1=0, f2; - peak_t *p, *p1=NULL, *p2; - double t1=0, t2; - double interval; - double ratio; - int first = 1; - - for(f2=0; f2 < numframes; f2++) - { - if(frames[f2]->keyframe) - { - t2 = frames[f2]->time; - p2 = &frames[f2]->peaks[peak]; - - if(first) - first = 0; - else - { - interval = t2 - t1; - - for(f=f1+1; fpeaks[peak]; - - ratio = (frames[f]->time - t1)/interval; - - p->pkfreq = p1->pkfreq + int((p2->pkfreq - p1->pkfreq)*ratio); - p->pkheight=p1->pkheight+int((p2->pkheight-p1->pkheight)*ratio); - p->pkwidth = p1->pkwidth + int((p2->pkwidth - p1->pkwidth)*ratio); - p->pkright =p1->pkright + int((p2->pkright - p2->pkright)*ratio); - } - } - f1 = f2; - t1 = t2; - p1 = p2; - } - } -} // end of SpectSeq::InterpolatePeak - - -void SpectSeq::InterpolatePeaks(int control) -{//========================================= -// 0=turn off 1=turn on - int f, peak; - - if(control==1) - { - for(peak=0; peakkeyframe == 0) - frames[f]->ZeroPeaks(); - } - } -} // end of SpectSeq::InterpolatePeaks - - -void SpectSeq::CopyDown(int frame, int direction) -{//============================================== -// Copy peaks down from next earlier/later keyframe - int f1; - - for(f1=frame+direction; f1>=0 && f1keyframe) - { - memcpy(frames[frame]->peaks, frames[f1]->peaks, sizeof(frames[frame]->peaks)); - memcpy(frames[frame]->klatt_param, frames[f1]->klatt_param, sizeof(frames[frame]->klatt_param)); - break; - } - } -} // end of CopyDown - - -void PeaksToFrame(SpectFrame *sp1, peak_t *pks, frame_t *fr) -{//========================================================= - int ix; - int x; - - fr->frflags = FRFLAG_KLATT; - - for(ix=0; ix < 8; ix++) - { - if(ix < 7) - { - fr->ffreq[ix] = pks[ix].pkfreq; - fr->klatt_ap[ix] = pks[ix].klt_ap; - fr->klatt_bp[ix] = pks[ix].klt_bp/2; - } - - if(ix < 4) - fr->bw[ix] = pks[ix].klt_bw/2; - - fr->fheight[ix] = pks[ix].pkheight >> 6; - if(ix < 6) - { - if((x = (pks[ix].pkwidth >> 2)) > 255) - x = 255; - fr->fwidth[ix] = x; - - if(ix < 3) - { - if((x = (pks[ix].pkright >> 2)) > 255) - x = 255; - fr->fright[ix] = x; - } - } - } - - for(ix=0; ixklattp[ix] = sp1->klatt_param[ix]; - } - fr->klattp[KLATT_FNZ] = sp1->klatt_param[KLATT_FNZ]/2; - if(fr->fheight[1] == 0) - { - fr->klattp[KLATT_AV] -= 10; // fade in/out - } -} - -static void SetSynth_mS(int length_mS, SpectFrame *sp1, SpectFrame *sp2, peak_t *pks1, peak_t *pks2, int control) -{//============================================================================================================== - static frame_t fr1, fr2; - - PeaksToFrame(sp1,pks1,&fr1); - PeaksToFrame(sp2,pks2,&fr2); - - if(voice->klattv[0]) - { -#ifdef INCLUDE_KLATT - SetSynth_Klatt((length_mS * samplerate) / 1000, 0, &fr1, &fr2, voice, control); // convert mS to samples -#endif - } - else - { - SetSynth((length_mS * samplerate) / 1000, 0, &fr1, &fr2, voice); // convert mS to samples - } -}; - - -void SpectFrame::MakeHtab(int numh, int *htab, int pitch) -{//====================================================== - // interpolate the spectrum to give a harmonic table for - // the given pitch (Hz<<12) - -} // end of SpectFrame::MakeHtab diff --git a/src/spect.h b/src/spect.h index cf40c78e..9691e118 100644 --- a/src/spect.h +++ b/src/spect.h @@ -92,15 +92,8 @@ public: ~SpectFrame(); int Load(wxInputStream &stream, int file_format_type); - void ZeroPeaks(); - void CopyPeaks(SpectFrame *sf); - void ToggleMarker(int n); - - void MakeHtab(int numh, int *htab, int pitch); double GetRms(int amp); - void KlattDefaults(); - int selected; int keyframe; int amp_adjust; float length_adjust; @@ -128,14 +121,7 @@ public: ~SpectSeq(); int Load(wxInputStream& stream); - void InterpolatePeaks(int on); - void CopyDown(int frame, int direction); - void SelectAll(int yes); - int CountSelected(); - void DeleteSelected(); float GetFrameLength(int frame, int plus, int *original_mS); - float GetKeyedLength(); - void SetFrameLengths(); int numframes; int amplitude; @@ -156,5 +142,4 @@ public: private: void Load2(wxInputStream& stream, int n); - void InterpolatePeak(int peak); };