[Csnd] how to create an array with random numbers

Dear community,
I’ve tried to fill an array with random numbers, but without success.
I can’t find what’s wrong with my code:

-odac -m0d ; ==============================================

sr = 44100
nchnls = 2
0dbfs = 1
seed 0
opcode
StefansRandArray,i[],iii
iMin,iMax,iSize xin
iOut[] init iSize
icount = 0
while icount < iSize do
irandNum random iMin,iMax
iOut[icount] = irandNum
icount += 1
od
xout iOut
endop

instr 1
iMin = 1
iMax = 10
iSize = 13
iArr[ ] StefansRandArray iMin,iMin,iSize
printarray iArr
endin

; ============================================== i1 0 4

I assume there’s is an obvious mistake .
I hope one of You could give me a hint!
Thanks,
Stefan

Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Hi, Stefan,

Your UDO is ok, but the following line in instr 1

iArr[ ] StefansRandArray iMin,iMin,iSize

should be

iArr[ ] StefansRandArray iMin,iMax,iSize

Best,
Tetsuya

2021/05/25 16:42、Stefan Thomas <kontrapunktstefan@gmail.com>のメール:

Dear community,
I've tried to fill an array with random numbers, but without success.
I can't find what's wrong with my code:
<CsoundSynthesizer>
<CsOptions>
-odac -m0d
</CsOptions>
; ==============================================
<CsInstruments>

sr = 44100
nchnls = 2
0dbfs = 1
seed 0
opcode
StefansRandArray,i[],iii
iMin,iMax,iSize xin
iOut[] init iSize
icount = 0
while icount < iSize do
irandNum random iMin,iMax
iOut[icount] = irandNum
icount += 1
od
xout iOut
endop

instr 1
iMin = 1
iMax = 10
iSize = 13
iArr[ ] StefansRandArray iMin,iMin,iSize
printarray iArr
endin

</CsInstruments>
; ==============================================
<CsScore>
i1 0 4
</CsScore>
</CsoundSynthesizer>

I assume there's is an obvious mistake .
I hope one of You could give me a hint!
Thanks,
Stefan

Csound mailing list Csound@listserv.heanet.ie LISTSERV 16.5 - CSOUND List at LISTSERV.HEANET.IE Send bugs reports to Issues · csound/csound · GitHub Discussions of bugs and features can be posted here

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        Issues · csound/csound · GitHub
Discussions of bugs and features can be posted here

Hi Tetsuya,

Those two statements look identical to me, unless I’m missing something extremely subtle…

  • Dave

Hi Dave,

It’s a simple typo. In the original code, the second parameter for StefansRandArray is iMin, but it should be iMax.

Best,
Tetsuya

2021/05/25 22:00、Dave Seidel <dave.seidel@GMAIL.COM>のメール:

Hi Tetsuya,

Those two statements look identical to me, unless I'm missing something extremely subtle...

- Dave

Hi, Stefan,

Your UDO is ok, but the following line in instr 1

iArr[ ] StefansRandArray iMin,iMin,iSize

should be

iArr[ ] StefansRandArray iMin,iMax,iSize

Best,
Tetsuya

> 2021/05/25 16:42、Stefan Thomas <kontrapunktstefan@gmail.com>のメール:
>
> Dear community,
> I've tried to fill an array with random numbers, but without success.
> I can't find what's wrong with my code:
> <CsoundSynthesizer>
> <CsOptions>
> -odac -m0d
> </CsOptions>
> ; ==============================================
> <CsInstruments>
>
> sr = 44100
> nchnls = 2
> 0dbfs = 1
> seed 0
> opcode
> StefansRandArray,i[],iii
> iMin,iMax,iSize xin
> iOut[] init iSize
> icount = 0
> while icount < iSize do
> irandNum random iMin,iMax
> iOut[icount] = irandNum
> icount += 1
> od
> xout iOut
> endop
>
> instr 1
> iMin = 1
> iMax = 10
> iSize = 13
> iArr[ ] StefansRandArray iMin,iMin,iSize
> printarray iArr
> endin
>
> </CsInstruments>
> ; ==============================================
> <CsScore>
> i1 0 4
> </CsScore>
> </CsoundSynthesizer>
>
> I assume there's is an obvious mistake .
> I hope one of You could give me a hint!
> Thanks,
> Stefan
>
> Csound mailing list Csound@listserv.heanet.ie LISTSERV 16.5 - CSOUND List at LISTSERV.HEANET.IE Send bugs reports to Issues · csound/csound · GitHub Discussions of bugs and features can be posted here

Csound mailing list
Csound@listserv.heanet.ie
LISTSERV 16.5 - CSOUND List at LISTSERV.HEANET.IE
Send bugs reports to
        Issues · csound/csound · GitHub
Discussions of bugs and features can be posted here
Csound mailing list Csound@listserv.heanet.ie LISTSERV 16.5 - CSOUND List at LISTSERV.HEANET.IE Send bugs reports to Issues · csound/csound · GitHub Discussions of bugs and features can be posted here

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        Issues · csound/csound · GitHub
Discussions of bugs and features can be posted here

Oh, how stupid!
Don’t know why I didn’t see it!
Thanks!

Oh, how stupid!
Don't know why I didn't see it!

*I* know...! (:-)) I looked at Tetsuya's post, and said "But there's no difference!"
Took me several minutes to actually *see* the error!!
Funny how the eye sees what it expects to see...

  -- Pete --

Thanks!

> Hi, Stefan,
>
> Your UDO is ok, but the following line in instr 1
>
> iArr[ ] StefansRandArray iMin,iMin,iSize
>
> should be
>
> iArr[ ] StefansRandArray iMin,iMax,iSize
>
> Best,
> Tetsuya

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        Issues · csound/csound · GitHub
Discussions of bugs and features can be posted here