void addOpt( char* arg, Codegen cg ) { if ( strcmp( "-O1", arg ) == 0 ) { std::cout << "Optimization: instruction combining" << std::endl; cg.opt_instcombine(); } else if ( strcmp( "-O2", arg ) == 0 ) { std::cout << "Optimization: reassociate" << std::endl; cg.opt_reassociate(); } else if ( strcmp( "-O3", arg ) == 0 ) { std::cout << "Optimization: dead code elimination" << std::endl; cg.opt_dce(); } else if ( strcmp( "-O4", arg ) == 0 ) { std::cout << "Optimization: global value numbering" << std::endl; cg.opt_gvn(); } else if ( strcmp( "-O5", arg ) == 0 ) { std::cout << "Optimization: simplify CFG" << std::endl; cg.opt_simplifyCFG(); } else if ( strcmp( "-Oall", arg ) == 0 ) { std::cout << "Optimization: instruction combining, " << std::endl << "\t reassociate, " << std::endl << "\t dead code elimination, " << std::endl << "\t global value numbering, " << std::endl << "\t simplify CFG" << std::endl; cg.opt_instcombine(); cg.opt_reassociate(); cg.opt_dce(); cg.opt_gvn(); cg.opt_simplifyCFG(); } }
void Eyrie::process() { if(recbin == NULL) { return; } if(GST_BUFFER_SIZE(buf) == 0) { endRecording(); QVariant ret; QMetaObject::invokeMethod(parent(), "setStatus", Q_RETURN_ARG(QVariant, ret), Q_ARG(QVariant, "Sorry, the recording failed.")); return; } mutex->lock(); const float *pcm = (const float *) GST_BUFFER_DATA(buf); Codegen *codegen = new Codegen(pcm, GST_BUFFER_SIZE(buf) / sizeof(float), 0); mutex->unlock(); std::string code = codegen->getCodeString(); QNetworkAccessManager *networkManager = new QNetworkAccessManager(); QUrl url("http://developer.echonest.com/api/v4/song/identify"); QByteArray params; params.append("api_key=RIUKSNTIPKUMPHPEO"); params.append("&query=[{\"metadata\":{\"version\":4.12},\"code\":\""); params.append(code.c_str()); params.append("\"}]"); QNetworkRequest request; request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded;charset=UTF-8"); request.setUrl(url); connect(networkManager, SIGNAL(finished(QNetworkReply *)), this, SLOT(parseResponse(QNetworkReply *))); networkManager->post(request, params); }
JNIEXPORT jstring JNICALL Java_com_appunite_ffmpeg_FFmpegPlayer_codegen(JNIEnv *env, jobject thiz, jfloatArray pcmData, jint numSamples) { // get the contents of the java array as native floats float *data = (float *) env->GetFloatArrayElements(pcmData, 0); // invoke the codegen Codegen c = Codegen(data, (unsigned int) numSamples, 0); const char *code = c.getCodeString().c_str(); // release the native array as we're done with them env->ReleaseFloatArrayElements(pcmData, data, 0); // return the fingerprint string return env->NewStringUTF(code); }
JNIEXPORT jstring JNICALL Java_musaic_songRecognizer_Codegen_EchoprintCodegen (JNIEnv *env, jobject thiz, jfloatArray javaPcmData, jint numSamples) { // cast de la jfloatArray la float* float *pcmData = (float *)env->GetFloatArrayElements(javaPcmData, 0); // utilizeaza libraria Echoprint pentru a obtine hashcode-ul Codegen c = Codegen(pcmData, (unsigned int)numSamples, 0); const char *code = c.getCodeString().c_str(); // elibereaza resursele folosite env->ReleaseFloatArrayElements(javaPcmData, pcmData , 0); // returneaza hashcode-ul return env->NewStringUTF(code); }
int main( int argc, char* argv[] ) { std::cout << "Tegan Language Compiler v.0.1" << std::endl<< std::endl << std::endl; FILE* file = fopen( argv[ 1 ], "r" ); if ( file == 0 ) { std::cout << "Can't open file " << argv[ 1 ] << "\n"; return 1; } if ( argv[ 2 ] == NULL ) { std::cout << "Specify output file" << std::endl; return 1; } char* output = argv[ 2 ]; auto parser = Parser(); Node* root = parser.parse( file ); std::cout << std::endl; Printer printer = Printer(); Codegen codegen = Codegen(); for ( int i = 3; i < argc; ++i ) { addOpt( argv[ i ], codegen ); } if ( root != NULL ) { std::cout << std::endl; root->accept( printer ); if ( !parser.isFailed() ) { std::cout << std::endl; root->accept( codegen ); codegen.dump(); codegen.save( output ); } } else { std::cout << "EXIT" << std::endl; } std::cout << std::endl << std::endl << std::endl; }
static PyObject * echoprint_codegen(PyObject *self, PyObject *args) { PyObject *py_samples; int start_offset = 0; PyObject *item; float *samples; uint num_samples; uint i; Codegen *pCodegen; PyObject *result; std::ostringstream version_string; if (!PyArg_ParseTuple(args, "O|i", &py_samples, &start_offset)) { return NULL; } if (!PySequence_Check(py_samples)) { PyErr_SetString(PyExc_TypeError, "expected sequence"); return NULL; } num_samples = PySequence_Size(py_samples); samples = new float[num_samples]; for (i = 0; i < num_samples; i++) { item = PySequence_GetItem(py_samples, i); if (!PyFloat_Check(item)) { delete[] samples; PyErr_SetString(PyExc_TypeError, "expected sequence of floats"); return NULL; } samples[i] = (float)PyFloat_AsDouble(item); Py_DECREF(item); } pCodegen = new Codegen(samples, num_samples, start_offset); version_string << pCodegen->getVersion(); result = Py_BuildValue("{s:s,s:s}", "code", pCodegen->getCodeString().c_str(), "version", version_string.str().c_str() ); delete pCodegen; delete[] samples; return result; }