mirror of
https://github.com/projectM-visualizer/projectm.git
synced 2026-03-05 06:55:20 +00:00
huge update with a few very awful bugs left
git-svn-id: https://projectm.svn.sourceforge.net/svnroot/projectm/trunk@815 6778bc44-b910-0410-a7a0-be141de4315d
This commit is contained in:
@ -170,11 +170,6 @@ void BeatDetect::getBeatVals( float *vdataL,float *vdataR ) {
|
||||
mid_att=.6 * mid_att + .4 * mid;
|
||||
bass_att=.6 * bass_att + .4 * bass;
|
||||
|
||||
DWRITE( "BeatDetect::getBeatVals: treb: %f\tmid: %f\tbass: %f\n",
|
||||
treb, mid, bass );
|
||||
DWRITE( "BeatDetect::getBeatVals: treb_att: %f\tmid_att: %f\tbass_att: %f\n",
|
||||
treb_att, mid_att, bass_att );
|
||||
|
||||
// *vol=(beat_instant[3])/(beat_history[3]);
|
||||
beat_buffer_pos++;
|
||||
if( beat_buffer_pos>79)beat_buffer_pos=0;
|
||||
|
||||
@ -411,42 +411,42 @@ CustomWave::CustomWave(int _id):
|
||||
param = Param::new_param_float ( "q1", P_FLAG_QVAR, &this->q1, NULL, MAX_DOUBLE_SIZE, -MAX_DOUBLE_SIZE, 0.0 );
|
||||
if ( ParamUtils::insert ( param, &this->param_tree ) < 0 )
|
||||
{
|
||||
DWRITE ( "%s\n", "failed to insert param!" );
|
||||
|
||||
}
|
||||
param = Param::new_param_float ( "q2", P_FLAG_QVAR, &this->q2, NULL, MAX_DOUBLE_SIZE, -MAX_DOUBLE_SIZE, 0.0 );
|
||||
if ( ParamUtils::insert ( param, &this->param_tree ) < 0 )
|
||||
{
|
||||
DWRITE ( "%s\n", "failed to insert param!" );
|
||||
|
||||
}
|
||||
param = Param::new_param_float ( "q3", P_FLAG_QVAR, &this->q3, NULL, MAX_DOUBLE_SIZE, -MAX_DOUBLE_SIZE, 0.0 );
|
||||
if ( ParamUtils::insert ( param, &this->param_tree ) < 0 )
|
||||
{
|
||||
DWRITE ( "%s\n", "failed to insert param!" );
|
||||
|
||||
}
|
||||
param = Param::new_param_float ( "q4", P_FLAG_QVAR, &this->q4, NULL, MAX_DOUBLE_SIZE, -MAX_DOUBLE_SIZE, 0.0 );
|
||||
if ( ParamUtils::insert ( param, &this->param_tree ) < 0 )
|
||||
{
|
||||
DWRITE ( "%s\n", "failed to insert param!" );
|
||||
|
||||
}
|
||||
param = Param::new_param_float ( "q5", P_FLAG_QVAR, &this->q5, NULL, MAX_DOUBLE_SIZE, -MAX_DOUBLE_SIZE, 0.0 );
|
||||
if ( ParamUtils::insert ( param, &this->param_tree ) < 0 )
|
||||
{
|
||||
DWRITE ( "%s\n", "failed to insert param!" );
|
||||
|
||||
}
|
||||
param = Param::new_param_float ( "q6", P_FLAG_QVAR, &this->q6, NULL, MAX_DOUBLE_SIZE, -MAX_DOUBLE_SIZE, 0.0 );
|
||||
if ( ParamUtils::insert ( param, &this->param_tree ) < 0 )
|
||||
{
|
||||
DWRITE ( "%s\n", "failed to insert param!" );
|
||||
|
||||
}
|
||||
param = Param::new_param_float ( "q7", P_FLAG_QVAR, &this->q7, NULL, MAX_DOUBLE_SIZE, -MAX_DOUBLE_SIZE, 0.0 );
|
||||
if ( ParamUtils::insert ( param, &this->param_tree ) < 0 )
|
||||
{
|
||||
DWRITE ( "%s\n", "failed to insert param!" );
|
||||
|
||||
}
|
||||
param = Param::new_param_float ( "q8", P_FLAG_QVAR, &this->q8, NULL, MAX_DOUBLE_SIZE, -MAX_DOUBLE_SIZE, 0.0 );
|
||||
if ( ParamUtils::insert ( param, &this->param_tree ) < 0 )
|
||||
{
|
||||
DWRITE ( "%s\n", "failed to insert param!" );
|
||||
|
||||
}
|
||||
/* End of parameter loading. Note that the read only parameters associated
|
||||
with custom waves (ie, sample) are variables stored in PresetFrameIO.hpp,
|
||||
|
||||
@ -147,9 +147,6 @@ RenderTarget::RenderTarget(int texsize, int width, int height) : useFBO(false) {
|
||||
else this->useFBO=0;
|
||||
}
|
||||
|
||||
|
||||
DWRITE( "using teximage hack fallback\n" );
|
||||
|
||||
/** Fallback pbuf;fer creation via teximage hack */
|
||||
/** Check the texture size against the viewport size */
|
||||
/** If the viewport is smaller, then we'll need to scale the texture size down */
|
||||
@ -160,18 +157,13 @@ RenderTarget::RenderTarget(int texsize, int width, int height) : useFBO(false) {
|
||||
|
||||
/* Create the texture that will be bound to the render this */
|
||||
if ( glIsTexture( this->textureID[0] ) ) {
|
||||
DWRITE( "texture already exists\n" );
|
||||
if ( this->texsize != origtexsize ) {
|
||||
DWRITE( "deleting existing texture due to resize\n" );
|
||||
if ( this->texsize != origtexsize )
|
||||
glDeleteTextures( 1, &this->textureID[0] );
|
||||
}
|
||||
}
|
||||
|
||||
if ( !glIsTexture( this->textureID[0] ) ) {
|
||||
glGenTextures(1, &this->textureID[0] );
|
||||
|
||||
DWRITE( "allocate texture: %d\ttexsize: %d x %d\n",
|
||||
this->textureID[0], this->texsize, this->texsize );
|
||||
glBindTexture(GL_TEXTURE_2D, this->textureID[0] );
|
||||
//glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
//glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
@ -201,9 +193,9 @@ RenderTarget::RenderTarget(int texsize, int width, int height) : useFBO(false) {
|
||||
|
||||
/* Create the texture that will be bound to the render this */
|
||||
if ( glIsTexture( this->textureID[0] ) ) {
|
||||
DWRITE( "texture already exists\n" );
|
||||
|
||||
if ( this->texsize != origtexsize ) {
|
||||
DWRITE( "deleting existing texture due to resize\n" );
|
||||
|
||||
glDeleteTextures( 1, &this->textureID[0] );
|
||||
}
|
||||
}
|
||||
@ -211,8 +203,6 @@ RenderTarget::RenderTarget(int texsize, int width, int height) : useFBO(false) {
|
||||
if ( !glIsTexture( this->textureID[0] ) ) {
|
||||
glGenTextures(1, &this->textureID[0] );
|
||||
|
||||
DWRITE( "allocate texture: %d\ttexsize: %d x %d\n",
|
||||
this->textureID[0], this->texsize, this->texsize );
|
||||
glBindTexture(GL_TEXTURE_2D, this->textureID[0] );
|
||||
//glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
//glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
@ -260,7 +250,7 @@ void RenderTarget::unlock() {
|
||||
}
|
||||
|
||||
/** Fallback texture path */
|
||||
DWRITE( "copying framebuffer to texture\n" );
|
||||
|
||||
glBindTexture( GL_TEXTURE_2D, this->textureID[0] );
|
||||
|
||||
glCopyTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, 0, 0, this->texsize, this->texsize );
|
||||
@ -275,8 +265,6 @@ int RenderTarget::nearestPower2( int value, TextureScale scaleRule ) {
|
||||
int x = value;
|
||||
int power = 0;
|
||||
|
||||
DWRITE( "nearestPower2(): %d\n", value );
|
||||
|
||||
while ( ( x & 0x01 ) != 1 ) {
|
||||
x >>= 1;
|
||||
}
|
||||
|
||||
@ -91,10 +91,7 @@ param->matrix_flag = false;
|
||||
/* Parameter is an integer type, just like C */
|
||||
|
||||
if ( param->type == P_TYPE_INT) {
|
||||
if (INIT_COND_DEBUG) {
|
||||
DWRITE( "init_cond: %s = %d (TYPE INT)\n", param->name.c_str(), init_val.int_val);
|
||||
}
|
||||
assert(param->engine_val);
|
||||
assert(param->engine_val);
|
||||
*((int*)param->engine_val) = init_val.int_val;
|
||||
return;
|
||||
}
|
||||
@ -102,11 +99,6 @@ param->matrix_flag = false;
|
||||
/* Parameter is of a float type, just like C */
|
||||
|
||||
if (param->type == P_TYPE_DOUBLE) {
|
||||
if (INIT_COND_DEBUG) {
|
||||
DWRITE( "init_cond: %s = %f (TYPE DOUBLE) -> %f -> %X -> %X\n", param->name.c_str(),
|
||||
init_val.float_val, *((float *)param->engine_val),
|
||||
param, param->engine_val );
|
||||
}
|
||||
assert(param->engine_val);
|
||||
*((float*)param->engine_val) = init_val.float_val;
|
||||
return;
|
||||
|
||||
@ -32,29 +32,32 @@
|
||||
#include "wipemalloc.h"
|
||||
#include "fftsg.h"
|
||||
#include "PCM.hpp"
|
||||
#include <cassert>
|
||||
|
||||
int PCM::maxsamples = 2048;
|
||||
|
||||
//initPCM(int samples)
|
||||
//
|
||||
//Initializes the PCM buffer to
|
||||
// number of samples specified.
|
||||
|
||||
#include <iostream>
|
||||
PCM::PCM() {
|
||||
initPCM( 2048 );
|
||||
std::cerr << "MAX SAMPLES:" << maxsamples << std::endl;
|
||||
}
|
||||
|
||||
void PCM::initPCM(int samples) {
|
||||
int i;
|
||||
|
||||
DWRITE( "initPCM()\n" );
|
||||
|
||||
waveSmoothing = 0;
|
||||
|
||||
//Allocate memory for PCM data buffer
|
||||
assert(samples == 2048);
|
||||
PCMd = (float **)wipemalloc(2 * sizeof(float *));
|
||||
PCMd[0] = (float *)wipemalloc(samples * sizeof(float));
|
||||
PCMd[1] = (float *)wipemalloc(samples * sizeof(float));
|
||||
|
||||
maxsamples=samples;
|
||||
//maxsamples=samples;
|
||||
newsamples=0;
|
||||
numsamples = maxsamples;
|
||||
|
||||
@ -98,33 +101,37 @@ PCM::~PCM() {
|
||||
|
||||
}
|
||||
|
||||
void PCM::addPCMfloat(float *PCMdata, int samples)
|
||||
#include <iostream>
|
||||
|
||||
void PCM::addPCMfloat(const float *PCMdata, int samples) const
|
||||
{
|
||||
int i,j;
|
||||
|
||||
|
||||
std::cerr << "start:" << this->start << std::endl;
|
||||
static bool firstTime = true;
|
||||
|
||||
if (firstTime) {
|
||||
start = 0;
|
||||
firstTime = false;
|
||||
}
|
||||
|
||||
for(i=0;i<samples;i++)
|
||||
{
|
||||
j=i+start;
|
||||
|
||||
|
||||
|
||||
if ( PCMdata[i] != 0 && PCMdata[i] != 0 ) {
|
||||
|
||||
if (PCMdata[i] != 0 ) {
|
||||
|
||||
PCMd[0][j%maxsamples]=(float)PCMdata[i];
|
||||
PCMd[1][j%maxsamples]=(float)PCMdata[i];
|
||||
PCMd[0][j%maxsamples]=PCMdata[i];
|
||||
PCMd[1][j%maxsamples]=PCMdata[i];
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
PCMd[0][j % maxsamples] =(float) 0;
|
||||
PCMd[1][j % maxsamples] =(float) 0;
|
||||
PCMd[0][j % maxsamples] = 0;
|
||||
PCMd[1][j % maxsamples] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
DWRITE("Added %d samples %d %d %f\n",samples,start,(start+samples)%maxsamples,PCMd[0][start+10]);
|
||||
|
||||
start+=samples;
|
||||
start=start%maxsamples;
|
||||
|
||||
@ -160,8 +167,6 @@ void PCM::addPCM16(short PCMdata[2][512])
|
||||
{
|
||||
int i,j;
|
||||
int samples=512;
|
||||
|
||||
DWRITE( "start: %d\n", start );
|
||||
|
||||
for(i=0;i<samples;i++)
|
||||
{
|
||||
@ -264,7 +269,7 @@ void PCM::addPCM8_512( const unsigned char PCMdata[2][512])
|
||||
|
||||
//returned values are normalized from -1 to 1
|
||||
|
||||
void PCM::getPCM(float *PCMdata, int samples, int channel, int freq, float smoothing, int derive)
|
||||
void PCM::getPCM(float *PCMdata, int samples, int channel, int freq, float smoothing, int derive) const
|
||||
{
|
||||
int i,index;
|
||||
|
||||
@ -312,7 +317,7 @@ void PCM::getPCM(float *PCMdata, int samples, int channel, int freq, float smoot
|
||||
//the actual return value is the number of samples, up to maxsamples.
|
||||
//the passed pointer, PCMData, must bee able to hold up to maxsamples
|
||||
|
||||
int PCM::getPCMnew(float *PCMdata, int channel, int freq, float smoothing, int derive, int reset)
|
||||
int PCM::getPCMnew(float *PCMdata, int channel, int freq, float smoothing, int derive, int reset) const
|
||||
{
|
||||
int i,index;
|
||||
|
||||
|
||||
@ -31,37 +31,38 @@
|
||||
|
||||
class PCM {
|
||||
public:
|
||||
float **PCMd;
|
||||
// int maxsamples;
|
||||
int start;
|
||||
mutable float **PCMd;
|
||||
mutable int start;
|
||||
|
||||
/** Use wave smoothing */
|
||||
float waveSmoothing;
|
||||
|
||||
int *ip;
|
||||
double *w;
|
||||
int newsamples;
|
||||
mutable int newsamples;
|
||||
|
||||
int maxsamples; //size of PCM buffer
|
||||
int numsamples; //size of new PCM info
|
||||
mutable int numsamples; //size of new PCM info
|
||||
float *pcmdataL; //holder for most recent pcm data
|
||||
float *pcmdataR; //holder for most recent pcm data
|
||||
|
||||
/** PCM data */
|
||||
float vdataL[512]; //holders for FFT data (spectrum)
|
||||
float vdataR[512];
|
||||
mutable float vdataL[512]; //holders for FFT data (spectrum)
|
||||
mutable float vdataR[512];
|
||||
|
||||
static int maxsamples;
|
||||
PCM();
|
||||
~PCM();
|
||||
void initPCM(int maxsamples);
|
||||
void addPCMfloat(float *PCMdata, int samples);
|
||||
void addPCMfloat(const float *PCMdata, int samples) const;
|
||||
void addPCM16(short [2][512]);
|
||||
void addPCM16Data(const short* pcm_data, short samples);
|
||||
void addPCM8( unsigned char [2][1024]);
|
||||
void addPCM8_512( const unsigned char [2][512]);
|
||||
void getPCM(float *data, int samples, int channel, int freq, float smoothing, int derive);
|
||||
void getPCM(float *data, int samples, int channel, int freq, float smoothing, int derive) const;
|
||||
void freePCM();
|
||||
int getPCMnew(float *PCMdata, int channel, int freq, float smoothing, int derive,int reset);
|
||||
int getPCMnew(float *PCMdata, int channel, int freq, float smoothing, int derive,int reset) const;
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif /** !_PCM_H */
|
||||
|
||||
@ -118,7 +118,7 @@ bool Param::is_valid_param_string( const char * string ) {
|
||||
|
||||
|
||||
/* Loads a float parameter into the builtin database */
|
||||
Param * Param::new_param_float(char * name, short int flags, void * engine_val, void * matrix,
|
||||
Param * Param::new_param_float(const char * name, short int flags, void * engine_val, void * matrix,
|
||||
float upper_bound, float lower_bound, float init_val) {
|
||||
|
||||
Param * param;
|
||||
@ -138,7 +138,7 @@ Param * Param::new_param_float(char * name, short int flags, void * engine_val,
|
||||
}
|
||||
|
||||
/* Creates a new parameter of type int */
|
||||
Param * Param::new_param_int(char * name, short int flags, void * engine_val,
|
||||
Param * Param::new_param_int(const char * name, short int flags, void * engine_val,
|
||||
int upper_bound, int lower_bound, int init_val) {
|
||||
|
||||
Param * param;
|
||||
@ -158,7 +158,7 @@ Param * Param::new_param_int(char * name, short int flags, void * engine_val,
|
||||
}
|
||||
|
||||
/* Creates a new parameter of type bool */
|
||||
Param * Param::new_param_bool(char * name, short int flags, void * engine_val,
|
||||
Param * Param::new_param_bool(const char * name, short int flags, void * engine_val,
|
||||
bool upper_bound, bool lower_bound, bool init_val) {
|
||||
|
||||
Param * param;
|
||||
@ -178,7 +178,7 @@ Param * Param::new_param_bool(char * name, short int flags, void * engine_val,
|
||||
}
|
||||
|
||||
/* Creates a new parameter of type string */
|
||||
Param * Param::new_param_string(char * name, short int flags, void * engine_val) {
|
||||
Param * Param::new_param_string(const char * name, short int flags, void * engine_val) {
|
||||
|
||||
Param * param;
|
||||
CValue iv, ub, lb;
|
||||
|
||||
@ -86,19 +86,19 @@ public:
|
||||
static bool is_valid_param_string( const char *string );
|
||||
void set_param( float val );
|
||||
|
||||
static Param *new_param_float( char *name, short int flags, void *engine_val,
|
||||
static Param *new_param_float( const char *name, short int flags, void *engine_val,
|
||||
void *matrix, float upper_bound,
|
||||
float lower_bound,
|
||||
float init_val );
|
||||
static Param *new_param_double( char *name, short int flags, void *engine_val,
|
||||
static Param *new_param_double(const char *name, short int flags, void *engine_val,
|
||||
void *matrix, double upper_bound,
|
||||
double lower_bound,
|
||||
double init_val );
|
||||
static Param * new_param_int( char * name, short int flags, void * engine_val,
|
||||
static Param * new_param_int(const char * name, short int flags, void * engine_val,
|
||||
int upper_bound, int lower_bound, int init_val );
|
||||
static Param * new_param_bool( char * name, short int flags, void * engine_val,
|
||||
static Param * new_param_bool(const char * name, short int flags, void * engine_val,
|
||||
bool upper_bound, bool lower_bound, bool init_val );
|
||||
static Param * new_param_string(char * name, short int flags, void * engine_val);
|
||||
static Param * new_param_string(const char * name, short int flags, void * engine_val);
|
||||
|
||||
};
|
||||
|
||||
|
||||
@ -336,10 +336,6 @@ int Parser::parse_preset_name(std::istream & fs, char * name)
|
||||
if ((token = parseToken(fs, name)) != tRBr)
|
||||
return PROJECTM_PARSE_ERROR;
|
||||
|
||||
#ifdef DEBUG
|
||||
if (PARSE_DEBUG) DWRITE("parse_preset_name: parsed preset (name = \"%s\")\n", name);
|
||||
#endif
|
||||
|
||||
return PROJECTM_SUCCESS;
|
||||
}
|
||||
|
||||
@ -352,9 +348,6 @@ int Parser::parse_per_pixel_eqn(std::istream & fs, Preset * preset, char * init
|
||||
char string[MAX_TOKEN_SIZE];
|
||||
GenExpr * gen_expr;
|
||||
|
||||
#ifdef DEBUG
|
||||
if (PARSE_DEBUG) DWRITE("parse_per_pixel: per_pixel equation parsing start...(LINE %d)\n", line_count);
|
||||
#endif
|
||||
|
||||
if (init_string != 0)
|
||||
{
|
||||
@ -365,10 +358,6 @@ int Parser::parse_per_pixel_eqn(std::istream & fs, Preset * preset, char * init
|
||||
|
||||
if (parseToken(fs, string) != tEq)
|
||||
{ /* parse per pixel operator name */
|
||||
#ifdef DEBUG
|
||||
if (PARSE_DEBUG) DWRITE("parse_per_pixel: equal operator expected after per pixel operator \"%s\", but not found (LINE %d)\n",
|
||||
string, line_count);
|
||||
#endif
|
||||
return PROJECTM_PARSE_ERROR;
|
||||
}
|
||||
}
|
||||
@ -376,9 +365,6 @@ int Parser::parse_per_pixel_eqn(std::istream & fs, Preset * preset, char * init
|
||||
/* Parse right side of equation as an expression */
|
||||
if ((gen_expr = parse_gen_expr(fs, NULL, preset)) == NULL)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
if (PARSE_DEBUG) DWRITE("parse_per_pixel: equation evaluated to null? (LINE %d)\n", line_count);
|
||||
#endif
|
||||
return PROJECTM_PARSE_ERROR;
|
||||
}
|
||||
|
||||
@ -387,7 +373,7 @@ int Parser::parse_per_pixel_eqn(std::istream & fs, Preset * preset, char * init
|
||||
{
|
||||
if (PARSE_DEBUG)
|
||||
{
|
||||
DWRITE( "parse_per_pixel: no param associated with \"%s\" (LINE %d)", string, line_count);
|
||||
|
||||
}
|
||||
delete gen_expr;
|
||||
return PROJECTM_PARSE_ERROR;
|
||||
@ -872,11 +858,6 @@ GenExpr * Parser::parse_gen_expr ( std::istream & fs, TreeExpr * tree_expr, Pre
|
||||
/* CASE 0: Empty string, parse error */
|
||||
if (*string == 0)
|
||||
{
|
||||
if (PARSE_DEBUG)
|
||||
{
|
||||
DWRITE( "parse_gen_expr: empty string coupled with infix op (ERROR!) (LINE %d) \n", line_count);
|
||||
|
||||
}
|
||||
if (tree_expr)
|
||||
delete tree_expr;
|
||||
return NULL;
|
||||
@ -1255,7 +1236,7 @@ int Parser::parse_int(std::istream & fs, int * int_ptr)
|
||||
char string[MAX_TOKEN_SIZE];
|
||||
token_t token;
|
||||
int sign;
|
||||
char * end_ptr = " ";
|
||||
char * end_ptr = (char*)" ";
|
||||
|
||||
token = parseToken(fs, string);
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
#include <cmath>
|
||||
|
||||
namespace RandomNumberGenerators {
|
||||
7
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -52,4 +52,4 @@ inline float gaussian(float mean, float sigma)
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -124,9 +124,7 @@ void Renderer::RenderFrame(PresetOutputs *presetOutputs, PresetInputs *presetInp
|
||||
|
||||
|
||||
|
||||
totalframes++;
|
||||
|
||||
DWRITE( "start Pass 1 \n" );
|
||||
totalframes++;
|
||||
|
||||
//BEGIN PASS 1
|
||||
//
|
||||
@ -163,8 +161,7 @@ void Renderer::RenderFrame(PresetOutputs *presetOutputs, PresetInputs *presetInp
|
||||
|
||||
glMatrixMode( GL_MODELVIEW );
|
||||
glLoadIdentity();
|
||||
|
||||
DWRITE( "renderFrame: renderTarget->texsize: %d x %d\n", this->renderTarget->texsize, this->renderTarget->texsize );
|
||||
|
||||
|
||||
if(this->renderTarget->useFBO)
|
||||
{
|
||||
@ -218,7 +215,7 @@ void Renderer::RenderFrame(PresetOutputs *presetOutputs, PresetInputs *presetInp
|
||||
}
|
||||
else glViewport( 0, 0, this->vw, this->vh );
|
||||
|
||||
DWRITE( "viewport: %d x %d\n", this->vw, this->vh );
|
||||
|
||||
|
||||
glBindTexture( GL_TEXTURE_2D, this->renderTarget->textureID[0] );
|
||||
|
||||
@ -249,7 +246,6 @@ void Renderer::RenderFrame(PresetOutputs *presetOutputs, PresetInputs *presetInp
|
||||
if(renderTarget->renderToTexture)
|
||||
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
|
||||
|
||||
DWRITE("End of Pass 2\n" );
|
||||
}
|
||||
|
||||
|
||||
@ -708,8 +704,6 @@ void Renderer::WaveformMath(PresetOutputs *presetOutputs, PresetInputs *presetIn
|
||||
|
||||
presetOutputs->two_waves = false;
|
||||
|
||||
DWRITE( "WaveformMath: %d\n", presetOutputs->nWaveMode );
|
||||
|
||||
switch(presetOutputs->nWaveMode)
|
||||
{
|
||||
|
||||
@ -720,7 +714,6 @@ void Renderer::WaveformMath(PresetOutputs *presetOutputs, PresetInputs *presetIn
|
||||
presetOutputs->wave_scale =1.0;
|
||||
presetOutputs->wave_y=-1*(presetOutputs->wave_y-1.0);
|
||||
|
||||
DWRITE( "nsamples: %d\n", beatDetect->pcm->numsamples );
|
||||
|
||||
presetOutputs->wave_samples = isSmoothing ? 512-32 : beatDetect->pcm->numsamples;
|
||||
// presetOutputs->wave_samples= 512-32;
|
||||
@ -1377,7 +1370,7 @@ void Renderer::draw_help( )
|
||||
|
||||
#ifdef USE_FTGL
|
||||
//glBlendFunc(GL_ONE_MINUS_DST_COLOR,GL_ZERO);
|
||||
DWRITE("pre-help");
|
||||
|
||||
glColor4f(1.0, 1.0, 1.0, 1.0);
|
||||
glPushMatrix();
|
||||
glTranslatef(0, 1, 0);
|
||||
@ -1426,7 +1419,7 @@ void Renderer::draw_help( )
|
||||
|
||||
glPopMatrix();
|
||||
// glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
|
||||
DWRITE("post-help");
|
||||
|
||||
#endif /** USE_FTGL */
|
||||
}
|
||||
|
||||
|
||||
@ -83,8 +83,10 @@ projectM::~projectM()
|
||||
delete ( renderer );
|
||||
if ( beatDetect )
|
||||
delete ( beatDetect );
|
||||
if ( pcm )
|
||||
delete ( pcm );
|
||||
if ( _pcm ) {
|
||||
delete ( _pcm );
|
||||
_pcm = 0;
|
||||
}
|
||||
}
|
||||
|
||||
DLLEXPORT unsigned projectM::initRenderToTexture()
|
||||
@ -98,11 +100,11 @@ DLLEXPORT void projectM::projectM_resetTextures()
|
||||
}
|
||||
|
||||
DLLEXPORT projectM::projectM ( std::string config_file ) :
|
||||
beatDetect ( 0 ), renderer ( 0 ), smoothFrame ( 0 ), m_presetQueuePos(0), oldFrame(1)
|
||||
beatDetect ( 0 ), renderer ( 0 ), smoothFrame ( 0 ), m_presetQueuePos(0), oldFrame(1), _pcm(0)
|
||||
{
|
||||
|
||||
readConfig ( config_file );
|
||||
projectM_reset();
|
||||
readConfig ( config_file );
|
||||
projectM_resetGL ( _settings.windowWidth, _settings.windowHeight);
|
||||
|
||||
}
|
||||
|
||||
@ -135,6 +137,9 @@ bool projectM::writeConfig(const std::string & configFile, const Settings & sett
|
||||
}
|
||||
|
||||
int projectM::sampledPresetDuration() {
|
||||
|
||||
|
||||
|
||||
return ( int ) (_settings.fps * fmax(1, fmin(60, RandomNumberGenerators::gaussian
|
||||
(settings().presetDuration, settings().easterEgg))));
|
||||
}
|
||||
@ -172,7 +177,7 @@ void projectM::readConfig (const std::string & configFile )
|
||||
else
|
||||
_settings.aspectCorrection = renderer->correction = 0;
|
||||
|
||||
projectM_resetGL ( _settings.windowWidth, _settings.windowHeight);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -204,16 +209,8 @@ DLLEXPORT void projectM::renderFrame()
|
||||
// printf("start:%d at:%d min:%d stop:%d on:%d %d\n",startframe, frame frame-startframe,avgtime, noSwitch,progress);
|
||||
presetInputs.ResetMesh();
|
||||
|
||||
// printf("%f %d\n",Time,frame);
|
||||
|
||||
|
||||
beatDetect->detectFromSamples();
|
||||
|
||||
DWRITE ( "=== vol: %f\tbass: %f\tmid: %f\ttreb: %f ===\n",
|
||||
beatDetect->vol,beatDetect->bass,beatDetect->mid,beatDetect->treb );
|
||||
DWRITE ( "=== bass_att: %f ===\n",
|
||||
beatDetect->bass_att );
|
||||
|
||||
presetInputs.bass = beatDetect->bass;
|
||||
presetInputs.mid = beatDetect->mid;
|
||||
presetInputs.treb = beatDetect->treb;
|
||||
@ -347,7 +344,7 @@ DLLEXPORT void projectM::renderFrame()
|
||||
this->timestart=getTicks ( &this->startTime );
|
||||
#endif /** !WIN32 */
|
||||
|
||||
DWRITE ( "exiting renderFrame()\n" );
|
||||
|
||||
}
|
||||
|
||||
void projectM::projectM_reset()
|
||||
@ -385,8 +382,6 @@ void projectM::projectM_init ( int gx, int gy, int fps, int texsize, int width,
|
||||
presetOutputs.Initialize ( gx, gy );
|
||||
presetOutputs2.Initialize ( gx, gy );
|
||||
|
||||
DWRITE ( "projectM plugin: Initializing\n" );
|
||||
|
||||
/** Initialise start time */
|
||||
#ifndef WIN32
|
||||
gettimeofday ( &this->startTime, NULL );
|
||||
@ -405,8 +400,11 @@ void projectM::projectM_init ( int gx, int gy, int fps, int texsize, int width,
|
||||
/** We need to initialise this before the builtin param db otherwise bass/mid etc won't bind correctly */
|
||||
assert ( !beatDetect );
|
||||
|
||||
pcm = new PCM();
|
||||
beatDetect = new BeatDetect ( pcm );
|
||||
std::cerr << "pcm new" << std::endl;
|
||||
if (!_pcm)
|
||||
_pcm = new PCM();
|
||||
assert(pcm());
|
||||
beatDetect = new BeatDetect ( _pcm );
|
||||
|
||||
initPresetTools();
|
||||
#if 0
|
||||
@ -535,6 +533,7 @@ void projectM::projectM_init ( int gx, int gy, int fps, int texsize, int width,
|
||||
|
||||
renderer->setPresetName ( m_activePreset->presetName() );
|
||||
|
||||
assert(pcm());
|
||||
// printf ( "exiting projectM_init()\n" );
|
||||
}
|
||||
|
||||
|
||||
@ -122,7 +122,7 @@ class projectM
|
||||
{
|
||||
public:
|
||||
|
||||
PCM *pcm;
|
||||
|
||||
|
||||
DLLEXPORT projectM(std::string config_file);
|
||||
DLLEXPORT projectM(int gx, int gy, int fps, int texsize, int width, int height,std::string preset_url,std::string title_fonturl, std::string title_menuurl);
|
||||
@ -210,7 +210,11 @@ public:
|
||||
/// Occurs when active preset has switched. Switched to index is returned
|
||||
virtual void presetSwitchedEvent(bool isHardCut, unsigned int index) const {};
|
||||
|
||||
inline const PCM * pcm() {
|
||||
return _pcm;
|
||||
}
|
||||
private:
|
||||
|
||||
int sampledPresetDuration();
|
||||
BeatDetect * beatDetect;
|
||||
Renderer *renderer;
|
||||
@ -279,6 +283,8 @@ private:
|
||||
/// A preset outputs container used for smooth preset switching
|
||||
PresetOutputs presetOutputs2;
|
||||
|
||||
PCM * _pcm;
|
||||
|
||||
int oldFrame;// = 1;
|
||||
|
||||
};
|
||||
|
||||
@ -196,7 +196,7 @@ int worker_func(void*)
|
||||
key = sdl2pmKeycode( event.key.keysym.sym );
|
||||
mod = sdl2pmModifier( event.key.keysym.mod );
|
||||
|
||||
if ( evt == PROJECTM_KEYDOWN ) {
|
||||
if ( evt == PROJECTM_KEYDOWN ) {
|
||||
|
||||
if(key == PROJECTM_K_c)
|
||||
{
|
||||
|
||||
@ -162,7 +162,7 @@ process (jack_nframes_t nframes, void *arg)
|
||||
|
||||
//memcpy (out, in,sizeof (jack_default_audio_sample_t) * nframes);
|
||||
|
||||
globalPM->pcm->addPCMfloat(in,nframes);
|
||||
globalPM->pcm()->addPCMfloat(in,nframes);
|
||||
// printf("%x %f\n",nframes,in[128]);
|
||||
|
||||
|
||||
|
||||
@ -7,8 +7,10 @@ include(${QT_USE_FILE} FindPkgConfig.cmake)
|
||||
FIND_PACKAGE(OpenGL)
|
||||
FIND_PACKAGE(Qt4 REQUIRED)
|
||||
|
||||
|
||||
pkg_search_module(PROJECTM REQUIRED libprojectM)
|
||||
pkg_search_module(PROJECTM REQUIRED libqprojectM)
|
||||
pkg_search_module(PROJECTM REQUIRED pulse)
|
||||
|
||||
# the variable "qprojectM_SRCS" contains all .cpp files of this project
|
||||
set(qprojectM_pulseaudio_SRCS
|
||||
|
||||
@ -37,7 +37,6 @@ void QPulseAudioDeviceChooser::readSettings()
|
||||
|
||||
void QPulseAudioDeviceChooser::updateDevicesListViewLock(int state) {
|
||||
|
||||
|
||||
|
||||
devicesListView->setEnabled(state != Qt::Checked);
|
||||
|
||||
@ -51,7 +50,7 @@ QPulseAudioDeviceChooser::QPulseAudioDeviceChooser ( QPulseAudioThread * qpulseA
|
||||
{
|
||||
|
||||
setupUi ( this );
|
||||
readSettings();
|
||||
readSettings();
|
||||
this->devicesListView->setModel ( &_qpulseAudioDeviceModel );
|
||||
|
||||
connect ( tryFirstPlayBackMonitorCheckBox, SIGNAL(stateChanged(int)), this, SLOT(updateDevicesListViewLock(int)));
|
||||
|
||||
@ -8,7 +8,7 @@ class QDialog;
|
||||
|
||||
|
||||
class QPulseAudioDeviceChooser : public QDialog, public Ui::pulseDeviceChooserDialog {
|
||||
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
@ -4,30 +4,10 @@
|
||||
#include <QString>
|
||||
#include <QVector>
|
||||
|
||||
|
||||
|
||||
/* $Id: pacat.c 1426 2007-02-13 15:35:19Z ossman $ */
|
||||
|
||||
/***
|
||||
This file is part of PulseAudio.
|
||||
/* Adopted from PulseAudio.
|
||||
|
||||
Copyright 2004-2006 Lennart Poettering
|
||||
Copyright 2006 Pierre Ossman <ossman@cendio.se> for Cendio AB
|
||||
|
||||
PulseAudio is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published
|
||||
by the Free Software Foundation; either version 2 of the License,
|
||||
or (at your option) any later version.
|
||||
|
||||
PulseAudio is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with PulseAudio; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
USA.
|
||||
***/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
@ -44,6 +24,8 @@
|
||||
#include <getopt.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include <QSettings>
|
||||
#include "QProjectM_MainWindow.hpp"
|
||||
|
||||
#define TIME_EVENT_USEC 50000
|
||||
|
||||
@ -54,30 +36,30 @@
|
||||
#define BUFSIZE 1024
|
||||
|
||||
|
||||
static pa_context *context = NULL;
|
||||
static pa_stream *stream = NULL;
|
||||
static pa_mainloop_api *mainloop_api = NULL;
|
||||
static pa_time_event *time_event = NULL;
|
||||
static float *buffer = NULL;
|
||||
static size_t buffer_length = 0, buffer_index = 0;
|
||||
static pa_threaded_mainloop* mainloop = NULL;
|
||||
static pa_io_event* stdio_event = NULL;
|
||||
static char *server = NULL;
|
||||
static char *stream_name = NULL, *client_name = NULL, *device =0;
|
||||
pa_context *QPulseAudioThread::context = NULL;
|
||||
pa_stream *QPulseAudioThread::stream = NULL;
|
||||
pa_mainloop_api *QPulseAudioThread::mainloop_api = NULL;
|
||||
pa_time_event *QPulseAudioThread::time_event = NULL;
|
||||
float *QPulseAudioThread::buffer = NULL;
|
||||
size_t QPulseAudioThread::buffer_length = 0, QPulseAudioThread::buffer_index = 0;
|
||||
pa_threaded_mainloop * QPulseAudioThread::mainloop = NULL;
|
||||
pa_io_event * QPulseAudioThread::stdio_event = NULL;
|
||||
char * QPulseAudioThread::server = NULL;
|
||||
char * QPulseAudioThread::stream_name = NULL, *QPulseAudioThread::client_name = NULL, *QPulseAudioThread::device =0;
|
||||
|
||||
static int verbose = 0;
|
||||
static pa_volume_t volume = PA_VOLUME_NORM;
|
||||
int QPulseAudioThread::verbose = 0;
|
||||
|
||||
static pa_channel_map channel_map;
|
||||
static int channel_map_set = 0;
|
||||
static pa_sample_spec sample_spec ;
|
||||
pa_volume_t QPulseAudioThread::volume = PA_VOLUME_NORM;
|
||||
|
||||
pa_channel_map QPulseAudioThread::channel_map;
|
||||
int QPulseAudioThread::channel_map_set = 0;
|
||||
pa_sample_spec QPulseAudioThread::sample_spec ;
|
||||
|
||||
QPulseAudioThread::SourceContainer QPulseAudioThread::s_sourceList;
|
||||
QPulseAudioThread::SourceContainer::const_iterator QPulseAudioThread::s_sourcePosition;
|
||||
|
||||
#include <QSettings>
|
||||
|
||||
QPulseAudioThread::QPulseAudioThread ( int _argc, char **_argv, projectM * _projectM, QObject * parent ) : QThread ( parent ), argc ( _argc ), argv ( _argv ), m_projectM ( _projectM )
|
||||
|
||||
|
||||
QPulseAudioThread::QPulseAudioThread ( int _argc, char **_argv, QProjectM * _projectM, QObject * parent ) : QThread ( parent ), argc ( _argc ), argv ( _argv ), m_projectM ( _projectM )
|
||||
{
|
||||
|
||||
}
|
||||
@ -98,10 +80,10 @@ QPulseAudioThread::SourceContainer::const_iterator QPulseAudioThread::readSettin
|
||||
|
||||
if ( tryFirst )
|
||||
{
|
||||
qDebug() << "try first is true";
|
||||
|
||||
return s_sourceList.end();
|
||||
} else {
|
||||
qDebug() << "try first is false";
|
||||
|
||||
QString deviceName = settings.value("pulseAudioDeviceName", QString()).toString();
|
||||
|
||||
qDebug() << "device name is " << deviceName;
|
||||
@ -110,7 +92,7 @@ QPulseAudioThread::SourceContainer::const_iterator QPulseAudioThread::readSettin
|
||||
if (*pos == deviceName) {
|
||||
return pos;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return s_sourceList.end();
|
||||
}
|
||||
@ -149,7 +131,6 @@ void QPulseAudioThread::cleanup()
|
||||
pa_threaded_mainloop_free ( mainloop );
|
||||
}
|
||||
|
||||
|
||||
if ( buffer )
|
||||
pa_xfree ( buffer );
|
||||
|
||||
@ -276,8 +257,11 @@ void QPulseAudioThread::pa_stream_success_callback(pa_stream *s, int success, vo
|
||||
else
|
||||
qDebug() << "play";
|
||||
|
||||
pausedFlag = !pausedFlag;
|
||||
|
||||
pausedFlag = !pausedFlag;
|
||||
//m_projectM._audioMutex.unlock();
|
||||
// necessarily static
|
||||
// can do pulse stuff here...
|
||||
}
|
||||
|
||||
|
||||
@ -448,7 +432,7 @@ void QPulseAudioThread::context_drain_complete ( pa_context*c, void *userdata )
|
||||
/* Some data may be written to STDOUT */
|
||||
void QPulseAudioThread::stdout_callback ( pa_mainloop_api*a, pa_io_event *e, int fd, pa_io_event_flags_t f, void *userdata )
|
||||
{
|
||||
ssize_t r;
|
||||
|
||||
assert ( a == mainloop_api && e && stdio_event == e );
|
||||
|
||||
if ( !buffer )
|
||||
@ -458,15 +442,19 @@ void QPulseAudioThread::stdout_callback ( pa_mainloop_api*a, pa_io_event *e, int
|
||||
}
|
||||
else
|
||||
{
|
||||
projectM * prjm = static_cast<projectM *> ( userdata );
|
||||
QProjectM * prjm = static_cast<QProjectM *> ( userdata );
|
||||
//int * int_buf = (int *) buffer;
|
||||
//qDebug() << int_buf[buffer_index];
|
||||
//qDebug() << buffer[buffer_index];
|
||||
|
||||
prjm->pcm->addPCMfloat
|
||||
( buffer+buffer_index, buffer_length / ( sizeof ( float ) ) );
|
||||
assert(prjm);
|
||||
assert(prjm->pcm());
|
||||
assert(buffer);
|
||||
qDebug() << "buffer index: " << buffer_index << ", buffer length:" << buffer_length;
|
||||
prjm->pcm()->addPCMfloat
|
||||
( buffer+buffer_index, buffer_length / ( sizeof ( float ) ) );
|
||||
|
||||
assert ( buffer_length );
|
||||
|
||||
|
||||
pa_xfree ( buffer );
|
||||
buffer = NULL;
|
||||
buffer_length = buffer_index = 0;
|
||||
@ -609,7 +597,7 @@ void QPulseAudioThread::run()
|
||||
|
||||
const char * error = "FOO";
|
||||
int ret = 1, r, c;
|
||||
char *bn = "projectM";
|
||||
const char *bn = "projectM";
|
||||
pa_operation * operation ;
|
||||
sample_spec.format = PA_SAMPLE_FLOAT32LE;
|
||||
sample_spec.rate = 44100;
|
||||
@ -666,6 +654,7 @@ void QPulseAudioThread::run()
|
||||
signal ( SIGPIPE, SIG_IGN );
|
||||
#endif
|
||||
|
||||
assert(m_projectM);
|
||||
if ( ! ( stdio_event = mainloop_api->io_new ( mainloop_api,
|
||||
STDOUT_FILENO,
|
||||
PA_IO_EVENT_OUTPUT,
|
||||
|
||||
@ -6,7 +6,8 @@
|
||||
#include <QString>
|
||||
#include <QModelIndex>
|
||||
#include <QHash>
|
||||
|
||||
#include <QtDebug>
|
||||
//
|
||||
extern "C"
|
||||
{
|
||||
#include <pulse/introspect.h>
|
||||
@ -14,7 +15,7 @@ extern "C"
|
||||
#include <pulse/browser.h>
|
||||
}
|
||||
|
||||
class projectM;
|
||||
class QProjectM;
|
||||
|
||||
|
||||
class QPulseAudioThread : public QThread
|
||||
@ -23,7 +24,7 @@ class QPulseAudioThread : public QThread
|
||||
public:
|
||||
typedef QHash<int, QString> SourceContainer;
|
||||
QPulseAudioThread () {}
|
||||
QPulseAudioThread(int _argc, char **_argv, projectM * projectM, QObject *parent);
|
||||
QPulseAudioThread(int _argc, char **_argv, QProjectM * projectM, QObject *parent);
|
||||
virtual ~QPulseAudioThread();
|
||||
void run();
|
||||
void cleanup();
|
||||
@ -38,9 +39,10 @@ class QPulseAudioThread : public QThread
|
||||
}
|
||||
|
||||
public slots:
|
||||
inline void projectM_New(projectM * projectM) {
|
||||
inline void projectM_New(QProjectM * projectM) {
|
||||
m_projectM = projectM;
|
||||
cork();
|
||||
qDebug() << "CORKING";
|
||||
cork();
|
||||
}
|
||||
|
||||
void cork();
|
||||
@ -55,6 +57,8 @@ class QPulseAudioThread : public QThread
|
||||
void deviceChanged();
|
||||
private:
|
||||
|
||||
QProjectM * m_projectM;
|
||||
//
|
||||
static SourceContainer::const_iterator readSettings();
|
||||
|
||||
static void reconnect(SourceContainer::const_iterator pos);
|
||||
@ -83,8 +87,26 @@ class QPulseAudioThread : public QThread
|
||||
static SourceContainer s_sourceList;
|
||||
static SourceContainer::const_iterator s_sourcePosition;
|
||||
int argc;
|
||||
char ** argv;
|
||||
projectM * m_projectM;
|
||||
char ** argv;
|
||||
static pa_context *context;
|
||||
static pa_stream *stream;
|
||||
static pa_mainloop_api *mainloop_api;
|
||||
static pa_time_event *time_event;
|
||||
static float * buffer;
|
||||
static size_t buffer_length, buffer_index;
|
||||
static pa_threaded_mainloop * mainloop;
|
||||
static pa_io_event * stdio_event;
|
||||
static char * server;
|
||||
static char * stream_name, *client_name, *device;
|
||||
|
||||
static int verbose;
|
||||
|
||||
static pa_volume_t volume;
|
||||
|
||||
static pa_channel_map channel_map;
|
||||
static int channel_map_set;;
|
||||
static pa_sample_spec sample_spec ;
|
||||
|
||||
|
||||
};
|
||||
#endif
|
||||
|
||||
@ -103,23 +103,22 @@ int main ( int argc, char*argv[] )
|
||||
|
||||
QPulseAudioThread * pulseThread = new QPulseAudioThread(argc, argv, mainWindow->getQProjectM(), mainWindow);
|
||||
|
||||
// First projectM_Initialized() has already happened, so manually start
|
||||
// First projectM_Initialized() has already happened, so manually start
|
||||
pulseThread->start();
|
||||
|
||||
QApplication::connect
|
||||
(mainWindow->getQProjectMWidget(), SIGNAL(projectM_Initialized(projectM *)), pulseThread, SLOT(projectM_New(projectM*)));
|
||||
|
||||
(mainWindow->getQProjectMWidget(), SIGNAL(projectM_Initialized(QProjectM *)), pulseThread, SLOT(projectM_New(QProjectM*)));
|
||||
QApplication::connect
|
||||
(mainWindow->getQProjectMWidget(), SIGNAL(projectM_BeforeDestroy()), pulseThread, SLOT(cork()));
|
||||
|
||||
QPulseAudioDeviceChooser devChooser(pulseThread, mainWindow);
|
||||
QPulseAudioDeviceChooser devChooser(pulseThread, mainWindow);
|
||||
QApplication::connect(&pulseAction, SIGNAL(triggered()), &devChooser, SLOT(open()));
|
||||
|
||||
|
||||
int ret = app.exec();
|
||||
devChooser.writeSettings();
|
||||
|
||||
mainWindow->unregisterSettingsAction(&pulseAction);
|
||||
if (mainWindow)
|
||||
mainWindow->unregisterSettingsAction(&pulseAction);
|
||||
|
||||
/// @bug this blows up the program!
|
||||
//delete(mainWindow);
|
||||
|
||||
@ -30,9 +30,9 @@
|
||||
|
||||
public:
|
||||
QPlaylistFileDialog(QWidget * parent = 0):
|
||||
QFileDialog(parent, "Open a new preset playlist", QString(), "Preset Playlists (*.ppl)" ) {
|
||||
QFileDialog(parent, "Open a playlist file or directory", QString(), "Preset Playlists (*.ppl)" ) {
|
||||
|
||||
this->setFileMode(QFileDialog::ExistingFile);
|
||||
this->setFileMode(QFileDialog::ExistingFiles);
|
||||
}
|
||||
|
||||
~QPlaylistFileDialog() { }
|
||||
|
||||
@ -2,16 +2,16 @@
|
||||
#include <QtDebug>
|
||||
#include <QAction>
|
||||
#include "QPlaylistFileDialog.hpp"
|
||||
#include <QSettings>
|
||||
|
||||
|
||||
QProjectMConfigDialog::QProjectMConfigDialog(const std::string & configFile, QProjectMWidget * qprojectMWidget, QWidget * parent, Qt::WindowFlags f) : QDialog(parent, f), _configFile(configFile), _qprojectMWidget(qprojectMWidget) {
|
||||
QProjectMConfigDialog::QProjectMConfigDialog(const std::string & configFile, QProjectMWidget * qprojectMWidget, QWidget * parent, Qt::WindowFlags f) : QDialog(parent, f), _configFile(configFile), _qprojectMWidget(qprojectMWidget), _settings("projectM", "qprojectM") {
|
||||
|
||||
_ui.setupUi(this);
|
||||
connect(_ui.buttonBox, SIGNAL(clicked(QAbstractButton*)), this, SLOT(buttonBoxHandler(QAbstractButton*)));
|
||||
connect(this, SIGNAL(projectM_Reset()), _qprojectMWidget, SLOT(resetProjectM()));
|
||||
connect (_ui.startupPlaylistToolButton, SIGNAL(clicked()), this, SLOT(openPlaylistFileDialog()));
|
||||
connect (_ui.titleFontPathToolButton, SIGNAL(clicked()), this, SLOT(openFontFileDialog()));
|
||||
connect (_ui.menuFontPathToolButton, SIGNAL(clicked()), this, SLOT(openFontFileDialog()));
|
||||
connect (_ui.titleFontPathToolButton, SIGNAL(clicked()), this, SLOT(openTitleFontFileDialog()));
|
||||
connect (_ui.menuFontPathToolButton, SIGNAL(clicked()), this, SLOT(openMenuFontFileDialog()));
|
||||
loadConfig();
|
||||
}
|
||||
|
||||
@ -47,7 +47,32 @@ void QProjectMConfigDialog::openPlaylistFileDialog() {
|
||||
}
|
||||
|
||||
|
||||
void QProjectMConfigDialog::openFontFileDialog() {
|
||||
void QProjectMConfigDialog::openMenuFontFileDialog() {
|
||||
|
||||
|
||||
QFileDialog dialog(this, "Select a menu font", _settings.value("Menu Font Directory", QString()).toString(), "True Type Fonts (*.ttf)" );
|
||||
dialog.setFileMode(QFileDialog::ExistingFile);
|
||||
|
||||
|
||||
if (dialog.exec()) {
|
||||
assert(!dialog.selectedFiles().empty());
|
||||
_ui.menuFontPathLineEdit->setText(dialog.selectedFiles()[0]);
|
||||
|
||||
_settings.setValue("Menu Font Directory", dialog.directory().absolutePath());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
void QProjectMConfigDialog::openTitleFontFileDialog() {
|
||||
QFileDialog dialog(this, "Select a title font", _settings.value("Title Font Directory", QString()).toString(), "True Type Fonts (*.ttf)" );
|
||||
dialog.setFileMode(QFileDialog::ExistingFile);
|
||||
|
||||
if (dialog.exec()) {
|
||||
assert(!dialog.selectedFiles().empty());
|
||||
_ui.titleFontPathLineEdit->setText(dialog.selectedFiles()[0]);
|
||||
_settings.setValue("Title Font Directory", dialog.directory().absolutePath());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -69,9 +94,13 @@ void QProjectMConfigDialog::saveConfig() {
|
||||
settings.fps = _ui.maxFPSSpinBox->value();
|
||||
settings.aspectCorrection = _ui.useAspectCorrectionCheckBox->checkState() == Qt::Checked;
|
||||
settings.beatSensitivity = _ui.beatSensitivitySpinBox->value();
|
||||
|
||||
settings.easterEgg = _ui.easterEggParameterSpinBox->value();
|
||||
projectM::writeConfig(_configFile, settings);
|
||||
|
||||
QSettings qSettings("projectM", "qprojectM");
|
||||
|
||||
qSettings.setValue("FullscreenOnStartup", _ui.fullscreenOnStartupCheckBox->checkState() == Qt::Checked);
|
||||
qSettings.setValue("MenuOnStartup", _ui.menuOnStartupCheckBox->checkState() == Qt::Checked);
|
||||
qDebug() << "save end";
|
||||
}
|
||||
|
||||
@ -87,8 +116,8 @@ void QProjectMConfigDialog::populateTextureSizeComboBox() {
|
||||
|
||||
void QProjectMConfigDialog::loadConfig() {
|
||||
|
||||
qDebug() << "load config";
|
||||
const projectM::Settings & settings =(* _qprojectMWidget->getQProjectM()).settings();
|
||||
qDebug() << "load config BEGIN";
|
||||
const projectM::Settings & settings = (* _qprojectMWidget->getQProjectM()).settings();
|
||||
|
||||
_ui.meshSizeWidthSpinBox->setValue(settings.meshX);
|
||||
_ui.meshSizeHeightSpinBox->setValue(settings.meshY);
|
||||
@ -109,7 +138,7 @@ void QProjectMConfigDialog::loadConfig() {
|
||||
|
||||
_ui.smoothPresetDurationSpinBox->setValue(settings.smoothPresetDuration);
|
||||
_ui.presetDurationSpinBox->setValue(settings.presetDuration);
|
||||
|
||||
_ui.easterEggParameterSpinBox->setValue(settings.easterEgg);
|
||||
qDebug() << "load config END";
|
||||
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
#define QPROJECTM_CONFIG_DIALOG_HPP
|
||||
#include "ui_QProjectMConfigDialog.h"
|
||||
#include "QProjectM_MainWindow.hpp"
|
||||
|
||||
#include <QSettings>
|
||||
class QProjectMConfigDialog : public QDialog {
|
||||
|
||||
Q_OBJECT
|
||||
@ -13,11 +13,13 @@ class QProjectMConfigDialog : public QDialog {
|
||||
void loadConfig();
|
||||
private slots:
|
||||
void openPlaylistFileDialog();
|
||||
void openFontFileDialog();
|
||||
void openMenuFontFileDialog();
|
||||
void openTitleFontFileDialog();
|
||||
void saveConfig();
|
||||
void buttonBoxHandler(QAbstractButton * button);
|
||||
|
||||
private:
|
||||
QSettings _settings;
|
||||
const std::string _configFile;
|
||||
QProjectMWidget * _qprojectMWidget;
|
||||
Ui::QProjectMConfigDialog _ui;
|
||||
|
||||
@ -618,7 +618,7 @@ p, li { white-space: pre-wrap; }
|
||||
<string>Easter Egg Parameter</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QDoubleSpinBox" name="beatSensitivitySpinBox_2" >
|
||||
<widget class="QDoubleSpinBox" name="easterEggParameterSpinBox" >
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>374</x>
|
||||
@ -634,7 +634,7 @@ p, li { white-space: pre-wrap; }
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">A mystery parameter!</p></body></html></string>
|
||||
</property>
|
||||
<property name="maximum" >
|
||||
<double>1.000000000000000</double>
|
||||
<double>20.000000000000000</double>
|
||||
</property>
|
||||
<property name="singleStep" >
|
||||
<double>0.010000000000000</double>
|
||||
|
||||
@ -71,7 +71,8 @@ class PlaylistWriteFunctor {
|
||||
};
|
||||
|
||||
QProjectM_MainWindow::QProjectM_MainWindow ( const std::string & config_file )
|
||||
:m_QPresetFileDialog ( new QPresetFileDialog ( this ) ), m_QPlaylistFileDialog ( new QPlaylistFileDialog ( this ) ), oldPresetIndex ( -1 ), playlistModel(0), configDialog(0)
|
||||
:m_QPresetFileDialog ( new QPresetFileDialog ( this ) ), m_QPlaylistFileDialog ( new QPlaylistFileDialog ( this ) ),
|
||||
oldPresetIndex ( -1 ), playlistModel(0), configDialog(0), _menuVisible(true)
|
||||
{
|
||||
|
||||
|
||||
@ -89,14 +90,14 @@ QProjectM_MainWindow::QProjectM_MainWindow ( const std::string & config_file )
|
||||
connect ( ui->clearPresetList_PushButton, SIGNAL ( pressed() ),
|
||||
this, SLOT ( clearPlaylist() ) );
|
||||
|
||||
connect ( m_QProjectMWidget, SIGNAL ( projectM_Initialized(projectM*) ), this, SLOT ( postProjectM_Initialize() ) );
|
||||
connect ( m_QProjectMWidget, SIGNAL ( projectM_Initialized(QProjectM*) ), this, SLOT ( postProjectM_Initialize() ) );
|
||||
|
||||
m_QProjectMWidget->makeCurrent();
|
||||
m_QProjectMWidget->setFocus();
|
||||
|
||||
m_timer->start ( 0 );
|
||||
|
||||
readConfig(config_file);
|
||||
//readConfig(config_file);
|
||||
setCentralWidget ( m_QProjectMWidget );
|
||||
createActions();
|
||||
createMenus();
|
||||
@ -123,17 +124,19 @@ void QProjectM_MainWindow::writeConfig() {
|
||||
|
||||
void QProjectM_MainWindow::readConfig(const std::string & configFile ) {
|
||||
|
||||
QSettings settings ( "projectM", "qprojectM" );
|
||||
|
||||
ConfigFile config ( configFile );
|
||||
|
||||
|
||||
if ( config.read ( "Fullscreen", false ) )
|
||||
if ( settings.value("FullscreenOnStartup", false).toBool() )
|
||||
this->setWindowState ( this->windowState() | Qt::WindowFullScreen );
|
||||
else
|
||||
this->setWindowState ( this->windowState() & ~Qt::WindowFullScreen );
|
||||
|
||||
int wvw = config.read<int> ( "Window Width", 512 );
|
||||
int wvh = config.read<int> ( "Window Height", 512 );
|
||||
setMenuVisible(settings.value("MenuOnStartup", false).toBool());
|
||||
|
||||
ConfigFile config ( configFile );
|
||||
|
||||
int wvw = config.read<int> ( "Window Width", 1024 );
|
||||
int wvh = config.read<int> ( "Window Height", 768 );
|
||||
|
||||
// Suggest to the widget the projectM window size configuration settings
|
||||
m_QProjectMWidget->setBaseSize ( wvw, wvh );
|
||||
@ -206,6 +209,7 @@ void QProjectM_MainWindow::selectPlaylistItem ( const QModelIndex & index )
|
||||
|
||||
void QProjectM_MainWindow::postProjectM_Initialize()
|
||||
{
|
||||
qDebug() << "QProjectM_MainWindow::postProjectM_Initialize()";
|
||||
ui->tableView->setModel(0);
|
||||
|
||||
if (playlistModel)
|
||||
@ -214,15 +218,17 @@ void QProjectM_MainWindow::postProjectM_Initialize()
|
||||
playlistModel = new QPlaylistModel ( *m_QProjectMWidget->getQProjectM(),this );
|
||||
|
||||
ui->tableView->setModel ( playlistModel );
|
||||
static int FOOBAR = 0;
|
||||
|
||||
if (FOOBAR == 0)
|
||||
/// @bug only do this at startup?
|
||||
refreshPlaylist();
|
||||
|
||||
FOOBAR++;
|
||||
|
||||
if (!configDialog)
|
||||
if (!configDialog) {
|
||||
configDialog = new QProjectMConfigDialog(m_QProjectMWidget->configFile(), m_QProjectMWidget, this);
|
||||
|
||||
}
|
||||
|
||||
readConfig(m_QProjectMWidget->configFile());
|
||||
|
||||
connect ( m_QProjectMWidget->getQProjectM(), SIGNAL ( presetSwitchedSignal ( bool,unsigned int ) ),
|
||||
this, SLOT ( updatePlaylistSelection ( bool,unsigned int ) ) );
|
||||
@ -241,8 +247,27 @@ void QProjectM_MainWindow::postProjectM_Initialize()
|
||||
|
||||
}
|
||||
|
||||
void QProjectM_MainWindow::changeRating ( const QModelIndex & index )
|
||||
{
|
||||
void QProjectM_MainWindow::setMenuVisible(bool visible) {
|
||||
|
||||
|
||||
|
||||
if (visible) {
|
||||
ui->presetPlayListDockWidget->show();
|
||||
menuBar()->show();
|
||||
statusBar()->show();
|
||||
//m_QProjectMWidget->setFocus();
|
||||
_menuVisible = true;
|
||||
} else {
|
||||
ui->presetPlayListDockWidget->hide();
|
||||
menuBar()->hide();
|
||||
statusBar()->hide();
|
||||
_menuVisible = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void QProjectM_MainWindow::changeRating ( const QModelIndex & index ) {
|
||||
|
||||
if ( index.column() == 0 )
|
||||
return;
|
||||
|
||||
@ -294,32 +319,7 @@ void QProjectM_MainWindow::keyReleaseEvent ( QKeyEvent * e )
|
||||
case Qt::Key_M:
|
||||
if ( ui->presetSearchBarLineEdit->hasFocus() )
|
||||
return;
|
||||
|
||||
if ( ui->presetPlayListDockWidget->isVisible() )
|
||||
{
|
||||
ui->presetPlayListDockWidget->hide();
|
||||
}
|
||||
else
|
||||
ui->presetPlayListDockWidget->show();
|
||||
|
||||
if ( menuBar()->isVisible() )
|
||||
{
|
||||
menuBar()->hide();
|
||||
m_QProjectMWidget->setFocus();
|
||||
}
|
||||
else
|
||||
{
|
||||
menuBar()->show();
|
||||
}
|
||||
|
||||
if ( statusBar()->isVisible() )
|
||||
{
|
||||
statusBar()->hide();
|
||||
}
|
||||
else
|
||||
{
|
||||
statusBar()->show();
|
||||
}
|
||||
setMenuVisible(!_menuVisible);
|
||||
return;
|
||||
|
||||
case Qt::Key_R:
|
||||
@ -562,9 +562,13 @@ void QProjectM_MainWindow::createStatusBar()
|
||||
|
||||
void QProjectM_MainWindow::readSettings()
|
||||
{
|
||||
QSettings settings ( "projectM", "QProjectM" );
|
||||
|
||||
// The settings exclusively due to qprojectM
|
||||
QSettings settings ( "projectM", "qprojectM" );
|
||||
QPoint pos = settings.value ( "pos", QPoint ( 200, 200 ) ).toPoint();
|
||||
QSize size = settings.value ( "size", QSize ( 1000, 600 ) ).toSize();
|
||||
QSize size = settings.value ( "size", QSize ( 1024, 768 ) ).toSize();
|
||||
|
||||
// Load up where the playlist file dialog last was visited last time
|
||||
m_QPlaylistFileDialog->setDirectory
|
||||
( settings.value ( "playlistPath", m_QPlaylistFileDialog->directory().absolutePath() ).toString() );
|
||||
|
||||
@ -574,14 +578,12 @@ void QProjectM_MainWindow::readSettings()
|
||||
|
||||
void QProjectM_MainWindow::writeSettings()
|
||||
{
|
||||
QSettings settings ( "projectM", "QProjectM" );
|
||||
QSettings settings ( "projectM", "qprojectM" );
|
||||
settings.setValue ( "pos", pos() );
|
||||
settings.setValue ( "size", size() );
|
||||
settings.setValue ( "playlistPath", m_QPlaylistFileDialog->directory().absolutePath() );
|
||||
}
|
||||
|
||||
|
||||
|
||||
void QProjectM_MainWindow::loadFile ( const QString &fileName, int rating )
|
||||
{
|
||||
|
||||
|
||||
@ -29,6 +29,7 @@
|
||||
#include <QGLWidget>
|
||||
#include <QHash>
|
||||
#include <QtDebug>
|
||||
#include <QMutex>
|
||||
|
||||
#include "projectM.hpp"
|
||||
|
||||
@ -80,8 +81,7 @@ class QProjectMWidget : public QGLWidget
|
||||
QProjectM * getQProjectM() { return m_projectM; }
|
||||
|
||||
private:
|
||||
void destroyProjectM() {
|
||||
|
||||
void destroyProjectM() {
|
||||
emit(projectM_BeforeDestroy());
|
||||
|
||||
if (m_projectM) {
|
||||
@ -89,26 +89,40 @@ class QProjectMWidget : public QGLWidget
|
||||
m_projectM = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public slots:
|
||||
|
||||
void resetProjectM() {
|
||||
|
||||
qDebug() << "reset start";
|
||||
// First wait for audio thread to stop by
|
||||
// waiting on it's mutex
|
||||
// s_audioMutex.tryLock(20000);
|
||||
|
||||
// Now destroy the projectM instance
|
||||
destroyProjectM();
|
||||
|
||||
// Make a new projectM instance and reset the opengl state
|
||||
initializeGL();
|
||||
|
||||
// Allow audio thread to continue its business
|
||||
// _audioMutex.unlock();
|
||||
|
||||
qDebug() << "reinit'ed";
|
||||
}
|
||||
|
||||
|
||||
void setPresetLock(int state) {
|
||||
m_projectM->setPresetLock((bool)state);
|
||||
presetLockChanged((bool)state);
|
||||
emit(presetLockChanged((bool)state));
|
||||
}
|
||||
signals:
|
||||
void projectM_BeforeDestroy();
|
||||
void projectM_Initialized(projectM *);
|
||||
void projectM_Initialized(QProjectM *);
|
||||
void presetLockChanged(bool isLocked);
|
||||
private:
|
||||
std::string config_file;
|
||||
QProjectM * m_projectM;
|
||||
|
||||
QMutex _audioMutex;
|
||||
protected:
|
||||
|
||||
|
||||
@ -159,14 +173,15 @@ void keyReleaseEvent ( QKeyEvent * e ) {
|
||||
|
||||
void initializeGL()
|
||||
{
|
||||
|
||||
|
||||
this->m_projectM = new QProjectM(config_file);
|
||||
projectM_Initialized(m_projectM);
|
||||
}
|
||||
|
||||
void resizeGL(int w, int h)
|
||||
{
|
||||
// setup viewport, projection etc.:
|
||||
/// @bug is setup necessary on resize or should just be in initializeGL() ?
|
||||
// Setup viewport, projection etc
|
||||
setup_opengl(w,h);
|
||||
m_projectM->projectM_resetGL( w, h );
|
||||
}
|
||||
@ -180,7 +195,7 @@ void keyReleaseEvent ( QKeyEvent * e ) {
|
||||
|
||||
void setup_opengl( int w, int h )
|
||||
{
|
||||
|
||||
|
||||
/* Our shading model--Gouraud (smooth). */
|
||||
glShadeModel( GL_SMOOTH);
|
||||
/* Culling. */
|
||||
@ -201,12 +216,12 @@ void keyReleaseEvent ( QKeyEvent * e ) {
|
||||
// gluOrtho2D(0.0, (GLfloat) width, 0.0, (GLfloat) height);
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
|
||||
// glFrustum(0.0, height, 0.0,width,10,40);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
|
||||
// glFrustum(0.0, height, 0.0,width,10,40);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
|
||||
glDrawBuffer(GL_BACK);
|
||||
glDrawBuffer(GL_BACK);
|
||||
glReadBuffer(GL_BACK);
|
||||
glEnable(GL_BLEND);
|
||||
|
||||
@ -248,6 +263,7 @@ public:
|
||||
virtual ~QProjectM_MainWindow();
|
||||
void registerSettingsAction(QAction * action);
|
||||
void unregisterSettingsAction(QAction * action);
|
||||
void setMenuVisible(bool visible);
|
||||
|
||||
void keyReleaseEvent ( QKeyEvent * e );
|
||||
QProjectM * getQProjectM();
|
||||
@ -287,11 +303,12 @@ private slots:
|
||||
QString m_currentPlaylistFile;
|
||||
|
||||
QPlaylistModel * playlistModel;
|
||||
Ui::QProjectM_MainWindow * ui;
|
||||
Ui::QProjectM_MainWindow * ui;
|
||||
QProjectMConfigDialog * configDialog;
|
||||
|
||||
QHash<QString, PlaylistItemVector*> historyHash;
|
||||
|
||||
bool _menuVisible;
|
||||
int oldPresetIndex;
|
||||
QTimer * m_timer;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user