filterNetworkAccessModule::filterNetworkAccessModule() { this->networkAccessStatus = -1; this->netManager = new QNetworkAccessManager(); this->finalObjects = new QList< QMultiMap < QString, QString>* >; connect(this, SIGNAL(dataProcessed()), this, SLOT(dataHasBeenProcessed())); }
void CPUProcessor::blockProcessed() { if (blocksCountToProcess > 0) blocksCountToProcess--; if (blocksCountToProcess == 0) { emit dataProcessed(); delete[] blocks; blocks = new float[blocksCount * blockSize]; blocksCountToProcess = blocksCount; emit processBlock(blocks, results); } }
CPUProcessor::CPUProcessor(unsigned int bs, unsigned int bc, QObject *parent) : QThread(parent), blockSize(bs), blocksCount(bc), blocksCountToProcess(0) { this->moveToThread(this); subProcessors = new SubProcessor*[blocksCount]; for (unsigned int i = 0; i < blocksCount; i++) { subProcessors[i] = new SubProcessor(i, blockSize); connect(subProcessors[i], SIGNAL(dataProcessed()), this, SLOT(blockProcessed())); connect(this, SIGNAL(processBlock(float*,float*)), subProcessors[i], SLOT(processData(float*, float*))); subProcessors[i]->start(); } blocks = new float[blocksCount * blockSize]; results = new float[blocksCount]; }
QNetworkReply *filterNetworkAccessModule::Get() { QUrl url(this->requestURL); QNetworkRequest req(url); this->reply = netManager->get(req); connect(reply, SIGNAL(finished()), this, SLOT(networkReply())); connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(networkError(QNetworkReply::NetworkError))); { QEventLoop loop; loop.connect(this, SIGNAL(dataProcessed()), SLOT(quit())); // std::cout << "...in event loop..." << std::endl; loop.exec(); // std::cout << "EVENT LOOP HAS EXITED" << std::endl; } return this->reply; }
void View::setTerminal(Connection::Terminal *terminal) { Q_D(View); if (d->terminal == terminal) return; if (d->terminal) { disconnect(d->terminal); delete d->terminal; } d->terminal = terminal; if (!d->terminal) return; d->terminal->setParent(this); d->terminal->setView(this); connect(d->terminal, SIGNAL(dataProcessed()), SLOT(updateScreen())); d->terminal->connection()->connect(this, SIGNAL(hasBytesToSend(QByteArray)), SLOT(sendBytes(QByteArray))); connect(d->terminal, SIGNAL(shouldExtendTop(int,int)), SLOT(extendTop(int,int))); connect(d->terminal, SIGNAL(shouldExtendBottom(int,int)), SLOT(extendBottom(int,int))); }
void AudioCapture::run() { m_userStop = false; while (!m_userStop) { m_mutex.lock(); if (m_pause == false && m_captureSize != 0) { if (readAudio(m_captureSize) == true) { processData(); emit dataProcessed(m_fftMagnitudeBuffer, m_maxMagnitude, m_signalPower); } else qDebug() << "Error reading data from audio source"; } else usleep(15000); m_mutex.unlock(); } }
void DeviceData::showDevice(int idx, QString &deviceName, QString &xmlDesc) { if ( device!=nullptr ) closeDataEdit(); emit dataProcessed(false); devName->setText(QString("<b>%1</b>").arg(deviceName)); QDomDocument doc; doc.setContent(xmlDesc); QString deviceType; QDomElement _el = doc.firstChildElement("device"); if ( _el.isNull() ) return; QDomNode _node = _el.firstChild(); if ( _node.isNull() ) return; deviceType = _node.nodeName(); devIcon = new QLabel(this); devIcon->setPixmap(QIcon::fromTheme( QString("device-%1").arg(deviceType)) .pixmap(64)); if ( deviceType == "disk" ) { device = new Disk_Edit( this, ptr_ConnPtr); connect(device, SIGNAL(errorMsg(QString&)), this, SIGNAL(errorMsg(QString&))); } else if ( deviceType == "interface" ) {
void AudioCapture::processData() { #ifdef HAS_FFTW3 unsigned int i; quint64 pwrSum = 0; // 1 ********* Initialize FFTW fftw_plan plan_forward; plan_forward = fftw_plan_dft_r2c_1d(m_captureSize, m_fftInputBuffer, (fftw_complex*)m_fftOutputBuffer , 0); // 2 ********* Apply a window to audio data // *********** and convert it to doubles for (i = 0; i < m_captureSize; i++) { if(m_audioBuffer[i] < 0) pwrSum += -1 * m_audioBuffer[i]; else pwrSum += m_audioBuffer[i]; #ifdef USE_BLACKMAN double a0 = (1-0.16)/2; double a1 = 0.5; double a2 = 0.16/2; m_fftInputBuffer[i] = m_audioBuffer[i] * (a0 - a1 * qCos((M_2PI * i) / (m_captureSize - 1)) + a2 * qCos((2 * M_2PI * i) / (m_captureSize - 1))); #endif #ifdef USE_HANNING m_fftInputBuffer[i] = m_audioBuffer[i] * (0.5 * (1.00 - qCos((M_2PI * i) / (m_captureSize - 1)))); #endif #ifdef USE_NO_WINDOW m_fftInputBuffer[i] = (double)m_audioBuffer[i]; #endif } // 3 ********* Perform FFT fftw_execute(plan_forward); fftw_destroy_plan(plan_forward); // 4 ********* Clear FFT noise #ifdef CLEAR_FFT_NOISE //We delete some values since these will ruin our output for (int n = 0; n < 5; n++) { ((fftw_complex*)m_fftOutputBuffer)[n][0] = 0; ((fftw_complex*)m_fftOutputBuffer)[n][1] = 0; } #endif // 5 ********* Calculate the average signal power m_signalPower = pwrSum / m_captureSize; // 6 ********* Calculate vector magnitude foreach(int barsNumber, m_fftMagnitudeMap.keys()) { double maxMagnitude = fillBandsData(barsNumber); emit dataProcessed(m_fftMagnitudeMap[barsNumber].m_fftMagnitudeBuffer.data(), m_fftMagnitudeMap[barsNumber].m_fftMagnitudeBuffer.size(), maxMagnitude, m_signalPower); } #endif }
void FFTransformer::onDataProcessed(QVector<double> &data) { emit dataProcessed(data); qDebug("data emitted"); }