Beispiel #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);
}
Beispiel #2
0
void MLDrawing::resizeWidget(const MLRect& b, const int u)
{
	// adapt vrect to juce rect
	Component* pC = getComponent();
	if(pC)
	{
		MLRect bb = b + mPixelOffset;
		if (bb.height() == 0) bb.setHeight(1);
		if (bb.width() == 0) bb.setWidth(1);
	
		// adapt vrect to juce rect
		Rectangle<int> c(bb.left(), bb.top(), bb.width(), bb.height());
		
		pC->setBounds(c);
	}
	
	// iterate over points
	int size = mGridPoints.size();
	for(int i = 0; i<size; ++i)
	{
		mTransformedPoints[i] = mGridPoints[i]*u;
//debug() << "pt. " << i << ":" << mTransformedPoints[i] <<  " ";
	}
//debug() << "\n";
}
Beispiel #3
0
void MLPanel::resizeWidget(const MLRect& b, const int)
{
    Component* pC = getComponent();
    if(pC)
    {
        // adapt vrect to juce rect
        Rectangle<int> c(b.left(), b.top(), b.width(), b.height());
        pC->setBounds(c);
    }
}
Beispiel #4
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);
}
Beispiel #5
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();
	}
}
Beispiel #7
0
void MLMultiSlider::mouseDrag(const MouseEvent& e)
{
	MLRect r = mPos.getLocalOutline();	
	float w = r.width();
	float h = r.height();
	
	int mx = ml::clamp(e.x, (int)r.left() + 1, (int)(r.left() + w));
	int my = ml::clamp(e.y, (int)r.top() + 1, (int)(r.top() + h));
	int dials = getNumSliders();
	int s = getSliderUnderPoint(Vec2(mx, my));
	
    if (isEnabled())
    {	
		if (ml::within(s, 0, dials))
		{
			const int mousePos = mVertical ? my : mx;
			float val;
			MLRange posRange;
			if (mVertical)
			{
				posRange.set(h, 1);
			}
			else
			{
				posRange.set(1, w);
			}
			posRange.convertTo(mRange);
			val = posRange(mousePos);
			
			// if dial changed in drag, interpolate, setting dials in between
			if((mCurrDragSlider >= 0) && (mCurrDragSlider != s)) 			
			{
				int span = (s - mCurrDragSlider);
				int dir = sign(span);
				float mix, mixedval;
				int startDrag = mCurrDragSlider + dir;
				int endDrag = s + dir;
				for(int i=startDrag; i != endDrag; i += dir)
				{
					mix = fabs(float(i - startDrag)/float(span));
					mixedval = lerp(mCurrDragValue, val, mix);
	
					// finish old drag and switch to dragging new dial
					if (i != mCurrDragSlider)
					{
						mCurrDragSlider = i;
					}
					sendSliderAction(snapValue (mixedval, false), i);
				}
			}
			else if (mCurrDragSlider == s) // set current drag dial
			{
				sendSliderAction(snapValue (val, false), s);
			}
			
			if (s != mSliderUnderMouse)
			{
				mSliderUnderMouse = s;
				repaint();
			}
			mCurrDragSlider = s;
			mCurrDragValue = val;
		}	
    }
}