Beispiel #1
0
void fillBufferWithInputProcess(uint8_t buffer_offset)
{
      getADC_Raw();
			uint16_t i = 0;
			int16_t current_sample = 0;    
	    if(buffer_offset == 0)
      {
					for (i = 0; i < (HALF_BUFFER_SIZE); i++)
					{
						if ((i & 1) == 0)
						{
							testTemp = myProcess(Receive_Buffer[i] * INV_TWO_TO_15) * TWO_TO_15;
							current_sample = (int16_t) testTemp;
						}
						Send_Buffer[i] = current_sample;
					}
      }
      
      if(buffer_offset == 1)
      {
					for (i = 0; i < (HALF_BUFFER_SIZE); i++)
					{
						if ((i & 1) == 0)
						{
 							testTemp = myProcess((float) (Receive_Buffer[HALF_BUFFER_SIZE + i] * INV_TWO_TO_15)) * TWO_TO_15;
							current_sample = (int16_t) testTemp;
						}
						Send_Buffer[HALF_BUFFER_SIZE + i] = current_sample;
					}
      } 
			//readExternalADC(whichknob);
			whichknob++;
			if (whichknob > 6)
			{
				whichknob = 0;
			}
}
Beispiel #2
0
void MediaDialog::addAudioPressed()
      {
      QString path = audioFile->text();
      if (score->audio() || path.isEmpty())
            return;
      QFile f(path);
      if (!f.open(QIODevice::ReadOnly))
            return;
      QByteArray ba = f.readAll();
      f.close();
      Audio* audio = new Audio;
      audio->setPath(path);
      audio->setData(ba);
      score->setAudio(audio);
      score->setDirty(true);
      mscore->updatePlayMode();

#if 0
      QString wavPath = QDir::tempPath() + "/score.wav";
      mscore->saveAs(score, true, wavPath, "wav");
      QString program = "D:/HACK/sonic-annotator/bologna.bat";
      QStringList arguments;
      arguments << QDir::toNativeSeparators(path)<< QDir::toNativeSeparators(wavPath);
      QProcess myProcess(this);
      myProcess.start(program, arguments);
      myProcess.waitForFinished();
      qDebug() << myProcess.readAll();
#endif

      QFileInfo fi(path);
      QFile syncFile(fi.absolutePath() + "/" + fi.baseName() + ".txt");

      TempoMap* tmo = score->tempomap();

      if (!syncFile.open(QIODevice::ReadOnly))
            return;

      qreal t = 0;
      int tick = 0;
      qreal lastTempo = tmo->tempo(0);
      TempoMap* tmn = new TempoMap();
      tmn->setTempo(0, lastTempo);
      int resolution = 25;
      while (!syncFile.atEnd()) {
            for (int i = 0; !syncFile.atEnd() && i < resolution-1; i++)
                  syncFile.readLine();

            if (syncFile.atEnd())
                  break;

            QByteArray line = syncFile.readLine();
            QString s(line);
            QStringList sl = s.split(":");

            qreal tScore = sl[0].trimmed().toDouble();
            qreal tPerformance = sl[1].trimmed().toDouble();

            // timestamp of last
            int scoreTick = tmo->time2tick(tScore);
            qreal deltaError = tmo->tick2time(scoreTick) - tScore;
            int dt = scoreTick - tick;
            qreal deltaTime = tPerformance - t;

            if (deltaTime > 0) {
                  qreal tempo = dt / (480 * deltaTime);
                  if(tempo != lastTempo) {
                  qDebug() << tempo;
                        tmn->setTempo(tick, tempo);
                        lastTempo = tempo;
                        }
                  }

            t = tPerformance - deltaError;
            tick = scoreTick;
            }
      score->setTempomap(tmn);
      syncFile.close();
      QMessageBox::information(0, "Done", "Done");
      }
void tetgen_options::accept()
{
	//Aplicamos los algoritmos de tetgen y dejamos el resultado en tetgen_result
	QString tetgen_app = settings->value("tetgen_app").toString();
	if (tetgen_app.isEmpty())
	{
		QMessageBox::warning (this, tr ("Error"), tr("Path to tetgen not defined in settings"));
		output = NULL;
		return;
	}

	//Creacion de los argumentos
	QString offFilename = Ui.outputDirectory->text() + "/tempfile.off";
	QStringList args;
    //argsChanged();//Allow user to override all args

    args << Ui.tetgen_args->text() << offFilename;

	qDebug() << tetgen_app << " " << args.join (" ");

	//Escribimos el nodo en el fichero OFF
	FILE *offFile = fopen(qPrintable(offFilename), "w");

	if (offFile == NULL)
	{
		QMessageBox::warning (this, tr ("Error"), tr("Could not create file ")+QString(offFilename));
		output = NULL;
		return;
	}

    if (input->getTail()->getTypeId().isDerivedFrom(SoIndexedFaceSet::getClassTypeId())) 
    {
    	IndexedFaceSet_to_OFF (input, offFile);
    }
    else if (input->getTail()->getTypeId().isDerivedFrom(SoVRMLIndexedFaceSet::getClassTypeId())) 
    {
		VRMLIndexedFaceSet_to_OFF((SoVRMLIndexedFaceSet *)input->getTail(), offFile);
    }

	fclose(offFile);

	//Iniciamos tetgen
	QProcess myProcess(this);
	myProcess.start(tetgen_app, args);

	//Esperamos hasta que comience el proceso y verificamos que lo hizo bien
	if (!myProcess.waitForStarted())
	{
		// error handling
		QString S;
		S = tr ("Error executing: ");
		S += tetgen_app + QString(" ") + args.join (" ");
		QMessageBox::warning (this, tr ("Error"), S);
		QDialog::accept();
		return;
	}

	//Esperamos hasta que haya finalizado
	if (!myProcess.waitForFinished (-1))
	{
		// error handling
		QString S;
		S = tr("tetgen returned an error")+"\n";
		S += myProcess.readAllStandardError (); 
		QMessageBox::warning (this, tr ("Error"), S);
		QDialog::accept();
		return;
	}

	//output handling
	QString S;
	S = tr("tetgen output")+"\n";
	S += myProcess.readAllStandardError (); 
	S += myProcess.readAllStandardOutput();

	//Mira si se ha producido un error en la salida de tetgen
	if (S.contains("Error: "))
	{
		QMessageBox::warning (this, tr ("Error"), S);
		QDialog::accept();
		return;
	}
	else
		QMessageBox::information(this, tr("tetgen output"), S);

	//Leemos el fichero .node de salida
	QString nodeFilename = Ui.outputDirectory->text() + "/tempfile.1.node";	
	output = import_tetgen(qPrintable(nodeFilename));

	if (output != NULL)
		output->setName("tetgen_output");

	QDialog::accept();
} // void tetgen_options::accept()