void Engine::startRecording() { if (m_audioInput) { if (QAudio::AudioInput == m_mode && QAudio::SuspendedState == m_state) { m_audioInput->resume(); } else { m_spectrumAnalyser.cancelCalculation(); spectrumChanged(0, 0, FrequencySpectrum()); m_buffer.fill(0); setRecordPosition(0, true); stopPlayback(); m_mode = QAudio::AudioInput; CHECKED_CONNECT(m_audioInput, SIGNAL(stateChanged(QAudio::State)), this, SLOT(audioStateChanged(QAudio::State))); CHECKED_CONNECT(m_audioInput, SIGNAL(notify()), this, SLOT(audioNotify())); m_count = 0; m_dataLength = 0; emit dataLengthChanged(0); m_audioInputIODevice = m_audioInput->start(); CHECKED_CONNECT(m_audioInputIODevice, SIGNAL(readyRead()), this, SLOT(audioDataReady())); } } }
void Engine::startPlayback() { if (m_audioOutput) { if (QAudio::AudioOutput == m_mode && QAudio::SuspendedState == m_state) { m_audioOutput->resume(); } else { m_spectrumAnalyser.cancelCalculation(); spectrumChanged(0, 0, FrequencySpectrum()); setPlayPosition(0, true); m_mode = QAudio::AudioOutput; CHECKED_CONNECT(m_audioOutput, SIGNAL(stateChanged(QAudio::State)), this, SLOT(audioStateChanged(QAudio::State))); CHECKED_CONNECT(m_audioOutput, SIGNAL(notify()), this, SLOT(audioNotify())); m_count = 0; if (m_file) { m_file->seek(0); m_bufferPosition = 0; m_dataLength = 0; m_audioOutput->start(m_file); } else { m_audioOutputIODevice.close(); m_audioOutputIODevice.setBuffer(&m_buffer); m_audioOutputIODevice.open(QIODevice::ReadOnly); m_audioOutput->start(&m_audioOutputIODevice); } } } }
SettingsDialog::SettingsDialog(const Settings& settings, qulonglong currModBase, QWidget* parent) : QDialog(parent) , m_UI(new Ui::SettingsDialog) , m_PaletteChanged(false) { m_UI->setupUi(this); CHECKED_CONNECT(connect(m_UI->bTestConnection, SIGNAL(clicked()), this, SIGNAL(testConnection()))); CHECKED_CONNECT(connect(m_UI->bDiscard, SIGNAL(clicked()), this, SLOT(reject()))); const QVariantList prevHosts = GlobalSettingsManger::instance(). value(GSK_PrevEnteredOllyHosts).toList(); m_UI->cbOllyIP->clear(); foreach(const QVariant& v, prevHosts) { const QString sv = v.toString().trimmed(); if (sv.isEmpty()) continue; m_UI->cbOllyIP->addItem(sv); } const QString currHostVal = QString::fromStdString(settings.host); int currHostIdx = m_UI->cbOllyIP->findText(currHostVal); if (currHostIdx == -1) { m_UI->cbOllyIP->insertItem(0, currHostVal); } m_UI->cbOllyIP->setCurrentIndex(m_UI->cbOllyIP->findText(currHostVal)); m_UI->sbOllyPort->setValue(settings.port); m_UI->leRemoteModuleBase->setText(QString("0x%1").arg(settings.remoteModBase, sizeof(ea_t) * 2, 16, QChar('0'))); m_UI->leRemoteModuleBase->setToolTip(QString("Current IDA DB's module base is 0x%1.").arg(currModBase, sizeof(ea_t) * 2, 16, QChar('0'))); m_UI->gbEnabledSync->setChecked(settings.enabled); m_UI->chDemangleNames->setChecked(settings.demangle); m_UI->chLocalLabels->setChecked(settings.localLabels); m_UI->chPerformPEAnalysis->setChecked(settings.analysePEHeader); m_UI->chPostProcessFixCallJumps->setChecked(settings.postProcessFixCallJumps); m_UI->chNonCodeNames->setChecked(settings.nonCodeNames); m_UI->cbOverwriteWarning->setCurrentIndex(settings.overwriteWarning); m_UI->cbCommentsSync->setCurrentIndex(settings.commentsSync); QLabel* const lVer = new QLabel(m_UI->tabWidget); lVer->setText(QString("v %1").arg(LABELESS_VER_STR)); lVer->setStyleSheet("color: rgb(0x8a, 0x8a, 0x8a);"); QGraphicsDropShadowEffect* const effect = new QGraphicsDropShadowEffect(lVer); effect->setBlurRadius(5); effect->setOffset(0); effect->setColor(Qt::white); lVer->setGraphicsEffect(effect); m_UI->tabWidget->setCornerWidget(lVer); setUpPalette(); setFixedSize(size()); adjustSize(); setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); }
SpectrumAnalyser::SpectrumAnalyser(QObject *parent) : QObject(parent) , m_thread(new SpectrumAnalyserThread(this)) , m_state(Idle) #ifdef DUMP_SPECTRUMANALYSER , m_count(0) #endif { CHECKED_CONNECT(m_thread, SIGNAL(calculationComplete(FrequencySpectrum)), this, SLOT(calculationComplete(FrequencySpectrum))); CHECKED_CONNECT(m_thread, SIGNAL(sampleLoaded(FrequencySpectrum)), this, SLOT(sampleLoaded(FrequencySpectrum))); }
Engine::Engine(QObject *parent) : QObject(parent) , m_mode(QAudio::AudioInput) , m_state(QAudio::StoppedState) , m_generateTone(false) , m_file(0) , m_analysisFile(0) , m_availableAudioOutputDevices (QAudioDeviceInfo::availableDevices(QAudio::AudioOutput)) , m_audioOutputDevice(QAudioDeviceInfo::defaultOutputDevice()) , m_audioOutput(0) , m_playPosition(0) , m_bufferPosition(0) , m_bufferLength(0) , m_dataLength(0) , m_levelBufferLength(0) , m_rmsLevel(0.0) , m_peakLevel(0.0) , m_spectrumBufferLength(0) , m_spectrumAnalyser() , m_spectrumPosition(0) , m_ffmpegHelper(new ffmpegHelper()) , m_count(0) { qRegisterMetaType<FrequencySpectrum>("FrequencySpectrum"); qRegisterMetaType<WindowFunction>("WindowFunction"); CHECKED_CONNECT(&m_spectrumAnalyser, SIGNAL(spectrumChanged(FrequencySpectrum)), this, SLOT(spectrumChanged(FrequencySpectrum))); connect(this, SIGNAL(bufferChanged(qint64, qint64, const QByteArray)),this,SLOT(handleBufferChanged(qint64, qint64, const QByteArray))); // check the system for the app #ifdef Q_OS_LINUX _OS = Linux; #endif #ifdef Q_OS_WIN _OS = Windows; #endif #ifdef Q_OS_ANDROID _OS = Android; #endif #ifdef Q_OS_IOS _OS = Ios; #endif #ifdef Q_OS_MAC _OS = Mac; #endif initialize(); m_bar.resize(SpectrumNumBands); }
SublevelNodeItem::SublevelNodeItem(Node *node, QGraphicsItem *parent) : NodeItem(node, parent) { m_sublevelNode = dynamic_cast<SublevelNode *>(node); m_rangeMeter = new RangeMeter(); CHECKED_CONNECT(m_sublevelNode, SIGNAL(levelChanged(qreal)), m_rangeMeter, SLOT(levelChanged(qreal))); QGraphicsProxyWidget *proxy = new QGraphicsProxyWidget(this); proxy->setWidget(m_rangeMeter); proxy->setPos(0, (m_node->getParams().size()+1)*guisettings->m_PIheight); }
TextEdit::TextEdit(QWidget* parent) : QTextEdit(parent) { m_Highlighter = new Highlighter(document()); m_Completer = new QCompleter(QStringList() << "class"<< "def"<< "import"<< "from"<< "with" << "__extern__" << "__result__" << "__result_str__", this); // TODO: add support to load from file m_Completer->setCompletionMode(QCompleter::PopupCompletion); m_Completer->setCaseSensitivity(Qt::CaseInsensitive); m_Completer->setWidget(this); CHECKED_CONNECT(connect(m_Completer, SIGNAL(activated(QString)), this, SLOT(insertCompletion(QString)))); setAcceptRichText(false); }
void AudioReceiver::initClient() { quint16 port = (quint16) (set->getAudioPort() + (io->audio_rx * 2)); QUdpSocket *socket = new QUdpSocket(); socket->setSocketOption(QAbstractSocket::LowDelayOption, 1); if (socket->bind(port, QUdpSocket::ReuseAddressHint | QUdpSocket::ShareAddress)) { CHECKED_CONNECT( socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(displayAudioRcvrSocketError(QAbstractSocket::SocketError))); CHECKED_CONNECT( socket, SIGNAL(readyRead()), this, SLOT(readPendingAudioRcvrData())); clientConnections.append(socket); AUDIO_RECEIVER << "client socket binding successful."; m_message = tr("[server]: listening for rx %1 audio on port %2."); emit messageEvent(m_message.arg(io->audio_rx).arg(port)); //m_dataEngine->clientConnected = true; // need to implement connection in dataEngine !!!! emit clientConnectedEvent(true); //rcveIQ_toggle = false; } else { m_message = tr("[server]: bind socket failed for socket on port %1."); emit messageEvent(m_message.arg(port)); } }
void Engine::startPlayback() { if (m_audioOutput) { if (QAudio::AudioOutput == m_mode && QAudio::SuspendedState == m_state) { #ifdef Q_OS_WIN // The Windows backend seems to internally go back into ActiveState // while still returning SuspendedState, so to ensure that it doesn't // ignore the resume() call, we first re-suspend m_audioOutput->suspend(); #endif m_audioOutput->resume(); } else { m_spectrumAnalyser.cancelCalculation(); spectrumChanged(0, 0, FrequencySpectrum()); setPlayPosition(0, true); stopRecording(); m_mode = QAudio::AudioOutput; CHECKED_CONNECT(m_audioOutput, SIGNAL(stateChanged(QAudio::State)), this, SLOT(audioStateChanged(QAudio::State))); CHECKED_CONNECT(m_audioOutput, SIGNAL(notify()), this, SLOT(audioNotify())); m_count = 0; if (m_file) { m_file->seek(0); m_bufferPosition = 0; m_dataLength = 0; m_audioOutput->start(m_file); } else { m_audioOutputIODevice.close(); m_audioOutputIODevice.setBuffer(&m_buffer); m_audioOutputIODevice.open(QIODevice::ReadOnly); m_audioOutput->start(&m_audioOutputIODevice); } } } }
Engine::Engine(QObject *parent) : QObject(parent) , m_mode(QAudio::AudioInput) , m_state(QAudio::StoppedState) , m_generateTone(false) , m_file(0) , m_analysisFile(0) , m_availableAudioInputDevices (QAudioDeviceInfo::availableDevices(QAudio::AudioInput)) , m_audioInputDevice(QAudioDeviceInfo::defaultInputDevice()) , m_audioInput(0) , m_audioInputIODevice(0) , m_recordPosition(0) , m_availableAudioOutputDevices (QAudioDeviceInfo::availableDevices(QAudio::AudioOutput)) , m_audioOutputDevice(QAudioDeviceInfo::defaultOutputDevice()) , m_audioOutput(0) , m_playPosition(0) , m_bufferPosition(0) , m_bufferLength(0) , m_dataLength(0) , m_levelBufferLength(0) , m_rmsLevel(0.0) , m_peakLevel(0.0) , m_spectrumBufferLength(0) , m_spectrumAnalyser() , m_spectrumPosition(0) , m_count(0) { qRegisterMetaType<FrequencySpectrum>("FrequencySpectrum"); qRegisterMetaType<WindowFunction>("WindowFunction"); CHECKED_CONNECT(&m_spectrumAnalyser, SIGNAL(spectrumChanged(FrequencySpectrum)), this, SLOT(spectrumChanged(FrequencySpectrum))); initialize(); #ifdef DUMP_DATA createOutputDir(); #endif #ifdef DUMP_SPECTRUM m_spectrumAnalyser.setOutputPath(outputPath()); #endif }
int Discoverer::findHPSDRDevices() { int devicesFound = 0; m_findDatagram.resize(63); m_findDatagram[0] = (char)0xEF; m_findDatagram[1] = (char)0xFE; m_findDatagram[2] = (char)0x02; for (int i = 3; i < 63; i++) m_findDatagram[i] = (char)0x00; QUdpSocket socket; CHECKED_CONNECT( &socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(displayDiscoverySocketError(QAbstractSocket::SocketError))); io->networkIOMutex.lock(); DISCOVERER_DEBUG << "using " << qPrintable(QHostAddress(set->getHPSDRDeviceLocalAddr()).toString()) << " for discovery."; io->networkIOMutex.unlock(); // clear comboBox entries in the network dialogue set->clearNetworkIOComboBoxEntry(); #if defined(Q_OS_WIN32) if (socket.bind( QHostAddress(set->getHPSDRDeviceLocalAddr()), 0, QUdpSocket::ReuseAddressHint | QUdpSocket::ShareAddress)) //QUdpSocket::ReuseAddressHint)) { set->setMetisPort(this, socket.localPort()); io->networkIOMutex.lock(); DISCOVERER_DEBUG << "discovery_socket bound successfully to port " << socket.localPort(); io->networkIOMutex.unlock(); } else { io->networkIOMutex.lock(); DISCOVERER_DEBUG << "discovery_socket bind failed."; io->networkIOMutex.unlock(); socket.close(); return 0; } #elif defined(Q_OS_LINUX) if (socket.bind( QHostAddress(set->getHPSDRDeviceLocalAddr()), QUdpSocket::DefaultForPlatform)) { CHECKED_CONNECT( &socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(displayDiscoverySocketError(QAbstractSocket::SocketError))); set->setMetisPort(this, socket.localPort()); io->networkIOMutex.lock(); DISCOVERER_DEBUG << "discovery_socket bound successfully to port " << socket.localPort(); io->networkIOMutex.unlock(); } else { io->networkIOMutex.lock(); DISCOVERER_DEBUG << "discovery_socket bind failed."; io->networkIOMutex.unlock(); socket.close(); return 0; } #endif if (socket.writeDatagram(m_findDatagram, QHostAddress::Broadcast, DEVICE_PORT) == 63) { io->networkIOMutex.lock(); DISCOVERER_DEBUG << "discovery data sent."; io->networkIOMutex.unlock(); } else { io->networkIOMutex.lock(); DISCOVERER_DEBUG << "discovery data not sent."; io->networkIOMutex.unlock(); } // wait a little //SleeperThread::msleep(30); SleeperThread::msleep(500); while (socket.hasPendingDatagrams()) { TNetworkDevicecard mc; quint16 port; m_deviceDatagram.resize(socket.pendingDatagramSize()); socket.readDatagram(m_deviceDatagram.data(), m_deviceDatagram.size(), &mc.ip_address, &port); if (m_deviceDatagram[0] == (char)0xEF && m_deviceDatagram[1] == (char)0xFE) { if (m_deviceDatagram[2] == (char)0x02) { sprintf(mc.mac_address, "%02X:%02X:%02X:%02X:%02X:%02X", m_deviceDatagram[3] & 0xFF, m_deviceDatagram[4] & 0xFF, m_deviceDatagram[5] & 0xFF, m_deviceDatagram[6] & 0xFF, m_deviceDatagram[7] & 0xFF, m_deviceDatagram[8] & 0xFF); io->networkIOMutex.lock(); DISCOVERER_DEBUG << "Device found at " << qPrintable(mc.ip_address.toString()) << ":" << port << "; Mac addr: [" << mc.mac_address << "]"; DISCOVERER_DEBUG << "Device code version: " << qPrintable(QString::number(m_deviceDatagram.at(9), 16)); io->networkIOMutex.unlock(); int no = m_deviceDatagram.at(10); QString str; if (no == 0) str = "Metis"; else if (no == 1) str = "Hermes"; else if (no == 2) str = "Griffin"; else if (no == 4) str = "Angelia"; mc.boardID = no; mc.boardName = str; io->networkIOMutex.lock(); DISCOVERER_DEBUG << "Device board ID: " << no; DISCOVERER_DEBUG << "Device is: " << qPrintable(str); io->networkIOMutex.unlock(); m_deviceCards.append(mc); str += " ("; str += mc.ip_address.toString(); str += ")"; set->addNetworkIOComboBoxEntry(str); devicesFound++; } else if (m_deviceDatagram[2] == (char)0x03) { io->networkIOMutex.lock(); DISCOVERER_DEBUG << "Device already sending data!"; io->networkIOMutex.unlock(); } } } set->setMetisCardList(m_deviceCards); if (devicesFound == 1) { set->setCurrentHPSDRDevice(m_deviceCards.at(0)); io->networkIOMutex.lock(); DISCOVERER_DEBUG << "Device selected: " << qPrintable(m_deviceCards.at(0).ip_address.toString()); io->networkIOMutex.unlock(); } socket.close(); return devicesFound; }
void TransmitOptionsWidget::createSourceGroup() { QLabel* sourceLabel = new QLabel("Source:", this); sourceLabel->setFrameStyle(QFrame::Box | QFrame::Raised); sourceLabel->setStyleSheet(set->getLabelStyle()); micInputBtn = new AeroButton("Mic Input", this); micInputBtn->setRoundness(0); micInputBtn->setFixedSize(btn_width, btn_height); micInputBtn->setBtnState(AeroButton::ON); CHECKED_CONNECT( micInputBtn, SIGNAL(clicked()), this, SLOT(inputButtonClicked())); lineInputBtn = new AeroButton("Line Input", this); lineInputBtn->setRoundness(0); lineInputBtn->setFixedSize(btn_width, btn_height); lineInputBtn->setBtnState(AeroButton::OFF); CHECKED_CONNECT( lineInputBtn, SIGNAL(clicked()), this, SLOT(inputButtonClicked())); QLabel* maxLabel = new QLabel("Max Gain (dB):", this); maxLabel->setFrameStyle(QFrame::Box | QFrame::Raised); maxLabel->setStyleSheet(set->getLabelStyle()); QLabel* minLabel = new QLabel("Min Gain (dB):", this); minLabel->setFrameStyle(QFrame::Box | QFrame::Raised); minLabel->setStyleSheet(set->getLabelStyle()); micGainMaxSpinBox = new QSpinBox(this); micGainMaxSpinBox->setMinimum(1); micGainMaxSpinBox->setMaximum(70); micGainMaxSpinBox->setStyleSheet(set->getSpinBoxStyle()); micGainMaxSpinBox->setValue(10); micGainMinSpinBox = new QSpinBox(this); micGainMinSpinBox->setMinimum(-96); micGainMinSpinBox->setMaximum(0); micGainMinSpinBox->setStyleSheet(set->getSpinBoxStyle()); micGainMinSpinBox->setValue(-40); QLabel* boostLabel = new QLabel("20 dB Mic Boost:", this); boostLabel->setFrameStyle(QFrame::Box | QFrame::Raised); boostLabel->setStyleSheet(set->getLabelStyle()); micBoostBtn = new AeroButton(" Off ", this); micBoostBtn->setRoundness(0); micBoostBtn->setFixedSize(btn_width, btn_height); micBoostBtn->setBtnState(AeroButton::OFF); CHECKED_CONNECT( micBoostBtn, SIGNAL(clicked()), this, SLOT(boostButtonClicked())); QHBoxLayout *hbox1 = new QHBoxLayout(); hbox1->setSpacing(4); hbox1->addWidget(sourceLabel); hbox1->addStretch(); hbox1->addWidget(micInputBtn); hbox1->addWidget(lineInputBtn); QHBoxLayout *hbox2 = new QHBoxLayout(); hbox2->setSpacing(4); hbox2->addWidget(boostLabel); hbox2->addStretch(); hbox2->addWidget(micBoostBtn); QHBoxLayout *hbox3 = new QHBoxLayout(); hbox3->setSpacing(4); hbox3->addWidget(maxLabel); hbox3->addStretch(); hbox3->addWidget(micGainMaxSpinBox); QHBoxLayout *hbox4 = new QHBoxLayout(); hbox4->setSpacing(4); hbox4->addWidget(minLabel); hbox4->addStretch(); hbox4->addWidget(micGainMinSpinBox); QVBoxLayout *vbox = new QVBoxLayout(); vbox->setSpacing(4); vbox->addSpacing(6); vbox->addLayout(hbox1); vbox->addLayout(hbox2); vbox->addSpacing(12); vbox->addLayout(hbox3); vbox->addLayout(hbox4); sourceGroup = new QGroupBox(tr("Mic / Line Options"), this); sourceGroup->setMinimumWidth(m_minimumGroupBoxWidth); sourceGroup->setLayout(vbox); sourceGroup->setStyleSheet(set->getWidgetStyle()); sourceGroup->setFont(QFont("Arial", 8)); }