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

Wyświetl plik

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

Wyświetl plik

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