| 712 | } |
| 713 | |
| 714 | void DurationController::handleOscOut(){ |
| 715 | |
| 716 | if(!settings.oscOutEnabled){ |
| 717 | return; |
| 718 | } |
| 719 | |
| 720 | unsigned long bundleTime = recordTimer.getAppTimeMillis(); |
| 721 | if(lastOSCBundleSent+oscFrequency > bundleTime){ |
| 722 | return; |
| 723 | } |
| 724 | //cout << "OSC RATE IS " << settings.oscRate << " osc FREQUENCY is " << oscFrequency << " sending num at record timer " << recordTimer.getAppTimeMillis() << endl; |
| 725 | |
| 726 | unsigned long timelineSampleTime = timeline.getCurrentTimeMillis(); |
| 727 | int numMessages = 0; |
| 728 | ofxOscBundle bundle; |
| 729 | |
| 730 | //lock(); |
| 731 | vector<ofxTLPage*>& pages = timeline.getPages(); |
| 732 | for(int i = 0; i < pages.size(); i++){ |
| 733 | vector<ofxTLTrack*>& tracks = pages[i]->getTracks(); |
| 734 | for(int t = 0; t < tracks.size(); t++){ |
| 735 | ofPtr<ofxTLUIHeader> header = headers[tracks[t]->getName()]; |
| 736 | if(!header->sendOSC()){ |
| 737 | continue; |
| 738 | } |
| 739 | unsigned long trackSampleTime = tracks[t]->getIsPlaying() ? tracks[t]->currentTrackTime() : timelineSampleTime; |
| 740 | string trackType = tracks[t]->getTrackType(); |
| 741 | if(trackType == "Curves" || trackType == "Switches" || trackType == "Colors" || trackType == "Audio" || trackType == "LFO"){ |
| 742 | bool messageValid = false; |
| 743 | ofxOscMessage m; |
| 744 | if(trackType == "Curves" || trackType == "LFO"){ |
| 745 | ofxTLKeyframes* curves = (ofxTLKeyframes*)tracks[t]; |
| 746 | float value = curves->getValueAtTimeInMillis(trackSampleTime); |
| 747 | if(value != header->lastFloatSent || !header->hasSentValue || refreshAllOscOut){ |
| 748 | m.addFloatArg(value); |
| 749 | header->lastFloatSent = value; |
| 750 | header->hasSentValue = true; |
| 751 | messageValid = true; |
| 752 | } |
| 753 | } |
| 754 | else if(trackType == "Switches"){ |
| 755 | ofxTLSwitches* switches = (ofxTLSwitches*)tracks[t]; |
| 756 | bool on = switches->isOnAtMillis(trackSampleTime); |
| 757 | if(on != header->lastBoolSent || !header->hasSentValue || refreshAllOscOut){ |
| 758 | m.addIntArg(on ? 1 : 0); |
| 759 | header->lastBoolSent = on; |
| 760 | header->hasSentValue = true; |
| 761 | messageValid = true; |
| 762 | } |
| 763 | } |
| 764 | else if(trackType == "Colors"){ |
| 765 | ofxTLColorTrack* colors = (ofxTLColorTrack*)tracks[t]; |
| 766 | ofColor color = colors->getColorAtMillis(trackSampleTime); |
| 767 | if(color != header->lastColorSent || !header->hasSentValue || refreshAllOscOut){ |
| 768 | m.addIntArg(color.r); |
| 769 | m.addIntArg(color.g); |
| 770 | m.addIntArg(color.b); |
| 771 | header->lastColorSent = color; |
nothing calls this directly
no test coverage detected