@@ -146,13 +146,15 @@ void moSonogram::drawObjectContent(ofTrueTypeFont *font, shared_ptr<ofBaseGLRend
146146 ofPushMatrix ();
147147 ofSetColor (0 ,0 ,0 ,0 );
148148 ofDrawRectangle (0 ,0 ,static_cast <ofTexture *>(_outletParams[0 ])->getWidth (),static_cast <ofTexture *>(_outletParams[0 ])->getHeight ());
149- for (size_t s=0 ;s<static_cast <size_t >(static_cast <vector<float > *>(_inletParams[0 ])->size ());s++){
150- float valueDB = log10 (ofMap (static_cast <vector<float > *>(_inletParams[0 ])->at (s),0 .0f ,1 .0f ,1 .0f ,10 .0f ,true ));
151- int colorIndex = static_cast <int >(floor (ofMap (valueDB,0 .0f ,1 .0f ,0 ,colors.size ()-1 ,true )));
152- ofSetColor (0 );
153- ofDrawRectangle (timePosition,ofMap (s,0 ,static_cast <int >(static_cast <vector<float > *>(_inletParams[0 ])->size ()),static_cast <ofTexture *>(_outletParams[0 ])->getHeight (),0 ,true ),1 ,1 );
154- ofSetColor (colors.at (colorIndex),255 *valueDB);
155- ofDrawRectangle (timePosition,ofMap (s,0 ,static_cast <int >(static_cast <vector<float > *>(_inletParams[0 ])->size ()),static_cast <ofTexture *>(_outletParams[0 ])->getHeight (),0 ,true ),1 ,1 );
149+ if (!static_cast <vector<float > *>(_inletParams[0 ])->empty ()){
150+ for (size_t s=0 ;s<static_cast <size_t >(static_cast <vector<float > *>(_inletParams[0 ])->size ());s++){
151+ float valueDB = log10 (ofMap (static_cast <vector<float > *>(_inletParams[0 ])->at (s),0 .0f ,1 .0f ,1 .0f ,10 .0f ,true ));
152+ int colorIndex = static_cast <int >(floor (ofMap (valueDB,0 .0f ,1 .0f ,0 ,colors.size ()-1 ,true )));
153+ ofSetColor (0 );
154+ ofDrawRectangle (timePosition,ofMap (s,0 ,static_cast <int >(static_cast <vector<float > *>(_inletParams[0 ])->size ()),static_cast <ofTexture *>(_outletParams[0 ])->getHeight (),0 ,true ),1 ,1 );
155+ ofSetColor (colors.at (colorIndex),255 *valueDB);
156+ ofDrawRectangle (timePosition,ofMap (s,0 ,static_cast <int >(static_cast <vector<float > *>(_inletParams[0 ])->size ()),static_cast <ofTexture *>(_outletParams[0 ])->getHeight (),0 ,true ),1 ,1 );
157+ }
156158 }
157159 ofPopMatrix ();
158160 ofPopStyle ();
0 commit comments