[Csnd] Question re log opcode error using base

The manual suggests the log opcode has an optional arbitrary ibas parameter when using arrays:

log — Returns a natural log of a number, or an array (with optional arbitrary base)

kout[]log kin[],ibas

https://csound.com/docs/manual/log.html

When attempting to use the ibas parameter it results in an error: Unable to find opcode entry for 'log' with matching arguement types. Found: k log ki

instr 1
  kVal[] fillarray 27
  kLog[] init 1
  iBase = 3
  kLog[0] log kVal[0], iBase
  printk 1, kLog[0]
endin

Can anyone suggest where the syntax is incorrect in this code? Using a kBase doesn't work either (error k log kk).

Best,
Scott

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

I don’t see this opcode anywhere in the system, I’ve only seen log() with 1 argument (for any rate and for i/k arrays).
I’ve implemented the array version but I don’t remember doing the 2 argument version. The source code only
contains the 1 input version. You will need to convert from the required base to either log, log2 or log10.

John’s name is in the docs so maybe he has more ideas about this.

Hi Scott,
it's just an idea, but in your code you used something like:
kLog[0] log kArray[0], iBase
But you said that the iBase arguments is for arrays only, so it should read:
kLog log kArray, iBase
No indices, because then the opcode will not see arrays, but one k-rate signal.

HTH.

Best wishes,

Jeanette

There is now an opcode like that in Csound 7 (develop branch).

Thanks Jeanette! That works for me. So basically it works on the whole array, not just individual indices. The manual description seems a little misleading, or perhaps I’m just a bit dimwitted :wink:

However, with most other array opcodes it’s defined in the manual, such as maparray:

karray **maparray** kinarray, String

So it’s a little unusual that log uses the array symbols:

kout[]**log** kin[][,ibas]

Anyways, this works great now:

instr 1
kVal[] fillarray, 9, 27, 81
kLog[] init 3
iBase = 3
kLog log kVal, iBase
printk 1, kLog[1]
printarray kLog, metro(1)
endin

Thanks again for your help =)

Best,
Scott

Thanks Victor, fortunately problem solved (user error =)).

Best,
Scott

Hi Scott,
oh a few opcodes use the [] symbols to mark arrays, but mostly when an array is a choice:
For example linlin:
https://csound.com/manual/linlin.html
And others. A few random number generators, I think, other matyhematical functions, if one needs them. Though with basic maths working with direct operators probably looks more straightforward.

Best wishes,

Jeanette

Thanks. Which version were you using?

Prof. Victor Lazzarini
Maynooth University
Ireland

Csound for Android ver 39 with library ver 6.18. The recent update M Gogins released.

Thks

Prof. Victor Lazzarini
Maynooth University
Ireland

I see now; there was no such opcode for i-time arrays (only for k-rate) and that was what tripped me.
Now I’ve added the i-time version to Csound 7.0 only (and removed the k-rate duplicate I had committed).