Forums > Javascript

Using [js] to create normalized [buffer~]s?

August 5, 2010 | 2:50 pm

I am attempting to use a [js] object to create and load a normalized (to -.2 dB) series of [buffer~] objects within a patcher. I’m able to create pre-loaded [buffer~]s but how would one go about sending an accompanying normalization command.

Attached is the contents of my [js] object.

Any help would be much appreciated

- Jon

Attachments:
  1. autobuffer1.txt

August 5, 2010 | 8:57 pm

I would do that using polybuffer~:

- send the readfolder message
- then, send 0 normalize 0.794328 (which sends the message normalize 0.794328 to every buffer~ objects).

you’re done ;-)


August 6, 2010 | 12:47 am

I’m confused as to where to put that information in the [js] and how. I am going to guess that it goes somewhere in this part of the code:

//after each successive new path
function filepath(path)
{
currentfilepath = path;
buffname = "thisbuff_" + count; // create a new name based on the count
p = this.patcher;
a = p.newdefault(200,ypos,"buffer~",buffname,currentfilepath);
//report last
bang();
}

I am very hazy as to the syntax needed to talk to other max objects. I will try to implement your advice but I am most likely going to need clarification.

best regards,

- Jon


August 6, 2010 | 1:14 am

It’s not JS, polybuffer~ is a whole new MSP object by EJ which does it all for you.

http://cycling74.com/forums/topic.php?id=26356

is your friend

There is no access to buffer~ data from JS anyway.

-A


August 6, 2010 | 4:02 am

Thank you for the advice. The [polybuffer~] object looks great though I am looking for a purely [js] object solution. One of the reasons is that I am trying to expand my js/max knowledge. I imagine sending an accompanying normalize message to a [buffer~] from a [js] would be simple but I am clueless.

- Jon


August 6, 2010 | 9:55 am

As Andrew mentioned, you won’t be able to access to the samples directly in JavaScript. However you can probably script everything. For instance if you look at this.patcher.apply you should be able to iterate through the object, test theObject.maxclass to see if the object is a buffer~ and send the normalize message. Have fun.


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