Primitive '_BasicNew' failed. Index not an Integer

View: New views
3 Messages — Rating Filter:   Alert me  

Primitive '_BasicNew' failed. Index not an Integer

by yvan volochine :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello.

I am new to this list so, first, thanks to all of you for all the great
help I found on the list/forum.

While trying to make some polyphony, I came through this error and I'd
like to understand what I'm doing wrong.
Here is my simplified code:

(
SynthDef(\yo, { |out=0, n=8|
    var src= SinOsc.ar({Rand(100, 2000)}!n, 0, 1/n);
    Out.ar(out, Mix.new(Pan2.ar(src, 0, 1)));
}).send(s);
)

Of course, if I use, say, 8 instead of n, I have no errors.

Best,
_yvan

_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/

Re: Primitive '_BasicNew' failed. Index not an Integer

by nescivi :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Tuesday 21 April 2009 16:48:15 yvan volochine wrote:

> Hello.
>
> I am new to this list so, first, thanks to all of you for all the great
> help I found on the list/forum.
>
> While trying to make some polyphony, I came through this error and I'd
> like to understand what I'm doing wrong.
> Here is my simplified code:
>
> (
> SynthDef(\yo, { |out=0, n=8|
>     var src= SinOsc.ar({Rand(100, 2000)}!n, 0, 1/n);
>     Out.ar(out, Mix.new(Pan2.ar(src, 0, 1)));
> }).send(s);
> )
>
> Of course, if I use, say, 8 instead of n, I have no errors.

You can't create a dynamic size array in a synthdef.

What would work is this:

(
var n = 8;
SynthDef(\yo++n, { |out=0|
     var src= SinOsc.ar({Rand(100, 2000)}!n, 0, 1/n);
     Out.ar(out, Mix.new(Pan2.ar(src, 0, 1)));
}).send(s);
)

You'll have to create a separate SynthDef for each amount of SinOscs you want
to have.

sincerely,
Marije

_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/

Re: Primitive '_BasicNew' failed. Index not an Integer

by yvan volochine :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

nescivi wrote:

> You can't create a dynamic size array in a synthdef.
>
> What would work is this:
>
> (
> var n = 8;
> SynthDef(\yo++n, { |out=0|
>      var src= SinOsc.ar({Rand(100, 2000)}!n, 0, 1/n);
>      Out.ar(out, Mix.new(Pan2.ar(src, 0, 1)));
> }).send(s);
> )
>
> You'll have to create a separate SynthDef for each amount of SinOscs you want
> to have.
>  
I see.
Thanks for clarifying.

_yvan

_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/