Skip to content

Commit

Permalink
sound sequence overhaul
Browse files Browse the repository at this point in the history
  • Loading branch information
obviousjim committed Apr 19, 2014
1 parent 1fb7f54 commit 4c0040b
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 34 deletions.
115 changes: 85 additions & 30 deletions CloudsLibrary/src/StoryEngine/CloudsAct.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,39 +145,38 @@ void CloudsAct::populateTime(){
introCue.soundQuestionKey = startTopic + ":" + startQuestion;
}

int introCueEndIndex = clips.size() > 2 ? 2 : 1;
introCue.mixLevel = 2;
introCue.dichotomies = dichotomiesMap[startClip.getLinkName()];
if(visualSystems.size() > 0 &&
visualSystems[0].hasSound() &&
//if the first system has sound...
if(visualSystems[0].hasSound() &&
//visualSystems.size() > 0 &&
visualSystemItems[visualSystems[0].getID()].startTime == 0)
{
introCue.startTime = visualSystemItems[ visualSystems[0].getID() ].endTime;
if(visualSystems.size() > 1){
introCue.duration = visualSystemItems[ visualSystems[0].getID() ].startTime - introCue.startTime;
cout << "systemend time is [" << visualSystemItems[visualSystems[0].getID()].startTime
<< " - " << visualSystemItems[visualSystems[0].getID()].endTime << endl;
introCue.duration = visualSystemItems[ visualSystems[0].getID() ].startTime - introCue.startTime;
<< " - " << visualSystemItems[visualSystems[0].getID()].endTime << endl;
}
else {
introCue.duration = duration - introCue.startTime;
introCue.duration = duration - introCue.startTime;
}
//skip the intro cue if it overlaps a sound system
}
else {
introCue.startTime = clipItems[startClip.getLinkName()].startTime;
introCue.duration = clipItems[clips[1].getLinkName()].startTime - introCue.startTime;
}



cues.push_back(introCue);

//calculate the 2 largest delta shifts;
vector< pair<string,float> > clipDeltas;
map<string, vector<CloudsDichotomy> >::iterator it;
vector<float> lastValues;
lastValues.resize(dichotomiesBase.size());

cout << "INTRO CUE ENDS AT INDEX " << introCueEndIndex << endl;
bool firstLoop = true;
for(int i = 1; i < clips.size()-2; i++){
for(int i = introCueEndIndex; i < clips.size()-2; i++){

string clipID = clips[i].getLinkName();
float startTime = clipItems[clipID].startTime;
Expand All @@ -194,9 +193,9 @@ void CloudsAct::populateTime(){
if(!firstLoop){
//deltaChange = MAX(abs(clipDichotomy[d].balance-lastValues[d]),deltaChange);
int change = abs(clipDichotomy[d].balance - lastValues[d]);
if(change > 1){
// if(change > 1){
deltaChange += change;
}
// }
}
lastValues[d] = clipDichotomy[d].balance;
}
Expand All @@ -210,7 +209,11 @@ void CloudsAct::populateTime(){
}

sort(clipDeltas.begin(), clipDeltas.end(), delta_sort);

cout << "CALCULATED CLIP DELTAS: " << endl;
for(int i = 0; i < clipDeltas.size(); i++){
cout << " clip Delta is " << clipDeltas[i].first << " d: " << clipDeltas[i].second << endl;
}

//MOOD CUES
ofxTLFlags* sections = timeline.addFlags("Sections");
if(clipDeltas.size() >= 2){
Expand All @@ -219,37 +222,89 @@ void CloudsAct::populateTime(){
energyShiftClipIDs.push_back(clipDeltas[0].first);

float secondFlagTime = clipItems[clipDeltas[1].first].startTime;

//if the flag are too close jump
if(abs(firstFlagTime-secondFlagTime) < 60 && clipDeltas.size() > 2){

energyShiftClipIDs.push_back(clipDeltas[2].first);
secondFlagTime = clipItems[clipDeltas[2].first].startTime;
sections->addFlagAtTime(ofToString(clipDeltas[2].second), secondFlagTime*1000.);

bool addEnergyShift = true;
if(abs(firstFlagTime-secondFlagTime) < 60){
if(clipDeltas.size() > 2 && abs(firstFlagTime-clipItems[clipDeltas[2].first].startTime) > 60 ){
cout << "ENERGY SHIFT: skipping to third flag " << clipDeltas[2].first << " at time " << clipItems[clipDeltas[2].first].startTime << endl;
energyShiftClipIDs.push_back(clipDeltas[2].first);
secondFlagTime = clipItems[clipDeltas[2].first].startTime;
sections->addFlagAtTime(ofToString(clipDeltas[2].second), secondFlagTime*1000.);
}
else{
//don't add the scrunched up sound, let the existing one just play out
addEnergyShift = false;
}
}
else{
cout << "ENERGY SHIFT: second flag " << clipDeltas[1].first << " at time " << clipItems[clipDeltas[1].first].startTime << endl;
energyShiftClipIDs.push_back(clipDeltas[1].first);
sections->addFlagAtTime(ofToString(clipDeltas[1].second), secondFlagTime*1000.);
}

//Add 2 cues, act begun and mood shift
//End of intro cue
// CloudsSoundCue actCue;
// actCue.mixLevel = 1;
// actCue.startTime = clipItems[clips[introCueEndIndex].getLinkName()].startTime;
// actCue.duration = clipItems[ energyShiftClipIDs[0] ].startTime - actCue.startTime;
// actCue.dichotomies = dichotomiesMap[ clips[introCueEndIndex].getLinkName() ];
// cues.push_back(actCue);
//
// CloudsSoundCue energyShift;
// energyShift.mixLevel = 1;
// energyShift.startTime = clipItems[ energyShiftClipIDs[0] ].startTime;
// energyShift.duration = duration - energyShift.startTime;
// energyShift.dichotomies = dichotomiesMap[startClip.getLinkName()];
// cues.push_back(energyShift);


introCue.duration = clipItems[ energyShiftClipIDs[0] ].startTime - introCue.startTime;
cues.push_back(introCue);

CloudsSoundCue actCue;
actCue.mixLevel = 1;
actCue.startTime = clipItems[clips[1].getLinkName()].startTime;
actCue.duration = clipItems[ energyShiftClipIDs[0] ].startTime - actCue.startTime - 3;
actCue.dichotomies = dichotomiesMap[ clips[1].getLinkName() ];
actCue.startTime = clipItems[ energyShiftClipIDs[0] ].startTime;
if(addEnergyShift){
actCue.duration = clipItems[ energyShiftClipIDs[1] ].startTime - actCue.startTime;
}
else{
actCue.duration = duration - actCue.startTime;
}
actCue.dichotomies = dichotomiesMap[ energyShiftClipIDs[0] ];
cout << "DICHOTOMIES CONTAINED FOR ACT? " << (dichotomiesMap.find(energyShiftClipIDs[0]) != dichotomiesMap.end() ? "YES" : "NO") << endl;
cues.push_back(actCue);

CloudsSoundCue energyShift;
energyShift.mixLevel = 1;
energyShift.startTime = clipItems[ energyShiftClipIDs[0] ].startTime - 3;
energyShift.duration = duration - energyShift.startTime;
energyShift.dichotomies = dichotomiesMap[startClip.getLinkName()];
cues.push_back(energyShift);

if(addEnergyShift){
CloudsSoundCue energyShift;
energyShift.mixLevel = 1;
energyShift.startTime = clipItems[ energyShiftClipIDs[1] ].startTime;
energyShift.duration = duration - energyShift.startTime;
energyShift.dichotomies = dichotomiesMap[ energyShiftClipIDs[1] ];
cout << "DICHOTOMIES CONTAINED FOR ENERGY SHIFT? " << (dichotomiesMap.find(energyShiftClipIDs[1]) != dichotomiesMap.end() ? "YES" : "NO") << endl;
cues.push_back(energyShift);
}
}
else {
//change at the one delta we calculated
if(clipDeltas.size() > 0){
introCue.duration = duration - clipItems[ clipDeltas[0].first ].startTime;
cues.push_back(introCue);

CloudsSoundCue energyShift;
energyShift.mixLevel = 1;
energyShift.startTime = clipItems[ clipDeltas[0].first ].startTime;
energyShift.duration = duration - energyShift.startTime;
energyShift.dichotomies = dichotomiesMap[ clipDeltas[0].first ];
cues.push_back(energyShift);
cout << "DICHOTOMIES CONTAINED FOR ENERGY SHIFT? " << (dichotomiesMap.find(clipDeltas[0].first) != dichotomiesMap.end() ? "YES" : "NO") << endl;
}
//or we have no deltas so just play the intor
else{
introCue.duration = duration - introCue.startTime;
cues.push_back(introCue);
}
ofLogError("CloudsAct::populateTime") << "Not enough clips to create section markers";
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@
2A4F33D71863C64B0070C0ED /* CloudsMixer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CloudsMixer.h; sourceTree = "<group>"; };
3D2EA006174C16EC002D9E02 /* ofxGameCamera.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ofxGameCamera.cpp; sourceTree = "<group>"; };
3D2EA007174C16EC002D9E02 /* ofxGameCamera.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ofxGameCamera.h; sourceTree = "<group>"; };
85E578C818867CEC0032E713 /* CloudsPortal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CloudsPortal.h; path = ../../CloudsLibrary/src/RGBD/Portal/CloudsPortal.h; sourceTree = "<group>"; };
85E578C818867CEC0032E713 /* CloudsPortal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CloudsPortal.h; path = RGBD/Portal/CloudsPortal.h; sourceTree = "<group>"; };
BBAB23BE13894E4700AA2426 /* GLUT.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = GLUT.framework; path = ../../../libs/glut/lib/osx/GLUT.framework; sourceTree = "<group>"; };
C102654C182EBDA900C7F895 /* CloudsSound.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CloudsSound.cpp; sourceTree = "<group>"; };
C102654D182EBDA900C7F895 /* CloudsSound.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CloudsSound.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -671,7 +671,6 @@
E779B6AB173D4DC8006357EF /* ofxCv */,
E7637D8F17359DED008ADC62 /* ofxUI */,
E745F6E31720FE9400B86D7E /* ofxXmlSettings */,
E745F6C61720FE0E00B86D7E /* CloudsLibrary */,
);
name = addons;
sourceTree = "<group>";
Expand Down Expand Up @@ -802,7 +801,7 @@
E4B69E1C0A3A1BDC003C02F2 /* src */ = {
isa = PBXGroup;
children = (
85E578C818867CEC0032E713 /* CloudsPortal.h */,
E745F6C61720FE0E00B86D7E /* CloudsLibrary */,
E4B69E1D0A3A1BDC003C02F2 /* main.cpp */,
E4B69E1F0A3A1BDC003C02F2 /* testApp.h */,
E4B69E1E0A3A1BDC003C02F2 /* testApp.cpp */,
Expand Down Expand Up @@ -843,14 +842,15 @@
E745F6CA1720FE0E00B86D7E /* src */,
);
name = CloudsLibrary;
path = ../CloudsLibrary;
path = ../../CloudsLibrary;
sourceTree = "<group>";
};
E745F6CA1720FE0E00B86D7E /* src */ = {
isa = PBXGroup;
children = (
186B68AC17EA1E6C0020C952 /* CloudsRGBDVideoPlayer.h */,
E7A89755182ED4FB00363188 /* CloudsRGBDVideoPlayer.cpp */,
85E578C818867CEC0032E713 /* CloudsPortal.h */,
1877A9F9178F417A006DAA37 /* CloudsGlobal.h */,
C102654B182EBDA900C7F895 /* Sound */,
E7637D401734DE68008ADC62 /* StoryEngine */,
Expand Down

0 comments on commit 4c0040b

Please sign in to comment.