|
|
@@ -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; pk<N_PEAKS; pk++) |
|
|
|
peaks[pk].pkheight = 0; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void SpectFrame::CopyPeaks(SpectFrame *sf) |
|
|
|
{//======================================= |
|
|
|
memcpy(peaks,sf->peaks,sizeof(peaks)); |
|
|
|
memcpy(klatt_param, sf->klatt_param, sizeof(klatt_param)); |
|
|
|
keyframe = sf->keyframe; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void SpectFrame::ToggleMarker(int n) |
|
|
|
{//================================= |
|
|
|
markers ^= 1<<n; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
double SpectFrame::GetRms(int seq_amplitude) |
|
|
|
{//========================================= |
|
|
|
int h; |
|
|
@@ -284,74 +251,6 @@ double SpectFrame::GetRms(int seq_amplitude) |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void SpectFrame::KlattDefaults() |
|
|
|
{//============================ |
|
|
|
// set default values for Klatt parameters |
|
|
|
int pk; |
|
|
|
int bw; |
|
|
|
int bw3; |
|
|
|
|
|
|
|
klatt_param[KLATT_AV] = 59; |
|
|
|
klatt_param[KLATT_AVp] = 0; |
|
|
|
klatt_param[KLATT_Fric] = 0; |
|
|
|
klatt_param[KLATT_FricBP] = 0; |
|
|
|
klatt_param[KLATT_Aspr] = 0; |
|
|
|
klatt_param[KLATT_Turb] = 0; |
|
|
|
klatt_param[KLATT_Skew] = 0; |
|
|
|
klatt_param[KLATT_Tilt] = 0; |
|
|
|
klatt_param[KLATT_Kopen] = 40; |
|
|
|
klatt_param[KLATT_FNZ] = 280; |
|
|
|
|
|
|
|
bw = 60; |
|
|
|
if(peaks[1].pkfreq < 400) |
|
|
|
bw = 55; |
|
|
|
if(peaks[1].pkfreq > 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; ix<numframes; ix++) |
|
|
|
frames[ix]->selected = yes; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
int SpectSeq::CountSelected() |
|
|
|
{//========================== |
|
|
|
int ix; |
|
|
|
int count=0; |
|
|
|
for(ix=0; ix<numframes; ix++) |
|
|
|
{ |
|
|
|
if(frames[ix]->selected) |
|
|
|
count++; |
|
|
|
} |
|
|
|
return(count); |
|
|
|
} // end of SpectSeq::CountSelected |
|
|
|
|
|
|
|
|
|
|
|
void SpectSeq::DeleteSelected() |
|
|
|
{//============================ |
|
|
|
int ix; |
|
|
|
int count=0; |
|
|
|
|
|
|
|
for(ix=0; ix<numframes; ix++) |
|
|
|
{ |
|
|
|
if(frames[ix]->selected) |
|
|
|
{ |
|
|
|
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; frame<numframes; frame++) |
|
|
|
{ |
|
|
|
if(frames[frame]->keyframe) |
|
|
|
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; ix<numframes; ix++) |
|
|
|
{ |
|
|
|
if(frames[ix]->keyframe) |
|
|
|
{ |
|
|
|
last = ix; |
|
|
|
if(first == -1) first = ix; |
|
|
|
} |
|
|
|
} |
|
|
|
if(first == -1) |
|
|
|
return(0); // no keyframes |
|
|
|
|
|
|
|
for(ix=first; ix<last; ix++) |
|
|
|
adjust += frames[ix]->length_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; f<f2; f++) |
|
|
|
{ |
|
|
|
p = &frames[f]->peaks[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; peak<N_PEAKS; peak++) |
|
|
|
{ |
|
|
|
InterpolatePeak(peak); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
for(f=0; f<numframes; f++) |
|
|
|
{ |
|
|
|
if(frames[f]->keyframe == 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 && f1<numframes; f1 += direction) |
|
|
|
{ |
|
|
|
if(frames[f1]->keyframe) |
|
|
|
{ |
|
|
|
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; ix<N_KLATTP; ix++) |
|
|
|
{ |
|
|
|
fr->klattp[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 |