Added OpenAL /w audio init test

This commit is contained in:
Charles J. Cliffe
2014-11-05 19:10:18 -05:00
parent d91cffbe58
commit f071b2b025
18 changed files with 3354 additions and 5 deletions
+23 -3
View File
@@ -16,6 +16,9 @@
#include <algorithm>
#include "Demodulate.h"
#define AL_NUM_BUFFERS 3
#define AL_BUFFER_SIZE 4096
wxString glGetwxString(GLenum name) {
const GLubyte *v = glGetString(name);
if (v == 0) {
@@ -63,7 +66,7 @@ PrimaryGLContext::PrimaryGLContext(wxGLCanvas *canvas) :
CheckGLError();
}
void PrimaryGLContext::Plot(std::vector<float> &points,std::vector<float> &points2) {
void PrimaryGLContext::Plot(std::vector<float> &points, std::vector<float> &points2) {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
@@ -117,6 +120,23 @@ TestGLCanvas::TestGLCanvas(wxWindow *parent, int *attribList) :
plan[1] = fftw_plan_dft_1d(out_block_size, in, out[1], FFTW_FORWARD, FFTW_MEASURE);
fft_ceil_ma = fft_ceil_maa = 1.0;
dev = alcOpenDevice(NULL);
if (!dev) {
fprintf(stderr, "Oops\n");
}
ctx = alcCreateContext(dev, NULL);
alcMakeContextCurrent(ctx);
if (!ctx) {
fprintf(stderr, "Oops2\n");
}
}
TestGLCanvas::~TestGLCanvas() {
alcMakeContextCurrent(NULL);
alcDestroyContext(ctx);
alcCloseDevice(dev);
}
void TestGLCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) {
@@ -126,7 +146,7 @@ void TestGLCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) {
PrimaryGLContext& canvas = wxGetApp().GetContext(this);
glViewport(0, 0, ClientSize.x, ClientSize.y);
canvas.Plot(spectrum_points,waveform_points);
canvas.Plot(spectrum_points, waveform_points);
SwapBuffers();
}
@@ -175,7 +195,7 @@ void TestGLCanvas::setData(std::vector<signed char> *data) {
for (int i = 0, iMax = demod.lp_len; i < iMax; i++) {
float v = fabs(demod.lowpassed[i]);
if (v>waveform_ceil) {
if (v > waveform_ceil) {
waveform_ceil = v;
}
}
+8
View File
@@ -9,6 +9,10 @@
#include "Demodulate.h"
#include <AL/al.h>
#include <AL/alc.h>
class PrimaryGLContext: public wxGLContext {
public:
PrimaryGLContext(wxGLCanvas *canvas);
@@ -23,6 +27,7 @@ private:
class TestGLCanvas: public wxGLCanvas {
public:
TestGLCanvas(wxWindow *parent, int *attribList = NULL);
~TestGLCanvas();
void setData(std::vector<signed char> *data);
@@ -47,5 +52,8 @@ private:
Demodulate demod;
ALCdevice *dev;
ALCcontext *ctx;
wxDECLARE_EVENT_TABLE();
};