Page 1 of 1
Posted: 10 Apr 2018, 19:38
by 23fx23
think oli faced maybe similar case but i couldn't find back the thread.
ive made kinda wavtable oscillator class .h .cpp
if i declare a float array to contain the wavtable in the .h like:
float wavtable[4096]; // no problem, that works
but if i ty to make it bigger
float wavtable[524288]; //256 tables of 2048 samples.
then i got errors on init and it get weird in paint and stuff
for debuging i don't call/use the array anywere, just creating few oscillators.
any ideas?
Posted: 10 Apr 2018, 21:30
by oli_lab
Hi !
As for the wavetable module, I used the sdk audiofile thingo :
in .h :
AudioFilePtr wavetable;
in .cpp :
void WTsynth::onInitModule(MasterInfo* pMasterInfo, ModuleInfo* pModuleInfo)
{
wavetable = sdkCreateAudioFile();
}
and in callback :
sdkLoadInMemoryAudioFile(wavetable, sdkGetEvtPChar(fileName));
Posted: 10 Apr 2018, 21:34
by oli_lab
for live sampler and affiliate :
in .h :
TPrecision* m_buffer; // Samples buffer
in .cpp :
// constructor
hydrogen::hydrogen()
{
//Initialize values
m_size = (lineSize+2) * 48000; //longueur fixe pour l'instant
//m_read[AUDIO_INS_OUTS_MAX] = 0;
//Ensure that initial sample values at buffer are 0.0f
m_buffer = new float[m_size];
for (int i = 0; i<m_size; i++)
{
m_buffer = 0.0f;
}
m_size = m_size - 2 * 48000;
m_write = m_size - 1;
}
// destructor
hydrogen::~hydrogen()
{
delete[] m_buffer;
}
then you fill this buffer as you wish !
Posted: 10 Apr 2018, 22:24
by 23fx23
ah cool thanks gonna investigate this method

Posted: 10 Apr 2018, 23:54
by oli_lab
is it waveterrain oscillator you're making ?
I did wavetable oscillator, I can send you the code if you want.
Posted: 11 Apr 2018, 01:19
by 23fx23
mm don't know wavterrain, not sure,
basically it's a 'simple' wavtable reader that read like 256 tables of 2048 samples, made a basic linear interpolation for now between current read table and next one samples, the oscillator itself is working ok , its just a bit strange that i can't create big arrays in 'external' files wich bugs me, like if there was a meory leak or something bit like your 'cannot be computed in a block issue' or something i don't understand yet..
but i made a different system tonight as workaround where i declare the big arrays in my main module file and pass the pointer, and that work ok that way.. so i don't really know why lol.
Posted: 11 Apr 2018, 13:23
by oli_lab
Interesting even tho I didn't get everything.
Curious about the workaround.
I did have trouble with the audiofile ask thing but my post disappeared after the hack attack on sensomusic server..
This sdkloadfile in memory works fine for small files but make the rack hanging if the loading takes longer than a block to load.
Should develop some sort of a trickling algorithm to load the file on more than one block so it leave time to other tasks to execute smoothly.
Posted: 11 Apr 2018, 14:17
by sm_jamieson
oli_lab wrote:Interesting even tho I didn't get everything.
Curious about the workaround.
I did have trouble with the audiofile ask thing but my post disappeared after the hack attack on sensomusic server..
This sdkloadfile in memory works fine for small files but make the rack hanging if the loading takes longer than a block to load.
Should develop some sort of a trickling algorithm to load the file on more than one block so it leave time to other tasks to execute smoothly.
They way to do this would be to create a new thread (c++ std:thread class) that can do whatever it wants, then when loading it finishes, set a flag to say the file has loaded. You can find thread examples with Google.
Also, the Wiimote user module does stuff with threads (see code in SDK), but I think it uses Juce.
Note that you will need thread locking (windows critical section, mutex, etc) to protect access to data accessed by several threads. If not, you will get occasional strange errors.
Posted: 12 Apr 2018, 14:04
by 23fx23