Skip to content

Commit

Permalink
Merge pull request #10 from Rocaloid/experimental
Browse files Browse the repository at this point in the history
Supports Cadencii PitchBend
  • Loading branch information
Sleepwalking committed Oct 11, 2014
2 parents ad8e416 + c683253 commit 70758a7
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Version.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
set(RUCE_VERSION_MAJOR 1)
set(RUCE_VERSION_MINOR 1)
set(RUCE_VERSION_REVISION 0)
set(RUCE_VERSION_PATCH 20140928)
set(RUCE_VERSION_PATCH 20141003)
set(RUCE_VERSION_TAG alpha3)

46 changes: 42 additions & 4 deletions cli/GetPara.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,50 @@ int RUCE_ParsePara(RUCE_UnitParam* Dest, int argc, char** argv)
int Ret = 1;
int CLV = argc;
int EnablePitchConv = 1;
float Tempo;
float Freq;

String PP, PBD;
RNew(String, & PP, & PBD);
if(CLV > 13)
{//Resolving Cadencii Style PitchBend
String_SetChars(& PBD, argv[12]);
String QChar;
RNew(String, & QChar);
String_SetChars(& QChar, "Q");
int QPos = InStrRev(& PBD, & QChar);
RDelete(& QChar);
if(QPos != -1)
{
Tempo = atof(String_GetChars(& PBD) + QPos + 1);
if(Tempo <= 0)
{
fprintf(stderr, "[Error] Invalid tempo as '%s'.\n", argv[12]);
Ret = 0;
goto RExit;
}
String_SetChars(& PP, argv[3]);
Freq = Tune_SPNToFreq_Float(& PP);

for(i = 0; i < (CLV - 13); ++ i)
{
float PitchCent = atof(argv[13 + i]);
PMatch_Float_Float_AddPair(&Dest -> Freq,
Tune_BeatToTime_Float(Tempo, (((float)i) / 96.0f)),
Tune_AddCentToFreq_Float(Freq, PitchCent));
}
/* printf("Detected Cadencii Style PitchBend,
Tempo = %f, Points = %d\n", Tempo, CLV - 13); */
CLV = 12;
EnablePitchConv = 0;
}
}
switch(CLV)
{
case 14:
String_SetChars(& PP, argv[3]);
String_SetChars(& PBD, argv[13]);
float Tempo = atof(argv[12] + 1);
Tempo = atof(argv[12] + 1);
if(Tempo <= 0)
{
fprintf(stderr, "[Error] Invalid tempo as '%s'.\n", argv[12]);
Expand All @@ -34,16 +69,18 @@ int RUCE_ParsePara(RUCE_UnitParam* Dest, int argc, char** argv)
}
int DataNum = RUCE_Pitchbend_GetLength(& PBD);
short* Data = RAlloc(DataNum * sizeof(short));
float Freq = Tune_SPNToFreq_Float(& PP);
Freq = Tune_SPNToFreq_Float(& PP);
RUCE_Pitchbend_Decode(Data, & PBD);
for(i = 0; i < DataNum; ++ i)
{
Data[i] = Data[i] > 2048 ? Data[i] - 4096 : Data[i];
PMatch_Float_Float_AddPair(& Dest -> Freq,
PMatch_Float_Float_AddPair(& Dest -> Freq,
Tune_BeatToTime_Float(Tempo, (((float)i) / 96.0f)),
Tune_AddCentToFreq_Float(Freq, Data[i]));
}
RFree(Data);
/* printf("Detected UTAU Style PitchBend, Tempo = %f
, Points = %d\n", Tempo, DataNum);*/
EnablePitchConv = 0; // Disable standalone pitch conv.
CLV -= 2;

Expand Down Expand Up @@ -213,7 +250,8 @@ int RUCE_ParsePara(RUCE_UnitParam* Dest, int argc, char** argv)
PrintUsage(argv[0]);
Ret = -1;
};

RExit:

RDelete(& PP, & PBD);
return Ret;
}
Expand Down

0 comments on commit 70758a7

Please sign in to comment.