This section provides examples of the GUIDO library use.
#include <iostream> #include "GUIDOEngine.h" #include "GDevicePostScript.h" using namespace std; // --------------------------------------------------------------------------- // This example of code is intended to show the minimum steps to read a // GMN file and to display it. // Take care that for simplicity, this example doesn't check return codes // --------------------------------------------------------------------------- void DrawGMNFile (const char * filename) { ARHandler arh; // use a GDevicePostScript with a 72 dpi resolution GDevicePostScript dev ((int)(21*72/2.54), (int)(29.7*72/2.54), "outfile.eps", "", ""); // declare a data structure for engine initialisation // we'll make use of the default graphic device (embedded in the library) // Guido font is guido2 and text font is times GuidoInitDesc gd = { &dev, 0, "guido2", "Times" }; GuidoOnDrawDesc desc; // declare a data structure for drawing GuidoInit (&gd); // Initialise the Guido Engine first // and parse the GMN file to get a GGR handle directly stored in the drawing struct GuidoParseFile (filename, &arh); GuidoAR2GR (arh, 0, &desc.handle); desc.hdc = &dev; // we'll draw on the postscript device desc.page = 1; // draw the first page only desc.updateRegion.erase = true; // and draw everything desc.scrollx = desc.scrolly = 0; // from the upper left page corner desc.sizex = desc.sizey = 500; // size of the drawing region GuidoOnDraw (&desc); } int main(int argc, char **argv) { const char * file = argv[1]; DrawGMNFile (file); return 0; }
#include "GUIDOFactory.h" // --------------------------------------------------------------------------- // Guido Factory example of use // Take care that for simplicity, this example doesn't check return codes // --------------------------------------------------------------------------- void TestGuidoFactory() { ARHandler ar; GRHandler gr; ARFactoryHandler *f; GuidoFactoryOpen(&f); // open the GUIDO Factory first GuidoFactoryOpenMusic(f); // and create a new score GuidoFactoryOpenVoice(f); // open a new voice GuidoFactoryOpenEvent(f, "c" ); // open a new note GuidoFactoryCloseEvent(f); // close the note which is now part of the opened voice GuidoFactoryOpenEvent(f, "e" ); // open another new note GuidoFactoryAddSharp(f); // add a sharp to the opened note GuidoFactoryCloseEvent(f); // and close the note which is now part of the opened voice GuidoFactoryCloseVoice(f); // close the voice which is now part of the opened score GuidoFactoryOpenVoice(f); // open a second voice GuidoFactoryOpenEvent(f, "a" ); // open a new voice GuidoFactoryAddFlat(f); // add a flat to the opened note GuidoFactoryCloseEvent(f); // and close the note which is now part of the second voice GuidoFactoryOpenEvent(f, "d" ); // open another new note GuidoFactoryCloseEvent(f); // and close the note which is now part of the second voice GuidoFactoryCloseVoice(f); // close the voice which is now part of the opened score // - Extract AR and GR ar = GuidoFactoryCloseMusic(f); // extract the GAR handle GuidoAR2GR( ar, 0, &gr ); // and the GGR handle GuidoFactoryClose(f); // close the GUIDO Factory which won't be used any more if( gr ) // check for the handle validity { // ... Do something with the GGR handle (i.e: draw) } }