Skip to content

Commit

Permalink
gap for cadence, update clipStartTime
Browse files Browse the repository at this point in the history
  • Loading branch information
samatt committed Oct 15, 2013
1 parent 14f5951 commit 64c395f
Show file tree
Hide file tree
Showing 6 changed files with 96 additions and 32 deletions.
7 changes: 6 additions & 1 deletion CloudsData/storyEngineParameters/vsGui.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<Widget>
<Kind>4</Kind>
<Name>MAX VS RUNTIME</Name>
<Value>14.187191963</Value>
<Value>30.738916397</Value>
</Widget>
<Widget>
<Kind>4</Kind>
Expand All @@ -35,3 +35,8 @@
<Name>LONG CLIP FAD IN %</Name>
<Value>0.500000000</Value>
</Widget>
<Widget>
<Kind>4</Kind>
<Name>CADENCE FOR TOPIC CHANGE</Name>
<Value>10.000000000</Value>
</Widget>
71 changes: 47 additions & 24 deletions CloudsLibrary/src/StoryEngine/CloudsAct.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,13 @@ void CloudsAct::populateTime(){
timeline.setDurationInSeconds(duration);
topicsTrack = timeline.addFlags("Topics");
visualSystemsTrack = timeline.addFlags("Visual Systems");
vsGapsTrack = timeline.addFlags("VS Gap");
clipsTrack = timeline.addFlags("Clips");
difficultyTrack = timeline.addFlags("Clip Difficulty");
clipPreRollTrack = timeline.addFlags("Clip PreRoll Flags");
questionsTrack = timeline.addFlags("Questions");




timeline.setInPointAtSeconds(0);
string previousTopic = "";
Expand All @@ -61,7 +63,7 @@ void CloudsAct::populateTime(){

clipsTrack->addFlagAtTime(item.key, item.startTime * 1000);
clipsTrack->addFlagAtTime(" ", item.endTime * 1000);

difficultyTrack->addFlagAtTime(clipDifficultyMap[item.key], item.startTime * 1000);
if(currentTopic != previousTopic){
topicsTrack->addFlagAtTime(currentTopic, item.startTime * 1000);
Expand All @@ -88,22 +90,25 @@ void CloudsAct::populateTime(){
}
else{
visualSystemsTrack->addFlagAtTime("outro :" + item.key, item.outroStartTime * 1000);
visualSystemsTrack->addFlagAtTime("end :" + item.key, item.endTime * 1000);
}
}
else if(item.type == PreRoll){
clipPreRollTrack->addFlagAtTime(item.key, item.startTime * 1000);
}
else if (item.type == Gap){
//nothing for now
vsGapsTrack->addFlagAtTime("gap start:" + item.key, item.startTime * 1000);
vsGapsTrack->addFlagAtTime("gap end:" + item.key, item.endTime * 1000);
// SM: Just doing this to display on the timeline. No events sent to the playback controller.
}
else if(item.type == Question){
questionsTrack->addFlagAtTime(item.key, item.startTime*1000);
}
}

topicDurationMap[previousTopic] = duration - currentTopicStartTime;


ofAddListener(timeline.events().bangFired, this, &CloudsAct::timelineEventFired);
ofAddListener(timeline.events().playbackEnded, this, &CloudsAct::timelineStopped);
}
Expand Down Expand Up @@ -143,7 +148,7 @@ void CloudsAct::timelineEventFired(ofxTLBangEventArgs& bang){
vector<string> clipName = ofSplitString(bang.flag, "%");
cout<<"sending clip: "<<clipName[1] <<" with Offset: "<< actItemsMap[bang.flag].handleLength << endl;
CloudsPreRollEventArgs args(clipMap[clipName[1]],actItemsMap[bang.flag].handleLength);
ofNotifyEvent(events.preRollRequested, args);
ofNotifyEvent(events.preRollRequested, args);
}
else if(bang.track == topicsTrack){
cout<<"sending topic: "<<bang.flag <<" with duration: "<< topicDurationMap[bang.flag] << endl;
Expand Down Expand Up @@ -239,7 +244,7 @@ void CloudsAct::addClip(CloudsClip clip, string topic, float startTime, float ha
else{
clipDifficulty = "medium";
}
// cout<<"added " <<clip.getLinkName()<< " to clip map "<<endl;
// cout<<"added " <<clip.getLinkName()<< " to clip map "<<endl;
ActTimeItem item;

item.type = Clip;
Expand All @@ -253,7 +258,7 @@ void CloudsAct::addClip(CloudsClip clip, string topic, float startTime, float ha
dichotomiesMap[item.key] = currentDichotomiesBalance;
clipItems[clip.getLinkName()] = item;
clipDifficultyMap[clip.getLinkName()] =clipDifficulty;


}

Expand All @@ -272,7 +277,7 @@ void CloudsAct::addClip(CloudsClip clip, string topic, float startTime){
else{
clipDifficulty = "medium";
}
// cout<<"added " <<clip.getLinkName()<< " to clip map "<<endl;
// cout<<"added " <<clip.getLinkName()<< " to clip map "<<endl;
ActTimeItem item;

item.type = Clip;
Expand All @@ -285,19 +290,33 @@ void CloudsAct::addClip(CloudsClip clip, string topic, float startTime){
actItems.push_back(item);
actItemsMap[item.key] = item;
clipItems[clip.getLinkName()] = item;
clipDifficultyMap[clip.getLinkName()] =clipDifficulty;
clipDifficultyMap[clip.getLinkName()] =clipDifficulty;
}

void CloudsAct:: updateClipStartTime(CloudsClip clip, float startTime,float handleLength, string topic){
for(int i =0; i<actItems.size(); i++){
if(actItems[i].type == Clip && actItems[i].key == clip.getLinkName()){

cout<<"updating clip start time for clip : "<<clip.getLinkName()<<" to account for VS gap"<<endl;
actItems[i].startTime = startTime;
//defaulting handle length to 1
actItems[i].endTime = startTime+clip.getDuration() + 1;
}

}
}

void CloudsAct::addVisualSystem(CloudsVisualSystemPreset preset, float startTime, float duration){
visualSystems.push_back(preset);
visualSystemsMap[preset.getID()] = preset;

// cout<<"added " <<preset.getID()<< " to VS map "<<endl;
// cout<<"added " <<preset.getID()<< " to VS map "<<endl;
ActTimeItem item;
// start the visual system halfway through the clip
float vsStartTime = startTime;
item.type = VS;
item.key =preset.getID();

item.key =preset.getID() ;
item.startTime = vsStartTime;
item.endTime = vsStartTime + duration;
item.introEndTime = vsStartTime + preset.introDuration;
Expand All @@ -310,16 +329,27 @@ void CloudsAct::addVisualSystem(CloudsVisualSystemPreset preset, float startTime
visualSystemItems[preset.getID()] = item;
}

void CloudsAct::addGapForVisualSystem(float startTime){
void CloudsAct::addGapForCadence(CloudsVisualSystemPreset preset,float startTime,float duration){
ActTimeItem item;
item.key = preset.getID();
item.type = Gap;
item.startTime = startTime;
item.endTime = startTime + visualSystemDuration;

duration = MAX(item.endTime, duration);

item.endTime = startTime + duration;
updateVsEndTime(preset, duration);
actItems.push_back(item);

}

void CloudsAct::updateVsEndTime(CloudsVisualSystemPreset preset, float newEndTime){
for(int i =0; i<actItems.size(); i++){
if(actItems[i].type == VS && actItems[i].key == preset.getID()){

actItems[i].outroStartTime += newEndTime;
actItems[i].endTime += newEndTime;

}
}

}
void CloudsAct::addClipPreRollFlag(float preRollFlagTime, float clipHandleLength, string clipName){
ActTimeItem item;
Expand Down Expand Up @@ -379,13 +409,6 @@ string CloudsAct::getTopicForClip(CloudsClip& clip){
return topicMap[ clip.getLinkName() ];
}

//vector<string>& CloudsAct::getAllTopics(){
// return topicHistory;
//}

//void CloudsAct::addTopicToHistory(string topic){
// topicHistory.push_back(topic);
//}

void CloudsAct::setTopicForClip(string topic, string clipName)
{
Expand Down
5 changes: 4 additions & 1 deletion CloudsLibrary/src/StoryEngine/CloudsAct.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ class CloudsAct{
CloudsVisualSystemPreset& getVisualSystemInAct(int index);
void addClip(CloudsClip clip, string topic, float startTime);
void addClip(CloudsClip clip, string topic, float startTime, float handleLength,vector<CloudsDichotomy> currentDichotomiesBalance);
void addGapForVisualSystem(float startTime);
void addGapForCadence(CloudsVisualSystemPreset preset,float startTime, float duration);
void updateClipStartTime(CloudsClip clip, float startTime, float handleLength,string topic);
void addQuestion(CloudsClip clip, float startTime);
void addVisualSystem(CloudsVisualSystemPreset preset, float startTime, float duration);
void addClipPreRollFlag(float preRollFlagTime, float clipHandleLength, string clipName);
Expand All @@ -91,6 +92,7 @@ class CloudsAct{

void removeQuestionAtTime(float startTime, float endTime);
void removeActItem(ActTimeItem item);
void updateVsEndTime(CloudsVisualSystemPreset preset, float newEndTime);
ActTimeItem& getItemForClip(CloudsClip& clip);
ActTimeItem& getItemForVisualSystem(CloudsVisualSystemPreset& preset);

Expand All @@ -114,6 +116,7 @@ class CloudsAct{
ofxTLFlags* topicsTrack;
ofxTLFlags* questionsTrack;
ofxTLFlags* difficultyTrack;
ofxTLFlags* vsGapsTrack;

ActItemType itemType;

Expand Down
37 changes: 34 additions & 3 deletions CloudsLibrary/src/StoryEngine/CloudsStoryEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,12 @@ CloudsStoryEngine::CloudsStoryEngine(){
longClipThreshold = 30;
longClipFadeInPercent = .5;
actLength = 10 * 60;
cadenceForTopicChangeMultiplier = 10;

lastClipSharesTopicBoost = 10;
twoClipsAgoSharesTopicBoost = 10;


topicRelevancyMultiplier = 100;
topicsInCommonMultiplier = 10;
topicsinCommonWithPreviousMultiplier = 5;
Expand Down Expand Up @@ -187,6 +189,7 @@ void CloudsStoryEngine::initGui(){
vsGui->addSlider("MAX VS GAPTIME", 0, 60, &maxVisualSystemGapTime);
vsGui->addSlider("LONG CLIP THRESHOLD", 0, 100,&longClipThreshold);
vsGui->addSlider("LONG CLIP FAD IN %", 0.0, 1.0, &longClipFadeInPercent);
vsGui->addSlider("CADENCE FOR TOPIC CHANGE", 1, 30, &cadenceForTopicChangeMultiplier);
vsGui->autoSizeToFitWidgets();

string filePath;
Expand Down Expand Up @@ -486,17 +489,44 @@ CloudsAct* CloudsStoryEngine::buildAct(CloudsRun run, CloudsClip& seed, string t
visualSystemDuration = clipStartTime - visualSystemStartTime;

if(isPresetIndefinite){
if(visualSystemDuration > systemMaxRunTime || topic != previousTopic){
//if the indefinite visual system has gone greater than the max run time end the system
// and add to the act
if(visualSystemDuration > systemMaxRunTime ){
if(clip.getDuration() > longClipThreshold){
visualSystemDuration += clip.getDuration()*longClipFadeInPercent;
visualSystemDuration += clip.getDuration()*longClipFadeInPercent;

}

act->addVisualSystem(currentPreset, visualSystemStartTime, visualSystemDuration);
act->removeQuestionAtTime(visualSystemStartTime, visualSystemDuration);
systemRunning = false;
lastVisualSystemEnded = visualSystemStartTime + visualSystemDuration;
}

//if the topic has changed and the system is still running extend the visual system, push back the clip start time
//and then start the new topic after that
else if(topic != previousTopic && systemRunning ){
float gapTimeForTopicChange =cadenceForTopicChangeMultiplier;

cout<<"Adding gap to respect topic change: "<< clip.getLinkName()<<endl;
//updating totalSecondsEnqueued here may not be the best way to do this
totalSecondsEnqueued +=cadenceForTopicChangeMultiplier;

//pushing back clip start time to account for new gap
act->updateClipStartTime(clip, totalSecondsEnqueued,clipHandleDuration, topic);
float test = totalSecondsEnqueued + clip.getDuration() + ( gapLengthMultiplier * clip.getDuration() ) + clipHandleDuration * 2;

act->addVisualSystem(currentPreset, visualSystemStartTime, visualSystemDuration );
act->addGapForCadence(currentPreset,visualSystemStartTime + visualSystemDuration, gapTimeForTopicChange);

act->removeQuestionAtTime(visualSystemStartTime, visualSystemDuration);
systemRunning = false;
lastVisualSystemEnded = visualSystemStartTime + visualSystemDuration;

}

}
//if the definite visual system duartion has been exceeded end the system and add to the act
else{
if(visualSystemDuration > definitePresetEndTime ){
definitePresetEndTime = 0;
Expand Down Expand Up @@ -545,6 +575,7 @@ CloudsAct* CloudsStoryEngine::buildAct(CloudsRun run, CloudsClip& seed, string t


//TODO: be aware if you have ended on a fixed duration VS to respect its duration
//SM:(I think we are doing this now?)
if(systemRunning){

float clipStartTime = act->getItemForClip(act->getClip(act->getAllClips().size()-1)).startTime;
Expand Down
2 changes: 2 additions & 0 deletions CloudsLibrary/src/StoryEngine/CloudsStoryEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ class CloudsStoryEngine {
float longClipThreshold;
float longClipFadeInPercent;
float getHandleForClip(CloudsClip& clip);
float cadenceForTopicChangeMultiplier;

//Story engine decision making parameters
float topicsInCommonMultiplier;
Expand All @@ -108,6 +109,7 @@ class CloudsStoryEngine {
float offTopicFactor;
float distantClipSuppressionFactor;


//Topic selection parameters
float topicRelevancyMultiplier;
float lastClipSharesTopicBoost;
Expand Down
6 changes: 3 additions & 3 deletions VSThingsInTheDark/ThingsInTheDark.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@
E45BE9770E8CC7DD009D7055 /* CoreServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreServices.framework; path = /System/Library/Frameworks/CoreServices.framework; sourceTree = "<absolute>"; };
E45BE9790E8CC7DD009D7055 /* OpenGL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGL.framework; path = /System/Library/Frameworks/OpenGL.framework; sourceTree = "<absolute>"; };
E45BE97A0E8CC7DD009D7055 /* QuickTime.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuickTime.framework; path = /System/Library/Frameworks/QuickTime.framework; sourceTree = "<absolute>"; };
E4B69B5B0A3A1756003C02F2 /* VSSeeingDarkDebug.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = VSSeeingDarkDebug.app; sourceTree = BUILT_PRODUCTS_DIR; };
E4B69B5B0A3A1756003C02F2 /* ThingsInTheDarkDebug.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ThingsInTheDarkDebug.app; sourceTree = BUILT_PRODUCTS_DIR; };
E4B69E1D0A3A1BDC003C02F2 /* main.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = main.cpp; path = src/main.cpp; sourceTree = SOURCE_ROOT; };
E4B69E1E0A3A1BDC003C02F2 /* testApp.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 30; name = testApp.cpp; path = src/testApp.cpp; sourceTree = SOURCE_ROOT; };
E4B69E1F0A3A1BDC003C02F2 /* testApp.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = testApp.h; path = src/testApp.h; sourceTree = SOURCE_ROOT; };
Expand Down Expand Up @@ -505,7 +505,7 @@
E4EEC9E9138DF44700A80321 /* openFrameworks */,
BB4B014C10F69532006C3DED /* addons */,
E45BE5980E8CC70C009D7055 /* frameworks */,
E4B69B5B0A3A1756003C02F2 /* VSSeeingDarkDebug.app */,
E4B69B5B0A3A1756003C02F2 /* ThingsInTheDarkDebug.app */,
);
sourceTree = "<group>";
};
Expand Down Expand Up @@ -1124,7 +1124,7 @@
);
name = ThingsInTheDark;
productName = myOFApp;
productReference = E4B69B5B0A3A1756003C02F2 /* VSSeeingDarkDebug.app */;
productReference = E4B69B5B0A3A1756003C02F2 /* ThingsInTheDarkDebug.app */;
productType = "com.apple.product-type.application";
};
/* End PBXNativeTarget section */
Expand Down

0 comments on commit 64c395f

Please sign in to comment.