detecting wake up from sleep
After waking my Imac from sleep, the midiin and midiout objects forget what ports they are assigned to.
Is there any way of detecting when a computer "wakes up" so I can reassign the midi ports using a bang ? Or some other soultion?
It gets confusing if i forget to manually reasssign the ports and all my midi ports are messed up.
You can send each midiin/out a message to tell it which midi port to connect to, so all you need to do is connect a loadmess to each port, containing the appropriate message for the desired connection and trigger them as per the video from week 9 on this page:
alternatively you could connect a bang to a send object and have multiple receive objects connected to messages to each port. You could hit this once you wake your computer up, setting all your ports back to their desired routings in one fell swoop. Check out the inport.maxhelp tab in the midiin help file for further clarification.
Hope this helps
I have already done as you suggest. But I really want to be able to detect when the computer wakes from sleep to automate the process
Is there no way Max can detect sleep mode?
You could bang a date (say, from something like a [metro 10000] object) and keep tab of the running differences between times. A sleep/wakeup cycle will (almost always) take a good deal longer than 15 seconds, so if the difference between two consecutive outputs from date is longer than that you could re-trigger your assign-MIDI-ports logic.
There can be a tiny bit of jitter in the metro object, depending on how much other processing is in your patch, so you want to set the test values generously enough that they won’t be fooled by any minor deviation coming out of the metro/date combination.
thank very much peter, wasn’t aware of the date object. should work fine
I see you’ve solved your problem, but since reading this post I thought about trying to code an external to do the job. Attached is a mac external that detects sleep and wake conditions. I’ve been to sleep and woken a few times and everything *seems* ok.
the source is included but may cause some distress?:)
brilliant! nice coding. thanks
Forums > MaxMSP