Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
  • Loading branch information
tipei committed Jul 12, 2022
1 parent b4dcd48 commit ed583ae
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 23 deletions.
21 changes: 10 additions & 11 deletions CMOD/src/Event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,7 @@ void Event::buildChildren() {
case 3: eventclass = "------L : ";break;
}
//Build the event's children.
//cout << "Event::buildChildren - name: " << name << endl;

//Create the event definition iterator.
/*
Expand Down Expand Up @@ -658,10 +659,6 @@ bool Event::buildSweep() {
&& Utilities::isSieveFunction(childDurationElement)
&& startType == "1"
&& durType == "1");
/*
cout << boolalpha << align << sieveAligned << endl;
int sT; cin >> sT;
*/

// find start time and dur of last child
if (currChildNum == 0) {
Expand Down Expand Up @@ -764,15 +761,16 @@ int sT; cin >> sT;
}

if(startType == "1" && durType == "1") {
/*
cout << " - previousChildEndTime=" << previousChildEndTime << endl;
cout << " " <<endl;
*/

endTime = Event::verify_valid(previousChildEndTime); //missnomer !!
tsChild.start = endTime *

// tsChild.start = endTime * SEVER 5/19 2022
tsChild.start = rawChildStartTime * //SEVER 5/19 2022
tempo.getEDUDurationInSeconds().To<float>();
tsChild.startEDU = Ratio((int)rawChildStartTime, 1);

//cout << "FIN: tsChild.start=" << tsChild.start << " endTime=" << endTime << endl;
//cin >> sT;

rawChildDuration = endTime - rawChildStartTime;
int rawChildDurationInt = (int)rawChildDuration;
tsChild.durationEDU = Ratio(rawChildDurationInt, 1);
Expand Down Expand Up @@ -1189,6 +1187,7 @@ int Event::getAvailableEDU()
int myDurationInt = (int)ts.duration;
Ratio EDUs;
float durationScalar;

if(ts.duration == (float)myDurationInt)
{
//Since duration is an integer, it may still be possible to have exact EDUs.
Expand Down Expand Up @@ -1470,6 +1469,6 @@ int Event::verify_valid(int endTime){
}
//cout << "endTime: " << eTime << " high_n: " << valid_time[high] << " low_n: " << valid_time[low] << endl;
int offset = attackSweep[high] - eTime <= eTime - attackSweep[low] ? attackSweep[high] - eTime : attackSweep[low] - eTime;
//cout << "endTime: " << endTime << " choose: " << endTime + offset << endl;
cout << "endTime: " << endTime << " choose: " << endTime + offset << endl;
return endTime + offset;
}
13 changes: 10 additions & 3 deletions CMOD/src/Matrix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ void Matrix::setDurations(Sieve* durSieve, int maxVal, vector<Envelope*> durEnvs
if(type != oldType) {
cout << "Matrix::setDurations - envelope for type " << type << endl;
durEnvs[type] -> print();
int sever; cin >> sever;
int sever; cin >> sever;
oldType = type;
}
*/
Expand All @@ -194,6 +194,7 @@ void Matrix::setDurations(Sieve* durSieve, int maxVal, vector<Envelope*> durEnvs
<< "][" << durNum << "].stime=" << matr[type][attNum][durNum].stime
<< " matr[" << type << "][" << attNum << "][" << durNum
<< "].attdurprob=" << matr[type][attNum][durNum].attdurprob << endl;
int sever; cin >> sever;
*/
if (( sieveAligned
&& att.count(durEnd % tempo.getEDUPerTempoBeat().Num()) == 0
Expand Down Expand Up @@ -247,6 +248,8 @@ MatPoint Matrix::chooseSweep(int remain) {
return chosenPt;
}


//---------------------------------------------------------------------------//
MatPoint Matrix::chooseContinuum() {
return choose();
}
Expand Down Expand Up @@ -419,9 +422,13 @@ int Matrix::verify_valid(int endTime){
return endTime;
}
}
//cout << "endTime: " << eTime << " high_n: " << valid_time[high] << " low_n: " << valid_time[low] << endl;
/*
cout << "Matrix:verify_valid - endTime: " << eTime << " high=" << high
<< " low=" << low << endl;
//<< " high_n: " << valid_time[high] << " low_n: " << valid_time[low]
*/
int offset = short_attime[high] - eTime <= eTime - short_attime[low] ? short_attime[high] - eTime : short_attime[low] - eTime;
//cout << "endTime: " << endTime << " choose: " << endTime + offset << endl;
//cout << "endTime: " << endTime << " choose: " << endTime + offset << endl;
return endTime + offset;
}

Expand Down
2 changes: 1 addition & 1 deletion CMOD/src/Random.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ int Random::RandInt(int lowNum, int highNum) {

//----------------------------------------------------------------------------//

int Random::RandOrderInt(int low, int high, int numChildren, int id) {
int Random::RandOrderInt(int low, int high, int id) {
static map<int, vector<int> > choicesMap;

// Initialize choices if a new random order function is found, or
Expand Down
6 changes: 2 additions & 4 deletions CMOD/src/Random.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,11 @@ class Random {
*
* Returns a random integer in the range [low, high].
* Avoids repetition, given that
* - number of children is greater than or equal to
* range of [low, high]
* - every RandomOrderInt function with range [low, high] and
* numChildren is unique
* - every RandomOrderInt function with range [low, high] is unique
* @param id - Distinguishes between unique calls of the randOrderInt function
*/
static int RandOrderInt(int low, int high, int numChildren, int id);
static int RandOrderInt(int low, int high, int id);

/**
* Randomly chooses a value from a list.
Expand Down
35 changes: 31 additions & 4 deletions CMOD/src/Utilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -704,10 +704,12 @@ Sieve* Utilities::evaluateSieveFunction(string _functionString,void* _object){
// cout << "Sieve* Utilities::evaluateSieveFunction - ValuePick" << endl;
resultSieve = sieve_ValuePick(root, _object);
}
/*
else if (functionName.compare("PREVIOUS_CHILD_DURATION")==0) {
// cout << "Sieve* Utilities::evaluateSieveFunction - PREVIOUS " << endl;
resultSieve = NULL;
}
*/

delete parser;
return resultSieve;
Expand Down Expand Up @@ -1111,6 +1113,30 @@ Sieve* Utilities::sieve_ValuePick(DOMElement* _functionElement, void* _object){
eMethod.c_str(), wMethod.c_str(),
eArgs[0], wArgVect,
offsetVect);

/* added by Sever
vector<int> attTimes;
vector<double> attProbs;
si.FillInVectors(attTimes, attProbs);
cout << " sieve_ValuePick - attTimes.size()=" << attTimes.size() << endl;
int beatEDUs;
beatEDUs = _tempo.getEDUPerTimeSignatureBeat().Num();
cout << " beatEDUs=" << beatEDUs << endl;
for(int i = 0; i < attTimes.size(); i++){
if(attTimes[i] > eArgs.size()){
break;
}
// short_attime.push_back(attTimes[i]);
cout << " attTimes.size=" << attTimes.size() << endl;
cout << attTimes[i] << " , ";
}
cout << endl;
*/

} else {
si.Build(minVal, maxVal, eMethod.c_str(), wMethod.c_str(), eArgVect, wArgVect, offsetVect);
}
Expand Down Expand Up @@ -1222,8 +1248,9 @@ string Utilities::function_Select(DOMElement* _functionElement, void* _object){
char result [50];
/*
for(int i=0; i<list.size(); ++i)
std::cout << list[i] << ' ';
std::cout << "Utilities::function_Select - list[" << i << "]=" << list[i] << ' ';
*/

sprintf(result, "%f", evaluate( list[index], _object));
/*
cout << " result= ";
Expand Down Expand Up @@ -1307,7 +1334,7 @@ string Utilities::function_RandomOrderInt(DOMElement* _functionElement, void* _o
int lowBound = (int)evaluate(XMLTranscode(lowBoundElement), _object);
int highBound = (int)evaluate(XMLTranscode(highBoundElement), _object);
int id = (int) evaluate(XMLTranscode(idElement), _object);
/*
Event* currentEvent = ((Event*)_object);
int numChildren = currentEvent->getNumberOfChildren();
string eventName = currentEvent->getEventName();
Expand All @@ -1320,9 +1347,9 @@ string Utilities::function_RandomOrderInt(DOMElement* _functionElement, void* _o
<< " This will cause repeated values."
<< endl;
}

*/
char result [50];
sprintf(result, "%d", Random::RandOrderInt(lowBound, highBound, numChildren, id));
sprintf(result, "%d", Random::RandOrderInt(lowBound, highBound, id));
return string(result);
}

Expand Down

0 comments on commit ed583ae

Please sign in to comment.