Working with jcom.hub’s notifications
There are some situations where you may want to know when your modules are created, when a specific module is properly initialized for example. Thanks to Jamoma framework remote communication possibilities, a number of events notifications can be listened to or queried.
Receive initialization notification from within a module
Whereas Max’s loadbang object can be used to know when a patch is properly loaded, it is of no use when trying to get when a Jamoma module is properly initialized. Indeed, for each module, a number of operations, such as initialization of jcom.parameters, loading of preset, etc. has to be done by jcom.hub. Thus Jamoma has a specific object somewhat similar to loadbang that comes to help.
jcom.init works like a loadbang but is local to a module. That is, it connects to jcom.hub found in the same abstraction and outputs a (max)bang when the module is properly initialized. Note that jcom.init can be placed in any sub-patcher as long as it does not contain another jcom.hub.
Receive initialization notification outside of a module
What if you want to know from a module that another module is properly initialized? For example, you may want to know that “jmod.mySamplePlayer” is properly initialized so your “jmod.myStepSequencer” can start playing its control sequence. Thanks to Jamoma remote communication possibilities, such a problem can be easily dealt with using jcom.initialized.
Go to the example folder provided with this documentation and open the patch named initialization notification or copy the compressed version below.
----------begin_max5_patcher----------
1090.3ocyX00ajZCE84Y9U3hpTjplNwevm8sp1G5S8kJ0WpVUQ.GFm.1yZLM
I6pM+1qwFRX1AlAlkAsJJvXyE6y83685i4yqW4bm3YZoC3W.+CX0pOud0JSW
0crpo8Jmh3mSxiKMl4jHJJnbkyF6yTzmUl9+CpjBXk.0NJnHNik.9gVa3UEL
dNUYF.TSm2KytyNuvsvMctf1BAenwn8wpjcLd1+JoIJq0HXXsU9lqHDp9FF1
4czylnR0Ncv1oSvU73BpAq+pjEm2hNVpoOwcO7yDWmNlWx9jwbDdKrt2urdc
8kMijn3zmzi4Q7zCZBbKiyTZHnmfTvsEu7WuvU65ksfCSDQQFF.RL2H1VQCR
Ds7tsK0K6o1gww4sW3.N5uoxzXdbKpRD4BY65kOJxGF91hFwGFD5V+q.n9In
2FvNTa+LK7hX1gBAu8VveR0LpR.TURNPvAwUoLAHlmBhSenpTA9OQdUgNPkC
to3keON4FyCuoYM3l1wLmwoIhJtYfIWi3XebPsUd91ENOy63FNSAx3YLP9Dz
8S6hUfXvSBdJUdeUNnj9wJJOgdkR9cIFqvVtCEPl0re30O6euj8NS1K0Lbld
nw2ItyoOimy.kBZYYbF83.EESmxggZbeqRjkkSAnd4.7IJ6i6lmfP1pdgyV4
tAIHzLRP2YbLprWmmLryisK8dtFul.sbfK7rderLqYycGS0t2c9SvKc7dT3a
PskndnPjtU+16qTutU6cZ31ZydIsTWnHVwD7tKcVX6gBOF8yWlkZfXpSjW4S
vlhtdla3ykXMXHUcJ8zhpPKfPie50oli44aTS4A8quEFs06x3iRVFW61SjRH
WeJINsT9pV0QcYDf9udIHuyGvDX29AdNwmtmgg1z8Wl+mHmgu9blQEDUBbmJ
Y0TzBCMb1Y2p18TYWszylKJYCsPp5EkIRM7o5c4jrrrApyiNKkg7swWX+yvY
3AKleAwRvkPIv8Rq.wW.+HBTvRYSsFUCEQvXaJXzBoCHZFYmGKyYoCDcbJWO
xtCkukAHlnCOxziNZxnNHSpiqF3Le4EeJGjKDOVsWezFfmGvGB7C.AnKbYuU
3uKZAyL7VJEfmuxPneGQvAST+2ukKRdbpJ.I8K.7iETkTLR8eXa.azQXe4IP
hUq2HjPi6iBsenlSPgaNV8S2Zr8SlH3tXYgfyRJGoj52Ov7fxoMyu46X7Ued
OC4T2+grbonRlz5GMU7.uSNozREiavQGaPGXyNVZJk28Ln5J76E55LMPXfU7
whHuQfnnu6PTvhhH2Qfn5C8+8FjV1HIxXhsgKJj9JFneLQlFjPjv5yvgrmWA
66Y+pYcaEX0XZOrWciuQ2.MlUazxF.hF0xcn1Hz3wjmdKLuZ8WFQYMeXRSqE
Cs3kiAwiASjowfeqXZLILdKafFbLzj6zvTStIRq9WeyWK8ss0hf1ksvL5fPn
SDmcoPR23Kq+eBWupfC
-----------end_max5_patcher-----------
In this example, we built a similar situation using three modules from Jamoma Modular core distribution (jmod.qmetro that we will use as a clock, jmod.10harmonics~ that we will use as mini synthesizer and jmod.output~~ so you can enjoy the wonderful 5 notes-based arpeggio composed for this example…). Similarly to the example aforementioned, we want to make sure that our synth is properly initialized before starting to play our sequence. jcom.initialized can then be used to send a (max)bang when the module defined as its argument is properly initialized. From then, the (max)bang message can trigger the message box that it is connected to and send to jmod.qmetro /myClock the following couple of message to set a speed and to turn it on.
/time 200
/toggle 1
Remember that there is currently no way to define an initialization order for each module. While the patch we used works for our demonstration purpose, it may be trickier in a complex patch involving a lot of modules. For example, you would probably want to make sure
(max)myClockis also properly initialized before receiving any message. We will let this as an exercise for the reader.
“Fine. But how does this really works?” Glad you asked.
jcom.initialized is a Max patch-based component (abstraction) that wraps a special feature of jcom.receive.
When provided (max)'notifications' as argument, jcom.receive can be used to notify of various operations done in Jamoma framework, i.e module creation, module deletion and more importantly here: module initialization. Thus, for each module in a patch, jcom.receive notifications will send the message (max)module.initialized followed by the class of the module and its instance name. In the previously used example, jcom.receive would send the following messages:
module.new jmod.output~ /myDac
module.new jmod.qmetro /myClock
module.new jmod.10harmonics~ /mySynth
module.initialized jmod.output~ /myDac
module.initialized jmod.qmetro /myClock
module.initialized jmod.10harmonics~ /mySynth
Thus jcom.initialized is a handy component that filters out notifications sent by jcom.receive notifications and sends a (max)bang when matching initialization notification for a given named module defined as argument.
Download
Here you can download the patch used for this tutorial (right-click and save).



