コード例 #1
0
ファイル: FilterEditor.cpp プロジェクト: eliezyer/plugin-GUI
void FilterEditor::setDefaults(double lowCut, double highCut)
{
    lastHighCutString = String(roundFloatToInt(highCut));
    lastLowCutString = String(roundFloatToInt(lowCut));

    resetToSavedText();
}
コード例 #2
0
//==============================================================================
void PianoGridKeyboard::getKeyPosition (int midiNoteNumber, float keyWidth, int& x, int& w) const
{
    jassert (midiNoteNumber >= 0 && midiNoteNumber < 128);

    static const float blackNoteWidth = 0.7f;

    static const float notePos[] = { 0.0f, 1 - blackNoteWidth * 0.6f,
                                     1.0f, 2 - blackNoteWidth * 0.4f,
                                     2.0f,
                                     3.0f, 4 - blackNoteWidth * 0.7f,
                                     4.0f, 5 - blackNoteWidth * 0.5f,
                                     5.0f, 6 - blackNoteWidth * 0.3f,
                                     6.0f };

    static const float widths[] = { 1.0f, blackNoteWidth,
                                    1.0f, blackNoteWidth,
                                    1.0f,
                                    1.0f, blackNoteWidth,
                                    1.0f, blackNoteWidth,
                                    1.0f, blackNoteWidth,
                                    1.0f };

    const int octave = midiNoteNumber / 12;
    const int note = midiNoteNumber % 12;

    x = roundFloatToInt ((octave * 7.0f * keyWidth) + notePos [note] * keyWidth);
    w = roundFloatToInt (widths [note] * keyWidth);
}
コード例 #3
0
ファイル: FilterEditor.cpp プロジェクト: KepecsLab/GUI
void FilterEditor::setDefaults(double lowCut, double highCut)
{
    lastHighCutString = String(roundFloatToInt(highCut));
    lastLowCutString = String(roundFloatToInt(lowCut));

    highCutValue->setText(lastHighCutString, dontSendNotification);
    lowCutValue->setText(lastLowCutString, dontSendNotification);
}
コード例 #4
0
const int CtrlrXYSurface::getValueForPosition(const int position, const bool forX)
{
	const bool flip		= forX ? (bool)getProperty(Ids::uiXYSuraceXFlip) : (bool)getProperty(Ids::uiXYSuraceYFlip);
	const float scale	= forX ? (float)getProperty(Ids::uiXYSurfaceMaxX) : (float)getProperty(Ids::uiXYSurfaceMaxY);
	const float dim		= forX ? (float)usableRectangle.getWidth() : (float)usableRectangle.getHeight();

	return (flip ? (scale - roundFloatToInt (scale / dim * position)) : roundFloatToInt (scale / dim * position));
}
コード例 #5
0
ファイル: juce_AudioThumbnail.cpp プロジェクト: Krewn/LIOS
    inline void setFloat (const float newMin, const float newMax) noexcept
    {
        values[0] = (char) jlimit (-128, 127, roundFloatToInt (newMin * 127.0f));
        values[1] = (char) jlimit (-128, 127, roundFloatToInt (newMax * 127.0f));

        if (values[0] == values[1])
        {
            if (values[1] == 127)
                values[0]--;
            else
                values[1]++;
        }
    }
コード例 #6
0
ファイル: juce_AudioThumbnail.cpp プロジェクト: 0x4d52/JUCE
    inline void setFloat (Range<float> newRange) noexcept
    {
        values[0] = (int8) jlimit (-128, 127, roundFloatToInt (newRange.getStart() * 127.0f));
        values[1] = (int8) jlimit (-128, 127, roundFloatToInt (newRange.getEnd()   * 127.0f));

        if (values[0] == values[1])
        {
            if (values[1] == 127)
                values[0]--;
            else
                values[1]++;
        }
    }
コード例 #7
0
void MidiGrid::setIndicatorPosition (const float newPosition)
{
    int newX = roundFloatToInt (newPosition * getWidth());

    indicator->setBounds (newX, 0, 2, getHeight());
    indicator->toFront (false);
}
コード例 #8
0
ファイル: RHD2000Editor.cpp プロジェクト: AGenews/GUI
void BandwidthInterface::labelTextChanged(Label* label)
{

    if (!(editor->acquisitionIsActive) && board->foundInputSource())
    {
        if (label == upperBandwidthSelection)
        {

            Value val = label->getTextValue();
            double requestedValue = double(val.getValue());

            if (requestedValue < 100.0 || requestedValue > 20000.0 || requestedValue < lastLowCutString.getFloatValue())
            {
                editor->sendActionMessage("Value out of range.");

                label->setText(lastHighCutString, dontSendNotification);

                return;
            }

            actualUpperBandwidth = board->setUpperBandwidth(requestedValue);

            std::cout << "Setting Upper Bandwidth to " << requestedValue << std::endl;
            std::cout << "Actual Upper Bandwidth:  " <<  actualUpperBandwidth  << std::endl;
            label->setText(String((roundFloatToInt)(actualUpperBandwidth)), dontSendNotification);

        }
        else
        {

            Value val = label->getTextValue();
            double requestedValue = double(val.getValue());

            if (requestedValue < 0.1 || requestedValue > 500.0 || requestedValue > lastHighCutString.getFloatValue())
            {
                editor->sendActionMessage("Value out of range.");

                label->setText(lastLowCutString, dontSendNotification);

                return;
            }

            actualLowerBandwidth = board->setLowerBandwidth(requestedValue);

            std::cout << "Setting Upper Bandwidth to " << requestedValue << std::endl;
            std::cout << "Actual Upper Bandwidth:  " <<  actualLowerBandwidth  << std::endl;
            label->setText(String(roundFloatToInt(actualLowerBandwidth)), dontSendNotification);
        }
    }
    else if (editor->acquisitionIsActive)
    {
        editor->sendActionMessage("Can't change bandwidth while acquisition is active!");
        if (label == upperBandwidthSelection)
            label->setText(lastHighCutString, dontSendNotification);
        else
            label->setText(lastLowCutString, dontSendNotification);
        return;
    }

}
コード例 #9
0
void ControlPanelComponent::resized()
{
    thresholdSlider->setBounds (25, proportionOfHeight (0.3975f), proportionOfWidth (0.8483f), 16);
    thresholdLabel->setBounds (16, proportionOfHeight (0.3675f), 80, 17);
    calcSimButton->setBounds (262 - 86, proportionOfHeight (0.2075f), 86, 20);
    rmsFeatureToggle->setBounds (96, proportionOfHeight (0.1775f), 50, 24);
    scFeatureToggle->setBounds (24, proportionOfHeight (0.2275f), 50, 24);
    mfccFeatureToggle->setBounds (24, proportionOfHeight (0.1775f), 50, 24);
    stickynessLabel->setBounds (16, proportionOfHeight (0.4275f), 72, 18);
    presetComboBox->setBounds (96, proportionOfHeight (0.1200f), 100, 24);
    presetsLabel->setBounds (21, proportionOfHeight (0.1175f), 60, 24);
    stickynessSlider->setBounds (25, proportionOfHeight (0.4575f), proportionOfWidth (0.8483f), 16);
    widthLabel->setBounds (16, proportionOfHeight (0.5250f), 80, 24);
    widthSlider->setBounds (25, proportionOfHeight (0.5550f), proportionOfWidth (0.8483f), 16);
    header2->setBounds (16, proportionOfHeight (0.3175f), 150, 24);
    header1->setBounds (16, proportionOfHeight (0.0700f), 150, 24);
    zcrFeatureToggle->setBounds (96, proportionOfHeight (0.2275f), 50, 24);
    invertRegionsToggle->setBounds (24, proportionOfHeight (0.6250f), 120, 24);
    exportSeparateButton->setBounds (24, proportionOfHeight (0.9125f), 104, 24);
    regionDescriptionLabel->setBounds (176, proportionOfHeight (0.6250f), 72, 24);
    regionCountLabel->setBounds ((176) + 72, proportionOfHeight (0.6250f), 30, 25);
    saveSingleFileToggleButton->setBounds ((24) + 0, proportionOfHeight (0.9525f), 112, 24);
    widthMinLabel->setBounds ((25) + 0, (proportionOfHeight (0.5550f)) + 17, 56, 24);
    widthMaxLabel->setBounds ((25) + roundFloatToInt ((proportionOfWidth (0.8483f)) * 0.9018f), (proportionOfHeight (0.5550f)) + 17, 48, 24);
    numRegionsComboBox->setBounds ((16) + 8, proportionOfHeight (0.7850f), 120, 24);
    header3->setBounds (16, proportionOfHeight (0.7250f), 120, 24);
    searchPercentComboBox->setBounds ((16) + 144, proportionOfHeight (0.7850f), 104, 24);
    searchButton->setBounds (24, proportionOfHeight (0.8425f), 96, 24);
    widthFilterSearchToggle->setBounds ((16) + 136, proportionOfHeight (0.7250f), 120, 24);
    exportTxtButton->setBounds ((24) + 152, proportionOfHeight (0.9125f), 104, 24);
    //[UserResized] Add your own custom resize handling here..
    //[/UserResized]
}
コード例 #10
0
Rectangle PianoGrid::getNoteRect (PianoGridNote* note)
{
    // update rows number
    int x, w;
    float snapsPerBeat = 1.0f / (snapQuantize / (float) divDenominator);
    float snapWidth = barWidth / (float) snapQuantize;
    float beatWidth = barWidth / (float) divDenominator;

    if (snapQuantize == 0)
    {
        x = roundFloatToInt (beatWidth * note->getBeat());
        w = roundFloatToInt (beatWidth * note->getLength());
    }
    else
    {
        x = roundFloatToInt (snapWidth * (note->getBeat() / snapsPerBeat));
        w = roundFloatToInt (snapWidth * (note->getLength() / snapsPerBeat));
    }

    float currentHeight = rowHeight - noteAdjustOffset [0];
    float previousHeight = 0;
    float pos_y = getHeight() - currentHeight;

    for (int row = rowsOffset;
             (row < numRows) && ((pos_y + previousHeight) >= 12.0f);
             row++)
    {
        int octaveNumber = row / 12;
        previousHeight = currentHeight;

        // check if we are inside
        if (row == note->getNote ())
            return Rectangle (x, (int)pos_y + 1, w, (int)previousHeight - 1);

        // offset for next height
        int nextNoteNumber = (row + 1) % 12;
        int nextOctaveNumber = (row + 1) / 12;
        currentHeight = rowHeight
                        - noteAdjustOffset [nextNoteNumber]
                        - ((nextOctaveNumber != octaveNumber) ? 1 : 0);

        pos_y -= currentHeight;
    }

    return Rectangle (0,0,1,1);
}
コード例 #11
0
//==============================================================================
void DrawablePad::drawButtonBackground (Graphics& g,
                                        Button& button,
                                        const Colour& backgroundColour,
                                        bool isMouseOverButton,
                                        bool isButtonDown)
{
    const int width = button.getWidth();
    const int height = button.getHeight();

    const float indent = 2.0f;
    const int cornerSize = jmin (roundFloatToInt (width * roundness),
                                 roundFloatToInt (height * roundness));

    Colour bc (backgroundColour);
    if (isMouseOverButton)
    {
        if (isButtonDown)
            bc = bc.brighter();
        else if (bc.getBrightness() > 0.5f)
            bc = bc.darker (0.1f);
        else
            bc = bc.brighter (0.1f);
    }

    g.setColour (bc);

    if (hex)
    {
        g.fillPath (hexpath);

        g.setColour (bc.contrasting().withAlpha ((isMouseOverButton) ? 0.6f : 0.4f));
        g.strokePath (hexpath, PathStrokeType ((isMouseOverButton) ? 2.0f : 1.4f));
    }
    else
    {
        Path p;
        p.addRoundedRectangle (indent, indent,
                               width - indent * 2.0f,
                               height - indent * 2.0f,
                               (float) cornerSize);
        g.fillPath (p);

        g.setColour (bc.contrasting().withAlpha ((isMouseOverButton) ? 0.6f : 0.4f));
        g.strokePath (p, PathStrokeType ((isMouseOverButton) ? 2.0f : 1.4f));
    }
}
コード例 #12
0
Rectangle AutomationGrid::getNoteRect (AutomationEvent* note)
{
	const int diameter = getEventDiameter();

    int x;
    float snapsPerBeat = 1.0f / (snapQuantize / (float) divDenominator);
    float snapWidth = barWidth / (float) snapQuantize;
    float beatWidth = barWidth / (float) divDenominator;

    if (snapQuantize == 0)
        x = roundFloatToInt (beatWidth * note->getBeat());
    else
        //x = roundFloatToInt (snapWidth * round(note->getBeat() / snapsPerBeat));
		x = roundFloatToInt (snapWidth * (note->getBeat() / snapsPerBeat));

	int fullh = getAvailableHeight(); // account for header & space for item's circle at top or bottom
	int y = fullh - (note->value * fullh); // upside down flip
	y += getEventDiameter() + getHeaderHeight();

	return Rectangle (x-diameter, y-diameter, diameter*2, diameter*2);
}
コード例 #13
0
void ADSRComponent::resized()
{
    attackSlider->setBounds (0, 0, proportionOfWidth (0.2504f), getHeight() - 30);
    decaySlider->setBounds ((0) + (proportionOfWidth (0.2504f)), 0, proportionOfWidth (0.2504f), getHeight() - 30);
    sustainSlider->setBounds (((0) + (proportionOfWidth (0.2504f))) + (proportionOfWidth (0.2504f)), 0, proportionOfWidth (0.2504f), getHeight() - 30);
    releaseSlider->setBounds ((((0) + (proportionOfWidth (0.2504f))) + (proportionOfWidth (0.2504f))) + (proportionOfWidth (0.2504f)), 0, proportionOfWidth (0.2504f), getHeight() - 30);
    attackLabel->setBounds ((0) + 0, getHeight() - 30, roundFloatToInt ((proportionOfWidth (0.2504f)) * 1.0000f), 30);
    decayLabel->setBounds (((0) + (proportionOfWidth (0.2504f))) + 0, getHeight() - 30, roundFloatToInt ((proportionOfWidth (0.2504f)) * 1.0000f), 30);
    sustainLabel->setBounds ((((0) + (proportionOfWidth (0.2504f))) + (proportionOfWidth (0.2504f))) + 0, (0) + (getHeight() - 30), roundFloatToInt ((proportionOfWidth (0.2504f)) * 1.0000f), 30);
    releaseLabel->setBounds (((((0) + (proportionOfWidth (0.2504f))) + (proportionOfWidth (0.2504f))) + (proportionOfWidth (0.2504f))) + 0, (0) + (getHeight() - 30), roundFloatToInt ((proportionOfWidth (0.2504f)) * 1.0000f), 30);
    //[UserResized] Add your own custom resize handling here..
    //[/UserResized]
}
コード例 #14
0
ファイル: MyLookAndFeel.cpp プロジェクト: jrigg/DISTRHO-Ports
void MyLookAndFeel::getIdealPopupMenuItemSize(const String& text,
                                              const bool isSeparator,
                                              int standardMenuItemHeight,
                                              int& idealWidth,
                                              int& idealHeight)
{
    if (isSeparator)
    {
        idealWidth = 50;
        idealHeight = standardMenuItemHeight > 0 ? standardMenuItemHeight / 2 : 10;
    }
    else
    {
        Font font (getPopupMenuFont());

        idealHeight = roundFloatToInt (font.getHeight() * 1.3f);
        idealWidth = font.getStringWidth (text) + idealHeight * 2;
    }
}
コード例 #15
0
const int EdoChatWindowMessage::getMessageHeight(const int parentWidth, const Justification justification)
{
	GlyphArrangement messageGlyphs;
	float top,left,right,bottom;

	applyOptions();
	messageGlyphs.clear();

	messageGlyphs.addJustifiedText (
										EdoRestoreFont (getPropertyString(EWND_MESSAGE_FONT), Font(14)), 
										messageLabel->getText(), 
										0, 
										0, 
										(float)parentWidth, 
										justification
									);

	messageGlyphs.getBoundingBox (0, -1, left, top, right, bottom, true);

	messageHeight = roundFloatToInt ((bottom - top) + SPACER);

	// Log (String::formatted (T("EdoChatWindowMessage::getMessageHeight parentWidth: %d height: %d"), parentWidth, messageHeight));

	if (avatar->isVisible())
	{
		if (messageHeight < (avatar->getHeight()+16))
		{
			messageHeight = avatar->getHeight()+16;
			return (messageHeight+SPACER);
		}
		else
		{
			return (messageHeight+SPACER);
		}
	}
	else
	{
		return (messageHeight+SPACER);
	}
}
コード例 #16
0
ファイル: piz_LookAndFeel.cpp プロジェクト: Amcut/pizmidi
void PizLookAndFeel::drawLinearSlider (Graphics& g,
                                             int x, int y,
                                             int w, int h,
                                             float sliderPos,
                                             float minSliderPos,
                                             float maxSliderPos,
                                             const Slider::SliderStyle style,
                                             Slider& slider)
{
    g.fillAll (slider.findColour (Slider::backgroundColourId));

    if (style == Slider::LinearBar)
    {
        g.setColour (slider.findColour (Slider::thumbColourId));
        g.fillRect (x, y, (int) sliderPos - x, h);

        g.setColour (slider.findColour (Slider::textBoxTextColourId).withMultipliedAlpha (0.5f));
        g.drawRect (x, y, (int) sliderPos - x, h);
    }
    else
    {
        g.setColour (slider.findColour (Slider::trackColourId)
                           .withMultipliedAlpha (slider.isEnabled() ? 1.0f : 0.3f));

        if (slider.isHorizontal())
        {
            int trackWidth = roundFloatToInt (h * 0.2f);
            g.fillRect (x, y + roundFloatToInt (h * 0.4f),
                        w, trackWidth);
        }
        else
        {
            int trackWidth = /*jmin (4, */roundFloatToInt (w * 0.15f)/*)*/;
            g.fillRect (x + roundFloatToInt(w*0.5f - (float)trackWidth), y,
                        trackWidth, h);
            //g.fillRect (x + roundFloatToInt (w * 0.5f - jmin (3.0f, w * 0.1f)), y,
            //            trackWidth, h);
        }

        float alpha = 0.35f;

        if (slider.isEnabled())
            alpha = slider.isMouseOverOrDragging() ? 1.0f : 0.7f;

        const Colour fill (slider.findColour (Slider::thumbColourId).withAlpha (alpha));
        const Colour outline (Colours::black.withAlpha (slider.isEnabled() ? 0.7f : 0.35f));

        if (style == Slider::TwoValueVertical || style == Slider::ThreeValueVertical)
        {
            drawTriangle (g, x + w * 0.5f + jmin (4.0f, w * 0.3f), minSliderPos,
                          x + w * 0.5f - jmin (8.0f, w * 0.4f), minSliderPos - 7.0f,
                          x + w * 0.5f - jmin (8.0f, w * 0.4f), minSliderPos,
                          fill, outline);

            drawTriangle (g, x + w * 0.5f + jmin (4.0f, w * 0.3f), maxSliderPos,
                          x + w * 0.5f - jmin (8.0f, w * 0.4f), maxSliderPos,
                          x + w * 0.5f - jmin (8.0f, w * 0.4f), maxSliderPos + 7.0f,
                          fill, outline);
        }
        else if (style == Slider::TwoValueHorizontal || style == Slider::ThreeValueHorizontal)
        {
            drawTriangle (g, minSliderPos, y + h * 0.6f - jmin (4.0f, h * 0.3f),
                          minSliderPos - 7.0f, y + h * 0.9f ,
                          minSliderPos, y + h * 0.9f,
                          fill, outline);

            drawTriangle (g, maxSliderPos, y + h * 0.6f - jmin (4.0f, h * 0.3f),
                          maxSliderPos, y + h * 0.9f,
                          maxSliderPos + 7.0f, y + h * 0.9f,
                          fill, outline);
        }

        if (style == Slider::LinearHorizontal || style == Slider::ThreeValueHorizontal)
        {
            drawTriangle (g, sliderPos, y + h * 0.9f,
                          sliderPos - 7.0f, y + h * 0.2f,
                          sliderPos + 7.0f, y + h * 0.2f,
                          fill, outline);

            g.setColour (slider.findColour(Slider::textBoxTextColourId).withMultipliedAlpha(0.6f));
            g.setFont ((float)h,Font::bold);
            double val = slider.getValue();
            if (fabs(val)<0.0000001) val=0.;
            g.drawText (String(val),
                        0, 0, w, h,
                        Justification::centred, true);
        }
        else if (style == Slider::LinearVertical || style == Slider::ThreeValueVertical)
        {
            //drawTriangle (g, x + w * 0.5f - jmin (4.0f, w * 0.3f), sliderPos,
            //              x + w * 0.5f + jmin (8.0f, w * 0.4f), sliderPos - 7.0f,
            //              x + w * 0.5f + jmin (8.0f, w * 0.4f), sliderPos + 7.0f,
            //              fill, outline);
            drawTriangle (g, x + w*0.3f, sliderPos,
                          x + w*0.8f, sliderPos - 7.0f,
                          x + w*0.8f, sliderPos + 7.0f,
                          fill, outline);
            g.setColour (slider.findColour(Slider::textBoxTextColourId).withMultipliedAlpha(0.6f));
            g.setFont ((float)w*0.5f,Font::bold);
            String val=String(slider.getValue(),1);
            if (val==String("100.0")) val="100";
            g.drawFittedText (val,
                        0, 0, w, h,
                        Justification::centred, 1);
        }
    }
}
コード例 #17
0
//==============================================================================
void MidiSequencePlugin::processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiMessages)
{
	MidiSequencePluginBase::processBlock(buffer, midiMessages);
	MidiMessageSequence sourceMidi = *midiSequence;
	
	std::vector<int> doneTheseControllers;

    if (transport->isPlaying () && getBoolValue(PROP_SEQENABLED, true))
    {
		const int blockSize = buffer.getNumSamples ();
		MidiBuffer* midiBuffer = midiBuffers.getUnchecked (0);

        const int frameCounter = transport->getPositionInFrames ();
        const int framesPerBeat = transport->getFramesPerBeat ();
        const int nextBlockFrameNumber = frameCounter + blockSize;
		const int seqIndex = getLoopRepeatIndex();
		const double beatCount = getLoopBeatPosition();
		const double frameLenBeatCount = (nextBlockFrameNumber - frameCounter) / (double)framesPerBeat;		
		double frameEndBeatCount = beatCount + frameLenBeatCount;
		if (frameEndBeatCount > getLengthInBeats())
			frameEndBeatCount -= getLengthInBeats();

		// loop for each controller we need to interpolate
		MidiMessage* lastCtrlEvent = NULL;
		do 
		{
			lastCtrlEvent = NULL;
			
			// hunt for a controller event before now
			int i;
			for (i = 0;	i < sourceMidi.getNumEvents (); i++)
			{
				int timeStampInSeq = roundFloatToInt (sourceMidi.getEventTime (i) * framesPerBeat);
				int timeStamp = timeStampInSeq + (seqIndex * getLengthInBeats() * framesPerBeat);

				MidiMessage* midiMessage = &sourceMidi.getEventPointer (i)->message;
				if (timeStamp >= nextBlockFrameNumber || !midiMessage) 
					break; // event is after now, leave

				//if (midiMessage->isController() && (std::find(doneTheseControllers.begin(), doneTheseControllers.end(), midiMessage->getControllerNumber()) == doneTheseControllers.end()))
				//	lastCtrlEvent = midiMessage;
			}

			// hunt for a matching event after that one
			if (lastCtrlEvent)
			{
				// store the controller number so we know which controllers we've done
				doneTheseControllers.push_back(lastCtrlEvent->getControllerNumber());

				MidiMessage* nextCtrlEvent = NULL;
				for (;	i < sourceMidi.getNumEvents (); i++)
				{
					MidiMessage* midiMessage = &sourceMidi.getEventPointer (i)->message;
					if (midiMessage->isController() && midiMessage->getControllerNumber() == lastCtrlEvent->getControllerNumber())
					{
						nextCtrlEvent = midiMessage;
						break;
					}
				}
			
				// render an interpolated event!...
				if (nextCtrlEvent)
				{
					double bt = nextCtrlEvent->getTimeStamp();
					double at = lastCtrlEvent->getTimeStamp();
					double deltaBeats = bt - at;
					int a = lastCtrlEvent->getControllerValue();
					int b = nextCtrlEvent->getControllerValue();
					double now = beatCount + (frameEndBeatCount - beatCount) / 2.0;
					double interpRemainBeats = deltaBeats - (now - at);
					if (deltaBeats > 0)
					{
						double nextPart = interpRemainBeats / deltaBeats;
						nextPart = 1 - nextPart;
						double interpdVal = a + nextPart * (b - a);
						MidiMessage interpy = MidiMessage::controllerEvent(lastCtrlEvent->getChannel(), lastCtrlEvent->getControllerNumber(), static_cast<int>(interpdVal));
						midiBuffer->addEvent (interpy, (nextBlockFrameNumber - frameCounter) / 2);
					}
					else
					{
						DBG ("Negative delta beats when rendering automation!!");
			        }
				}
			
			} 
			
			// now we also need to do that again if there are multiple events per frame AND we are interpolating multiple times per frame
			// (at the moment only interpolating once per audio frame)
		} while (lastCtrlEvent != NULL);
	}
}
コード例 #18
0
void DRowAudioFilter::processBlock (AudioSampleBuffer& buffer,
									MidiBuffer& midiMessages)
{
	smoothParameters();
	const int numInputChannels = getNumInputChannels();
	int numSamples = buffer.getNumSamples();

	// set up the parameters to be used
	float preDelay = (float)params[PREDELAY].getSmoothedValue();
	float earlyDecay = (float)params[EARLYDECAY].getSmoothedNormalisedValue();
	earlyDecay = sqrt(sqrt(earlyDecay));
	float late = (float)params[EARLYLATEMIX].getSmoothedNormalisedValue();
	float early = 1.0f - late;
	float fbCoeff = (float)params[FBCOEFF].getSmoothedNormalisedValue();
	fbCoeff = -sqrt(sqrt(fbCoeff));
	float delayTime = (float)params[DELTIME].getSmoothedValue();
	float filterCf = (float)params[FILTERCF].getSmoothedValue();
	float allpassCoeff = (float)params[DIFFUSION].getSmoothedNormalisedValue();
	float spread1 = (float)params[SPREAD].getSmoothedNormalisedValue();
	float spread2 = 1.0f - spread1;
	float lowEQGain = (float)decibelsToAbsolute(params[LOWEQ].getSmoothedValue());
	float highEQGain = (float)decibelsToAbsolute(params[HIGHEQ].getSmoothedValue());
	float wet = (float)params[WETDRYMIX].getSmoothedNormalisedValue();
	float dry = 1.0f - wet;

	float width = (spread1-0.5f) * 0.1f * delayTime;


	// we can only deal with 2-in, 2-out at the moment
	if (numInputChannels == 2)
	{
		// pre-delay section
		preDelayFilterL.setDelayTime(currentSampleRate, preDelay);
		preDelayFilterR.setDelayTime(currentSampleRate, preDelay);


		// early reflections section
		int roomShape = roundFloatToInt(params[ROOMSHAPE].getValue());
		float delayCoeff = 0.08f * delayTime;
		if (roomShape != prevRoomShape)
		{
			delayLineL.removeAllTaps();
			delayLineR.removeAllTaps();

			for(int i = 0; i < 5; i++) {
				delayLineL.addTapAtTime(earlyReflectionCoeffs[roomShape-3][i], currentSampleRate);
				delayLineR.addTapAtTime(earlyReflectionCoeffs[roomShape-3][i], currentSampleRate);
			}

			// we have to set this here incase the delay time has not changed
			delayLineL.setTapSpacingExplicitly(delayCoeff);
			delayLineR.setTapSpacingExplicitly(delayCoeff + spread1);

			prevRoomShape = roomShape;
		}

		delayLineL.setTapSpacing(delayCoeff);
		delayLineL.scaleFeedbacks(earlyDecay);
		delayLineR.setTapSpacing(delayCoeff + spread1);
		delayLineR.scaleFeedbacks(earlyDecay);


		// comb filter section
		for (int i = 0; i < 8; ++i)
		{
			delayTime *= filterMultCoeffs[i];
			delayTime += Random::getSystemRandom().nextInt(100)*0.0001;

			setupFilter(combFilterL[i], fbCoeff, delayTime, filterCf);
			setupFilter(combFilterR[i], fbCoeff, delayTime + width, filterCf);
		}

		// allpass section
		for (int i = 0; i < 4; ++i)
		{
			delayTime *= allpassMultCoeffs[i];
			delayTime -= Random::getSystemRandom().nextInt(100)*0.0001;

			allpassFilterL[i].setGain(allpassCoeff);
			allpassFilterL[i].setDelayTime(currentSampleRate, delayTime);

			allpassFilterR[i].setGain(allpassCoeff);
			allpassFilterR[i].setDelayTime(currentSampleRate, delayTime + width);
		}

		// final EQ section
		lowEQL.makeLowShelf(currentSampleRate, 500, 1, lowEQGain);
		lowEQR.makeLowShelf(currentSampleRate, 500, 1, lowEQGain);
		highEQL.makeHighShelf(currentSampleRate, 3000, 1, highEQGain);
		highEQR.makeHighShelf(currentSampleRate, 3000, 1, highEQGain);


		//========================================================================
		//	Processing
		//========================================================================
		int noSamples = buffer.getNumSamples();
		int noChannels = buffer.getNumChannels();

		// create a copy of the input buffer so we can apply a wet/dry mix later
		AudioSampleBuffer wetBuffer(noChannels, noSamples);
		wetBuffer.copyFrom(0, 0, buffer, 0, 0, noSamples);
		wetBuffer.copyFrom(1, 0, buffer, 1, 0, noSamples);

		// mono mix wet buffer (used for stereo spread later)
		float *pfWetL = wetBuffer.getSampleData(0);
		float *pfWetR = wetBuffer.getSampleData(1);
		while (--numSamples >= 0)
		{
			*pfWetL = *pfWetR = (0.5f * (*pfWetL + *pfWetR));
			pfWetL++;
			pfWetR++;
		}
		numSamples = buffer.getNumSamples();

		// apply the pre-delay to the wet buffer
		preDelayFilterL.processSamples(wetBuffer.getSampleData(0), noSamples);
		preDelayFilterR.processSamples(wetBuffer.getSampleData(1), noSamples);


		// create a buffer to hold the early reflections
		AudioSampleBuffer earlyReflections(noChannels, noSamples);
		earlyReflections.copyFrom(0, 0, wetBuffer, 0, 0, noSamples);
		earlyReflections.copyFrom(1, 0, wetBuffer, 1, 0, noSamples);

		// and process the early reflections
		delayLineL.processSamples(earlyReflections.getSampleData(0), noSamples);
		delayLineR.processSamples(earlyReflections.getSampleData(1), noSamples);


		// create a buffer to hold the late reverb
		AudioSampleBuffer lateReverb(noChannels, noSamples);
		lateReverb.clear();

		float *pfLateL = lateReverb.getSampleData(0);
		float *pfLateR = lateReverb.getSampleData(1);
		pfWetL = wetBuffer.getSampleData(0);
		pfWetR = wetBuffer.getSampleData(1);

		// comb filter section
		for (int i = 0; i < 8; ++i)
		{
			combFilterL[i].processSamplesAdding(pfWetL, pfLateL, noSamples);
			combFilterR[i].processSamplesAdding(pfWetR, pfLateR, noSamples);
		}

		// allpass filter section
		for (int i = 0; i < 4; ++i)
		{
			allpassFilterL[i].processSamples(lateReverb.getSampleData(0), noSamples);
			allpassFilterR[i].processSamples(lateReverb.getSampleData(1), noSamples);
		}


		// clear wet buffer
		wetBuffer.clear();
		// add early reflections to wet buffer
		wetBuffer.addFrom(0, 0, earlyReflections, 0, 0, noSamples, early);
		wetBuffer.addFrom(1, 0, earlyReflections, 1, 0, noSamples, early);
		// add late reverb to wet buffer
		lateReverb.applyGain(0, noSamples, 0.1f);
		wetBuffer.addFrom(0, 0, lateReverb, 0, 0, noSamples, late);
		wetBuffer.addFrom(1, 0, lateReverb, 1, 0, noSamples, late);

		// final EQ
		lowEQL.processSamples(pfWetL, noSamples);
		lowEQR.processSamples(pfWetR, noSamples);

		highEQL.processSamples(pfWetL, noSamples);
		highEQR.processSamples(pfWetR, noSamples);

		// create stereo spread
		while (--numSamples >= 0)
		{
			float fLeft = *pfWetL;
			float fRight = *pfWetR;
			*pfWetL = (fLeft * spread1) + (fRight * spread2);
			*pfWetR = (fRight * spread1) + (fLeft * spread2);
			pfWetL++;
			pfWetR++;
		}
		numSamples = buffer.getNumSamples();

		// apply wet/dry mix gains
		wetBuffer.applyGain(0, noSamples, wet);
		buffer.applyGain(0, noSamples, dry);

		// add wet buffer to output buffer
		buffer.addFrom(0, 0, wetBuffer, 0, 0, noSamples);
		buffer.addFrom(1, 0, wetBuffer, 1, 0, noSamples);
	}
	//========================================================================


    // in case we have more outputs than inputs, we'll clear any output
    // channels that didn't contain input data, (because these aren't
    // guaranteed to be empty - they may contain garbage).
    for (int i = getNumInputChannels(); i < getNumOutputChannels(); ++i)
    {
        buffer.clear (i, 0, buffer.getNumSamples());
    }
}
コード例 #19
0
ファイル: RHD2000Editor.cpp プロジェクト: AGenews/GUI
void AudioInterface::setNoiseSlicerLevel(int value)
{
    actualNoiseSlicerLevel = board->setNoiseSlicerLevel(value);
    noiseSlicerLevelSelection->setText(String(roundFloatToInt(actualNoiseSlicerLevel)), dontSendNotification);
}
コード例 #20
0
ファイル: RHD2000Editor.cpp プロジェクト: AGenews/GUI
void BandwidthInterface::setUpperBandwidth(double value)
{
    actualUpperBandwidth = board->setUpperBandwidth(value);
    upperBandwidthSelection->setText(String(roundFloatToInt(actualUpperBandwidth)), dontSendNotification);
}
コード例 #21
0
ファイル: jucer_PaintElementPath.cpp プロジェクト: Krewn/LIOS
//==============================================================================
int PaintElementPath::getBorderSize() const
{
    return isStrokePresent ? 1 + roundFloatToInt (strokeType.stroke.getStrokeThickness())
                           : 0;
}
コード例 #22
0
//==============================================================================
void MidiTransform::processEvents (MidiBuffer& midiMessages, const int blockSize)
{
    int timeStamp;
    MidiMessage message (0xf4, 0.0);
    MidiBuffer::Iterator it (midiMessages);

    MidiBuffer midiOutput;

    switch (command)
    {
    case MidiTransform::KeepEvents:
            break;
    case MidiTransform::DiscardEvents:
        {
            midiMessages.clear ();
            break;
        }
    case MidiTransform::RemapChannel:
        {
            while (it.getNextEvent (message, timeStamp))
            {
                message.setChannel (channelNumber);
                midiOutput.addEvent (message, timeStamp);
            }
            midiMessages = midiOutput;
            break;
        }
    case MidiTransform::ScaleNotes:
        {
            while (it.getNextEvent (message, timeStamp))
            {
                if (message.isNoteOnOrOff ())
                {
                    message.setNoteNumber (roundFloatToInt (message.getNoteNumber () * noteScale));
                    midiOutput.addEvent (message, timeStamp);
                }
            }
            midiMessages = midiOutput;
            break;
        }
    case MidiTransform::InvertNotes:
        {
            while (it.getNextEvent (message, timeStamp))
            {
                if (message.isNoteOnOrOff ())
                {
                    message.setNoteNumber (127 - message.getNoteNumber ());
                    midiOutput.addEvent (message, timeStamp);
                }
            }
            midiMessages = midiOutput;
        }
    case MidiTransform::TransposeNotes:
        {
            while (it.getNextEvent (message, timeStamp))
            {
                if (message.isNoteOnOrOff ())
                {
                    message.setNoteNumber (jmax (0, jmin (127, message.getNoteNumber () - noteTranspose)));
                    midiOutput.addEvent (message, timeStamp);
                }
            }
            midiMessages = midiOutput;
            break;
        }
    case MidiTransform::ScaleVelocity:
        {
            while (it.getNextEvent (message, timeStamp))
            {
                if (message.isNoteOn ())
                {
                    message.setVelocity ((message.getVelocity () / 127.0f) * velocityScale);
                    midiOutput.addEvent (message, timeStamp);
                }
            }
            midiMessages = midiOutput;
            break;
        }
    case MidiTransform::InvertVelocity:
        {
            while (it.getNextEvent (message, timeStamp))
            {
                if (message.isNoteOn ())
                {
                    message.setVelocity ((uint8) (127 - message.getVelocity ()));
                    midiOutput.addEvent (message, timeStamp);
                }
            }
            midiMessages = midiOutput;
            break;
        }
    case MidiTransform::TransposeVelocity:
        {
            while (it.getNextEvent (message, timeStamp))
            {
                if (message.isNoteOn ())
                {
                    message.setVelocity (jmax (0, jmin (127, message.getVelocity () - velocityTranspose)));
                    midiOutput.addEvent (message, timeStamp);
                }
            }
            midiMessages = midiOutput;
            break;
        }
    case MidiTransform::TriggerCC:
        {
            break;
        }
    case MidiTransform::TriggerNote:
        {
            break;
        }
    }
}