Yeah, just clocked that, with SPOUT, say Iām holding a pointer to that, can I just increment that pointer every time I want a new sample and then dereference it to get the sampleās value?
hereās the CsoundWrapper class:
CsoundWrapper::CsoundWrapper()
{
}
CsoundWrapper::~CsoundWrapper()
{
}
bool CsoundWrapper::loadCsd(std::string csdPath)
{
std::lock_guard< std::mutex > guard(csIns._mutex);
csIns.cs = new Csound();
csIns.cs->SetHostImplementedAudioIO(true, 1024);
if(csIns.cs->CompileCsd(csdPath.c_str()) == 0)
{
csIns.cs->Start();
csIns.csPerfThread = new CsoundPerformanceThread(csIns.cs);
csIns.csPerfThread->Play();
return true;
}
else{
return false;
}
}
void CsoundWrapper::passParameter(std::string channel, MYFLT value)
{
std::lock_guard< std::mutex > guard(csIns._mutex);
csIns.cs->SetChannel(channel.c_str(), value);
}
void CsoundWrapper::passParameter(std::string channel, std::string value)
{
std::lock_guard< std::mutex > guard(csIns._mutex);
char *cVal = new char[value.size() + 1];
std::copy(value.begin(), value.end(), cVal);
cVal[value.size()] = ā\0ā;
csIns.cs->SetStringChannel(channel.c_str(), cVal);
delete[] cVal;
}
void CsoundWrapper::sendScoreEvent(std::vector p)
{
std::lock_guard< std::mutex > guard(csIns._mutex);
MYFLT pFields[p.size()];
std::copy(p.begin(), p.end(), pFields);
csIns.csPerfThread->ScoreEvent(āiā, 0, p.size(), pFields);
std::vector().swapĀ§;
}
MYFLT* CsoundWrapper::getOutputBuffer()
{
return csIns.cs->GetOutputBuffer();
}
MYFLT* CsoundWrapper::getSpoutBuffer()
{
return csIns.cs->GetSpout();
}
InstanceData CsoundWrapper::getInstanceData(){
std::lock_guard< std::mutex > guard(csIns._mutex);
auto sr = csIns.cs->GetSr();
auto ksmps = csIns.cs->GetKsmps();
auto nchnls = csIns.cs->GetNchnls();
return InstanceData(ksmps, sr, nchnls);
}
No idea whats going on with the formatting there hahaha, csIns is just a struct with a Csound*, a CsoundPerformanceThread* and a mutex
Edit: Swapping to SPOUT seems promising, promising in that I got a lovely new crash, saying my call to QueueAudio wasnāt in the game thread (Surely it shouldnāt be lol)