newbie asks the hive: this works but, is there a better way?
hello,
the following patch takes in a midi note (so far only set up for 70 and 70)
and depending on how it is set either lets the note play until a midi off comes, or it forces a set duration for the note.(which needs to be customisable for each different note)
this patch is going to go into a patch that drives a real world mechanical orchestra. some of the instruments like horns, need to sound as long as the note is open, others like xylophones are best played quick.
i'm not a newbie programmer but i'm a noob patcher, so there's probably lots of really basic stuff i haven't figured out how to use properly yet, such as encapsulation of patches within patches, so i've basically used the first things that got the job done that i found. and it works fine...
but
i can see that by the time i make this patch work for the full range of notes i need its going to be huge and repetitive.
and maybe there's a much smarter way to get the job done.
anyone got any ideas?
cheers
mathew
this demonstrates one simple, but powerful, thing that took me a while
to fully comprehend.
first, save this as "sub_patch":
then, in the same directory, save this as "main_patch":
now when you open "main_patch" you will find two instances of your
"sub_patch". obviously you can make hundreds of instances as needed. the
cool part is that if you need to change something in "sub_patch", you
just need to open that file and do it once. every instance will be
updated in "main_patch"
this is just one encapsulation method, but it's very handy. if you look
at some of the more complex patches in the "examples" folder you will
see this practiced widely.
hth,
david
Here's how I would do it. It starts with David's abstraction approach (make sure you understand that first!) but instead of separate abstractions is uses a single poly~ to handle all 128 MIDI note values without creating a ton of objects.
The pattr system is used to manage all your settings (including saving and loading them to disk - read up on pattstorage for how to do that).
In programming terms, this is how you would make an array of objects in Max.
Try selecting MIDI note number 70 and changing the sustain and and duration settings. If you go to 71 and then come back, it remembers your settings. Pretty cool, right?
Save this as midi-note-output.pat
and here's the main patch (save in same directory and then reopen):
ah such nice people on these forums.
thank you,
this looks really good,
will plunge in an see what i can do
cheers
mat
i would suggest putting each instrument on a different MIDI channel. then, filter the incoming notes by channel (using some trivial gates and logic that don't seem to be beyond your grasp). For the trumpet channel, just pass the notes through and wait for the note-off. For the xylophone channel, set a duration using the makenote object. See below:
thats a very sensible idea,
and one i think it would have been great to use.
unfortunately all the instruments are controlled on a single midi channel (10) and the builder has been getting people to compose works just using channel one, using his note mapping.
but perhaps i should create a note remapping that maps from general midi mapping (where the instrument exists in the machine) to the one channel mapping, then i could incorporate your idea?
thanks
mathew