Bug fixes for audio textures
This commit is contained in:
@@ -5,8 +5,9 @@
|
||||
#include <QQuickImageProvider>
|
||||
|
||||
#include "AudioModel.h"
|
||||
#include "Komplex_global.h"
|
||||
|
||||
class AudioImageProvider : public QQuickImageProvider
|
||||
class KOMPLEX_EXPORT AudioImageProvider : public QQuickImageProvider
|
||||
{
|
||||
public:
|
||||
explicit AudioImageProvider();
|
||||
|
||||
@@ -120,6 +120,9 @@ AudioModel::~AudioModel()
|
||||
|
||||
void AudioModel::startCapture()
|
||||
{
|
||||
if(!m_instance)
|
||||
m_instance = new AudioModel();
|
||||
|
||||
if(m_thread->isRunning())
|
||||
return;
|
||||
|
||||
@@ -139,6 +142,9 @@ void AudioModel::startCaptureAsync()
|
||||
|
||||
QPixmap AudioModel::frame()
|
||||
{
|
||||
if(!m_instance)
|
||||
return QPixmap();
|
||||
|
||||
return m_instance->m_frame;
|
||||
}
|
||||
|
||||
@@ -319,7 +325,8 @@ void AudioModel::on_process(void *userdata)
|
||||
}
|
||||
|
||||
// Blackman window function
|
||||
std::vector<double> AudioModel::createBlackmanWindow(int size) {
|
||||
std::vector<double> AudioModel::createBlackmanWindow(int size)
|
||||
{
|
||||
std::vector<double> window(size);
|
||||
const double a0 = 0.42;
|
||||
const double a1 = 0.5;
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
* https://webaudio.github.io/web-audio-api/#smoothing-over-time
|
||||
*
|
||||
* The described smoothing method was resulting in inconsistent data. This
|
||||
* is likely to a poor implementation. A linear smoothing algo seems to work
|
||||
* is likely due to a poor implementation. A linear smoothing algo seems to work
|
||||
* (at least visually). Will need to revisit the temporal implementation if
|
||||
* things do not work as expected.
|
||||
*
|
||||
|
||||
@@ -7,6 +7,15 @@
|
||||
#include "ShaderPackModel.h"
|
||||
#include "Komplex_global.h"
|
||||
|
||||
AudioModel *komplexAudioSingletonProvider(QQmlEngine *engine, QJSEngine *scriptEngine)
|
||||
{
|
||||
Q_UNUSED(engine)
|
||||
Q_UNUSED(scriptEngine)
|
||||
|
||||
AudioModel *model = new AudioModel();
|
||||
return model;
|
||||
}
|
||||
|
||||
class KOMPLEX_EXPORT KomplexPlugin : public QQmlExtensionPlugin
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -16,7 +25,7 @@ public:
|
||||
{
|
||||
Q_ASSERT(QLatin1String(uri) == QLatin1String("com.github.digitalartifex.komplex"));
|
||||
|
||||
qmlRegisterType<AudioModel>(uri, 1, 0, "AudioModel");
|
||||
qmlRegisterSingletonType<AudioModel*>(uri, 1, 0, "AudioModel", komplexAudioSingletonProvider);
|
||||
qmlRegisterType<ShaderPackModel>(uri, 1, 0, "ShaderPackModel");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user