joeribraams
New member
Hello, I've soldered 2 PSRAM chips on my T4.1, the memory test program works and shows both chips, and when I make an EXTMEM array in the main .ino file it works. However if I try to make an EXTMEM array in an class in a seperate .h file, if gives me this error (with verbose output this is the only relevant part):
This is my code for the class:
Does anyone here have any idea what causes this? I've searched the forums and elsewhere online but no luck so far. Does my suspicion that it's caused by the buffer being inside a class make any sense? Can I solve this in the class or will I have to move the buffer outside of the class somehow?
Code:
\sketch\FxLooper.h:110:41: error: section attribute not allowed for 'bufferL'
EXTMEM int16_t bufferL[LOOPER_MAX_SIZE];
^
This is my code for the class:
Code:
#ifndef Looper_h
#define Looper_h
#include "Arduino.h"
#define LOOPER_MAX_SIZE 441000
class Looper
{
public:
// Constructor and destructor ////////////////////////////////////////////////////////////////
Looper(uint16_t blockSize, bool killDry)
{
this->blockSize = blockSize;
this->killDry = killDry;
}
~Looper() {}
// Process a block of samples ////////////////////////////////////////////////////////////////
void processBlock(int16_t * inL, int16_t * inR, int16_t * outL, int16_t * outR)
{
for(uint16_t i = 0; i < blockSize; i++)
{
if(recording)
{
bufferL[bufStep] = (bufferL[bufStep] * playing) + inL[i];
bufferR[bufStep] = (bufferR[bufStep] * playing) + inR[i];
checkLength();
}
bufStep <= bufLen ? bufStep++ : bufStep = 0; // Increment and wrap index
killDry ? dryOut = !playing : dryOut = true;
outL[i] = (inL[i] * dryOut) + (bufferL[bufStep] * playing);
outR[i] = (inL[i] * dryOut) + (bufferR[bufStep] * playing);
}
}
// Setters for footswitch control ////////////////////////////////////////////////////////////////
void fsClick()
{
if(playing)
{
initLooper();
}
else // A short tap when not playing can also start the loop
{
fsStop();
}
}
void fsHold()
{
if(!blockRec && millis() > (debounce + 50))
{
recording = true;
blockRec = true;
}
}
void fsStop()
{
recording = false;
playing = true;
blockRec = false;
debounce = millis();
}
void initLooper()
{
playing = false;
recording = false;
blockRec = false;
debounce = millis();
bufStep = 0;
bufLen = 0;
}
// Getter for the led state ////////////////////////////////////////////////////////////////
uint8_t checkLeds()
{
return recording ? 2 : playing;
}
private:
// To prevent buffer overflow ////////////////////////////////////////////////////////////////
void checkLength()
{
if(!playing)
{
bufLen < LOOPER_MAX_SIZE ? bufLen++ : playing = true;
}
}
// Stores the samples in PSRAM ////////////////////////////////////////////////////////////////
EXTMEM int16_t bufferL[LOOPER_MAX_SIZE];
EXTMEM int16_t bufferR[LOOPER_MAX_SIZE];
// Place in and length of loop ////////////////////////////////////////////////////////////////
uint32_t bufStep = 0;
uint32_t bufLen = 0;
// Stores state of system ////////////////////////////////////////////////////////////////
bool recording = false;
bool playing = false;
bool blockRec = false;
bool killDry;
bool dryOut = true;
uint32_t debounce;
uint16_t blockSize;
};
#endif
Does anyone here have any idea what causes this? I've searched the forums and elsewhere online but no luck so far. Does my suspicion that it's caused by the buffer being inside a class make any sense? Can I solve this in the class or will I have to move the buffer outside of the class somehow?