Using the bufer object
How could I make the buffer object read how long any sound loaded into it is (via a read message), and then use that length as its buffer size? Because if I could do that, I can use the buffersize to control other playback and envelope parts of the patch. Any ideas?
Use a "replace" message instead of a "read" message. It will automatically re-size the buffer to the length of the file you load in to it.
OK thanks. But how do I then output the length of the new sound as an integer to control other things?
Bang an info~ object with the same name as your buffer~ using the right outlet of buffer~.
Thanks, that helped!
One more question – I’m trying to use the joysticks of my game controller and its proving much harder than I anticipated. This is because obviously they dont function as simply as the buttons and aren’t simply on or off, they constantly spew out numbers.
Anyway, my main problem is that I’m trying to use one of the sticks to alter playback speed of looping samples, and need to only use half of its x axis (ie pulling down on the stick from the central position and not up, lowest point being fastest playback and central being normal speed). Also I’d like to know how I can then make that value stay, when I’ve found a particular speed. Otherwise when I let go of the stick it just goes straight back to 0, or rather the middle point which at the moment isn’t 0 but rather some other unhelpful speed!
Hope that makes some sense, any help would be greatly appreciated.
So its hard to know how to solve the problem without seeing the numbers that the joystick outputs… but for you the best way to see everything that it outputs would probably be sending it to a [print] object and then back tracking in the max window…
then once youve got the numbers figured out i would bet the a scale object would be what you want… so since it seems that the range of numbers goes from low to high at each extreme of the joysticks range physically, instead of 0 in the middle… they probably just wanted to stick with positive numbers… so what you could do is just use a [- ] and then subtrack (or add if thats what it ends up being) to give you easy numbers. Or you could just have the messages go straight to the [scale] and just do the math in your arguments…
if the x axis ranges from 0 when the joystick is at the far left, to 99 at the far right… then you want to send the messages through a [scale 50 99 x y]… so you just would put in numbers for x and y that would make the [groove~] happy (or however you are playing it back) and it will only respond to messages within the first range, so moving it to the right will effect it and moving it left will not…
as far as keeping the number you choose, maybe you could have one of the buttons attached to a [gate] so that when the button is pressed the messages sent will affect the playback speed, and when you let go, the [gate] closes thus keeping the last number sent, while you are free to move the joystick around
basically the [scale] object is your best friend when taking messages from game controllers… at least that is what i have found… [route] is also very nice to have
Given this kind of question, it would seem to me as though perhaps there are a few good reasons to spend some time with or return to the Max tutorials. In particular, I’d have a little search for objects that can store data [such as the i/int and f/float objects], objects that allow you to redirect or stop/start the flow of data [the gate object], and the fantastic scale and zmap objects. Happily, Max 5 has a search facility, so you should be able to quickly get a sense of how things work and how to use other parts of your controller [like the trigger buttons, for example] to grab/sample the output number stream from your joysticks. I’d definitely have a good look at those things. While this sort of humble stuff may seem less interesting than building samplers etc., a good grasp of controlling and rerouting the stream of data your higher level objects produce is something you’ll probably spend a much higher amount of your time on [ask anyone who’s patched for any length of time :-)]. You’ll be glad you did – both now, and with your next question.
Quote: keyworth wrote on Wed, 11 February 2009 11:37
> One more question – I’m trying to use the joysticks of my game controller and its proving much harder than I anticipated. This is because obviously they dont function as simply as the buttons and aren’t simply on or off, they constantly spew out numbers.
Really? The one I used only spit out 1 when pressed and a 0 when not, but not constantly. These could readily be used for gates as mentioned, either to "hold" the latest stick value or to send the values to a different parameter (filtergraph~ effects? :) If it keeps sending the values over and over, use a [change] object on the 1/0 value, so that you only get new values when it changes.
> Anyway, my main problem is that I’m trying to use one of the sticks to alter playback speed of looping samples, and need to only use half of its x axis (ie pulling down on the stick from the central position and not up, lowest point being fastest playback and central being normal speed). Also I’d like to know how I can then make that value stay, when I’ve found a particular speed. Otherwise when I let go of the stick it just goes straight back to 0, or rather the middle point which at the moment isn’t 0 but rather some other unhelpful speed!
As mentioned, check out the values coming out using a print object, determine the ranges, then [scale] or use other math objects accordingly. You can also use [split] to remove unwanted ranges at the outset, which may make the scaling easier.
Some more time fiddling around with scale, gate, route, etc. is well worth the time. Generally in Max you start with an idea and try to solve it, but a number of other ideas will come up based on your searching, and the process continues… it’ll often get you sidetracked from your original idea, but that can be a very good thing too. You really can do pretty much anything you want, so re-reading those help files again and again will illuminate ever-more possibilities for each object (and collection of objects) depending on the frame of mind you’re reading them in. It’s cool that way… you’re solving questions and creating new ones as you get more familiar with what’s possible.
For real-time control over playback, as it sounds like you want using the joystick, also look into [mtr] as this can be used to record your actions (in this case, numerical parameters from the stick motion) and play them back. Then it’s one step removed from real-time, true, but it allows you to track what you did and tweak settings accordingly, as well as add new layers of activity over ones you’ve already done… like having two joysticks and four hands, or more.
Thanks for the kind help fellas – I’ll keep working on it, and take note of the ideas you’ve suggested and I’ll get there eventually!
Forums > MaxMSP