|
|
|
09-21-2017, 04:42 PM
|
#1
|
Human being with feelings
Join Date: Aug 2013
Location: Bowral, Australia
Posts: 1,638
|
Use of memset.
The JS documentation reads:
'memset(dest,value,length)
The memset() function provides the ability to quickly set a region of the local memory buffer to a particular value.'
I assume that 'dest' is the number of the first item of memory and 'length' is the number of items, is that correct? So e.g. if I want to set a block of memory samplesblock long starting from zero to a value of -1, my code should read memset(0,-1,samplesblock)?
|
|
|
09-21-2017, 10:32 PM
|
#2
|
Human being with feelings
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 14,686
|
Quote:
Originally Posted by Time Waster
I want to set a block of memory samplesblock long starting from zero to a value of -1, my code should read memset(0,-1,samplesblock)?
|
???
if samplesblock is an "array", in JSFX-Speak meaning that you do something like "sampleslock = 987;" to locate it somewhere in the JSFX instances local memory and then can access it's elements by e.g. samplesblock[0], samplesblock[1], ... and the memory you need for sampleblock is 100 elements, you would do "memset(samplesblock, -1, 100);"
-Michael
|
|
|
09-21-2017, 11:30 PM
|
#3
|
Human being with feelings
Join Date: Aug 2013
Location: Bowral, Australia
Posts: 1,638
|
Maybe not a good example. 'samplesblock' is a special variable (read only) which provides the number of samples per block. So it's just a number, not an array.
I was assuming that 'dest' would point to the first item in memory and 'length' would refer to the last item, and that those items and all the items in between would be set to 'value'. By your explanation, 'dest' would refer to a block of memory, but then how would you locate the block and why have the 'length' argument? The documentation is not very clear, a simple example would have helped.
|
|
|
09-22-2017, 06:04 AM
|
#4
|
Human being with feelings
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 14,686
|
This is just how arrays work in EEL .
There is just one "array" of local memory. (Another one is "global".)
If you want to use multiple arrays, you need to select a number for each of them determining the starting point (element number) of same.
For convenience you write that number in a variable (say "a", a = 80).
Now most conveniently you access element number "i" say i = 9 in your array as "a[i]"
But you also could write 80[9], 0[a+i], (a+i)[0], 0[89], 89[0], ...
-Michael (sorry for being fooled regarding "sampleblock")
|
|
|
09-22-2017, 06:29 AM
|
#5
|
Human being with feelings
Join Date: Aug 2013
Location: Bowral, Australia
Posts: 1,638
|
Well, whatever I'm doing, it seems to be working for now.
|
|
|
09-22-2017, 11:31 AM
|
#6
|
Human being with feelings
Join Date: Jan 2007
Location: mcr:uk
Posts: 3,889
|
Quote:
Originally Posted by Time Waster
if I want to set a block of memory samplesblock long starting from zero to a value of -1, my code should read memset(0,-1,samplesblock)?
|
Yes, that's correct.
|
|
|
09-23-2017, 07:52 AM
|
#7
|
Human being with feelings
Join Date: Aug 2013
Location: Bowral, Australia
Posts: 1,638
|
Thanks IXix!
|
|
|
09-24-2017, 05:46 AM
|
#8
|
Human being with feelings
Join Date: Jan 2007
Location: mcr:uk
Posts: 3,889
|
Quote:
Originally Posted by IXix
Yes, that's correct.
|
Quick warning. If you're using samplesblock like that you should be aware that (IIRC) the value of samplesblock is zero until the first @block happens. That has caught me out a couple of times.
|
|
|
09-24-2017, 11:36 PM
|
#9
|
Human being with feelings
Join Date: Aug 2013
Location: Bowral, Australia
Posts: 1,638
|
I have been caught out by that myself when trying to use samplesblock @slider.
|
|
|
09-25-2017, 02:42 AM
|
#10
|
Human being with feelings
Join Date: Jan 2007
Location: mcr:uk
Posts: 3,889
|
Quote:
Originally Posted by Time Waster
I have been caught out by that myself when trying to use samplesblock @slider.
|
Rite of passage.
|
|
|
Thread Tools |
|
Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -7. The time now is 08:20 AM.
|