Cabbage Logo
Back to Cabbage Site

Off topic: looking for info on table vs arrays

Alright, I’ve used CSound in the past, but with the addition of arrays, I feel I’ve got to relearn a few things.

I’ve always had trouble understanding function tables and resigned myself to using them only for wavetables, mostly because I never got out of them what I put in… I just want to state specific days in tables, but everytime I go to read them, the data somehow gets normalized or something…

So, could someone show me a reference that explains how tables and arrays differ?

Thanks!

Function tables:

  • can be filled with GEN routines
  • can be accessed and modified using table read/write opcodes
  • can only be single dimensions
  • can be written to and read at i, k and a rates
  • data will be normalized unless you specify a negative GEN routine, for example, f1 0 4 -2 1 2 3 4
  • can not hold string data

Arrays:

  • can be filled using fillarray, or manually be index
  • can hold scalar, vector or string data
  • can be accessed using the array subscript operators []
  • can have multiple dimensions
  • can be operating on using a host of dedicated array opcodes

I’d be happy to answer any specific questions you might have about them.

Is there any kind of performance difference? I’m planning on creating large tables of data, and was also wanting to display that data, so copying data into a function tables to display it might get cumbersome.

I’m going to assume that function tables are slightly faster, but a little more cumbersome to code. If you want to display the data then using tables is probably better.

I remember my first experience with function tables, I remember that I gave up figuring out how to use the negative values of both the size and the gen parameters. I’m still confused because I’m trying to create a table using some negative numbers, and while it doesn’t give an error, those negative numbers never make it into the table. It just might have something to do with those negative size and gen numbers… I’ll try again tonight. Thanks for your help.

Post some code if you can’t get it to work. I thought arrays would be the best thing ever when they were introduced, but I find myself going back to function tables again and again.

OK, Thanks again, I spent last night figuring out my issues… BUT now I’ve got a question on gentable objects. I am going to start a new topic, as that is specifically about Cabbage.