Example #1
0
void QuteWidget::applyProperties()
{
//	qDebug() << "QuteWidget::applyProperties()";
#ifdef  USE_WIDGET_MUTEX
	widgetLock.lockForRead();
#endif
	setProperty("QCS_objectName", nameLineEdit->text());
	setProperty("QCS_x", xSpinBox->value());
	setProperty("QCS_y",ySpinBox->value());
	setProperty("QCS_width", wSpinBox->value());
	setProperty("QCS_height", hSpinBox->value());
	if (acceptsMidi()) {
		setProperty("QCS_midicc", midiccSpinBox->value());
		setProperty("QCS_midichan", midichanSpinBox->value());
	}
#ifdef  USE_WIDGET_MUTEX
	widgetLock.unlock();
#endif
	applyInternalProperties();
	//  setChannelName(nameLineEdit->text());
	//  setWidgetGeometry(xSpinBox->value(), ySpinBox->value(), wSpinBox->value(), hSpinBox->value());

	//  this->setMouseTracking(true); // Necessary to pass mouse tracking to widget panel for _MouseX channels
	emit(widgetChanged(this));
	emit propertiesAccepted();
	parentWidget()->setFocus(Qt::PopupFocusReason); // For some reason focus is grabbed away from the layout
	m_valueChanged = true;
}
Example #2
0
void QuteWidget::updateDialogWindow(int cc, int channel) // to update values from midi Learn window to widget properties' dialog
{
	if (dialog->isVisible() && acceptsMidi()) {
		midiccSpinBox->setValue(cc);
		midichanSpinBox->setValue(channel);
		//qDebug()<<"Updated MIDI values in properties dialog"<<cc<<channel;
	}
}
Example #3
0
void MLPluginProcessor::processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiMessages)
{
 	if (mEngine.isEnabled() && !isSuspended())
	{
		unsigned samples = buffer.getNumSamples();
		
		// get current time from host.
		// should refer to the start of the current block.
		AudioPlayHead::CurrentPositionInfo newTime;
		if (getPlayHead() != 0 && getPlayHead()->getCurrentPosition (newTime))
		{
			lastPosInfo = newTime;
		}
		else
		{
			lastPosInfo.resetToDefault();
		}

		// set host phasor 
		double bpm = lastPosInfo.isPlaying ? lastPosInfo.bpm : 0.;
		double ppqPosition = lastPosInfo.ppqPosition;
		double secsPosition = lastPosInfo.timeInSeconds;
		int64 samplesPosition = lastPosInfo.timeInSamples;
		bool isPlaying = lastPosInfo.isPlaying;
		
		// TEST
		if(0)
		if(lastPosInfo.isPlaying)
		{
			debug() << "bpm:" << lastPosInfo.bpm 
			<< " ppq:" << std::setprecision(5) << ppqPosition << std::setprecision(2) 
			<< " secs:" << secsPosition << "\n";
		}
			
		// set Engine I/O.  done here each time because JUCE may change pointers on us.  possibly.
		MLDSPEngine::ClientIOMap ioMap;
		for (int i=0; i<getNumInputChannels(); ++i)
		{
			ioMap.inputs[i] = buffer.getReadPointer(i);
		}		
		for (int i=0; i<getNumOutputChannels(); ++i)
		{
			ioMap.outputs[i] = buffer.getWritePointer(i);
		}
		mEngine.setIOBuffers(ioMap);
        
        if(acceptsMidi())
        {
            convertMIDIToEvents(midiMessages, mControlEvents);
            midiMessages.clear(); // otherwise messages will be passed back to the host
        }
        mEngine.processBlock(samples, mControlEvents, samplesPosition, secsPosition, ppqPosition, bpm, isPlaying);
    }
	else
	{
		buffer.clear();
	}
}
Example #4
0
void QuteWidget::openProperties()
{
	createPropertiesDialog();

	connect(acceptButton, SIGNAL(released()), dialog, SLOT(accept()));
	connect(dialog, SIGNAL(accepted()), this, SLOT(apply()));
	connect(applyButton, SIGNAL(released()), this, SLOT(apply()));
	connect(cancelButton, SIGNAL(released()), dialog, SLOT(close()));
	if (acceptsMidi()) {
		connect(midiLearnButton, SIGNAL(released()),this, SLOT(openMidiDialog()));
	}
	dialog->exec();
	if (dialog->result() != QDialog::Accepted) {
		qDebug() << "QuteWidget::openProperties() dialog not accepted";
	}
	//  dialog->deleteLater();
	parentWidget()->setFocus(Qt::OtherFocusReason); // For some reason focus is grabbed away from the layout, but this doesn't solve the problem...
}
Example #5
0
void Node::update ()
{
    const auto node = graph.getNodeForID (id);

    numIns = node->getNumInputChannels ();

    if (node->acceptsMidi ())
        ++numIns;

    numOuts = node->getNumOutputChannels ();
    if (node->producesMidi ())
        ++numOuts;

    int w = 100;
    int h = 40;

    w = jmax (w, (jmax (numIns, numOuts) + 1) * 20);

    const int textWidth = font.getStringWidth (node->getName ());
    w = jmax (w, 16 + jmin (textWidth, 300));
    if (textWidth > 300)
        h = 100;

    setSize (w, h);
    setName (node->getName ());

    setCentreRelative (std::get<0> (node->getPosition ()),
                       std::get<1> (node->getPosition ()));

    if (numIns != numInputs || numOuts != numOutputs)
    {
        numInputs = numIns;
        numOutputs = numOuts;

        inputs.clear();
        outputs.clear();
        midiIn  = nullptr;
        midiOut = nullptr;
        deleteAllChildren ();

        for (auto i = 0u; i < node->getNumInputChannels (); ++i)
        {
            Pin* const newPin = new Pin (Pin::AudioInput, id, i, *graphComp);
            inputs.push_back (newPin);
            addAndMakeVisible (newPin);
        }    

        for (auto i = 0u; i < node->getNumOutputChannels (); ++i)
        {
            Pin* const newPin = new Pin (Pin::AudioOutput, id, i, *graphComp);
            outputs.push_back (newPin);
            addAndMakeVisible (newPin);
        }

		if (node->acceptsMidi())
		{
			Pin* const midiInPin = new Pin (Pin::MidiInput, id, Pin::midi_num, *graphComp);
			addAndMakeVisible(midiInPin);
		}

        if (node->producesMidi ())
        {
            Pin* const midiOutPin = new Pin (Pin::MidiOutput, id, Pin::midi_num, *graphComp);
            addAndMakeVisible (midiOutPin);
        }

        resized ();
    }
}
Example #6
0
void QuteWidget::createPropertiesDialog()
{
//	qDebug() << "QuteWidget::createPropertiesDialog()---Dynamic Properties:\n" << dynamicPropertyNames ();
	dialog = new QDialog(this);
	dialog->resize(300, 300);
	//  dialog->setModal(true);
	layout = new QGridLayout(dialog);
	QLabel *label = new QLabel(dialog);
	label->setText("X =");
	layout->addWidget(label, 0, 0, Qt::AlignRight|Qt::AlignVCenter);
	xSpinBox = new QSpinBox(dialog);
	xSpinBox->setMaximum(9999);
	layout->addWidget(xSpinBox, 0, 1, Qt::AlignLeft|Qt::AlignVCenter);
	label = new QLabel(dialog);
	label->setText("Y =");
	layout->addWidget(label, 0, 2, Qt::AlignRight|Qt::AlignVCenter);
	ySpinBox = new QSpinBox(dialog);
	ySpinBox->setMaximum(9999);
	layout->addWidget(ySpinBox, 0, 3, Qt::AlignLeft|Qt::AlignVCenter);
	label = new QLabel(dialog);
	label->setText(tr("Width ="));
	layout->addWidget(label, 1, 0, Qt::AlignRight|Qt::AlignVCenter);
	wSpinBox = new QSpinBox(dialog);
	wSpinBox->setMaximum(9999);
	layout->addWidget(wSpinBox, 1, 1, Qt::AlignLeft|Qt::AlignVCenter);
	label = new QLabel(dialog);
	label->setText(tr("Height ="));
	layout->addWidget(label, 1, 2, Qt::AlignRight|Qt::AlignVCenter);
	hSpinBox = new QSpinBox(dialog);
	hSpinBox->setMaximum(9999);
	layout->addWidget(hSpinBox, 1, 3, Qt::AlignLeft|Qt::AlignVCenter);
	channelLabel = new QLabel(dialog);
	channelLabel->setText(tr("Channel name ="));
	channelLabel->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
	layout->addWidget(channelLabel, 3, 0, Qt::AlignLeft|Qt::AlignVCenter);
	nameLineEdit = new QLineEdit(dialog);
	nameLineEdit->setFocus(Qt::OtherFocusReason);
	nameLineEdit->selectAll();
	layout->addWidget(nameLineEdit, 3, 1, Qt::AlignLeft|Qt::AlignVCenter);
	if (acceptsMidi()) { // only when MIDI-enabled widgets
		label = new QLabel(dialog);
		label->setText("MIDI CC =");
		layout->addWidget(label, 14, 0, Qt::AlignRight|Qt::AlignVCenter);
		midiccSpinBox = new QSpinBox(dialog);
		midiccSpinBox->setRange(0,119);
		layout->addWidget(midiccSpinBox, 14,1, Qt::AlignLeft|Qt::AlignVCenter);
		label = new QLabel(dialog);
		label->setText("MIDI Channel =");
		layout->addWidget(label, 14, 2, Qt::AlignRight|Qt::AlignVCenter);
		midichanSpinBox = new QSpinBox(dialog);
		midichanSpinBox->setRange(0,127);
		layout->addWidget(midichanSpinBox, 14,3, Qt::AlignLeft|Qt::AlignVCenter);

		midiLearnButton = new QPushButton(tr("Midi learn"));
		layout->addWidget(midiLearnButton,14,4, Qt::AlignLeft|Qt::AlignVCenter);
	}
	acceptButton = new QPushButton(tr("Ok"));
	layout->addWidget(acceptButton, 15, 3, Qt::AlignCenter|Qt::AlignVCenter);
	applyButton = new QPushButton(tr("Apply"));
	layout->addWidget(applyButton, 15, 1, Qt::AlignCenter|Qt::AlignVCenter);
	cancelButton = new QPushButton(tr("Cancel"));
	layout->addWidget(cancelButton, 15, 2, Qt::AlignCenter|Qt::AlignVCenter);
#ifdef  USE_WIDGET_MUTEX
	widgetLock.lockForRead();
#endif
	xSpinBox->setValue(this->x());
	ySpinBox->setValue(this->y());
	wSpinBox->setValue(this->width());
	hSpinBox->setValue(this->height());
	nameLineEdit->setText(getChannelName());
	if (acceptsMidi()) {
		midiccSpinBox->setValue(this->m_midicc);
		midichanSpinBox->setValue(this->m_midichan);
	}
#ifdef  USE_WIDGET_MUTEX
	widgetLock.unlock();
#endif
}