Esempio n. 1
0
// add the entire signal b to this signal, at the subpixel destination offset. 
// 
void MLSignal::add2D(const MLSignal& b, const Vec2& destOffset)
{
	MLSignal& a = *this;
		
	Vec2 iDestOffset, fDestOffset;
	destOffset.getIntAndFracParts(iDestOffset, fDestOffset);
	
	int destX = iDestOffset[0];
	int destY = iDestOffset[1];	
	float srcPosFX = fDestOffset[0];
	float srcPosFY = fDestOffset[1];
	
	MLRect srcRect(0, 0, b.getWidth() + 1, b.getHeight() + 1); // add (1, 1) for interpolation
	MLRect destRect = srcRect.translated(iDestOffset).intersect(getBoundsRect());
	
	for(int j=destRect.top(); j<destRect.bottom(); ++j)
	{
		for(int i=destRect.left(); i<destRect.right(); ++i)
		{
			a(i, j) += b.getInterpolatedLinear(i - destX - srcPosFX, j - destY - srcPosFY);
		}
	}

	setConstant(false);
}
Esempio n. 2
0
// add the entire signal b to this signal, at the integer destination offset. 
// 
void MLSignal::add2D(const MLSignal& b, int destX, int destY)
{
	MLSignal& a = *this;
	MLRect srcRect(0, 0, b.getWidth(), b.getHeight());
	MLRect destRect = srcRect.translated(Vec2(destX, destY)).intersect(getBoundsRect());
	
	for(int j=destRect.top(); j<destRect.bottom(); ++j)
	{
		for(int i=destRect.left(); i<destRect.right(); ++i)
		{
			a(i, j) += b(i - destX, j - destY);
		}
	}

	setConstant(false);
}
Esempio n. 3
0
void MLSignal::dump(std::ostream& s, const MLRect& b) const
{
	const MLSignal& f = *this;
	{
        s << std::fixed << std::setprecision(3);
		for (int j=b.top(); j< b.bottom(); ++j)
		{
			s << j << " | ";
			for(int i=b.left(); i< b.right(); ++i)
			{
				s << f(i, j) << " ";
			}
			s << "\n";
		}
	}
}
void SoundplaneTouchGraphView::renderTouchBarGraphs()
{
	if (!mpModel) return;
	if (!isShowing()) return;
    
    int viewW = getBackingLayerWidth();
    int viewH = getBackingLayerHeight();
	
	const MLSignal& currentTouch = mpModel->getTouchFrame();
	const MLSignal& touchHistory = mpModel->getTouchHistory();
	const int frames = mpModel->getFloatProperty("max_touches");
	if (!frames) return;
		
	const Colour c = findColour(MLLookAndFeel::backgroundColor);
	float p = c.getBrightness();
		
	int margin = viewH / 30;
	int numSize = margin*2;
	int left = margin*2 + numSize;
	
	int right = viewW - margin;
	int top = margin;
	int bottom = viewH - margin;
	
	int frameWidth = right - left;
	int frameOffset = (bottom - top)/frames;
	int frameHeight = frameOffset - margin;
	MLRect frameSize(0, 0, frameWidth, frameHeight);		

    MLGL::orthoView(viewW, viewH);
	for(int j=0; j<frames; ++j)
	{
		// draw frames
		p = 0.9f;
		glColor4f(p, p, p, 1.0f);
		MLRect fr = frameSize.translated(Vec2(left, margin + j*frameOffset));
		MLGL::fillRect(fr);	
		p = 0.6f;
		glColor4f(p, p, p, 1.0f);
        MLGL::strokeRect(fr);
		
		// draw touch activity indicators at left
		glColor4fv(MLGL::getIndicatorColor(j));
		MLRect r(0, 0, numSize, numSize);		
		MLRect tr = r.translated(Vec2(margin, margin + j*frameOffset + (frameHeight - numSize)/2));				
		int age = currentTouch(4, j);		
		if (age > 0)
			MLGL::fillRect(tr);	
		else
			MLGL::strokeRect(tr);
			
		// draw history	
		MLRange frameXRange(fr.left(), fr.right());
		frameXRange.convertTo(MLRange(0, (float)kSoundplaneHistorySize));		
		MLRange frameYRange(0, 1);
		frameYRange.convertTo(MLRange(fr.bottom(), fr.top()));
		
		glBegin(GL_LINES);
		for(int i=fr.left() + 1; i<fr.right()-1; ++i)
		{
			int time = frameXRange(i);			
			float force = touchHistory(2, j, time);
	//		float d = touchHistory(3, j, time);
	//		int age = touchHistory(4, j, time);
			float y = frameYRange.convert(force);
	//		float drawY = (age > 0) ? y : 0.;	
	//		y = frameYRange.convert(d);
			
			// draw line
			glVertex2f(i, fr.bottom());	
			glVertex2f(i, y);	
		}
		glEnd();
	}
}