mirror of
https://github.com/lubosz/overte.git
synced 2025-08-07 17:41:12 +02:00
commit
af20969eb9
3 changed files with 32 additions and 25 deletions
|
@ -16,6 +16,9 @@
|
||||||
#include <AudioClient.h>
|
#include <AudioClient.h>
|
||||||
#include <AudioConstants.h>
|
#include <AudioConstants.h>
|
||||||
#include <GeometryCache.h>
|
#include <GeometryCache.h>
|
||||||
|
#include <TextureCache.h>
|
||||||
|
#include <gpu/Context.h>
|
||||||
|
#include <GLMHelpers.h>
|
||||||
|
|
||||||
#include "AudioScope.h"
|
#include "AudioScope.h"
|
||||||
|
|
||||||
|
@ -104,7 +107,7 @@ void AudioScope::freeScope() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioScope::render(int width, int height) {
|
void AudioScope::render(RenderArgs* renderArgs, int width, int height) {
|
||||||
|
|
||||||
if (!_isEnabled) {
|
if (!_isEnabled) {
|
||||||
return;
|
return;
|
||||||
|
@ -122,24 +125,26 @@ void AudioScope::render(int width, int height) {
|
||||||
int y = (height - (int)SCOPE_HEIGHT) / 2;
|
int y = (height - (int)SCOPE_HEIGHT) / 2;
|
||||||
int w = (int)SCOPE_WIDTH;
|
int w = (int)SCOPE_WIDTH;
|
||||||
int h = (int)SCOPE_HEIGHT;
|
int h = (int)SCOPE_HEIGHT;
|
||||||
|
|
||||||
renderBackground(backgroundColor, x, y, w, h);
|
gpu::Batch batch;
|
||||||
renderGrid(gridColor, x, y, w, h, gridRows, gridCols);
|
auto geometryCache = DependencyManager::get<GeometryCache>();
|
||||||
|
geometryCache->useSimpleDrawPipeline(batch);
|
||||||
renderLineStrip(_inputID, inputColor, x, y, _samplesPerScope, _scopeInputOffset, _scopeInput);
|
auto textureCache = DependencyManager::get<TextureCache>();
|
||||||
renderLineStrip(_outputLeftID, outputLeftColor, x, y, _samplesPerScope, _scopeOutputOffset, _scopeOutputLeft);
|
batch.setUniformTexture(0, textureCache->getWhiteTexture());
|
||||||
renderLineStrip(_outputRightD, outputRightColor, x, y, _samplesPerScope, _scopeOutputOffset, _scopeOutputRight);
|
mat4 legacyProjection = glm::ortho<float>(0, width, height, 0, -1000, 1000);
|
||||||
|
batch.setProjectionTransform(legacyProjection);
|
||||||
|
batch.setModelTransform(Transform());
|
||||||
|
batch.setViewTransform(Transform());
|
||||||
|
geometryCache->renderQuad(batch, x, y, w, h, backgroundColor);
|
||||||
|
geometryCache->renderGrid(batch, x, y, w, h, gridRows, gridCols, gridColor, _audioScopeGrid);
|
||||||
|
renderLineStrip(batch, _inputID, inputColor, x, y, _samplesPerScope, _scopeInputOffset, _scopeInput);
|
||||||
|
renderLineStrip(batch, _outputLeftID, outputLeftColor, x, y, _samplesPerScope, _scopeOutputOffset, _scopeOutputLeft);
|
||||||
|
renderLineStrip(batch, _outputRightD, outputRightColor, x, y, _samplesPerScope, _scopeOutputOffset, _scopeOutputRight);
|
||||||
|
renderArgs->_context->syncCache();
|
||||||
|
renderArgs->_context->render(batch);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioScope::renderBackground(const glm::vec4& color, int x, int y, int width, int height) {
|
void AudioScope::renderLineStrip(gpu::Batch& batch, int id, const glm::vec4& color, int x, int y, int n, int offset, const QByteArray* byteArray) {
|
||||||
DependencyManager::get<GeometryCache>()->renderQuad(x, y, width, height, color);
|
|
||||||
}
|
|
||||||
|
|
||||||
void AudioScope::renderGrid(const glm::vec4& color, int x, int y, int width, int height, int rows, int cols) {
|
|
||||||
DependencyManager::get<GeometryCache>()->renderGrid(x, y, width, height, rows, cols, color, _audioScopeGrid);
|
|
||||||
}
|
|
||||||
|
|
||||||
void AudioScope::renderLineStrip(int id, const glm::vec4& color, int x, int y, int n, int offset, const QByteArray* byteArray) {
|
|
||||||
|
|
||||||
int16_t sample;
|
int16_t sample;
|
||||||
int16_t* samples = ((int16_t*) byteArray->data()) + offset;
|
int16_t* samples = ((int16_t*) byteArray->data()) + offset;
|
||||||
|
@ -194,7 +199,7 @@ void AudioScope::renderLineStrip(int id, const glm::vec4& color, int x, int y, i
|
||||||
|
|
||||||
|
|
||||||
geometryCache->updateVertices(id, points, color);
|
geometryCache->updateVertices(id, points, color);
|
||||||
geometryCache->renderVertices(gpu::LINE_STRIP, id);
|
geometryCache->renderVertices(batch, gpu::LINE_STRIP, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
int AudioScope::addBufferToScope(QByteArray* byteArray, int frameOffset, const int16_t* source, int sourceSamplesPerChannel,
|
int AudioScope::addBufferToScope(QByteArray* byteArray, int frameOffset, const int16_t* source, int sourceSamplesPerChannel,
|
||||||
|
|
|
@ -14,11 +14,14 @@
|
||||||
|
|
||||||
#include <glm/glm.hpp>
|
#include <glm/glm.hpp>
|
||||||
|
|
||||||
#include <DependencyManager.h>
|
|
||||||
|
|
||||||
#include <QByteArray>
|
#include <QByteArray>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
|
#include <DependencyManager.h>
|
||||||
|
#include <gpu/Batch.h>
|
||||||
|
#include <RenderArgs.h>
|
||||||
|
|
||||||
|
|
||||||
class AudioScope : public QObject, public Dependency {
|
class AudioScope : public QObject, public Dependency {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
SINGLETON_DEPENDENCY
|
SINGLETON_DEPENDENCY
|
||||||
|
@ -28,7 +31,7 @@ public:
|
||||||
void freeScope();
|
void freeScope();
|
||||||
void reallocateScope(int frames);
|
void reallocateScope(int frames);
|
||||||
|
|
||||||
void render(int width, int height);
|
void render(RenderArgs* renderArgs, int width, int height);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void toggle();
|
void toggle();
|
||||||
|
@ -48,9 +51,7 @@ private slots:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Audio scope methods for rendering
|
// Audio scope methods for rendering
|
||||||
static void renderBackground(const glm::vec4& color, int x, int y, int width, int height);
|
void renderLineStrip(gpu::Batch& batch, int id, const glm::vec4& color, int x, int y, int n, int offset, const QByteArray* byteArray);
|
||||||
void renderGrid(const glm::vec4& color, int x, int y, int width, int height, int rows, int cols);
|
|
||||||
void renderLineStrip(int id, const glm::vec4& color, int x, int y, int n, int offset, const QByteArray* byteArray);
|
|
||||||
|
|
||||||
// Audio scope methods for data acquisition
|
// Audio scope methods for data acquisition
|
||||||
int addBufferToScope(QByteArray* byteArray, int frameOffset, const int16_t* source, int sourceSamples,
|
int addBufferToScope(QByteArray* byteArray, int frameOffset, const int16_t* source, int sourceSamples,
|
||||||
|
|
|
@ -129,11 +129,12 @@ void ApplicationOverlay::renderOverlays(RenderArgs* renderArgs) {
|
||||||
emit qApp->renderingOverlay();
|
emit qApp->renderingOverlay();
|
||||||
qApp->getOverlays().renderHUD(renderArgs);
|
qApp->getOverlays().renderHUD(renderArgs);
|
||||||
|
|
||||||
|
DependencyManager::get<AudioScope>()->render(renderArgs, _overlayFramebuffer->size().width(), _overlayFramebuffer->size().height());
|
||||||
|
|
||||||
glMatrixMode(GL_PROJECTION);
|
glMatrixMode(GL_PROJECTION);
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
glMatrixMode(GL_MODELVIEW);
|
glMatrixMode(GL_MODELVIEW);
|
||||||
|
|
||||||
renderArgs->_context->syncCache();
|
|
||||||
fboViewport(_overlayFramebuffer);
|
fboViewport(_overlayFramebuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue