Forums > MaxMSP

help with a simple max patch

June 16, 2007 | 5:13 am

Hey everyone. I am currently using an Arduino to capture the data of a Flex sensor, and inputting that into my computer via Midi. I borrowed code for the Arduino program (in order to utilize Midi) and it is transmitting the data into Max perfectly well. I am stuck, however, converting this data into sound in Max.

I want the flex sensor data to dictate the pitch of the sound coming out of Max. I don’t want anything complex, I just want a basic tone that increases and decreases in pitch as the flex sensor flexes. I am using an already existing patch in an attempt to form a suitable patch for myself, but thus far I have failed. I know that I need to patch "midiin" into "xbendin" and then patch that into a box that holds the flex sensor data (currently, the number wavers between 400 and 600…maybe this is my problem…?). Finally, I would patch this into a "speaker" object, in order to enable sound. Still, I get zero sound. I have looked at multiple tutorials and cannot seem to solve my problem. Yet I feel that there should be a relatively easy solution. If anybody could help me out I would be EXTREMELY grateful. Thanks a bunch in advance!


June 16, 2007 | 6:03 am

Um, it’s best if you post a patch. Nevertheless, sounds like you need
something for the info to control. If you’re just going from the
number box to the "speaker" – ezdac~, then you won’t get anything.
You need to control a cycle~ or phasor~ or something like that. I’m
assuming from what you said that this is what you’re missing, but a
patch would be great.

You’ll be controlling a sine wave from 400hz to 600hz. If you want a
larger or smaller range, check out the scale object. If I assumed too
much, please post a patch.

Keith

On 6/16/07, Dylan Irving wrote:
>
> Hey everyone. I am currently using an Arduino to capture the data of a Flex sensor, and inputting that into my computer via Midi. I borrowed code for the Arduino program (in order to utilize Midi) and it is transmitting the data into Max perfectly well. I am stuck, however, converting this data into sound in Max.
>
> I want the flex sensor data to dictate the pitch of the sound coming out of Max. I don’t want anything complex, I just want a basic tone that increases and decreases in pitch as the flex sensor flexes. I am using an already existing patch in an attempt to form a suitable patch for myself, but thus far I have failed. I know that I need to patch "midiin" into "xbendin" and then patch that into a box that holds the flex sensor data (currently, the number wavers between 400 and 600…maybe this is my problem…?). Finally, I would patch this into a "speaker" object, in order to enable sound. Still, I get zero sound. I have looked at multiple tutorials and cannot seem to solve my problem. Yet I feel that there should be a relatively easy solution. If anybody could help me out I would be EXTREMELY grateful. Thanks a bunch in advance!
>


June 16, 2007 | 9:11 am

midi data in, probably via [ctlin] unless the Arduino is specifically
putting out pitchbend data.

The midi data will be in the range 0-127 (unless it _is pitchbend),
so you need to scale that to the frequency range you want to produce
- the simplest way would be to use [scale 0 127 x y] (where x & y are
your low and high frequencies – make sure that you use float values
(ie 50. rather than 50 ).
If you want a more musical scaling, look at [mtof] and [scale]

The scaled numbers go to [sig~] and from there to [cycle~]
The output of [cycle~] goes via a signal level fader (in the object
menu at the top of the window) to a [dac~] or [exdac~] object.

You’ll find that the sensor data is very noisy, so you’ll probably
want to smooth it. There are a number of ways to do this – I usually
use 3rd part objects like tap.smooth, or there’s a data smoother in
(I think) jasch’s objects.

You’ll probably find that the sensor data is pretty noisy!

midi data in -> scale to appropriate range -> convert to control
signal -> control frequency of oscillator -> control output level of
oscillator -> output signal via convertor (dac~)

David

On 16 Jun 2007, at 6:13, Dylan Irving wrote:

>
> Hey everyone. I am currently using an Arduino to capture the data
> of a Flex sensor, and inputting that into my computer via Midi. I
> borrowed code for the Arduino program (in order to utilize Midi)
> and it is transmitting the data into Max perfectly well. I am
> stuck, however, converting this data into sound in Max.
>


June 16, 2007 | 1:37 pm

Quote: david stevens wrote on Sat, 16 June 2007 03:11
—————————————————-
> midi data in, probably via [ctlin] unless the Arduino is specifically
> putting out pitchbend data.
>
> David
>
>
> On 16 Jun 2007, at 6:13, Dylan Irving wrote:
>
> >
> > Hey everyone. I am currently using an Arduino to capture the data
> > of a Flex sensor, and inputting that into my computer via Midi. I
> > borrowed code for the Arduino program (in order to utilize Midi)
> > and it is transmitting the data into Max perfectly well. I am
> > stuck, however, converting this data into sound in Max.
> >
>
>
—————————————————-

That’s one thing I forgot to mention. The Arduino IS putting out pitchbend data. Will that change anything you’ve said above? Thank you for your help! I’m on the run now so I can’t test out the info you’ve given me quite yet, but it seems like I might be able to do this pretty easily….


June 16, 2007 | 2:33 pm

Pitch bend isn’t something I use, so I had to check, and it uses the
same range of values (0-127) – at least that’s what comes out of
midiparse. If you were using a pitch bend wheel, your default
position would be in the middle of the range, and you might want to
do something about that. But a bend strip should give out roughly 0
when it’s flat, and 127 at its maximum bend. If you’re not sure
what’s going on, connect a [midiin] (make sure you set the right
port) to a midiparse, and have a look at the values you’re getting.
If it’s not starting at 0, all you have to do is set an offset (add
or subtract whatever the resting value is from the data stream to
bring it to zero) and then scale the resulting numbers to get them to
the range you want.
My experience with bend sensors has been that by the time you’ve
eliminated the noise floor of the sensor, smoothed, offset and scaled
the sensor output, you’re not going to get all the intermediate
values between 0 and 127. You’ll also probably find that the sensor
will need recalibrating from time to time while you’re using it.
Which is why I use the auto-scale objects that are available.

So you should be able to make a basic patch that does what you want
very easily. And then there are many ways to improve it!

HTH

David

On 16 Jun 2007, at 14:37, Dylan Irving wrote:

>
> That’s one thing I forgot to mention. The Arduino IS putting out
> pitchbend data. Will that change anything you’ve said above? Thank
> you for your help! I’m on the run now so I can’t test out the info
> you’ve given me quite yet, but it seems like I might be able to do
> this pretty easily….
>


Viewing 5 posts - 1 through 5 (of 5 total)