Skip to content

Commit

Permalink
release V0.1.1 Alpha
Browse files Browse the repository at this point in the history
Detail see log 2021-01-16  to log 2021-01-18
  • Loading branch information
YANG-Mingcong committed Jan 18, 2021
1 parent af4be7c commit 3404e24
Show file tree
Hide file tree
Showing 4 changed files with 145 additions and 32 deletions.
31 changes: 21 additions & 10 deletions OSC_sender_test_1/OSCNetCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,17 @@ void OSCNetCore::changeSendToPort(qint16 _s)
OSCNetcore_sendToPort = _s;
}

void OSCNetCore::sendDatagram(QString oscString)
void OSCNetCore::sendDatagram(QString oscString, int _port, bool _mode)
{
this->sendOSCMessageDataGram(oscString);
//this->sendOSCBundleDataGram(oscString);
OSCNetcore_sendToPort = _port;
if(!_mode)
{
this->sendOSCMessageDataGram(oscString);
}
else
{
this->sendOSCBundleDataGram(oscString);
}
}

void OSCNetCore::sendOSCMessageDataGram(QString _oscString)
Expand Down Expand Up @@ -47,6 +54,10 @@ void OSCNetCore::sendOSCBundleDataGram(QString _oscString)
{
QByteArray sentDataGram = this->OSCNetCore_oscBundleToDataGram(_oscString);
OSCNetCore_udpsocket->writeDatagram(sentDataGram, QHostAddress::Broadcast, OSCNetcore_sendToPort);
//wait 2 millisec for next package
QElapsedTimer t;
t.start();
while(t.elapsed()<2);
}

}
Expand All @@ -70,6 +81,11 @@ QByteArray OSCNetCore::OSCNetCore_oscMessageToDataGram(QString _s)
qDebug() << "OSC Arg is :" << oscCommand_Arg << Qt::endl;
qDebug() << "OSC Arg size is :" << oscCommand_Arg.size() << Qt::endl;

QByteArray _arg_Flag;
_arg_Flag.append(',');

QByteArray _arg_Content;

if(0 < oscCommand_Arg.size())
{
QStringList oscCommand_Arg_List;
Expand All @@ -84,11 +100,6 @@ QByteArray OSCNetCore::OSCNetCore_oscMessageToDataGram(QString _s)
}
qDebug() << oscCommand_Arg_List << Qt::endl;

QByteArray _arg_Flag;
_arg_Flag.append(',');

QByteArray _arg_Content;

for(qint64 i_ArgList = 0;
i_ArgList < oscCommand_Arg_List.size();
i_ArgList++ )
Expand Down Expand Up @@ -129,11 +140,11 @@ QByteArray OSCNetCore::OSCNetCore_oscMessageToDataGram(QString _s)
}

_arg_Flag.append('\0');

}
_r.append(this->_FourByteFormat(_addr));
_r.append(this->_FourByteFormat(_arg_Flag));
_r.append(_arg_Content);
}

qDebug() <<"What is this?"<< _r <<Qt::endl;
return _r;
}
Expand Down
3 changes: 2 additions & 1 deletion OSC_sender_test_1/OSCNetCore.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <QString>
#include <QUdpSocket>
#include <QByteArray>
#include <QElapsedTimer>

class OSCNetCore : public QObject
{
Expand All @@ -24,7 +25,7 @@ class OSCNetCore : public QObject
qint16 OSCNetcore_sendToPort;

private slots:
void sendDatagram(QString);
void sendDatagram(QString, int, bool);
void changeSendToPort(qint16);


Expand Down
128 changes: 108 additions & 20 deletions OSC_sender_test_1/OSCSenderWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,20 @@
* @brief OSCSenderWidget::OSCSenderWidget
* @param parent
* @author YANG Mingcong
* @date 2021-JAN-17
* @date 2021-JAN-18
* @version 0.1.1 Alpha
*/

OSCSenderWidget::OSCSenderWidget(QWidget *parent)
: QWidget(parent)
{
this->OSCSenderWidget_dataInitial();

OSCSenderWidget_OSCNetCore = new OSCNetCore();

QHBoxLayout *OSCSenderWidget_mainLayout = new QHBoxLayout(this);
this->setLayout(OSCSenderWidget_mainLayout);
this->setWindowTitle("TEMPO - OSC Sender");
this->setWindowTitle("TEMPO - OSC Sender - for Millumin & vvvv (V0.1.1_Alpha)");
this->setMinimumSize(640, 360);

QWidget *OSCSenderWidget_leftWidget = new QWidget(this);
Expand Down Expand Up @@ -44,32 +46,25 @@ OSCSenderWidget::OSCSenderWidget(QWidget *parent)
OSCSenderWidget_statusWidgetLayout->addWidget(OSCSenderWidget_label_cbx, 0, 0);

QComboBox *OSCSenderWidget_cbxProfile = new QComboBox(OSCSenderWidget_statusWidget);
OSCSenderWidget_cbxProfile->addItem("General OSC Message");
OSCSenderWidget_cbxProfile->addItem("General OSC Bundle");
OSCSenderWidget_cbxProfile->addItem("Millumin Example");
OSCSenderWidget_cbxProfile->addItem("vvvv 00_Examples_1-1");
OSCSenderWidget_cbxProfile->addItem("vvvv 00_Examples_1-2");
OSCSenderWidget_cbxProfile->addItem("vvvv 00_Examples_1-3");
OSCSenderWidget_cbxProfile->addItem("vvvv 01_Examples_1-2");
for (qint16 i = 0; OSCSenderWidget_data_cbxName->size() > i; i++ )
{
OSCSenderWidget_cbxProfile->addItem(OSCSenderWidget_data_cbxName->at(i));
}
OSCSenderWidget_statusWidgetLayout->addWidget(OSCSenderWidget_cbxProfile, 0, 1);

QLabel *OSCSenderWidget_label_port = new QLabel(OSCSenderWidget_statusWidget);
OSCSenderWidget_label_port->setText("Output port: ");
OSCSenderWidget_label_port->setAlignment(Qt::AlignRight);
OSCSenderWidget_statusWidgetLayout->addWidget(OSCSenderWidget_label_port, 1, 1);

QSpinBox *OSCSenderWidget_spbPort = new QSpinBox(OSCSenderWidget_statusWidget);
OSCSenderWidget_spbPort = new QSpinBox(OSCSenderWidget_statusWidget);
OSCSenderWidget_spbPort->setRange(1,65535);
OSCSenderWidget_spbPort->setValue(5000);
OSCSenderWidget_spbPort->setDisplayIntegerBase(10000);
OSCSenderWidget_statusWidgetLayout->addWidget(OSCSenderWidget_spbPort, 1, 2);





OSCSenderWidget_commandTextEdit = new QTextEdit(OSCSenderWidget_leftWidget);
OSCSenderWidget_commandTextEdit->setText("/action/launchOrStopColumn [1]\n/layer:Layer/media/speed [0.5]");
OSCSenderWidget_commandTextEdit->setText("/action/launchOrStopColumn [1]");
OSCSenderWidget_mainLeftLayout->addWidget(OSCSenderWidget_commandTextEdit);
OSCSenderWidget_mainLeftLayout->setStretchFactor(OSCSenderWidget_commandTextEdit,4);

Expand All @@ -79,8 +74,9 @@ OSCSenderWidget::OSCSenderWidget(QWidget *parent)
OSCSenderWidget_mainLeftLayout->setStretchFactor(OSCSenderWidget_sendButton,1);


QLabel *OSCSenderWidget_label_2 = new QLabel(OSCSenderWidget_leftWidget);
OSCSenderWidget_label_2->setText("Status: Broadcasting -> 255.255.255.255, out port 5000");
OSCSenderWidget_label_2 = new QLabel(OSCSenderWidget_leftWidget);
OSCSenderWidget_label_2->setText(tr("Status: Broadcasting, Mode: Message, out port %1")
.arg(OSCSenderWidget_data_ports->at(_cbxProfile_index).toInt()));
OSCSenderWidget_mainLeftLayout->addWidget(OSCSenderWidget_label_2);
OSCSenderWidget_mainLeftLayout->setStretchFactor(OSCSenderWidget_label_2,1);

Expand All @@ -93,8 +89,18 @@ OSCSenderWidget::OSCSenderWidget(QWidget *parent)
connect(OSCSenderWidget_sendButton, SIGNAL(pressed()),
this, SLOT(sendButton_Pressed()));

connect(this, SIGNAL(sendCommand(QString)),
OSCSenderWidget_OSCNetCore, SLOT(sendDatagram(QString)));
connect(OSCSenderWidget_cbxProfile, SIGNAL(currentIndexChanged(int)),
this, SLOT(on_cbxProfile_indexChanged(int)));

connect(OSCSenderWidget_spbPort, SIGNAL(valueChanged(int)),
this, SLOT(on_spbPort_valueChanged(int)));

connect(OSCSenderWidget_spbPort, QOverload<int>::of(&QSpinBox::valueChanged),
[=](int i){ _sendPort = i; });

connect(this, SIGNAL(sendCommand(QString,int,bool)),
OSCSenderWidget_OSCNetCore, SLOT(sendDatagram(QString,int,bool)));

}

OSCSenderWidget::~OSCSenderWidget()
Expand All @@ -103,11 +109,93 @@ OSCSenderWidget::~OSCSenderWidget()

void OSCSenderWidget::sendButton_Pressed()
{
emit this->sendCommand(OSCSenderWidget_commandTextEdit->toPlainText());
emit this->sendCommand(OSCSenderWidget_commandTextEdit->toPlainText(), OSCSenderWidget_spbPort->value(), _sentModeBundle);
}

void OSCSenderWidget::OSCSenderWidget_dataInitial()
{
OSCSenderWidget_data_cbxName = new QStringList();

OSCSenderWidget_data_cbxName->append("General OSC Message"); //index 0
OSCSenderWidget_data_cbxName->append("General OSC Bundle"); //index 1
OSCSenderWidget_data_cbxName->append("Millumin Example"); //index 2
OSCSenderWidget_data_cbxName->append("vvvv 00_Examples_1-1"); //index 3
OSCSenderWidget_data_cbxName->append("vvvv 00_Examples_1-2"); //index 4
OSCSenderWidget_data_cbxName->append("vvvv 00_Examples_1-3"); //index 5
OSCSenderWidget_data_cbxName->append("vvvv 01_Examples_2"); //index 6

OSCSenderWidget_data_oscType = new QStringList();
OSCSenderWidget_data_oscType->append("Message");
OSCSenderWidget_data_oscType->append("Bundle");
OSCSenderWidget_data_oscType->append("Message");
OSCSenderWidget_data_oscType->append("Bundle");
OSCSenderWidget_data_oscType->append("Bundle");
OSCSenderWidget_data_oscType->append("Bundle");
OSCSenderWidget_data_oscType->append("Bundle");

OSCSenderWidget_data_ports = new QStringList();
OSCSenderWidget_data_ports->append("5000");
OSCSenderWidget_data_ports->append("4450");
OSCSenderWidget_data_ports->append("5000");
OSCSenderWidget_data_ports->append("55551");
OSCSenderWidget_data_ports->append("55552");
OSCSenderWidget_data_ports->append("55553");
OSCSenderWidget_data_ports->append("4450");

OSCSenderWidget_data_oscCommand = new QStringList();
OSCSenderWidget_data_oscCommand->append("");
OSCSenderWidget_data_oscCommand->append("");
OSCSenderWidget_data_oscCommand->append("/action/launchOrStopColumn [1]\n/layer:Layer/media/time [\"00:00:10.400\"]");
OSCSenderWidget_data_oscCommand->append("/vvvv 18.03");
OSCSenderWidget_data_oscCommand->append("/vvvv/vector 21.3 12.5 17.2");
OSCSenderWidget_data_oscCommand->append("/vvvv/vector 18.3 1.35 33.2\n/vvvv/date 2021.01.18-20:11:30");
OSCSenderWidget_data_oscCommand->append("/right/id 3\n/right/color |0.5165,0.8876,0.5543,0.9943|\n/right/info 0.502 0.374 MGPR_TEMPO");

_cbxProfile_index = 0; //as default
_sentModeBundle = false;
_sendPort = 5000;
}

void OSCSenderWidget::on_cbxProfile_indexChanged(int _i)
{
_cbxProfile_index = _i;

OSCSenderWidget_commandTextEdit->setText(OSCSenderWidget_data_oscCommand->at(_i));

_sendPort = OSCSenderWidget_data_ports->at(_i).toInt();
OSCSenderWidget_spbPort->setValue(_sendPort);

if("Bundle" == OSCSenderWidget_data_oscType->at(_i))
{
_sentModeBundle = true;
OSCSenderWidget_label_2->setText(tr("Status: Broadcasting, Mode: Bundle, out port %1")
.arg(OSCSenderWidget_data_ports->at(_i).toInt()));
}
else
{
_sentModeBundle = false;
OSCSenderWidget_label_2->setText(tr("Status: Broadcasting, Mode: Message, out port %1")
.arg(OSCSenderWidget_data_ports->at(_i).toInt()));
}



}

void OSCSenderWidget::on_spbPort_valueChanged(int _p)
{
_sendPort = _p;
if(_sentModeBundle)
{
OSCSenderWidget_label_2->setText(tr("Status: Broadcasting, Mode: Bundle, out port %1")
.arg(_p));
}
else
{
OSCSenderWidget_label_2->setText(tr("Status: Broadcasting, Mode: Message, out port %1")
.arg(_p));
}

}


15 changes: 14 additions & 1 deletion OSC_sender_test_1/OSCSenderWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,27 @@ class OSCSenderWidget : public QWidget
OSCNetCore *OSCSenderWidget_OSCNetCore;

signals:
void sendCommand(QString);
void sendCommand(QString, int, bool);

private slots:
void sendButton_Pressed();
void on_cbxProfile_indexChanged(int);
void on_spbPort_valueChanged(int);

private:
QTextEdit *OSCSenderWidget_commandTextEdit;
QSpinBox *OSCSenderWidget_spbPort;
QLabel *OSCSenderWidget_label_2;
QPushButton *OSCSenderWidget_sendButton;
QStringList *OSCSenderWidget_data_cbxName;
QStringList *OSCSenderWidget_data_ports;
QStringList *OSCSenderWidget_data_oscCommand;
QStringList *OSCSenderWidget_data_oscType;
qint16 _cbxProfile_index;
qint32 _sendPort;
bool _sentModeBundle;

void OSCSenderWidget_dataInitial();


};
Expand Down

0 comments on commit 3404e24

Please sign in to comment.