store array module
Hi !
so I build a store array module !
I did a
TPrecision* m_buffer;
and
int bufferSize = MAX_ARRAY_SIZE * SLOTNUMBER;
in .h
that init like this in .cpp:
storeArray::storeArray()
{
//Ensure that initial memo values at buffer are 0.0f
m_buffer = new float[bufferSize];
for (int i = 0; i<bufferSize; i++)
{
m_buffer = 0.0f;
}
so I have a buffer in which all the memory slots will be saved
for example, if I set 128 slots of 1024 bits there will be a fixed amount of memory that will be taken for this module.
- is it a problem ?
- is there another way to have the size been chosen from the size of the incoming array at input ?
thanx
so I build a store array module !
I did a
TPrecision* m_buffer;
and
int bufferSize = MAX_ARRAY_SIZE * SLOTNUMBER;
in .h
that init like this in .cpp:
storeArray::storeArray()
{
//Ensure that initial memo values at buffer are 0.0f
m_buffer = new float[bufferSize];
for (int i = 0; i<bufferSize; i++)
{
m_buffer = 0.0f;
}
so I have a buffer in which all the memory slots will be saved
for example, if I set 128 slots of 1024 bits there will be a fixed amount of memory that will be taken for this module.
- is it a problem ?
- is there another way to have the size been chosen from the size of the incoming array at input ?
thanx
http://oli-lab.org
Win11 Ryzen9/32GB RAM - RME MADIFACE - SSL alpha link 4-16 - OSC capable interfaces
follow OLI_LAB adventures on Mastodon
@olivar_premier@mastodon.social
Win11 Ryzen9/32GB RAM - RME MADIFACE - SSL alpha link 4-16 - OSC capable interfaces
follow OLI_LAB adventures on Mastodon
@olivar_premier@mastodon.social
im not that an expert and might be wrong, but i think performance wise if you have ram it's better to make a static allocated size at fist, possible in the .h like
float mybuffer[MAX_SIZE];
or you can use new in cpp but be careful to delete the array prior a new one at some point if multiple calls or ram use will increase
delete[] mybuffer; mybuffer = nullptr;
if want dynamic size i think it's better to use vector.
vector has a reserve size where you would put max size, and a resize function to dynamically alter its size without needing to recreate a new one.
vector.reserve(size); ie at init and vector.resize(newsize) in the code, ie getting length of your input buffer first
#include <vector>
std::vector<float> mybuffer;
mybuffer.reserve(MAX_SIZE);
mybuffer.resize(NEW_SIZE);
you can resize even without a reserve size set first, then it will find some freespace in ram and allocate, but internally the resizing will be more efficient if you had reserved first,
tho of course i assume the max_size is locked space in ram then.
no problem looping and setting to 0 each id, but if setting to 0 the whole array man can use memset:
memset(mybuffer, 0 , sizeof(float)*MAX_SIZE); or more simply memset(mybuffer, 0 , sizeof(mybuffer));
or assuming you know the MAX_SIZE, the bytes size is MAX_SIZE * 4 (4 bytes per float) so for a 1024 array its 4094 bytes
memset(mybuffer,0,4096);
float mybuffer[MAX_SIZE];
or you can use new in cpp but be careful to delete the array prior a new one at some point if multiple calls or ram use will increase
delete[] mybuffer; mybuffer = nullptr;
if want dynamic size i think it's better to use vector.
vector has a reserve size where you would put max size, and a resize function to dynamically alter its size without needing to recreate a new one.
vector.reserve(size); ie at init and vector.resize(newsize) in the code, ie getting length of your input buffer first
#include <vector>
std::vector<float> mybuffer;
mybuffer.reserve(MAX_SIZE);
mybuffer.resize(NEW_SIZE);
you can resize even without a reserve size set first, then it will find some freespace in ram and allocate, but internally the resizing will be more efficient if you had reserved first,
tho of course i assume the max_size is locked space in ram then.
no problem looping and setting to 0 each id, but if setting to 0 the whole array man can use memset:
memset(mybuffer, 0 , sizeof(float)*MAX_SIZE); or more simply memset(mybuffer, 0 , sizeof(mybuffer));
or assuming you know the MAX_SIZE, the bytes size is MAX_SIZE * 4 (4 bytes per float) so for a 1024 array its 4094 bytes
memset(mybuffer,0,4096);
Thanks I'l l try that tonight !
The next idea is to build wavetables from fft :
From an audio signal snap a fft every 10ms then resynthetise from the fft data on one period.
Put the waves each after the other in one big wavetable that can be scanned.
This way I can store a large amount of spectral data with fewer ram.
The next idea is to build wavetables from fft :
From an audio signal snap a fft every 10ms then resynthetise from the fft data on one period.
Put the waves each after the other in one big wavetable that can be scanned.
This way I can store a large amount of spectral data with fewer ram.
http://oli-lab.org
Win11 Ryzen9/32GB RAM - RME MADIFACE - SSL alpha link 4-16 - OSC capable interfaces
follow OLI_LAB adventures on Mastodon
@olivar_premier@mastodon.social
Win11 Ryzen9/32GB RAM - RME MADIFACE - SSL alpha link 4-16 - OSC capable interfaces
follow OLI_LAB adventures on Mastodon
@olivar_premier@mastodon.social
One function you might wanna look at too in your case is memcpy , wich allows a direct copy of a pointer content to another, allowing to skip looping.
for conveniance i pers would do a bi-dimentional vector or array of nb_slots, nb_floats_per_slot, then let you set/get a slot.
for ex
mybuffer[128][1024]; //128 slots, 1024 floats
TPrecision* Out_Ptr; //pointer to float adress
Out_Ptr = sdkGetEvtDataAddr(pArrayOut); // get mem adress of output pin array
memcpy(Out_Ptr, &(mybuffer[5][0]), slot_bytes_size); //copy to output array the content starting at start mem adress of slot 5, of slot size.
for conveniance i pers would do a bi-dimentional vector or array of nb_slots, nb_floats_per_slot, then let you set/get a slot.
for ex
mybuffer[128][1024]; //128 slots, 1024 floats
TPrecision* Out_Ptr; //pointer to float adress
Out_Ptr = sdkGetEvtDataAddr(pArrayOut); // get mem adress of output pin array
memcpy(Out_Ptr, &(mybuffer[5][0]), slot_bytes_size); //copy to output array the content starting at start mem adress of slot 5, of slot size.
sry, we maybe cross-eited tghe post, adn't seen your second message completely, yeah sound nice idea!
hi !
how would you declare mybuffer[128][1024]; //128 slots, 1024 floats
as 128 is for int and 1024 is for floats. ?
how would you declare mybuffer[128][1024]; //128 slots, 1024 floats
as 128 is for int and 1024 is for floats. ?
http://oli-lab.org
Win11 Ryzen9/32GB RAM - RME MADIFACE - SSL alpha link 4-16 - OSC capable interfaces
follow OLI_LAB adventures on Mastodon
@olivar_premier@mastodon.social
Win11 Ryzen9/32GB RAM - RME MADIFACE - SSL alpha link 4-16 - OSC capable interfaces
follow OLI_LAB adventures on Mastodon
@olivar_premier@mastodon.social
yes sorry should be for ex in .h
float mybuffer[128][1024]; // both are int representing X Y sizes for a float contening array. where here for ex 128 is your nb of 'slots' and 1024 nb of floats want in each slot.
float mybuffer[128][1024]; // both are int representing X Y sizes for a float contening array. where here for ex 128 is your nb of 'slots' and 1024 nb of floats want in each slot.
got it !
I did the tricks on your first post.
put 8 array outputs so I can scan the memory slots differently for each of my 8 loudspeakers.
File uploaded: http://www.sensomusic.com/forums/upload ... ray_V1.zip
tell me if your on OSX.
I did the tricks on your first post.
put 8 array outputs so I can scan the memory slots differently for each of my 8 loudspeakers.
File uploaded: http://www.sensomusic.com/forums/upload ... ray_V1.zip
tell me if your on OSX.
http://oli-lab.org
Win11 Ryzen9/32GB RAM - RME MADIFACE - SSL alpha link 4-16 - OSC capable interfaces
follow OLI_LAB adventures on Mastodon
@olivar_premier@mastodon.social
Win11 Ryzen9/32GB RAM - RME MADIFACE - SSL alpha link 4-16 - OSC capable interfaces
follow OLI_LAB adventures on Mastodon
@olivar_premier@mastodon.social
Who is online
Users browsing this forum: No registered users and 7 guests
