Пример #1
0
NSPStatus
Namespace::namespaceInit(bool useDeviceManager)
{
	// Initialise TT environments
	TTModularInit(m_appName, "");
	
	GalamusApplication = (TTApplicationPtr)TTModularGetApplication(TT(m_appName));
	
	if (NSPDirectory == NULL) {
		return NSP_INIT_ERROR;
	}

	if (useDeviceManager) {
		// Initialise DeviceManager if wanted
		/*TTDeviceManagerPtr */m_deMan = NULL;
		TTValue	args;
		
		// Make a TTDeviceManager object
		args.append(GalamusApplication);
		args.append(TT(m_appName));
		
		TTObjectInstantiate(TTSymbol("DeviceManager"), TTObjectHandle(&m_deMan), args);
		
		// Load plugins and config with xml
		TTValue value;
		value.append(TT(PLUGINS_PATH));
		value.append(TT(XML_CONFIG_PATH));
		m_deMan->LoadPlugins(value);

		// Load devices with xml
		m_deMan->LoadDeviceXmlConfig(TT(XML_CONFIG_PATH));
	}

	return NSP_NO_ERROR;
}
Пример #2
0
void
DemoApp::SetupModular()
{
    TTValue     args, v, out, none;
    TTAddress   address;
    TTErr       err;
    
    TTLogMessage("\n*** Initialisation of Modular environnement ***\n");
    /////////////////////////////////////////////////////////////////////
    
    // Init the Modular library (passing the folder path where all the dylibs are)
    TTModularInit("/usr/local/jamoma");
    
    // Create an application manager
    mApplicationManager = TTObject("ApplicationManager");
    
    
    TTLogMessage("\n*** Creation of mApplicationDemo application ***\n");
    /////////////////////////////////////////////////////////////////////
    
    // Create a local application called "demo" and get it back
    err = mApplicationManager.send("ApplicationInstantiateLocal", "demo", out);
    
    if (err) {
        TTLogError("Error : can't create demo application \n");
        return;
    }
    else
        mApplicationDemo = out[0];
    
    
	TTLogMessage("\n*** Creation of mApplicationDemo datas ***\n");
    /////////////////////////////////////////////////////////////////////
    
    // Create a parameter data and set its callback function and baton and some attributes
    mDataDemoParameter = TTObject("Data", "parameter");
    
    // Setup the callback mechanism to get the value back
    args = TTValue(TTPtr(this), mDataDemoParameter);
    mDataDemoParameter.set("baton", args);
    mDataDemoParameter.set("function", TTPtr(&DemoAppDataReturnValueCallback));

    // Setup the data attributes depending of its use inside the application
    mDataDemoParameter.set("type", "decimal");
    mDataDemoParameter.set("rangeBounds", TTValue(0., 1.));
    mDataDemoParameter.set("rangeClipmode", "low");
    mDataDemoParameter.set("description", "any information relative to the state of the application");
    
    // Register the parameter data into mApplicationDemo at an address
    args = TTValue("/myParameter", mDataDemoParameter);
    mApplicationDemo.send("ObjectRegister", args, out);
    
    
    // Create a message data and set its callback function and baton and some attributes
    mDataDemoMessage = TTObject("Data", "message");
    
    // Setup the callback mechanism to get the value back
    args = TTValue(TTPtr(this), mDataDemoMessage);
    mDataDemoMessage.set("baton", args);
    mDataDemoMessage.set("function", TTPtr(&DemoAppDataReturnValueCallback));
    
    // Setup the data attributes depending of its use inside the application
    mDataDemoMessage.set("type", "string");
    mDataDemoMessage.set("description", "any information to provide to the application");
    
    // Register the message data into mApplicationDemo at an address
    args = TTValue("/myMessage", mDataDemoMessage);
    mApplicationDemo.send("ObjectRegister", args, out);
    
    
    // Create a return data and set its callback function and baton and some attributes
    mDataDemoReturn = TTObject("Data", "return");
    
    // Setup the callback mechanism to get the value back
    args = TTValue(TTPtr(this), mDataDemoReturn);
    mDataDemoReturn.set("baton", args);
    mDataDemoReturn.set("function", TTPtr(&DemoAppDataReturnValueCallback));

    // Setup the data attributes depending of its use inside the application
    mDataDemoReturn.set("type", "integer");
    mDataDemoReturn.set("defaultValue", 0);
    mDataDemoReturn.set("description", "any information the application returns back");
    
    // Register the return data into mApplicationDemo at an address
    args = TTValue("/myReturn", mDataDemoReturn);
    mApplicationDemo.send("ObjectRegister", args, out);
    
    // Initialise the application and all datas inside (using defaultValue attribute)
    mApplicationDemo.send("Init");
}
Пример #3
0
void jamoma_init(void)
{
    short		outvol = 0;
    t_fourcc	outtype, filetype = 'TEXT';
    char        name[MAX_PATH_CHARS], fullname[MAX_PATH_CHARS];
    
	if (!initialized) {
        
		t_object	*max = SymbolGen("max")->s_thing;
        TTString    JamomaConfigurationFilePath;
		t_atom		a[4];
		TTValue		v, out;
        TTErr       err;

		if (maxversion() < 1798)
        {
			error("Jamoma  %s  |  build %s can't run under Max version ealier than 7.0.6", JAMOMA_MAX_VERSION, JAMOMA_MAX_REV);
            return;
        }
        
		// Initialize the Modular library
        TTModularInit();
        
#ifdef TTSCORE_IMPORT
        // Initialize the Score framework
        TTScoreInit();
#endif
        
        // Prepare a symbol for Max application
        kTTSym_Max = TTSymbol("Max");
        
        // Create an application manager
        MaxApplicationManager = TTObject("ApplicationManager");
        
        // Create a local application called "Max" and get it back
        err = MaxApplicationManager.send("ApplicationInstantiateLocal", kTTSym_Max, out);
        
        if (err) {
            TTLogError("Error : can't create Jamoma application \n");
            return;
        }
        else
            MaxApplication = out[0];

        // check if the JamomaConfiguration.xml file exists
        strncpy_zero(name, "JamomaConfiguration.xml", MAX_PATH_CHARS);
        if (locatefile_extended(name, &outvol, &outtype, &filetype, 1))
            return error("Jamoma not loaded : can't find %s", name);
        
        path_topathname(outvol, name, fullname);


        // MaxApplication have to read JamomaConfiguration.xml
        TTObject anXmlHandler(kTTSym_XmlHandler);
        anXmlHandler.set(kTTSym_object, MaxApplication);
        std::string path = fullname;
        #if ( __APPLE__ )
        // remove drive name prefix
        size_t pos = path.find(":/");
        path = path.substr(pos+1);
       	v = TTSymbol(path);
        #else
        v = TTSymbol(fullname);
		#endif
        anXmlHandler.send(kTTSym_Read, v, out);

		// Initialize common symbols
		common_symbols_init();
		jamomaSymbolsInit();
		
		// Initialize common regex
		ttRegexForJmod = new TTRegex("(jmod.)");
		ttRegexForJcom = new TTRegex("(j\\.)");
		ttRegexForModel = new TTRegex("(.model)");
		ttRegexForModule = new TTRegex("(.module)");
		ttRegexForView = new TTRegex("(.view)");
		ttRegexForMaxpat = new TTRegex("(.maxpat)");
		ttRegexForMaxhelp = new TTRegex("(.maxhelp)");
		ttRegexForBracket = new TTRegex("\\[(\\d|\\d\\d|\\d\\d\\d)\\]");	// parse until 999
		
		ModelPatcherFormat = new TTString("%s.model.maxpat");
		ModelPresetFormat = new TTString("%s.model.presets.txt");
		ViewPresetFormat = new TTString("%s.view.presets.txt");
		HelpPatcherFormat = new TTString("%s.model");
		RefpageFormat = new TTString("%s.model");
		DocumentationFormat = new TTString("%s.model.html");
		
		// Create Required Global Instances
		hash_modules = (t_hashtab*)hashtab_new(0);
		// TODO: Use quittask_install() to set up a destructor for this to free it before Max exits

		// Add Jamoma Key Commands
		
		// J -- Jamoma: a new object box with "j." in it
		atom_setsym(a+0, SymbolGen("k"));
		atom_setsym(a+1, SymbolGen("patcher"));
		atom_setsym(a+2, SymbolGen("inserttextobj"));
		atom_setsym(a+3, SymbolGen("j."));
		object_method_typed(max, SymbolGen("definecommand"), 4, a, NULL);
				
//		// M -- Module: a new object box with ".model" in it
//		atom_setsym(a+0, SymbolGen("M"));
//		atom_setsym(a+1, SymbolGen("patcher"));
//		atom_setsym(a+2, SymbolGen("inserttextobj"));
//		atom_setsym(a+3, SymbolGen(".model"));
//		object_method_typed(max, SymbolGen("definecommand"), 4, a, NULL);
//        
		
//		// B -- BPatcher: a new module in a bpatcher
//		object_method_parse(max, SymbolGen("definecommand"), (char*)"B patcher inserttextobj \"bpatcher @name .module @args myModule\"", NULL);		

//		// D -- Demo: a new module in a bpatcher, but with the args reverse which is handy for super-fast demos when you don't care about the OSC name
//		object_method_parse(max, SymbolGen("definecommand"), (char*)"D patcher inserttextobj \"bpatcher @name .module\"", NULL);		

//		// X -- Continuous Mapper module
//		object_method_parse(max, SymbolGen("definecommand"), (char*)"X patcher insertobj bpatcher @name mapper.module.maxpat @args mapper", NULL);
				
		// now the jamoma object
		{
			t_symbol *jamomaSymbol = SymbolGen("jamoma");
		
			jamoma_object_initclass();
			jamomaSymbol->s_thing = jamoma_object_new();
		}
		
		post("Jamoma  %s  |  build %s", JAMOMA_MAX_VERSION, JAMOMA_MAX_REV );

		initialized = true;
	}
}
Пример #4
0
int main(int argc, const char * argv[])
{
    // parsing arguments (ignoring the first)
    TTValue args;
    for (TTUInt8 i = 1; i < argc; i++)
    {
        TTSymbol arg(argv[i]);
        args.append(arg);
    }

    // check for file path
    if (args.size() == 1)
    {
        if (args[0].type() == kTypeSymbol)
        {
            TTSymbol filepath = args[0];    // .score file to load

            // initialisation of Modular environnement (passing the folder path where all the dylibs are)
            TTModularInit("/usr/local/jamoma", true);

            // create an application manager
            TTObject applicationManager("ApplicationManager");

            // create a local application named i-score
            TTObject applicationLocal = applicationManager.send("ApplicationInstantiateLocal", "i-score");

            // loads protocol unit
            // TODO : when parsing project file
            {
                // create Minuit protocol unit
                TTObject protocolMinuit = applicationManager.send("ProtocolInstantiate", "Minuit");

                // create OSC protocol unit
                TTObject protocolOSC = applicationManager.send("ProtocolInstantiate", "OSC");

                // create WebSocket protocol unit
                TTObject protocolWebSocket = applicationManager.send("ProtocolInstantiate", "WebSocket");
            }

            // initialisation of Score environnement (passing the folder path where all the dylibs are)
            TTScoreInit("/usr/local/jamoma");

            // create a scenario
            TTObject scenario("Scenario");

            // load project file
            TTObject xmlHandler("XmlHandler");
            xmlHandler.set("object", TTValue(applicationManager, scenario));
            xmlHandler.send("Read", filepath);

            // run scenario
            scenario.send("Start");

            // wait for scenario
            TTBoolean running;
            do
            {
                sleep(1);
                scenario.get("running", running);
            }
            while (running);

            return EXIT_SUCCESS;
        }
    }

    return EXIT_FAILURE;
}