void ofxGuido::loadString(const char * s){ ARHandler arh = GuidoString2AR(mGuidoParser, s); int l, c; const char * errstr; GuidoErrCode err = GuidoParserGetErrorCode(mGuidoParser, l, c, &errstr); if(err != guidoNoErr){ GuidoFreeAR(arh); ofLogError("ofxGuido") << "GuidoParser error: " << errstr; } else{ GRHandler grh; err = GuidoAR2GR(arh, &mGuidoLayoutSettings, &grh); if(err == guidoNoErr){ if(mGRHandler){ GuidoFreeGR(mGRHandler); } mGRHandler = grh; mARHandler = arh; GuidoResizePageToMusic(mGRHandler); mGuidoOnDrawDesc.handle = mGRHandler; } else{ errstr = GuidoGetErrorString(err); ofLogError("ofxGuido") << "GuidoAR2GR error: " << errstr; GuidoFreeAR(arh); } } }
//------------------------------------------------------------------------- bool QGuidoPainter::setGMNData( const QString& dataSource , GuidoParseFunction parseFunction ) { // Read the gmnCode and build the score's Abstract Representation, // containing all the notes, rests, staffs, lyrics ... ARHandler arh; GRHandler grh; mLastErr = parseFunction( dataSource.toAscii().data(), &arh ); if ( mLastErr != guidoNoErr ) return false; // Build a new score Graphic Representation according the score's Abstract Representation. GuidoPageFormat currentFormat; GuidoGetDefaultPageFormat ( ¤tFormat ); GuidoSetDefaultPageFormat( &mPageFormat ); mLastErr = GuidoAR2GR (arh, &mLayoutSettings , &grh); GuidoSetDefaultPageFormat( ¤tFormat ); if (mLastErr == guidoNoErr) { GuidoFreeGR( mDesc.handle ); mDesc.handle = grh; GuidoFreeAR( mARHandler ); mARHandler = arh; if ( mResizePageToMusic ) mLastErr = GuidoResizePageToMusic( mDesc.handle ); } return (mLastErr == guidoNoErr); }
ofxGuido::~ofxGuido(){ GuidoFreeGR(mGRHandler); GuidoFreeAR(mARHandler); GuidoCloseParser(mGuidoParser); if(mGuidoDevice){ delete mGuidoDevice; } }
//------------------------------------------------------------------------- void QGuidoPainter::setARHandler( ARHandler ar ) { if (!ar) return; if (mDesc.handle) GuidoFreeGR( mDesc.handle ); if (mARHandler) GuidoFreeAR( mARHandler ); // Build a new score Graphic Representation according the score's Abstract Representation. mARHandler = ar; mGMNCode = ""; GuidoPageFormat currentFormat; GuidoGetDefaultPageFormat ( ¤tFormat ); GuidoSetDefaultPageFormat( &mPageFormat ); GuidoAR2GR (mARHandler, &mLayoutSettings , &mDesc.handle); GuidoSetDefaultPageFormat( ¤tFormat ); if ( mResizePageToMusic ) mLastErr = GuidoResizePageToMusic( mDesc.handle ); }
//------------------------------------------------------------------------- QGuidoPainter::~QGuidoPainter() { GuidoFreeGR( mDesc.handle ); GuidoFreeAR( mARHandler ); }