Advanced dragging and dropping - is it possible to fire actions by dropping files and/or other stuff in Max?
** Note! The post maybe seemed to suggest I'd be doing this with M4L inside Ableton Live, which is not the case. I'll be doing it in the standalone Max, so the objects or anything else isn't required to be limited to those available in Live (if such limitations even exist anymore).
Hello,
Some background (feel free to skip to the next section):
I am (fantasizing about) designing a sample player to be used with Ableton Push2. I love Push2 as hardware, but can't seem to do the things I'd like to do (at least as comfortably I'd want to) by working with Ableton Live. Also, building an instrument from scratch would allow for more customization and adding features along the way as needed / they pop into mind.
After reading articles and watching a lot of videos from Cycling '74 a, I'm pretty confident I might be able to pull this off with Max but I haven't really found much about dragging and dropping.
The question itself:
I'm thinking about creating a graphical representation of the pads of push, maybe using panels. I'd like to be able to drag files (or maybe some objects just representing files) on top of the panels (or maybe there is some other object that is more suitable, possibly such that could be aligned 'behind' the panel or hidden) and then be in control what happens to the files. Maybe this could be done with scripting, like event handling, so that each pad (panel) would have a listener and then the event would contain a reference to the file, and I could then decide what happens based on which file was dragged on top of which pad.
Or, maybe the GUI would have a media pool window where one could drag files and then drag those files (or objects representing them) onto the panels. Also, the user should be able to move or copy (by using a key modifier etc.) the files from one pad to another.
Now that I wrote all that down I realized it might seem like I'm trying to wind screws with a hammer but (even / especially) building a GUI is mostly pain with the programming languages I'm familiar with. Moreover, I believe Max would suit most of the other stuff needed pretty well so I'm still hopeful.
Note that the way I describe the event listener implementation is just a tool for explaining the functionality and doesn't have to be at all how it will be actually done, the main thing is of course to achieve the functionality.
I'm anxious to hear any proposals on how to implement the stuff I've described as well as different approaches to the functionality all together (although I haven't described it too much - I'm only outlining it myself. I might make a dedicated blog style post about the development as I get something actually done).
Also, I couldn't really decide what would be the most suitable category for this post so I just put it under 'MaxMSP'. I'm happy to change it based on more seasoned forum users suggestions.
Sorry for the long and broad post (& excessive use of parenthesis) and thanks in advance!
Actually, it could be simpler than you think:
In this example, I put a [live.drop] object under a [live.toggle], set the [live.toggle]'s background opacity to 60% so you can read the text from [live.drop]. You can simply drop any file onto it and the filename will be output by [live.drop]'s left outlet. From there, you can triggering other events using the [trigger] object
Not geared towards Live, but you can also drag & drop a file's path from [chooser].
Great, thanks LSKA!
I thought that this part (dropping files onto objects dedicated to file dropping) would be pretty easy, and since the file name can be acquired after the drop, even more advanced operations (assigning the sample to several buffers, making adjustments to sound file's playback speed/pitch depending on its length/current key etc.) are probably rather simple to implement.
But what about dragging samples from one pad (panel etc.) to another? Can objects even be dragged when the patch is locked (ideally the draggable thing would be just text with the sample name)? If real dragging isn't possible, then maybe this could be done simply by reading mouse input, eg. pressing LMB on certain area would trigger the dragging and then moving the pointer and then releasing LMB in another certain area would indicate dropping. The downside in that would be the lack of visual feedback in the form of text moving along with the mouse pointer, but that would be a minor problem and could be compensated with other visual clues, like changing the appearance of the source and destination pads, and maybe altering the pointer while dragging.
Thank you, Jean-Francois!
I'll be using standalone Max, so the patch is not limited to M4L functionality.
I think I found at least one answer to the pad-to-pad from this post:
https://cycling74.com/forums/dragging-object-fun
So thanks for both of your inputs, LSKA and Jean-Francois. At this point I'm fairly confident that everything I'll need will be possible to do in Max. Awesome!
Someone experienced and clever reminded me that [textedit] accepts dropping any text on it. Like this, for instance:
Someone experienced and clever reminded me that [textedit] accepts dropping any text on it.
This sounds very promising!
However, the [chooser] in your patch seems to be a new object introduced on Max 8 and unfortunately I'm stuck with Max 7 for now. Can you think of an alternative for it?
I've just realized that most Max objects or their contents can't be dragged. The contents of [textedit] can be selected, but the subsequent mouse click initiates a new selection deselecting the previously selected text. The contents of message and comment box can't be even selected.
Your patch looks like a good basis for the media pool implementation and in any case, I'm sure knowing about [textedit] will make things easier for me along the way.
Thanks!
Although is is a bit OT, it may be time to remind the community of the still undocumented [opened] object.
It outputs usefull information about (accepted) files dropped on Max' icon.
Although is is a bit OT, it may be time to remind the community of the still undocumented [opened] object. It outputs usefull information about (accepted) files dropped on Max' icon.
What do you mean by Max' icon?
The application's icon, the one you use to launch Max from your prefered OS.
The application's icon, the one you use to launch Max from your prefered OS.
It took a while to get it working, since in Windows dragging files on top of a shortcut icon wont work and instead you have to dig up the Max installation folder an drag the file on the actual Max.exe file.
Funnily, I just watched a video about standalone Max apps where [opened] is discussed briefly, and it seems [opened] is much more convenient to use with Mac OS, since it works with dragging stuff on the icon in the OSX icon bar thingy (on Widows you have to exit the patcher window, then have both the Max installation folder and the folder containing the file itself open).
Anyways, thanks for pitching in!