// Create void *receive_new(t_symbol *s, long argc, t_atom *argv) { long attrstart = attr_args_offset(argc, argv); // support normal arguments t_receive *x = (t_receive *)object_alloc(s_receive_class); if (x) { object_obex_store((void *)x, _sym_dumpout, (object *)outlet_new(x, NULL)); x->outlet = outlet_new(x, NULL); if (!g_receivemaster_object) g_receivemaster_object = (t_object *)object_new_typed(CLASS_NOBOX, SymbolGen("jcom.receivemaster"), 0, NULL); x->callback = NULL; x->attr_name = NULL; // attr_args_process(x, argc, argv); // handle attribute args // If no name was specified as an attribute if (x->attr_name == NULL) { if (attrstart > 0) x->attr_name = atom_getsym(argv); else x->attr_name = SymbolGen("jcom.receive no arg specified"); receive_bind(x); } } return x; }
GainDataspace::GainDataspace() : DataspaceLib("gain", "linear") { // Create one of each kind of unit, and cache them in a hash registerUnit(new LinearAmplitudeUnit, SymbolGen("linear")); registerUnit(new MidiGainUnit, SymbolGen("midi")); registerUnit(new DecibelUnit, SymbolGen("dB")); registerUnit(new DecibelUnit, SymbolGen("db")); // Now that the cache is created, we can create a set of default units setInputUnit(neutralUnit); setOutputUnit(neutralUnit); }
void audiosend_dsp(t_audiosend *x, t_signal **sp, short *count) { long numInputs = x->num_inputs; short i, j; t_object *hub; if (x->attr_target && x->attr_target != _sym_nothing) { hub = jamoma_get_hub_for_module_named(x->attr_target); if (hub != x->obj_target) { if (hub) { x->obj_target = hub; // we could attach to the hub here to listen for free notifications // but freeing it will restart the dsp anyway, so I don't think there is any need [tap] x->obj_direct_target = (t_object*)object_method(hub, SymbolGen("getobj_audioin")); } } if (x->obj_target) { for (i=0, j=0; i<numInputs; i++) { if (count[i]) j=i; x->audio_in[i] = sp[i]->s_vec; } numInputs = j+1; dsp_add(audiosend_perform, 2, x, numInputs); } } }
t_int* audiosend_perform(t_int *w) { t_audiosend *x = (t_audiosend*)(w[1]); object_method(x->obj_direct_target, SymbolGen("remoteaudio"), x->audio_in, (long)(w[2])); return(w+3); }
void audioreceive_dsp(t_audioreceive *x, t_signal **sp, short *count) { long numOutputs = x->num_outputs; short i, j; t_object *hub; if (x->attr_target && x->attr_target != _sym_nothing) { hub = jamoma_get_hub_for_module_named(x->attr_target); if (hub != x->obj_target) { if (hub) { x->obj_target = hub; // we could attach to the hub here to listen for free notifications // but freeing it will restart the dsp anyway, so I don't think there is any need [tap] x->obj_direct_target = (t_object*)object_method(hub, SymbolGen("getobj_audioout")); } } if (x->obj_target) { for (i=0, j=0; i<numOutputs; i++) { if (count[i+1]) // the +1 is to account for the inlet in this object j=i; x->audio_out[i] = (t_float*)sp[i+1]->s_vec; } numOutputs = j+1; x->vs = sp[0]->s_n; dsp_add(audioreceive_perform, 2, x, numOutputs); } } }
void audiosend_bang(t_audiosend *x) { t_atom a[2]; t_symbol **moduleNames = NULL; long numModules = 0; long i; jamoma_get_all_module_names(&numModules, &moduleNames); atom_setsym(a+0, SymbolGen("clear")); outlet_anything(x->dumpout, SymbolGen("menu"), 1, a); atom_setsym(a+0, SymbolGen("append")); for (i=0; i<numModules; i++) { atom_setsym(a+1, moduleNames[i]); outlet_anything(x->dumpout, SymbolGen("menu"), 2, a); } if (moduleNames) sysmem_freeptr(moduleNames); }
t_max_err audiosend_attr_settarget(t_audiosend *x, void *attr, long argc, t_atom *argv) { t_object *hub; x->attr_target = atom_getsym(argv); hub = jamoma_get_hub_for_module_named(x->attr_target); if (hub) { x->obj_target = hub; x->obj_direct_target = (t_object*)object_method(hub, SymbolGen("getobj_audioin")); } return MAX_ERR_NONE; }
t_max_err jcom_core_attr_setdescription(t_jcom_core_subscriber_extended *x, void *attr, long argc, t_atom *argv) { char* text = NULL; long textsize = 0; atom_gettext(argc, argv, &textsize, &text, OBEX_UTIL_ATOM_GETTEXT_SYM_NO_QUOTE); if (text && textsize) { x->attr_description = SymbolGen(text); sysmem_freeptr(text); } return MAX_ERR_NONE; }
TemperatureDataspace::TemperatureDataspace() : DataspaceLib("temperature", "Kelvin") { // Create one of each kind of unit, and cache them in a hash registerUnit(new CelsiusUnit, SymbolGen("C")); registerUnit(new CelsiusUnit, SymbolGen("Celsius")); registerUnit(new FahrenheitUnit, SymbolGen("F")); registerUnit(new FahrenheitUnit, SymbolGen("Fahrenheit")); registerUnit(new KelvinUnit, SymbolGen("K")); registerUnit(new KelvinUnit, SymbolGen("Kelvin")); // Now that the cache is created, we can create a set of default units setInputUnit(neutralUnit); setOutputUnit(neutralUnit); }
t_int* audioreceive_perform(t_int *w) { t_audioreceive *x = (t_audioreceive*)(w[1]); int channel; int n; float *vector = NULL; float *out; //object_method(x->obj_direct_target, SymbolGen("remoteaudio"), x->audio_out, (long)(w[2])); for (channel = 0; channel < x->num_outputs; channel++) { n = x->vs; object_method(x->obj_direct_target, SymbolGen("getAudioForChannel"), channel, &vector); out = x->audio_out[channel]; if (vector) { while (n--) *out++ = *vector++; } } return(w+3); }
// COMMON ATTRIBUTE: name t_max_err jcom_core_subscriber_attribute_common_setname(t_jcom_core_subscriber_common *x, void *attr, long argc, t_atom *argv) { t_symbol *arg = atom_getsym(argv); x->attr_name = arg; if (arg->s_name[strlen(arg->s_name)-1] == '*') x->has_wildcard = true; else x->has_wildcard = false; // if (x->subscriber_type == jps_subscribe_return && x->hub) { if (x->hub) { jcom_core_unsubscribe(x->hub, x); x->hub = NULL; // x->attr_name = atom_getsym(argv); jcom_core_subscriber_subscribe((t_jcom_core_subscriber_common*)x); } // if the client understands 'update_name' then we call it object_method(x, SymbolGen("update_name")); return MAX_ERR_NONE; }
void jamomaSymbolsInit() { jps_done = SymbolGen("done"); // ramp stuff jps_none = SymbolGen("none"); jps_linear = SymbolGen("linear"); jps_linear_q = SymbolGen("linear.q"); //jps_ramp_update = SymbolGen("ramp_update"); jps_slash_ramp_slash_update = SymbolGen("/ramp/update"); //clip stuff jps_low = SymbolGen("low"); jps_high = SymbolGen("high"); jps_both = SymbolGen("both"); jps_wrap = SymbolGen("wrap"); jps_fold = SymbolGen("fold"); // increase and decrease jps_inc = SymbolGen("inc"); jps_dec = SymbolGen("dec"); // types jps_generic = SymbolGen("generic"); jps_integer = SymbolGen("integer"); jps_decimal = SymbolGen("decimal"); jps_string = SymbolGen("string"); jps_array = SymbolGen("array"); jps_decimalArray = SymbolGen("decimalArray"); jps_integerArray = SymbolGen("integerArray"); jps_boolean = SymbolGen("boolean"); //jps_list_int = SymbolGen("list_int"); //jps_list_float = SymbolGen("list_float"); jps_none = SymbolGen("none"); // this type only used by jcom.message jps_jcom_hub = SymbolGen("jcom.hub"); jps_feedback = SymbolGen("__feedback__"); // used for parameter feedback to the hub // common OSC messages according to the JIG jps_alias = SymbolGen("alias"); jps_module_name_get = SymbolGen("/module_name:/get"); jps_core_module_name_get = SymbolGen("core_module_name:/get"); jps_dumpout = SymbolGen("dumpout"); jps_audio = SymbolGen("audio"); jps_video = SymbolGen("video"); jps_control = SymbolGen("control"); jps_dispatched = SymbolGen("dispatched"); jps_parameter_name = SymbolGen("/parameter_name"); jps_message_name = SymbolGen("/message_name"); jps_message_return = SymbolGen("/return_name"); jps_parameter_names_start = SymbolGen("/parameter_names_start"); jps_parameter_names_end = SymbolGen("/parameter_names_end"); jps_message_names_start = SymbolGen("/message_names_start"); jps_message_names_end = SymbolGen("/message_names_end"); jps_return_names_start = SymbolGen("/return_names_start"); jps_return_names_end = SymbolGen("/return_names_end"); jps_parameter_values_start = SymbolGen("/parameter_values_start"); jps_parameter_values_end = SymbolGen("/parameter_values_end"); jps_parameter_value = SymbolGen("/parameter_value"); // subscribe stuff jps_subscribe = SymbolGen("subscribe"); jps_unsubscribe = SymbolGen("unsubscribe"); jps_release = SymbolGen("release"); jps_subscribe_in = SymbolGen("subscribe_in"); jps_subscribe_out = SymbolGen("subscribe_out"); jps_subscribe_message = SymbolGen("subscribe_message"); jps_subscribe_parameter = SymbolGen("subscribe_parameter"); jps_subscribe_remote = SymbolGen("subscribe_remote"); jps_subscribe_return = SymbolGen("subscribe_return"); jps_subscribe_init = SymbolGen("subscribe_init"); jps_subscribe_meter = SymbolGen("subscribe_meter"); // signal inlets and outlets jps_num_inputs = SymbolGen("num_inputs"); jps_num_outputs = SymbolGen("num_outputs"); // parameter/message/return attributes //jps_inspector = SymbolGen("inspector"); jps_type = SymbolGen("type"); jps_dataspace = SymbolGen("dataspace"); jps_unit = SymbolGen("dataspace/unit"); jps_range_bounds = SymbolGen("range/bounds"); jps_range_clipmode = SymbolGen("range/clipmode"); jps_ramp = SymbolGen("ramp"); jps_ramp_drive = SymbolGen("ramp/drive"); jps_ramp_function = SymbolGen("ramp/function"); jps_repetitions_allow = SymbolGen("repetitions/allow"); jps_description = SymbolGen("description"); jps_enable = SymbolGen("enable"); jps_value = SymbolGen("value"); jps_value_default = SymbolGen("value/default"); jps_value_stepsize = SymbolGen("value/stepsize"); jps_algorithm_type = SymbolGen("algorithm_type"); jps_name = SymbolGen("name"); jps_readonly = SymbolGen("readonly"); jps_priority = SymbolGen("priority"); // signals to module jps_sigcount = SymbolGen("sigcount"); jps_siglist = SymbolGen("siglist"); jps_config_changed = SymbolGen("config_changed"); jps_algorithm = SymbolGen("algorithm"); jps_get_num_channels = SymbolGen("get_num_channels"); // module type jps_module_name = SymbolGen("module_name"); jps_slash_module_name = SymbolGen("/module_name"); jps_module_class = SymbolGen("module_class"); jps_module_type = SymbolGen("module_type"); //jps_poly = SymbolGen("poly"); jps_default = SymbolGen("default"); jps_jitter = SymbolGen("jitter"); jps_1U = SymbolGen("1U"); jps_1U_half = SymbolGen("1U-half"); jps_algorithm_message = SymbolGen("algorithm_message"); jps_private = SymbolGen("private"); // method called in the hub by jcom.remote jps__gui__ = SymbolGen("__GUI__"); // name of jcom.remote in the gui jps__jcom_in__ = SymbolGen("__jcom_in__"); // name of the module's jcom.in object jps__jcom_out__ = SymbolGen("__jcom_out__"); // name of the module's jcom.out object jps___preview__ = SymbolGen("__preview__"); // name of the remote for jitter preview matrices jps_return = SymbolGen("return"); // method called in the hub by jcom.return jps_return_address = SymbolGen("return_address"); jps_return_extended = SymbolGen("return_extended"); jps_return_signal = SymbolGen("return_signal"); jps_return_value = SymbolGen("return_value"); jps_go = SymbolGen("go"); // method in jcom.init called by the hub jps_init = SymbolGen("/init"); // method in the hub called from jcom.init //jps_ATTRIBUTES = SymbolGen("ATTRIBUTES"); //jps_BUILD = SymbolGen("BUILD"); //jps_MODULE_NAME = SymbolGen("MODULE_NAME"); // name of this module class //jps_MODULE_TITLE = SymbolGen("MODULE_TITLE"); // OSC id of of this module instance //jps_PARAMETER = SymbolGen("PARAMETER"); //jps_NEW_PRESETS_START = SymbolGen("NEW_PRESETS_START"); //jps_NEW_PRESETS = SymbolGen("NEW_PRESETS"); //jps_MENU_REBUILD = SymbolGen("MENU_REBUILD"); jps_size = SymbolGen("size"); //jps_skin = SymbolGen("skin"); jps_jcom_send = SymbolGen("jcom.send"); jps_jcom_receive = SymbolGen("jcom.receive"); jps_jcom_remote_fromModule = SymbolGen("jcom.remote.module.from"); // different than in jamoma 0.3.x to avoid conflicts... jps_jcom_remote_toModule = SymbolGen("jcom.remote.module.to"); jps_jcom_broadcast_fromHub = SymbolGen("jcom.broadcast.hub.from"); // used to tell subscribers in a module to subscribe (hub has changed) jps_from_in_object = SymbolGen("from_in_object"); // messages to the jcom.out object jps_box = SymbolGen("box"); jps_setcallback = SymbolGen("setcallback"); jps_link_in = SymbolGen("link_in"); jps_link_out = SymbolGen("link_out"); jps_unlink_in = SymbolGen("unlink_in"); jps_unlink_out = SymbolGen("unlink_out"); jps_audio_gain = SymbolGen("audio/gain"); // used by the i/o objects... jps_slash_audio_gain = SymbolGen("/audio/gain"); //jps_audio_gain_midi = SymbolGen("audio/gain/midi"); // used by the i/o objects... //jps_slash_audio_gain_midi = SymbolGen("/audio/gain/midi"); jps_gain = SymbolGen("gain"); jps_slash_gain = SymbolGen("/gain"); jps_audio_mute = SymbolGen("audio/mute"); jps_slash_audio_mute = SymbolGen("/audio/mute"); jps_audio_bypass = SymbolGen("audio/bypass"); jps_slash_audio_bypass = SymbolGen("/audio/bypass"); jps_bypass = SymbolGen("bypass"); jps_slash_bypass = SymbolGen("/bypass"); jps_audio_mix = SymbolGen("audio/mix"); jps_slash_audio_mix = SymbolGen("/audio/mix"); jps_mix = SymbolGen("mix"); jps_slash_mix = SymbolGen("/mix"); jps_mix_slash_weight = SymbolGen("mix/weight"); //jps_audio_sample_rate = SymbolGen("audio/sample_rate"); //jps_slash_audio_sample_rate = SymbolGen("/audio/sample_rate"); jps_audio_meters_freeze = SymbolGen("audio/meters/freeze"); jps_slash_audio_meters_freeze = SymbolGen("/audio/meters/freeze"); jps_video_mute = SymbolGen("video/mute"); jps_slash_video_mute = SymbolGen("/video/mute"); jps_video_bypass = SymbolGen("video/bypass"); jps_slash_video_bypass = SymbolGen("/video/bypass"); jps_freeze = SymbolGen("freeze"); jps_slash_freeze = SymbolGen("/freeze"); jps_video_freeze = SymbolGen("video/freeze"); jps_slash_video_freeze = SymbolGen("/video/freeze"); jps_video_preview = SymbolGen("video/preview"); jps_slash_video_preview = SymbolGen("/video/preview"); jps_preview = SymbolGen("preview"); jps_slash_preview = SymbolGen("/preview"); jps_register_meter = SymbolGen("register_meter"); jps_register_preview = SymbolGen("register_preview"); jps_open = SymbolGen("open"); jps_slash_getstate = SymbolGen("/getstate"); jps_slash_view_slash_panel = SymbolGen("/view/panel"); jps_slash_module_view_internals = SymbolGen("/module/view_internals"); jps_slash_module_slash_reference = SymbolGen("/module/reference"); jps_slash_module_slash_help = SymbolGen("/module/help"); jps_slash_preset_slash_interface = SymbolGen("/preset/interface"); jps_slash_preset_slash_default = SymbolGen("/preset/default"); jps_slash_preset_slash_load = SymbolGen("/preset/load"); jps_slash_preset_slash_recall = SymbolGen("/preset/recall"); jps_slash_preset_slash_write = SymbolGen("/preset/write"); jps_preset_slash_write = SymbolGen("preset/write"); jps_slash_preset_slash_writeagain = SymbolGen("/preset/writeagain"); jps_preset_slash_writeagain = SymbolGen("preset/writeagain"); jps_slash_preset_slash_store = SymbolGen("/preset/store"); jps_slash_preset_slash_storenext = SymbolGen("/preset/storenext"); jps_slash_preset_slash_storecurrent = SymbolGen("/preset/storecurrent"); jps_preset_slash_mix = SymbolGen("preset/mix"); jps_preset_slash_default = SymbolGen("preset/default"); jps_preset_slash_interpolate = SymbolGen("preset/interpolate"); jps_slash_preset_slash_copy = SymbolGen("/preset/copy"); jps_slash_ui_slash_internals = SymbolGen("/view/internals"); jps_ui_slash_internals = SymbolGen("view/internals"); jps_ui_slash_freeze = SymbolGen("view/freeze"); jps_slash_ui_slash_freeze = SymbolGen("/view/freeze"); jps_ui_slash_refresh = SymbolGen("view/refresh"); jps_slash_ui_slash_refresh = SymbolGen("/view/refresh"); //jps_voices = SymbolGen("voices"); jps_settext = SymbolGen("settext"); jps_mute = SymbolGen("mute"); jps_slash_mute = SymbolGen("/mute"); jps_target = SymbolGen("target"); jps_sendlastvalue = SymbolGen("sendlastvalue"); jps_sendbypassedvalue = SymbolGen("sendbypassedvalue"); jps_star = SymbolGen("*"); jps_add = SymbolGen("add"); // used for calling methods on jcom.receivemaster jps_remove = SymbolGen("remove"); jps_dispatch = SymbolGen("dispatch"); jps_bpatcher = SymbolGen("bpatcher"); jps_subpatcher = SymbolGen("subpatcher"); }
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; } }