Skip to content
This repository has been archived by the owner on Aug 28, 2018. It is now read-only.

Commit

Permalink
Ready to release.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sleepwalking committed Jul 15, 2014
1 parent 6f0444e commit 33c9e68
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 46 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ Todo & Plan List
- [ ] Implement `GainIterfector` in CVEDSP2(in: `Wave` `Wave`, out: `Wave`)
- [ ] Implement `MixIterfector` in CVEDSP2(in: `Wave` `Wave`, out: `Wave`)
- [ ] Implement `PulseItersizer` in CVEDSP2(in: `Position`, out: `Wave`)
- [ ] Implement `TurbIterfector`(in: `Wave` `Wave`, out: `Wave`)

####Step3: Voice Manipulation

- [ ] Timbre adjustment related to pitch scaling
- [x] Timbre adjustment related to pitch scaling
- [ ] Turbulent Noise regeneration in `HNMItersizer`
- [ ] Implement `GenKlatt` based on `FWindow`
- [ ] Implement `EpRParam` structure
- [ ] Implement `EpRParam_ToHNMContour`
Expand Down
14 changes: 7 additions & 7 deletions src/Spectral/Pitch.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,17 @@ void CSVP_PitchModel_SetDefault(First, int Gender)
RCall(_PMatch, AddPair)(& This -> HmncCurve, 150.0, -1.0);
RCall(_PMatch, AddPair)(& This -> HmncCurve, 0.0, -2.0);

RCall(_PMatch, AddPair)(& This -> NoizCurve, 700.0, -2.0);
RCall(_PMatch, AddPair)(& This -> NoizCurve, 300.0, +0.0);
RCall(_PMatch, AddPair)(& This -> NoizCurve, 200.0, +0.0);
RCall(_PMatch, AddPair)(& This -> NoizCurve, 150.0, -0.5);
RCall(_PMatch, AddPair)(& This -> NoizCurve, 0.0, -1.5);
RCall(_PMatch, AddPair)(& This -> NoizCurve, 700.0, -1.0);
RCall(_PMatch, AddPair)(& This -> NoizCurve, 300.0, +1.0);
RCall(_PMatch, AddPair)(& This -> NoizCurve, 200.0, +1.0);
RCall(_PMatch, AddPair)(& This -> NoizCurve, 150.0, +0.5);
RCall(_PMatch, AddPair)(& This -> NoizCurve, 0.0, -0.5);

RCall(_PMatch, AddPair)(& This -> PhseCurve, 700.0, 1.7);
RCall(_PMatch, AddPair)(& This -> PhseCurve, 360.0, 1.0);
RCall(_PMatch, AddPair)(& This -> PhseCurve, 260.0, 1.0);
RCall(_PMatch, AddPair)(& This -> PhseCurve, 200.0, 0.6);
RCall(_PMatch, AddPair)(& This -> PhseCurve, 150.0, 0.3);
RCall(_PMatch, AddPair)(& This -> PhseCurve, 200.0, 0.5);
RCall(_PMatch, AddPair)(& This -> PhseCurve, 150.0, 0.2);
RCall(_PMatch, AddPair)(& This -> PhseCurve, 0.0, 0.0);
}

Expand Down
3 changes: 3 additions & 0 deletions src/Spectral/_Pitch.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ RTFunc(void, CSVP_PitchShiftHNMContour, _HNMContour* Dest,
RTFunc(void, CSVP_PitchAdjustHNMContour, _HNMContour* Dest,
CSVP_PitchModel* Sorc, _T1 F0, int SampleRate);

RTFunc(void, CSVP_PitchConvertHNMFrame, _HNMContour* Dest, _HNMFrame* Sorc,
CSVP_PitchModel* Model, _T1 F0, int UFreq, int SampleRate);

#undef _HNMFrame
#undef _HNMContour

23 changes: 23 additions & 0 deletions src/Spectral/_Pitch.rc
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,29 @@ RTFunc(void, CSVP_PitchAdjustHNMContour, _HNMContour* Dest,
RCall(CDSP2_VCAdd, _T1)(Dest -> Noiz, Dest -> Noiz, NoizAmp, Size);
}

RTFunc(void, CSVP_PitchConvertHNMFrame, _HNMContour* Dest, _HNMFrame* Sorc,
CSVP_PitchModel* Model, _T1 F0, int UFreq, int SampleRate)
{
float Sum1, Sum2, Ratio;

_HNMFrame TempHNM;
RCall(_HNMFrame, Ctor)(& TempHNM);

RCall(_HNMFrame, ToContour)(Sorc, Dest);
CSVP_PitchShiftHNMContour_Float(Dest, Model, F0 - Sorc -> Hmnc.Freq[0],
SampleRate);

Sum1 = CSVP_EnergyFromHNMFrame_Float(Sorc);
RCall(_HNMFrame, FromContour)(& TempHNM, Dest, F0, UFreq);
Sum2 = CSVP_EnergyFromHNMFrame_Float(& TempHNM);
Ratio = log((1.0 + sqrt(Sum1 / Sum2)) / 2.0);

CSVP_PitchAdjustHNMContour_Float(Dest, Model, F0, SampleRate);
CDSP2_VCAdd_Float(Dest -> Hmnc, Dest -> Hmnc, Ratio, Dest -> Size / 2 + 1);

RCall(_HNMFrame, Dtor)(& TempHNM);
}

#undef _HNMFrame
#undef _HNMContour

44 changes: 7 additions & 37 deletions test/TestSMS/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ int main()

String Path;
String_Ctor(& Path);
String_SetChars(& Path, "/tmp/duan.wav");
String_SetChars(& Path, "/tmp/yao.wav");
RCall(Wave, FromFile)(& XWave, & Path);
RCall(Wave, Resize)(& YWave, XWave.Size * Stretch + 5000);

Expand Down Expand Up @@ -93,19 +93,9 @@ int main()
{
HNMFrame* OrigHNM = & HNMIter.HNMList.Frames[i];

RCall(HNMFrame, ToContour)(OrigHNM, & TempCont);
float Sum1, Sum2, Ratio;
float F0 = OrigHNM -> Hmnc.Freq[0] * 2;
Sum1 = CSVP_EnergyFromHNMFrame_Float(OrigHNM);
CSVP_PitchShiftHNMContour_Float(& TempCont, & PM,
F0 - OrigHNM -> Hmnc.Freq[0], XWave.SampleRate);
float F0 = OrigHNM -> Hmnc.Freq[0] * 1.5;

RCall(HNMFrame, FromContour)(& TempHNM, & TempCont, F0, 12000);
Sum2 = CSVP_EnergyFromHNMFrame_Float(& TempHNM);
Ratio = sqrt(Sum1 / Sum2);

RCall(CDSP2_VCAdd, Float)(TempCont.Noiz, TempCont.Noiz, 1.0, 1025);
CSVP_PitchAdjustHNMContour_Float(& TempCont, & PM, F0,
CSVP_PitchConvertHNMFrame_Float(& TempCont, OrigHNM, & PM, F0, 12000,
XWave.SampleRate);
RCall(HNMFrame, From)(& TempHNM, OrigHNM);
RCall(HNMFrame, FromContour)(& TempHNM, & TempCont, F0, 12000);
Expand All @@ -127,8 +117,6 @@ int main()
printf("%f\n", TempCont.Hmnc[j]);
exit(0);
}*/
for(j = 0; j < TempHNM.Hmnc.Size; j ++)
TempHNM.Hmnc.Ampl[j] *= (1.0 + Ratio) / 2;

for(j = 0; j < Stretch; j ++)
{
Expand All @@ -138,13 +126,7 @@ int main()
}
Last = HNMSizer.PulseList.Frames[i * Stretch - 1];
RDelete(& TempCont, & TempHNM, & PM);

//int f = i / 2;

//for(j = 0; j < HNMIter.PhseList.Frames[f].Size; j ++)
// HNMIter.PhseList.Frames[f].Data[j] = 2.0 * M_PI;
// + (float)rand() / RAND_MAX * (float) j;


RCall(HNMItersizer, SetHopSize)(& HNMSizer, FFTSIZE);
RCall(HNMItersizer, SetWave)(& HNMSizer, & YWave);

Expand All @@ -155,30 +137,18 @@ int main()
printf("%f\n", HNMSizer.SubsizerS -> PhseMatch.PulseList.X[5]);

HNMSizer.Option.PhaseControl = 1;


//printf("%d %d\n", Last - 1000, HNMIter.PulseList.Frames[f]);


RCall(HNMItersizer, PrevTo )(& HNMSizer, 0);
RCall(HNMItersizer, IterNextTo)(& HNMSizer, Last - 8000);
RCall(HNMItersizer, IterNextTo)(& HNMSizer, Last - 1000);
RCall(HNMItersizer, IterNextTo)(& HNMSizer, Last);

String_SetChars(& Path, "/tmp/out.wav");
RCall(Wave, ToFile)(& YWave, & Path);

HNMContour TestCont;
HNMFrame TestFrame;
RCall(HNMFrame, Ctor)(& TestFrame);
RCall(HNMContour, Ctor)(& TestCont);
RCall(HNMFrame, ToContour)(& HNMIter.HNMList.Frames[i / 2], & TestCont);
RCall(HNMFrame, FromContour)(& TestFrame, & TestCont, 200, 8000);
//for(i = 0; i < TestFrame.Hmnc.Size; i ++)
// printf("%f, %f\n", TestFrame.Hmnc.Freq[i], TestFrame.Hmnc.Ampl[i]);



RFree(Win);
RDelete(& Path, & TestCont, & TestFrame);
RDelete(& Path);
RDelete(& XWave, & YWave, & HNMIter, & HNMSizer, & F0Iter);
return 0;
}
Expand Down

0 comments on commit 33c9e68

Please sign in to comment.