Compiles, and does not crash!

Audio sounds bad, which means the plugin code is starting to work.
Current bugs: buffer size seems to be changing between 2728 bytes and
1112 bytes, so will need to make the plugin buffer dynamic.
audioplugins
Elliott Liggett 2021-08-01 13:51:14 -07:00
rodzic 2bf131afd5
commit f922789e2d
3 zmienionych plików z 33 dodań i 18 usunięć

Wyświetl plik

@ -303,6 +303,7 @@ void audioHandler::setupLADSP()
// setup for the plugin:
int lPluginIndex;
pre_control = 0.01f;
void *pvPluginHandle = loadLADSPAPluginLibrary(pcPluginFilename);
dlerror();
@ -663,10 +664,6 @@ void audioHandler::incomingAudio(audioPacket inPacket)
//qDebug(logAudio()) << "Adding packet to buffer:" << inPacket.seq << ": " << inPacket.data.length();
if (!ringBuf->try_write(inPacket))
{
qDebug(logAudio()) << "Buffer full! capacity:" << ringBuf->capacity() << "length" << ringBuf->size();
}
// Begin plugin code:
@ -679,17 +676,13 @@ void audioHandler::incomingAudio(audioPacket inPacket)
qDebug() << "about to make byte array:";
// Why does the next line down crash!?!?!
QByteArray pluginOutputQBA;
qDebug() << "made byte array.";
// pluginOutputQBA.reserve(inPacket.data.size());
// pluginOutputQBA.resize(inPacket.data.size());
pluginOutputQBA.fill('0', inPacket.data.size());
qDebug(logAudio()) << "size of inPacket data: " << inPacket.data.size();
qDebug(logAudio()) << "size of BUF_SIZE: " << BUF_SIZE;
// qDebug(logAudio()) << "plugin output QBA size: " << pluginOutputQBA.length();
volatile qint16* pluginOutput = (qint16*)pluginOutputQBA.data();
pluginOutput16bitInterlaced = (uint16_t *)malloc(sizeof(uint16_t) * inPacket.data.size() );
// Copy data from "out" to pInBuffer:
// copyDataIn();
@ -705,23 +698,39 @@ void audioHandler::incomingAudio(audioPacket inPacket)
pInBuffer[1][n/2] = (out[n+1] - mid) * scalingFactor;
}
control = pre_control;
runPlugin();
// copy data back out from pOutBuffer to inPacket.data
// pOutBuffer[0] has size BUF_SIZE/2
// pOutBuffer[1] has size BUF_SIZE/2
// pOut/inBuffer[0] has size BUF_SIZE/2
// pOut/inBuffer[1] has size BUF_SIZE/2
// Maybe the issue is here?
for (int n = 0; n+1 < BUF_SIZE; n += 2) {
pluginOutput[n] = (pOutBuffer[0][n/2] + 1) * max;
pluginOutput[n+1] = (pOutBuffer[1][n/2] + 1) * max;
pluginOutput16bitInterlaced[n] = (pOutBuffer[0][n/2] + 1) * max;
pluginOutput16bitInterlaced[n+1] = (pOutBuffer[1][n/2] + 1) * max;
}
// copyDataOut();
for(int i=0; i < BUF_SIZE; i++)
{
inPacket.data[i] = pluginOutput16bitInterlaced[i];
}
// --- End plugin code.
if (!ringBuf->try_write(inPacket))
{
qDebug(logAudio()) << "Buffer full! capacity:" << ringBuf->capacity() << "length" << ringBuf->size();
}
free(pluginOutput16bitInterlaced);
pluginMutex.unlock();
return;

Wyświetl plik

@ -183,6 +183,10 @@ private:
// --- Plugin support:
QMutex pluginMutex;
//QByteArray pluginOutputQBA;
uint16_t *pluginOutput16bitInterlaced;
uint16_t SAMPLE_RATE;
uint16_t BUF_SIZE;
const LADSPA_Descriptor * psDescriptor;

Wyświetl plik

@ -237,11 +237,12 @@ void rigCommander::prepDataAndSend(QByteArray data)
//printHex(data, false, true);
data.append(payloadSuffix);
// TODO: better filtering here
if(data[4] != '\x15')
{
// We don't print out requests for meter levels
qDebug(logRig()) << "Final payload in rig commander to be sent to rig: ";
printHex(data);
//qDebug(logRig()) << "Final payload in rig commander to be sent to rig: ";
//printHex(data);
}
emit dataForComm(data);
@ -1177,11 +1178,12 @@ void rigCommander::parseCommand()
bool isSpectrumData = payloadIn.startsWith(QByteArray().setRawData("\x27\x00", 2));
// TODO: better filter here:
if( (!isSpectrumData) && (payloadIn[00] != '\x15') )
{
// We do not log spectrum and meter data,
// as they tend to clog up any useful logging.
printHex(payloadIn);
// printHex(payloadIn);
}
switch(payloadIn[00])