From 0f6ae1830fd505d0fa2d3c3e2245d5c4e628a74f Mon Sep 17 00:00:00 2001 From: psperl Date: Sat, 28 Jun 2008 19:17:19 +0000 Subject: [PATCH] So much for branching. Fuck you trunk! Actually, this will work just fine, but you just lost waveform transitions during smooth preset merging. It will be back soon enough. git-svn-id: https://projectm.svn.sourceforge.net/svnroot/projectm/trunk@1064 6778bc44-b910-0410-a7a0-be141de4315d --- src/projectM-engine/BuiltinParams.cpp | 82 +-- src/projectM-engine/MilkdropCompatability.hpp | 5 + src/projectM-engine/MilkdropWaveform.cpp | 48 +- src/projectM-engine/MilkdropWaveform.hpp | 11 +- src/projectM-engine/MstressJuppyDancer.hpp | 22 +- src/projectM-engine/PresetFrameIO.hpp | 62 +- src/projectM-engine/PresetMerge.cpp | 148 ++--- src/projectM-engine/RLGFractalDrop7c.hpp | 146 +++++ src/projectM-engine/Renderer.cpp | 550 ++---------------- src/projectM-engine/Renderer.hpp | 9 +- src/projectM-engine/TextureManager.cpp | 77 ++- src/projectM-engine/TextureManager.hpp | 24 +- src/projectM-engine/TimeKeeper.cpp | 26 +- src/projectM-engine/Waveform.cpp | 26 +- src/projectM-engine/Waveform.hpp | 16 +- src/projectM-engine/projectM.cpp | 315 +++++----- 16 files changed, 579 insertions(+), 988 deletions(-) create mode 100644 src/projectM-engine/RLGFractalDrop7c.hpp diff --git a/src/projectM-engine/BuiltinParams.cpp b/src/projectM-engine/BuiltinParams.cpp index ba4f316f7..7ace40561 100644 --- a/src/projectM-engine/BuiltinParams.cpp +++ b/src/projectM-engine/BuiltinParams.cpp @@ -83,7 +83,7 @@ std::transform(lowerName.begin(), lowerName.end(), lowerName.begin(), tolower); std::string alt_lower_name(alt_name); std::transform(alt_lower_name.begin(), alt_lower_name.end(), alt_lower_name.begin(), tolower); insert_param_alt_name(param,alt_lower_name); - + if (BUILTIN_PARAMS_DEBUG == 2) { printf("alt_name inserted..."); @@ -116,7 +116,7 @@ int BuiltinParams::insert_param_alt_name(Param * param, const std::string & alt_ { assert(param); - + aliasMap.insert(std::make_pair(alt_name, param->name)); return PROJECTM_SUCCESS; @@ -126,7 +126,7 @@ Param * BuiltinParams::find_builtin_param(const std::string & name) { - + AliasMap::iterator pos = aliasMap.find(name); Param * param = 0; //std::cerr << "[BuiltinParams] find_builtin_param: name is " << name << std::endl; @@ -143,7 +143,7 @@ Param * BuiltinParams::find_builtin_param(const std::string & name) { std::map::iterator builtinPos = builtin_param_tree.find(pos->second); - + if (builtinPos != builtin_param_tree.end()) { //std::cerr << "[BuiltinParams] find_builtin_param: found it indirectly." << std::endl; param = builtinPos->second; @@ -186,7 +186,7 @@ std::transform(lowerName.begin(), lowerName.end(), lowerName.begin(), tolower); std::string alt_lower_name(alt_name); std::transform(alt_lower_name.begin(), alt_lower_name.end(), alt_lower_name.begin(), tolower); insert_param_alt_name(param,alt_lower_name); - + } return PROJECTM_SUCCESS; @@ -273,14 +273,14 @@ int BuiltinParams::load_all_builtin_param(const PresetInputs & presetInputs, Pre { load_builtin_param_float("frating", (void*)&presetOutputs.fRating, NULL, P_FLAG_NONE, 0.0 , 5.0, 0.0, ""); - load_builtin_param_float("fwavescale", (void*)&presetOutputs.fWaveScale, NULL, P_FLAG_NONE, 0.0, MAX_DOUBLE_SIZE, -MAX_DOUBLE_SIZE, ""); + load_builtin_param_float("fwavescale", (void*)&presetOutputs.wave.scale, NULL, P_FLAG_NONE, 0.0, MAX_DOUBLE_SIZE, -MAX_DOUBLE_SIZE, ""); load_builtin_param_float("gamma", (void*)&presetOutputs.fGammaAdj, NULL, P_FLAG_NONE, 0.0, MAX_DOUBLE_SIZE, 0, "fGammaAdj"); load_builtin_param_float("echo_zoom", (void*)&presetOutputs.fVideoEchoZoom, NULL, P_FLAG_NONE, 0.0, MAX_DOUBLE_SIZE, 0, "fVideoEchoZoom"); load_builtin_param_float("echo_alpha", (void*)&presetOutputs.fVideoEchoAlpha, NULL, P_FLAG_NONE, 0.0, MAX_DOUBLE_SIZE, 0, "fvideoechoalpha"); - load_builtin_param_float("wave_a", (void*)&presetOutputs.fWaveAlpha, NULL, P_FLAG_NONE, 0.0, 1.0, 0, "fwavealpha"); - load_builtin_param_float("fwavesmoothing", (void*)&presetOutputs.fWaveSmoothing, NULL, P_FLAG_NONE, 0.0, 1.0, -1.0, ""); - load_builtin_param_float("fmodwavealphastart", (void*)&presetOutputs.fModWaveAlphaStart, NULL, P_FLAG_NONE, 0.0, 1.0, -1.0, ""); - load_builtin_param_float("fmodwavealphaend", (void*)&presetOutputs.fModWaveAlphaEnd, NULL, P_FLAG_NONE, 0.0, 1.0, -1.0, ""); + load_builtin_param_float("wave_a", (void*)&presetOutputs.wave.a, NULL, P_FLAG_NONE, 0.0, 1.0, 0, "fwavealpha"); + load_builtin_param_float("fwavesmoothing", (void*)&presetOutputs.wave.smoothing, NULL, P_FLAG_NONE, 0.0, 1.0, -1.0, ""); + load_builtin_param_float("fmodwavealphastart", (void*)&presetOutputs.wave.modOpacityStart, NULL, P_FLAG_NONE, 0.0, 1.0, -1.0, ""); + load_builtin_param_float("fmodwavealphaend", (void*)&presetOutputs.wave.modOpacityEnd, NULL, P_FLAG_NONE, 0.0, 1.0, -1.0, ""); load_builtin_param_float("fWarpAnimSpeed", (void*)&presetOutputs.fWarpAnimSpeed, NULL, P_FLAG_NONE, 0.0, 1.0, -1.0, ""); load_builtin_param_float("fWarpScale", (void*)&presetOutputs.fWarpScale, NULL, P_FLAG_NONE, 0.0, 1.0, -1.0, ""); // load_builtin_param_float("warp", (void*)&presetOutputs.warp, warp_mesh, P_FLAG_NONE, 0.0, MAX_DOUBLE_SIZE, 0, ""); @@ -289,11 +289,11 @@ int BuiltinParams::load_all_builtin_param(const PresetInputs & presetInputs, Pre load_builtin_param_float("decay", (void*)&presetOutputs.decay, NULL, P_FLAG_NONE, 0.0, 1.0, 0, "fdecay"); load_builtin_param_int("echo_orient", (void*)&presetOutputs.nVideoEchoOrientation, P_FLAG_NONE, 0, 3, 0, "nVideoEchoOrientation"); - load_builtin_param_int("wave_mode", (void*)&presetOutputs.nWaveMode, P_FLAG_NONE, 0, 7, 0, "nwavemode"); + load_builtin_param_int("wave_mode", (void*)&presetOutputs.wave.mode, P_FLAG_NONE, 0, 7, 0, "nwavemode"); - load_builtin_param_bool("wave_additive", (void*)&presetOutputs.bAdditiveWaves, P_FLAG_NONE, false, "bAdditiveWaves"); - load_builtin_param_bool("bmodwavealphabyvolume", (void*)&presetOutputs.bModWaveAlphaByVolume, P_FLAG_NONE, false, ""); - load_builtin_param_bool("wave_brighten", (void*)&presetOutputs.bMaximizeWaveColor, P_FLAG_NONE, false, "bMaximizeWaveColor"); + load_builtin_param_bool("wave_additive", (void*)&presetOutputs.wave.additive, P_FLAG_NONE, false, "bAdditiveWaves"); + load_builtin_param_bool("bmodwavealphabyvolume", (void*)&presetOutputs.wave.modulateAlphaByVolume, P_FLAG_NONE, false, ""); + load_builtin_param_bool("wave_brighten", (void*)&presetOutputs.wave.maximizeColors, P_FLAG_NONE, false, "bMaximizeWaveColor"); load_builtin_param_bool("wrap", (void*)&presetOutputs.bTexWrap, P_FLAG_NONE, false, "btexwrap"); load_builtin_param_bool("darken_center", (void*)&presetOutputs.bDarkenCenter, P_FLAG_NONE, false, "bdarkencenter"); load_builtin_param_bool("bredbluestereo", (void*)&presetOutputs.bRedBlueStereo, P_FLAG_NONE, false, ""); @@ -302,8 +302,8 @@ int BuiltinParams::load_all_builtin_param(const PresetInputs & presetInputs, Pre load_builtin_param_bool("solarize", (void*)&presetOutputs.bSolarize, P_FLAG_NONE, false, "bsolarize"); load_builtin_param_bool("invert", (void*)&presetOutputs.bInvert, P_FLAG_NONE, false, "binvert"); load_builtin_param_bool("bmotionvectorson", (void*)&presetOutputs.bMotionVectorsOn, P_FLAG_NONE, false, ""); - load_builtin_param_bool("wave_dots", (void*)&presetOutputs.bWaveDots, P_FLAG_NONE, false, "bwavedots"); - load_builtin_param_bool("wave_thick", (void*)&presetOutputs.bWaveThick, P_FLAG_NONE, false, "bwavethick"); + load_builtin_param_bool("wave_dots", (void*)&presetOutputs.wave.dots, P_FLAG_NONE, false, "bwavedots"); + load_builtin_param_bool("wave_thick", (void*)&presetOutputs.wave.thick, P_FLAG_NONE, false, "bwavethick"); load_builtin_param_float("warp", (void*)&presetOutputs.warp, presetOutputs.warp_mesh, P_FLAG_PER_PIXEL |P_FLAG_NONE, 0.0, MAX_DOUBLE_SIZE, MIN_DOUBLE_SIZE, ""); load_builtin_param_float("zoom", (void*)&presetOutputs.zoom, presetOutputs.zoom_mesh, P_FLAG_PER_PIXEL |P_FLAG_NONE, 0.0, MAX_DOUBLE_SIZE, MIN_DOUBLE_SIZE, ""); load_builtin_param_float("rot", (void*)&presetOutputs.rot, presetOutputs.rot_mesh, P_FLAG_PER_PIXEL |P_FLAG_NONE, 0.0, MAX_DOUBLE_SIZE, MIN_DOUBLE_SIZE, ""); @@ -317,34 +317,34 @@ int BuiltinParams::load_all_builtin_param(const PresetInputs & presetInputs, Pre load_builtin_param_float("sx", (void*)&presetOutputs.sx, presetOutputs.sx_mesh, P_FLAG_PER_PIXEL |P_FLAG_NONE, 0.0, MAX_DOUBLE_SIZE, MIN_DOUBLE_SIZE, ""); load_builtin_param_float("sy", (void*)&presetOutputs.sy, presetOutputs.sy_mesh, P_FLAG_PER_PIXEL |P_FLAG_NONE, 0.0, MAX_DOUBLE_SIZE, MIN_DOUBLE_SIZE, ""); - load_builtin_param_float("wave_r", (void*)&presetOutputs.wave_r, NULL, P_FLAG_NONE, 0.0, 1.0, 0.0, ""); - load_builtin_param_float("wave_g", (void*)&presetOutputs.wave_g, NULL, P_FLAG_NONE, 0.0, 1.0, 0.0, ""); - load_builtin_param_float("wave_b", (void*)&presetOutputs.wave_b, NULL, P_FLAG_NONE, 0.0, 1.0, 0.0, ""); - load_builtin_param_float("wave_x", (void*)&presetOutputs.wave_x, NULL, P_FLAG_NONE, 0.0, 1.0, 0.0, ""); - load_builtin_param_float("wave_y", (void*)&presetOutputs.wave_y, NULL, P_FLAG_NONE, 0.0, 1.0, 0.0, ""); - load_builtin_param_float("wave_mystery", (void*)&presetOutputs.wave_mystery, NULL, P_FLAG_NONE, 0.0, 1.0, -1.0, "fWaveParam"); + load_builtin_param_float("wave_r", (void*)&presetOutputs.wave.r, NULL, P_FLAG_NONE, 0.0, 1.0, 0.0, ""); + load_builtin_param_float("wave_g", (void*)&presetOutputs.wave.g, NULL, P_FLAG_NONE, 0.0, 1.0, 0.0, ""); + load_builtin_param_float("wave_b", (void*)&presetOutputs.wave.b, NULL, P_FLAG_NONE, 0.0, 1.0, 0.0, ""); + load_builtin_param_float("wave_x", (void*)&presetOutputs.wave.x, NULL, P_FLAG_NONE, 0.0, 1.0, 0.0, ""); + load_builtin_param_float("wave_y", (void*)&presetOutputs.wave.y, NULL, P_FLAG_NONE, 0.0, 1.0, 0.0, ""); + load_builtin_param_float("wave_mystery", (void*)&presetOutputs.wave.mystery, NULL, P_FLAG_NONE, 0.0, 1.0, -1.0, "fWaveParam"); - load_builtin_param_float("ob_size", (void*)&presetOutputs.ob_size, NULL, P_FLAG_NONE, 0.0, 0.5, 0, ""); - load_builtin_param_float("ob_r", (void*)&presetOutputs.ob_r, NULL, P_FLAG_NONE, 0.0, 1.0, 0.0, ""); - load_builtin_param_float("ob_g", (void*)&presetOutputs.ob_g, NULL, P_FLAG_NONE, 0.0, 1.0, 0.0, ""); - load_builtin_param_float("ob_b", (void*)&presetOutputs.ob_b, NULL, P_FLAG_NONE, 0.0, 1.0, 0.0, ""); - load_builtin_param_float("ob_a", (void*)&presetOutputs.ob_a, NULL, P_FLAG_NONE, 0.0, 1.0, 0.0, ""); + load_builtin_param_float("ob_size", (void*)&presetOutputs.border.outer_size, NULL, P_FLAG_NONE, 0.0, 0.5, 0, ""); + load_builtin_param_float("ob_r", (void*)&presetOutputs.border.outer_r, NULL, P_FLAG_NONE, 0.0, 1.0, 0.0, ""); + load_builtin_param_float("ob_g", (void*)&presetOutputs.border.outer_g, NULL, P_FLAG_NONE, 0.0, 1.0, 0.0, ""); + load_builtin_param_float("ob_b", (void*)&presetOutputs.border.outer_b, NULL, P_FLAG_NONE, 0.0, 1.0, 0.0, ""); + load_builtin_param_float("ob_a", (void*)&presetOutputs.border.outer_a, NULL, P_FLAG_NONE, 0.0, 1.0, 0.0, ""); - load_builtin_param_float("ib_size", (void*)&presetOutputs.ib_size, NULL,P_FLAG_NONE, 0.0, .5, 0.0, ""); - load_builtin_param_float("ib_r", (void*)&presetOutputs.ib_r, NULL,P_FLAG_NONE, 0.0, 1.0, 0.0, ""); - load_builtin_param_float("ib_g", (void*)&presetOutputs.ib_g, NULL,P_FLAG_NONE, 0.0, 1.0, 0.0, ""); - load_builtin_param_float("ib_b", (void*)&presetOutputs.ib_b, NULL,P_FLAG_NONE, 0.0, 1.0, 0.0, ""); - load_builtin_param_float("ib_a", (void*)&presetOutputs.ib_a, NULL,P_FLAG_NONE, 0.0, 1.0, 0.0, ""); + load_builtin_param_float("ib_size", (void*)&presetOutputs.border.inner_size, NULL,P_FLAG_NONE, 0.0, .5, 0.0, ""); + load_builtin_param_float("ib_r", (void*)&presetOutputs.border.inner_r, NULL,P_FLAG_NONE, 0.0, 1.0, 0.0, ""); + load_builtin_param_float("ib_g", (void*)&presetOutputs.border.inner_g, NULL,P_FLAG_NONE, 0.0, 1.0, 0.0, ""); + load_builtin_param_float("ib_b", (void*)&presetOutputs.border.inner_b, NULL,P_FLAG_NONE, 0.0, 1.0, 0.0, ""); + load_builtin_param_float("ib_a", (void*)&presetOutputs.border.inner_a, NULL,P_FLAG_NONE, 0.0, 1.0, 0.0, ""); - load_builtin_param_float("mv_r", (void*)&presetOutputs.mv_r, NULL,P_FLAG_NONE, 0.0, 1.0, 0.0, ""); - load_builtin_param_float("mv_g", (void*)&presetOutputs.mv_g, NULL,P_FLAG_NONE, 0.0, 1.0, 0.0, ""); - load_builtin_param_float("mv_b", (void*)&presetOutputs.mv_b, NULL,P_FLAG_NONE, 0.0, 1.0, 0.0, ""); - load_builtin_param_float("mv_x", (void*)&presetOutputs.mv_x, NULL,P_FLAG_NONE, 0.0, 64.0, 0.0, "nmotionvectorsx"); - load_builtin_param_float("mv_y", (void*)&presetOutputs.mv_y, NULL,P_FLAG_NONE, 0.0, 48.0, 0.0, "nmotionvectorsy"); - load_builtin_param_float("mv_l", (void*)&presetOutputs.mv_l, NULL,P_FLAG_NONE, 0.0, 5.0, 0.0, ""); - load_builtin_param_float("mv_dy", (void*)&presetOutputs.mv_dy, NULL, P_FLAG_NONE, 0.0, 1.0, -1.0, ""); - load_builtin_param_float("mv_dx", (void*)&presetOutputs.mv_dx, NULL,P_FLAG_NONE, 0.0, 1.0, -1.0, ""); - load_builtin_param_float("mv_a", (void*)&presetOutputs.mv_a, NULL,P_FLAG_NONE, 0.0, 1.0, 0.0, ""); + load_builtin_param_float("mv_r", (void*)&presetOutputs.mv.r, NULL,P_FLAG_NONE, 0.0, 1.0, 0.0, ""); + load_builtin_param_float("mv_g", (void*)&presetOutputs.mv.g, NULL,P_FLAG_NONE, 0.0, 1.0, 0.0, ""); + load_builtin_param_float("mv_b", (void*)&presetOutputs.mv.b, NULL,P_FLAG_NONE, 0.0, 1.0, 0.0, ""); + load_builtin_param_float("mv_x", (void*)&presetOutputs.mv.x_num, NULL,P_FLAG_NONE, 0.0, 64.0, 0.0, "nmotionvectorsx"); + load_builtin_param_float("mv_y", (void*)&presetOutputs.mv.y_num, NULL,P_FLAG_NONE, 0.0, 48.0, 0.0, "nmotionvectorsy"); + load_builtin_param_float("mv_l", (void*)&presetOutputs.mv.length, NULL,P_FLAG_NONE, 0.0, 5.0, 0.0, ""); + load_builtin_param_float("mv_dy", (void*)&presetOutputs.mv.x_offset, NULL, P_FLAG_NONE, 0.0, 1.0, -1.0, ""); + load_builtin_param_float("mv_dx", (void*)&presetOutputs.mv.y_offset, NULL,P_FLAG_NONE, 0.0, 1.0, -1.0, ""); + load_builtin_param_float("mv_a", (void*)&presetOutputs.mv.a, NULL,P_FLAG_NONE, 0.0, 1.0, 0.0, ""); load_builtin_param_float("time", (void*)&presetInputs.time, NULL,P_FLAG_READONLY, 0.0, MAX_DOUBLE_SIZE, 0.0, ""); load_builtin_param_float("bass", (void*)&presetInputs.bass, NULL,P_FLAG_READONLY, 0.0, MAX_DOUBLE_SIZE, 0.0, ""); diff --git a/src/projectM-engine/MilkdropCompatability.hpp b/src/projectM-engine/MilkdropCompatability.hpp index d656f6d85..f5517e147 100644 --- a/src/projectM-engine/MilkdropCompatability.hpp +++ b/src/projectM-engine/MilkdropCompatability.hpp @@ -30,6 +30,11 @@ inline float min(float a, float b) return a < b ? a : b; } +inline float max(float a, float b) +{ + return a > b ? a : b; +} + inline float if_milk(float a, float b, float c) { return (a==1.0) ? b : c; diff --git a/src/projectM-engine/MilkdropWaveform.cpp b/src/projectM-engine/MilkdropWaveform.cpp index 589493ea9..b67ccde26 100644 --- a/src/projectM-engine/MilkdropWaveform.cpp +++ b/src/projectM-engine/MilkdropWaveform.cpp @@ -5,6 +5,15 @@ * Author: pete */ +#ifdef LINUX +#include +#endif +#ifdef WIN32 +#include "glew.h" +#endif +#ifdef __APPLE__ +#include +#endif #include "MilkdropWaveform.hpp" #include "math.h" @@ -22,6 +31,7 @@ void MilkdropWaveform::Draw(RenderContext &context) glLoadIdentity(); if(modulateAlphaByVolume) ModulateOpacityByVolume(context); + else temp_a = a; MaximizeColors(context); #ifndef USE_GLES1 @@ -79,9 +89,9 @@ void MilkdropWaveform::ModulateOpacityByVolume(RenderContext &context) //calculate the opacity from 0=lower to 1=upper //based on current volume - if (context.beatDetect->vol<= modOpacityStart) a=0.0; - else if (context.beatDetect->vol>=modOpacityEnd) a=a; - else a*=((context.beatDetect->vol-modOpacityStart)/(modOpacityEnd-modOpacityStart)); + if (context.beatDetect->vol<= modOpacityStart) temp_a=0.0; + else if (context.beatDetect->vol>=modOpacityEnd) temp_a=a; + else temp_a=a*((context.beatDetect->vol-modOpacityStart)/(modOpacityEnd-modOpacityStart)); } @@ -96,22 +106,22 @@ void MilkdropWaveform::MaximizeColors(RenderContext &context) if(mode==Blob2 || mode==Blob5) switch(context.texsize) { - case 256: a *= 0.07f; break; - case 512: a *= 0.09f; break; - case 1024: a *= 0.11f; break; - case 2048: a *= 0.13f; break; + case 256: temp_a *= 0.07f; break; + case 512: temp_a *= 0.09f; break; + case 1024: temp_a *= 0.11f; break; + case 2048: temp_a *= 0.13f; break; } else if(mode==Blob3) { switch(context.texsize) { - case 256: a *= 0.075f; break; - case 512: a *= 0.15f; break; - case 1024: a *= 0.22f; break; - case 2048: a *= 0.33f; break; + case 256: temp_a *= 0.075f; break; + case 512: temp_a *= 0.15f; break; + case 1024: temp_a *= 0.22f; break; + case 2048: temp_a *= 0.33f; break; } - a*=1.3f; - a*=powf(context.beatDetect->treb , 2.0f); + temp_a*=1.3f; + temp_a*=powf(context.beatDetect->treb , 2.0f); } if (maximizeColors==true) @@ -138,11 +148,11 @@ void MilkdropWaveform::MaximizeColors(RenderContext &context) } - glColor4f(wave_r_switch, wave_g_switch, wave_b_switch, a); + glColor4f(wave_r_switch, wave_g_switch, wave_b_switch, temp_a); } else { - glColor4f(r, g, b, a); + glColor4f(r, g, b, temp_a); } } @@ -192,10 +202,10 @@ void MilkdropWaveform::WaveformMath(RenderContext &context) { float value = context.beatDetect->pcm->pcmdataR[i]+context.beatDetect->pcm->pcmdataL[i]; - value += offset * (x/(float)samples); + value += offset * (i/(float)samples); r=(0.5 + 0.4f*.12*value*scale + mystery)*.5; - theta=(x)*inv_nverts_minus_one*6.28f + context.time*0.2f; + theta=i*inv_nverts_minus_one*6.28f + context.time*0.2f; wavearray[i][0]=(r*cos(theta)*(context.aspectCorrect? context.aspectRatio : 1.0)+x); wavearray[i][1]=(r*sin(theta)+temp_y); @@ -342,13 +352,13 @@ void MilkdropWaveform::WaveformMath(RenderContext &context) for ( int i=0;ipcm->pcmdataL[i]*.04*scale+(wave_y_temp+y_adj); } for ( int i=0;ipcm->pcmdataR[i]*.04*scale+(wave_y_temp-y_adj); } diff --git a/src/projectM-engine/MilkdropWaveform.hpp b/src/projectM-engine/MilkdropWaveform.hpp index 3e3f6ab26..d6906ecab 100644 --- a/src/projectM-engine/MilkdropWaveform.hpp +++ b/src/projectM-engine/MilkdropWaveform.hpp @@ -10,14 +10,16 @@ #include "Renderable.hpp" +enum MilkdropWaveformMode + { + RadialBlob=0, Circle, Blob2, Blob3, DerivativeLine, Blob5, Line, DoubleLine + }; + + class MilkdropWaveform : public RenderItem { public: - enum MilkdropWaveformMode - { - RadialBlob, Circle, Blob2, Blob3, DerivativeLine, Blob5, Line, DoubleLine - }; float x; float y; @@ -46,6 +48,7 @@ public: float modOpacityEnd; private: + float temp_a; float rot; float aspectScale; int samples; diff --git a/src/projectM-engine/MstressJuppyDancer.hpp b/src/projectM-engine/MstressJuppyDancer.hpp index 89cd91bb4..8d1353f20 100644 --- a/src/projectM-engine/MstressJuppyDancer.hpp +++ b/src/projectM-engine/MstressJuppyDancer.hpp @@ -58,16 +58,16 @@ public: } - ColoredPoint PerPoint(ColoredPoint p, const float sample, const BeatDetect &music) + ColoredPoint PerPoint(ColoredPoint p, const WaveformContext context) { - meanbass = 0.01*(meanbass*99+music.bass); - meantreb = 0.01*(meantreb*99+music.treb); - meanmid = 0.01*(meanmid*99+music.mid); - float bassdiff = (music.bass - meanbass)*15; - float trebdiff = (music.treb - meantreb)*15; - float middiff = (music.mid - meanmid)*15; + meanbass = 0.01*(meanbass*99+context.music->bass); + meantreb = 0.01*(meantreb*99+context.music->treb); + meanmid = 0.01*(meanmid*99+context.music->mid); + float bassdiff = (context.music->bass - meanbass)*15; + float trebdiff = (context.music->treb - meantreb)*15; + float middiff = (context.music->mid - meanmid)*15; float ba = min(above(bassdiff,0)*bassdiff*.005,.11); float tr = min(above(trebdiff,0)*trebdiff*.005,.11); float mi = min(above(middiff,0)*middiff*.005,.11); @@ -76,7 +76,7 @@ public: gam = abs(gam-above(mi2_prg,5)); mi2_prg= if_milk(above(mi2_prg,5),0,mi2_prg); - float s = sample * 15; + float s = context.sample_int; //Gambe p.x= if_milk(equal(int(s),1),.4,.4); p.y= if_milk(equal(int(s),1),.2+((ba+tr)*.5)*gam,.2+((ba+tr)*.5)*gam); @@ -138,9 +138,9 @@ public: p.x=p.x*temp_dim+temp_xpos; p.y=p.y*temp_dim+temp_ypos; - float hm=sample+mi2_prg; - float ht=sample+tr_prg; - float hb=sample+ba_prg; + float hm=context.sample+mi2_prg; + float ht=context.sample+tr_prg; + float hb=context.sample+ba_prg; p.r=hm; p.g=ht; diff --git a/src/projectM-engine/PresetFrameIO.hpp b/src/projectM-engine/PresetFrameIO.hpp index b5d02a0fc..f7b5f00bd 100644 --- a/src/projectM-engine/PresetFrameIO.hpp +++ b/src/projectM-engine/PresetFrameIO.hpp @@ -1,11 +1,14 @@ #ifndef PRESET_FRAME_IO_HPP #define PRESET_FRAME_IO_HPP #include +#include "MilkdropWaveform.hpp" +#include "Renderable.hpp" + class CustomWave; class CustomShape; -/// Container class for all preset writeable engine variables. This is the important glue +/// Container class for all preset writeable engine variables. This is the important glue /// between the presets and renderer to facilitate smooth preset switching /// Every preset object needs a reference to one of these. class PresetOutputs { @@ -34,35 +37,9 @@ public: float decay; - float wave_r; - float wave_g; - float wave_b; - float wave_o; - float wave_x; - float wave_y; - float wave_mystery; - - float ob_size; - float ob_r; - float ob_g; - float ob_b; - float ob_a; - - float ib_size; - float ib_r; - float ib_g; - float ib_b; - float ib_a; - - float mv_a ; - float mv_r ; - float mv_g ; - float mv_b ; - float mv_l; - float mv_x; - float mv_y; - float mv_dy; - float mv_dx; + MilkdropWaveform wave; + Border border; + MotionVectors mv; int gy,gx; /* PER_FRAME VARIABLES END */ @@ -73,13 +50,7 @@ public: float fVideoEchoAlpha; int nVideoEchoOrientation; - int nWaveMode; - bool bAdditiveWaves; - bool bWaveDots; - bool bWaveThick; - bool bModWaveAlphaByVolume; - bool bMaximizeWaveColor; bool bTexWrap; bool bDarkenCenter; bool bRedBlueStereo; @@ -89,13 +60,6 @@ public: bool bInvert; bool bMotionVectorsOn; - - float fWaveAlpha ; - float fWaveScale; - float fWaveSmoothing; - float fWaveParam; - float fModWaveAlphaStart; - float fModWaveAlphaEnd; float fWarpAnimSpeed; float fWarpScale; float fShader; @@ -130,19 +94,9 @@ public: float **x_mesh; float **y_mesh; - float wavearray[2048][2]; - float wavearray2[2048][2]; - - int wave_samples; - bool two_waves; - bool draw_wave_as_loop; - double wave_rot; - double wave_scale; - - }; -/// Container for all *read only* engine variables a preset requires to +/// Container for all *read only* engine variables a preset requires to /// evaluate milkdrop equations. Every preset object needs a reference to one of these. class PresetInputs { diff --git a/src/projectM-engine/PresetMerge.cpp b/src/projectM-engine/PresetMerge.cpp index 97ad4ad0c..7fbd2694f 100644 --- a/src/projectM-engine/PresetMerge.cpp +++ b/src/projectM-engine/PresetMerge.cpp @@ -3,70 +3,27 @@ #include void PresetMerger::MergePresets(PresetOutputs & A, PresetOutputs & B, double ratio, int gx, int gy) -{ +{ double invratio = 1.0 - ratio; //Merge Simple Waveforms // - // All the mess is because of Waveform 7, which is two lines. + // All the mess is because of Waveform 7, which is two lines. // - A.wave_rot = A.wave_rot* invratio + B.wave_rot*ratio; - A.wave_scale = A.wave_scale* invratio + B.wave_scale*ratio; - - if (!B.draw_wave_as_loop) A.draw_wave_as_loop = false; - if (A.two_waves && B.two_waves) - { - for (int x = 0; xa *= invratio; (*pos)->a2 *= invratio; (*pos)->border_a *= invratio; } - + for (PresetOutputs::cshape_container::iterator pos = B.customShapes.begin(); - pos != B.customShapes.end(); ++pos) + pos != B.customShapes.end(); ++pos) { (*pos)->a *= ratio; (*pos)->a2 *= ratio; @@ -76,7 +33,7 @@ double invratio = 1.0 - ratio; } for (PresetOutputs::cwave_container::iterator pos = A.customWaves.begin(); - pos != A.customWaves.end(); ++pos) + pos != A.customWaves.end(); ++pos) { (*pos)->a *= invratio; for (int x=0; x < (*pos)->samples; x++) @@ -86,9 +43,9 @@ double invratio = 1.0 - ratio; } for (PresetOutputs::cwave_container::iterator pos = B.customWaves.begin(); - pos != B.customWaves.end(); ++pos) + pos != B.customWaves.end(); ++pos) { - (*pos)->a *= ratio; + (*pos)->a *= ratio; for (int x=0; x < (*pos)->samples; x++) { (*pos)->a_mesh[x]= (*pos)->a_mesh[x]*ratio; @@ -115,68 +72,57 @@ double invratio = 1.0 - ratio; } - + //Interpolate PerFrame floats A.decay = A.decay * invratio + B.decay * ratio; - - A.wave_r = A.wave_r* invratio + B.wave_r*ratio; - A.wave_g = A.wave_g* invratio + B.wave_g*ratio; - A.wave_b = A.wave_b* invratio + B.wave_b*ratio; - A.wave_o = A.wave_o* invratio + B.wave_o*ratio; - A.wave_x = A.wave_x* invratio + B.wave_x*ratio; - A.wave_y = A.wave_y* invratio + B.wave_y*ratio; - A.wave_mystery = A.wave_mystery* invratio + B.wave_mystery*ratio; - - A.ob_size = A.ob_size* invratio + B.ob_size*ratio; - A.ob_r = A.ob_r* invratio + B.ob_r*ratio; - A.ob_g = A.ob_g* invratio + B.ob_g*ratio; - A.ob_b = A.ob_b* invratio + B.ob_b*ratio; - A.ob_a = A.ob_a* invratio + B.ob_a*ratio; - - A.ib_size = A.ib_size* invratio + B.ib_size*ratio; - A.ib_r = A.ib_r* invratio + B.ib_r*ratio; - A.ib_g = A.ib_g* invratio + B.ib_g*ratio; - A.ib_b = A.ib_b* invratio + B.ib_b*ratio; - A.ib_a = A.ib_a* invratio + B.ib_a*ratio; - - A.mv_a = A.mv_a* invratio + B.mv_a*ratio; - A.mv_r = A.mv_r* invratio + B.mv_r*ratio; - A.mv_g = A.mv_g* invratio + B.mv_g*ratio; - A.mv_b = A.mv_b* invratio + B.mv_b*ratio; - A.mv_l = A.mv_l* invratio + B.mv_l*ratio; - A.mv_x = A.mv_x* invratio + B.mv_x*ratio; - A.mv_y = A.mv_y* invratio + B.mv_y*ratio; - A.mv_dy = A.mv_dy* invratio + B.mv_dy*ratio; - A.mv_dx = A.mv_dx* invratio + B.mv_dx*ratio; - + A.wave.r = A.wave.r* invratio + B.wave.r*ratio; + A.wave.g = A.wave.g* invratio + B.wave.g*ratio; + A.wave.b = A.wave.b* invratio + B.wave.b*ratio; + A.wave.a = A.wave.a* invratio + B.wave.a*ratio; + A.wave.x = A.wave.x* invratio + B.wave.x*ratio; + A.wave.y = A.wave.y* invratio + B.wave.y*ratio; + A.wave.mystery = A.wave.mystery* invratio + B.wave.mystery*ratio; + + A.border.outer_size = A.border.outer_size* invratio + B.border.outer_size*ratio; + A.border.outer_r = A.border.outer_r* invratio + B.border.outer_r*ratio; + A.border.outer_g = A.border.outer_g* invratio + B.border.outer_g*ratio; + A.border.outer_b = A.border.outer_b* invratio + B.border.outer_b*ratio; + A.border.outer_a = A.border.outer_a* invratio + B.border.outer_a*ratio; + + A.border.inner_size = A.border.inner_size* invratio + B.border.inner_size*ratio; + A.border.inner_r = A.border.inner_r* invratio + B.border.inner_r*ratio; + A.border.inner_g = A.border.inner_g* invratio + B.border.inner_g*ratio; + A.border.inner_b = A.border.inner_b* invratio + B.border.inner_b*ratio; + A.border.inner_a = A.border.inner_a* invratio + B.border.inner_a*ratio; + + A.mv.a = A.mv.a* invratio + B.mv.a*ratio; + A.mv.r = A.mv.r* invratio + B.mv.r*ratio; + A.mv.g = A.mv.g* invratio + B.mv.g*ratio; + A.mv.b = A.mv.b* invratio + B.mv.b*ratio; + A.mv.length = A.mv.length* invratio + B.mv.length*ratio; + A.mv.x_num = A.mv.x_num* invratio + B.mv.x_num*ratio; + A.mv.y_num = A.mv.y_num* invratio + B.mv.y_num*ratio; + A.mv.y_offset = A.mv.y_offset* invratio + B.mv.y_offset*ratio; + A.mv.x_offset = A.mv.x_offset* invratio + B.mv.x_offset*ratio; + + A.fRating = A.fRating* invratio + B.fRating*ratio; A.fGammaAdj = A.fGammaAdj* invratio + B.fGammaAdj*ratio; A.fVideoEchoZoom = A.fVideoEchoZoom* invratio + B.fVideoEchoZoom*ratio; A.fVideoEchoAlpha = A.fVideoEchoAlpha* invratio + B.fVideoEchoAlpha*ratio; - - A.fWaveAlpha = A.fWaveAlpha* invratio + B.fWaveAlpha*ratio; - A.fWaveScale = A.fWaveScale* invratio + B.fWaveScale*ratio; - A.fWaveSmoothing = A.fWaveSmoothing* invratio + B.fWaveSmoothing*ratio; - A.fWaveParam = A.fWaveParam* invratio + B.fWaveParam*ratio; - A.fModWaveAlphaStart = A.fModWaveAlphaStart* invratio + B.fModWaveAlphaStart*ratio; - A.fModWaveAlphaEnd = A.fModWaveAlphaEnd * invratio + B.fModWaveAlphaEnd *ratio; + + A.fWarpAnimSpeed = A.fWarpAnimSpeed* invratio + B.fWarpAnimSpeed*ratio; A.fWarpScale = A.fWarpScale* invratio + B.fWarpScale*ratio; - A.fShader = A.fShader* invratio + B.fShader*ratio; + A.fShader = A.fShader* invratio + B.fShader*ratio; //Switch bools and discrete values halfway. Maybe we should do some interesting stuff here. - + if (ratio > 0.5) { A.nVideoEchoOrientation = B.nVideoEchoOrientation; - A.nWaveMode = B.nWaveMode; - A.bAdditiveWaves = B.bAdditiveWaves; - A.bWaveDots = B.bWaveDots; - A.bWaveThick = B.bWaveThick; - A.bModWaveAlphaByVolume = B.bModWaveAlphaByVolume; - A.bMaximizeWaveColor = B.bMaximizeWaveColor; A.bTexWrap = B.bTexWrap; A.bDarkenCenter = B.bDarkenCenter; A.bRedBlueStereo = B.bRedBlueStereo; @@ -185,7 +131,7 @@ double invratio = 1.0 - ratio; A.bSolarize = B.bSolarize; A.bInvert = B.bInvert; A.bMotionVectorsOn = B.bMotionVectorsOn; - } + } return; } diff --git a/src/projectM-engine/RLGFractalDrop7c.hpp b/src/projectM-engine/RLGFractalDrop7c.hpp new file mode 100644 index 000000000..c133c0c0b --- /dev/null +++ b/src/projectM-engine/RLGFractalDrop7c.hpp @@ -0,0 +1,146 @@ +/* + * RovastarFractalSpiral.hpp + * + * Created on: Jun 22, 2008 + * Author: pete + */ + + +#include "Pipeline.hpp" +#include "Transformation.hpp" +#include "MilkdropCompatability.hpp" + +class RLGFractalDrop7c : public Pipeline +{ +public: + + Shape shape1,shape2,shape3,shape4; + MilkdropWaveform wave; + + float movement, t1, t2, t3, t4; + + RLGFractalDrop7c() : Pipeline() + { + drawables.push_back(&shape1); + drawables.push_back(&shape2); + drawables.push_back(&shape3); + drawables.push_back(&shape4); + drawables.push_back(&wave); + + textureWrap = true; + screenDecay = 1.0; + + videoEchoOrientation = 1; + videoEchoZoom = 1.006752; + videoEchoAlpha = 0.5; + + wave.mode = DoubleLine; + wave.additive = true; + wave.scale = 3.815202; + wave.smoothing = 0.9; + wave.modOpacityEnd = 1.1; + wave.modOpacityStart = 0.0; + wave.maximizeColors = true; + wave.modulateAlphaByVolume = true; + wave.r = 0.65; + wave.g = 0.65; + wave.b = 1; + wave.a = 0.1; + + movement = 0; + + t1 = (rand()%100)*0.01; + t2 = (rand()%100)*0.01; + t3 = (rand()%100)*0.01; + t4 = (rand()%100)*0.01; + + shape1.sides =3; + shape1.x = 0.37; + shape1.y = 0.5; + shape1.radius = 6.811289; + shape1.ang = 3.644249; + shape1.a = 0.5; + shape1.a2 = 0.5; + shape1.border_r = 1; + shape1.border_g = 1; + shape1.border_b = 1; + shape1.border_a = 1; + + shape2.sides =100; + shape2.additive = true; + shape2.textured = true; + + shape2.radius = 0.897961; + shape2.ang = 3.644249; + shape2.a = 0.5; + shape2.a2 = 1; + + shape3.sides =100; + shape3.additive = true; + shape3.textured = true; + shape3.radius = 0.513861; + shape3.ang = 4.209736; + shape3.a = 1; + shape3.a2 = 1; + + shape4.sides =100; + shape4.additive = true; + shape4.textured = true; + shape4.ang = 0; + shape4.a = 1; + shape4.r = 0.6; + shape4.g = 0.8; + shape4.b = 1; + shape4.a2 = 1; + } + + virtual void Render(const BeatDetect &music, const PipelineContext &context) + { + movement += 0.1*max(0,music.bass+music.bass_att-2) + 0.15*pow(music.bass,3) + 0.005; + float time = context.time; + + shape1.ang = movement*(0.303 + 0.01*t1); + shape1.r = min(1,max(0,0+ 0.1*sin(time*0.417 + 1))); + shape1.g = min(1,max(0,0 + 0.1*sin(time*0.391 + 2))); + shape1.b = min(1,max(0,0 + 0.1*sin(time*0.432 + 4))); + shape1.r2 = min(1,max(0, 0.02*sin(time*0.657 + 3))); + shape1.g2 = min(1,max(0, 0.02*sin(time*0.737 + 5))); + shape1.b2 = min(1,max(0, 0.02*sin(time*0.884 + 6))); + shape1.additive = ((0.5+0.15*(music.bass+music.bass_att)) > 1.0) ? true : false; + + + shape2.x = 0.37 + 0.07*sin(movement*0.15+3); + shape2.y = 0.5 + 0.03*sin(movement*0.19+1); + shape2.tex_ang = movement*(0.01 + 0.0001*t2); + shape2.r = min(1,max(0, 1 + 0.01*sin(time*0.0417 + 1))); + shape2.g = min(1,max(0, 1 + 0.01*sin(time*0.391 + 2))); + shape2.b = min(1,max(0, 1 + 0.01*sin(time*0.432 + 4))); + shape2.r2 = min(1,max(0, 0.01*sin(time*0.457 + 3))); + shape2.g2 = min(1,max(0, 0.01*sin(time*0.0437 + 5))); + shape2.b2 = min(1,max(0, 0.01*sin(time*0.484 + 6))); + + shape3.x = 0.67 + 0.05*sin(movement*0.017); + shape3.y = 0.43 + 0.09*sin(movement*0.013); + shape3.tex_ang = movement*(0.02 + 0.0001*t3); + shape3.radius = 0.222979 * (0.9 + 0.2*t4); + shape3.r = min(1,max(0,1+ 0.01*sin(time*0.417 + 1))); + shape3.g = min(1,max(0,1 + 0.01*sin(time*0.391 + 2))); + shape3.b = min(1,max(0,1 + 0.01*sin(time*0.432 + 4))); + shape3.r2 = min(1,max(0,0.01*sin(time*0.457 + 3))); + shape3.g2 = min(1,max(0,0.01*sin(time*0.437 + 5))); + shape3.b2 = min(1,max(0,0.01*sin(time*0.484 + 6))); + + shape4.x = 0.5 + 0.08*sin(movement*0.25); + shape4.y = 0.5 + 0.1*sin(movement*0.5+2); + shape4.ang = time; + } + + virtual Point PerPixel(Point p, const PerPixelContext context) + { + Transforms::Zoom(p,context,1.029902,1.00); + return p; + } + +}; + + diff --git a/src/projectM-engine/Renderer.cpp b/src/projectM-engine/Renderer.cpp index c9fa6f8c3..6ca98c5e4 100644 --- a/src/projectM-engine/Renderer.cpp +++ b/src/projectM-engine/Renderer.cpp @@ -167,6 +167,30 @@ myCgContext = cgCreateContext(); } +void Renderer::SetupCgVariables(CGprogram program, const PipelineContext &context) +{ + cgGLSetParameter1f(cgGetNamedParameter(program, "time"), context.time); + cgGLSetParameter4f(cgGetNamedParameter(program, "rand_preset"), 0.6, 0.43, 0.87, 0.3); + cgGLSetParameter4f(cgGetNamedParameter(program, "rand_frame"), (rand()%100) * .01,(rand()%100) * .01,(rand()%100) * .01,(rand()%100) * .01); + cgGLSetParameter1f(cgGetNamedParameter(program, "fps"), context.fps); + cgGLSetParameter1f(cgGetNamedParameter(program, "frame"), context.frame); + cgGLSetParameter1f(cgGetNamedParameter(program, "progress"), context.progress); + + cgGLSetParameter1f(cgGetNamedParameter(program, "bass"), beatDetect->bass); + cgGLSetParameter1f(cgGetNamedParameter(program, "mid"), beatDetect->mid); + cgGLSetParameter1f(cgGetNamedParameter(program, "treb"), beatDetect->treb); + cgGLSetParameter1f(cgGetNamedParameter(program, "bass_att"), beatDetect->bass_att); + cgGLSetParameter1f(cgGetNamedParameter(program, "mid_att"), beatDetect->mid_att); + cgGLSetParameter1f(cgGetNamedParameter(program, "treb_att"), beatDetect->treb_att); + cgGLSetParameter1f(cgGetNamedParameter(program, "vol"), beatDetect->vol); + cgGLSetParameter1f(cgGetNamedParameter(program, "vol_att"), beatDetect->vol); + + cgGLSetParameter4f(cgGetNamedParameter(program, "texsize"), renderTarget->texsize, renderTarget->texsize, 1/(float)renderTarget->texsize,1/(float)renderTarget->texsize); + cgGLSetParameter4f(cgGetNamedParameter(program, "aspect"), aspect,1,1/aspect,1); + + + +} #endif @@ -285,21 +309,8 @@ void Renderer::RenderFrame(const Pipeline* pipeline, const PipelineContext &pipe glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glLineWidth( this->renderTarget->texsize < 512 ? 1 : this->renderTarget->texsize/512.0); -/* -#ifdef USE_CG - cgGLBindProgram(myCgCompositeProgram); - checkForCgError("binding warp program"); - cgGLEnableProfile(myCgCompositeProfile); - checkForCgError("enabling warp profile"); -#endif CompositeOutput(pipeline); -#ifdef USE_CG - cgGLDisableProfile(myCgCompositeProfile); - checkForCgError("disabling fragment profile"); - -#endif -*/ CompositeOutput(pipeline); #ifdef USE_FBO if(renderTarget->renderToTexture) glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); @@ -358,26 +369,25 @@ void Renderer::RenderFrame(PresetOutputs *presetOutputs, PresetInputs *presetInp glMatrixMode( GL_MODELVIEW ); glLoadIdentity(); - - if(this->renderTarget->useFBO) - { - //draw_motion_vectors(); //draw motion vectors - //unlockPBuffer( this->renderTarget); - //lockPBuffer( this->renderTarget, PBUFFER_PASS1 ); - } + renderContext.time = presetInputs->time; + renderContext.texsize = texsize; + renderContext.aspectCorrect = correction; + renderContext.aspectRatio = aspect; + renderContext.textureManager = textureManager; + renderContext.beatDetect = beatDetect; Interpolation(presetOutputs, presetInputs); - // if(!this->renderTarget->useFBO) - { - draw_motion_vectors(presetOutputs); - } + + presetOutputs->mv.Draw(renderContext); + + draw_shapes(presetOutputs); draw_custom_waves(presetOutputs); - draw_waveform(presetOutputs); + presetOutputs->wave.Draw(renderContext); if(presetOutputs->bDarkenCenter)darken_center(); - draw_borders(presetOutputs); + presetOutputs->border.Draw(renderContext); draw_title_to_texture(); /** Restore original view state */ glMatrixMode( GL_MODELVIEW ); @@ -813,7 +823,7 @@ void Renderer::draw_custom_waves(PresetOutputs *presetOutputs) // printf("%f\n",pcmL[0]); - float mult= (*pos)->scaling*presetOutputs->fWaveScale*( (*pos)->bSpectrum ? 0.015f :1.0f); + float mult= (*pos)->scaling*presetOutputs->wave.scale*( (*pos)->bSpectrum ? 0.015f :1.0f); for(x=0;x< (*pos)->samples;x++) { (*pos)->value1[x]*=mult;} @@ -1016,7 +1026,7 @@ void Renderer::draw_shapes(PresetOutputs *presetOutputs) //draw first n-1 triangular pieces } - if (presetOutputs->bWaveThick==1) glLineWidth(this->renderTarget->texsize < 512 ? 1 : 2*this->renderTarget->texsize/512); + if ((*pos)->thickOutline==1) glLineWidth(this->renderTarget->texsize < 512 ? 1 : 2*this->renderTarget->texsize/512); glEnableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_COLOR_ARRAY); @@ -1036,7 +1046,7 @@ void Renderer::draw_shapes(PresetOutputs *presetOutputs) glVertexPointer(2,GL_FLOAT,0,points); glDrawArrays(GL_LINE_LOOP,0,(*pos)->sides); - if (presetOutputs->bWaveThick==1) glLineWidth(this->renderTarget->texsize < 512 ? 1 : this->renderTarget->texsize/512); + if ((*pos)->thickOutline==1) glLineWidth(this->renderTarget->texsize < 512 ? 1 : this->renderTarget->texsize/512); } @@ -1045,366 +1055,6 @@ void Renderer::draw_shapes(PresetOutputs *presetOutputs) } -void Renderer::WaveformMath(PresetOutputs *presetOutputs, PresetInputs *presetInputs, bool isSmoothing) -{ - - int x; - - float r, theta; - - float offset, scale; - - float wave_x_temp=0; - float wave_y_temp=0; - - float cos_rot; - float sin_rot; - - offset=presetOutputs->wave_x-.5; - scale=505.0/512.0; - - presetOutputs->two_waves = false; - presetOutputs->draw_wave_as_loop = false; - - switch(presetOutputs->nWaveMode) - { - - case 0: - { - presetOutputs->draw_wave_as_loop = true; - presetOutputs->wave_rot = 0; - presetOutputs->wave_scale =1.0; - presetOutputs->wave_y=-1*(presetOutputs->wave_y-1.0); - - - presetOutputs->wave_samples = isSmoothing ? 512-32 : beatDetect->pcm->numsamples; - - float inv_nverts_minus_one = 1.0f/(float)(presetOutputs->wave_samples); - - float last_value = beatDetect->pcm->pcmdataR[presetOutputs->wave_samples-1]+beatDetect->pcm->pcmdataL[presetOutputs->wave_samples-1]; - float first_value = beatDetect->pcm->pcmdataR[0]+beatDetect->pcm->pcmdataL[0]; - float offset = first_value-last_value; - - for ( x=0;xwave_samples;x++) - { - - - float value = beatDetect->pcm->pcmdataR[x]+beatDetect->pcm->pcmdataL[x]; - value += offset * (x/(float)presetOutputs->wave_samples); - - r=(0.5 + 0.4f*.12*value*presetOutputs->fWaveScale + presetOutputs->wave_mystery)*.5; - theta=(x)*inv_nverts_minus_one*6.28f + presetInputs->time*0.2f; - - presetOutputs->wavearray[x][0]=(r*cos(theta)*(this->correction ? this->aspect : 1.0)+presetOutputs->wave_x); - presetOutputs->wavearray[x][1]=(r*sin(theta)+presetOutputs->wave_y); - - } - - } - - break; - - case 1://circularly moving waveform - - presetOutputs->wave_rot = 0; - presetOutputs->wave_scale = this->vh/(float)this->vw; - - - presetOutputs->wave_y=-1*(presetOutputs->wave_y-1.0); - - - presetOutputs->wave_samples = 512-32; - for ( x=0;x<(512-32);x++) - { - - theta=beatDetect->pcm->pcmdataL[x+32]*0.06*presetOutputs->fWaveScale * 1.57 + presetInputs->time*2.3; - r=(0.53 + 0.43*beatDetect->pcm->pcmdataR[x]*0.12*presetOutputs->fWaveScale+ presetOutputs->wave_mystery)*.5; - - presetOutputs->wavearray[x][0]=(r*cos(theta)*(this->correction ? this->aspect : 1.0)+presetOutputs->wave_x); - presetOutputs->wavearray[x][1]=(r*sin(theta)+presetOutputs->wave_y); - - } - - - - break; - - case 2://EXPERIMENTAL - - - presetOutputs->wave_y=-1*(presetOutputs->wave_y-1.0); - presetOutputs->wave_rot = 0; - presetOutputs->wave_scale =1.0; - presetOutputs->wave_samples = 512-32; - - - for (x=0; x<512-32; x++) - { - presetOutputs->wavearray[x][0]=(beatDetect->pcm->pcmdataR[x]*presetOutputs->fWaveScale*0.5*(this->correction ? this->aspect : 1.0) + presetOutputs->wave_x); - - presetOutputs->wavearray[x][1]=(beatDetect->pcm->pcmdataL[x+32]*presetOutputs->fWaveScale*0.5 + presetOutputs->wave_y); - - } - - - break; - - case 3://EXPERIMENTAL - - - presetOutputs->wave_y=-1*(presetOutputs->wave_y-1.0); - - presetOutputs->wave_rot = 0; - presetOutputs->wave_scale =1.0; - - - presetOutputs->wave_samples = 512-32; - - for (x=0; x<512-32; x++) - { - presetOutputs->wavearray[x][0]=(beatDetect->pcm->pcmdataR[x] * presetOutputs->fWaveScale*0.5 + presetOutputs->wave_x); - presetOutputs->wavearray[x][1]=( (beatDetect->pcm->pcmdataL[x+32]*presetOutputs->fWaveScale*0.5 + presetOutputs->wave_y)); - - } - - - break; - - case 4://single x-axis derivative waveform - { - - presetOutputs->wave_rot =-presetOutputs->wave_mystery*90; - presetOutputs->wave_scale=1.0; - - presetOutputs->wave_y=-1*(presetOutputs->wave_y-1.0); - - - float w1 = 0.45f + 0.5f*(presetOutputs->wave_mystery*0.5f + 0.5f); - float w2 = 1.0f - w1; - float xx[512], yy[512]; - presetOutputs->wave_samples = 512-32; - - for (int i=0; i<512-32; i++) - { - xx[i] = -1.0f + 2.0f*(i/(512.0-32.0)) + presetOutputs->wave_x; - yy[i] =0.4* beatDetect->pcm->pcmdataL[i]*0.47f*presetOutputs->fWaveScale + presetOutputs->wave_y; - xx[i] += 0.4*beatDetect->pcm->pcmdataR[i]*0.44f*presetOutputs->fWaveScale; - - if (i>1) - { - xx[i] = xx[i]*w2 + w1*(xx[i-1]*2.0f - xx[i-2]); - yy[i] = yy[i]*w2 + w1*(yy[i-1]*2.0f - yy[i-2]); - } - presetOutputs->wavearray[i][0]=xx[i]; - presetOutputs->wavearray[i][1]=yy[i]; - } } - break; - - case 5://EXPERIMENTAL - - presetOutputs->wave_rot = 0; - presetOutputs->wave_scale =1.0; - - presetOutputs->wave_y=-1*(presetOutputs->wave_y-1.0); - - cos_rot = cosf(presetInputs->time*0.3f); - sin_rot = sinf(presetInputs->time*0.3f); - presetOutputs->wave_samples = 512-32; - - for (x=0; x<512-32; x++) - { - float x0 = (beatDetect->pcm->pcmdataR[x]*beatDetect->pcm->pcmdataL[x+32] + beatDetect->pcm->pcmdataL[x+32]*beatDetect->pcm->pcmdataR[x]); - float y0 = (beatDetect->pcm->pcmdataR[x]*beatDetect->pcm->pcmdataR[x] - beatDetect->pcm->pcmdataL[x+32]*beatDetect->pcm->pcmdataL[x+32]); - presetOutputs->wavearray[x][0]=((x0*cos_rot - y0*sin_rot)*presetOutputs->fWaveScale*0.5*(this->correction ? this->aspect : 1.0) + presetOutputs->wave_x); - presetOutputs->wavearray[x][1]=( (x0*sin_rot + y0*cos_rot)*presetOutputs->fWaveScale*0.5 + presetOutputs->wave_y); - - } - - - - break; - - case 6://single waveform - - - - wave_x_temp=-2*0.4142*(fabs(fabs(presetOutputs->wave_mystery)-.5)-.5); - - presetOutputs->wave_rot = -presetOutputs->wave_mystery*90; - presetOutputs->wave_scale =1.0+wave_x_temp; - wave_x_temp=-1*(presetOutputs->wave_x-1.0); - presetOutputs->wave_samples = isSmoothing ? 512-32 : beatDetect->pcm->numsamples; - - for ( x=0;x< presetOutputs->wave_samples;x++) - { - - presetOutputs->wavearray[x][0]=x/(float) presetOutputs->wave_samples; - presetOutputs->wavearray[x][1]=beatDetect->pcm->pcmdataR[x]*.04*presetOutputs->fWaveScale+wave_x_temp; - - } - // printf("%f %f\n",renderTarget->texsize*wave_y_temp,wave_y_temp); - - break; - - case 7://dual waveforms - - - wave_x_temp=-2*0.4142*(fabs(fabs(presetOutputs->wave_mystery)-.5)-.5); - - presetOutputs->wave_rot = -presetOutputs->wave_mystery*90; - presetOutputs->wave_scale =1.0+wave_x_temp; - - - presetOutputs->wave_samples = isSmoothing ? 512-32 : beatDetect->pcm->numsamples; - presetOutputs->two_waves = true; - - double y_adj = presetOutputs->wave_y*presetOutputs->wave_y*.5; - - wave_y_temp=-1*(presetOutputs->wave_x-1); - - for ( x=0;x< presetOutputs->wave_samples ;x++) - { - presetOutputs->wavearray[x][0]=x/((float) presetOutputs->wave_samples); - presetOutputs->wavearray[x][1]= beatDetect->pcm->pcmdataL[x]*.04*presetOutputs->fWaveScale+(wave_y_temp+y_adj); - - } - - for ( x=0;x< presetOutputs->wave_samples;x++) - { - - presetOutputs->wavearray2[x][0]=x/((float) presetOutputs->wave_samples); - presetOutputs->wavearray2[x][1]=beatDetect->pcm->pcmdataR[x]*.04*presetOutputs->fWaveScale+(wave_y_temp-y_adj); - - } - - break; - - - } - - -} - -void Renderer::draw_waveform(PresetOutputs * presetOutputs) -{ - - glMatrixMode( GL_MODELVIEW ); - glPushMatrix(); - glLoadIdentity(); - - modulate_opacity_by_volume(presetOutputs); - maximize_colors(presetOutputs); - -#ifndef USE_GLES1 - if(presetOutputs->bWaveDots==1) glEnable(GL_LINE_STIPPLE); -#endif - - //Thick wave drawing - if (presetOutputs->bWaveThick==1) glLineWidth( (this->renderTarget->texsize < 512 ) ? 2 : 2*this->renderTarget->texsize/512); - else glLineWidth( (this->renderTarget->texsize < 512 ) ? 1 : this->renderTarget->texsize/512); - - //Additive wave drawing (vice overwrite) - if (presetOutputs->bAdditiveWaves==0) glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - else glBlendFunc(GL_SRC_ALPHA, GL_ONE); - - glTranslatef(.5, .5, 0); - glRotatef(presetOutputs->wave_rot, 0, 0, 1); - glScalef(presetOutputs->wave_scale, 1.0, 1.0); - glTranslatef(-.5, -.5, 0); - - - glEnableClientState(GL_VERTEX_ARRAY); - glDisableClientState(GL_TEXTURE_COORD_ARRAY); - glDisableClientState(GL_COLOR_ARRAY); - glVertexPointer(2,GL_FLOAT,0,presetOutputs->wavearray); - - if (presetOutputs->draw_wave_as_loop) - glDrawArrays(GL_LINE_LOOP,0,presetOutputs->wave_samples); - else - glDrawArrays(GL_LINE_STRIP,0,presetOutputs->wave_samples); - - - if (presetOutputs->two_waves) - { - glVertexPointer(2,GL_FLOAT,0,presetOutputs->wavearray2); - if (presetOutputs->draw_wave_as_loop) - glDrawArrays(GL_LINE_LOOP,0,presetOutputs->wave_samples); - else - glDrawArrays(GL_LINE_STRIP,0,presetOutputs->wave_samples); - } - - -#ifndef USE_GLES1 - if(presetOutputs->bWaveDots==1) glDisable(GL_LINE_STIPPLE); -#endif - - glPopMatrix(); -} - -void Renderer::maximize_colors(PresetOutputs *presetOutputs) -{ - - float wave_r_switch=0, wave_g_switch=0, wave_b_switch=0; - //wave color brightening - // - //forces max color value to 1.0 and scales - // the rest accordingly - if(presetOutputs->nWaveMode==2 || presetOutputs->nWaveMode==5) - { - switch(this->renderTarget->texsize) - { - case 256: presetOutputs->wave_o *= 0.07f; break; - case 512: presetOutputs->wave_o *= 0.09f; break; - case 1024: presetOutputs->wave_o *= 0.11f; break; - case 2048: presetOutputs->wave_o *= 0.13f; break; - } - } - - else if(presetOutputs->nWaveMode==3) - { - switch(this->renderTarget->texsize) - { - case 256: presetOutputs->wave_o *= 0.075f; break; - case 512: presetOutputs->wave_o *= 0.15f; break; - case 1024: presetOutputs->wave_o *= 0.22f; break; - case 2048: presetOutputs->wave_o *= 0.33f; break; - } - presetOutputs->wave_o*=1.3f; - presetOutputs->wave_o*=powf(beatDetect->treb , 2.0f); - } - - if (presetOutputs->bMaximizeWaveColor==1) - { - if(presetOutputs->wave_r>=presetOutputs->wave_g && presetOutputs->wave_r>=presetOutputs->wave_b) //red brightest - { - wave_b_switch=presetOutputs->wave_b*(1/presetOutputs->wave_r); - wave_g_switch=presetOutputs->wave_g*(1/presetOutputs->wave_r); - wave_r_switch=1.0; - } - else if (presetOutputs->wave_b>=presetOutputs->wave_g && presetOutputs->wave_b>=presetOutputs->wave_r) //blue brightest - { - wave_r_switch=presetOutputs->wave_r*(1/presetOutputs->wave_b); - wave_g_switch=presetOutputs->wave_g*(1/presetOutputs->wave_b); - wave_b_switch=1.0; - - } - - else if (presetOutputs->wave_g>=presetOutputs->wave_b && presetOutputs->wave_g>=presetOutputs->wave_r) //green brightest - { - wave_b_switch=presetOutputs->wave_b*(1/presetOutputs->wave_g); - wave_r_switch=presetOutputs->wave_r*(1/presetOutputs->wave_g); - wave_g_switch=1.0; - } - - - glColor4f(wave_r_switch, wave_g_switch, wave_b_switch, presetOutputs->wave_o); - } - else - { - glColor4f(presetOutputs->wave_r, presetOutputs->wave_g, presetOutputs->wave_b, presetOutputs->wave_o); - } - -} void Renderer::darken_center() { @@ -1439,135 +1089,13 @@ void Renderer::darken_center() } -void Renderer::modulate_opacity_by_volume(PresetOutputs *presetOutputs) -{ - //modulate volume by opacity - // - //set an upper and lower bound and linearly - //calculate the opacity from 0=lower to 1=upper - //based on current volume - - - if (presetOutputs->bModWaveAlphaByVolume==1) - {if (beatDetect->vol<=presetOutputs->fModWaveAlphaStart) presetOutputs->wave_o=0.0; - else if (beatDetect->vol>=presetOutputs->fModWaveAlphaEnd) presetOutputs->wave_o=presetOutputs->fWaveAlpha; - else presetOutputs->wave_o=presetOutputs->fWaveAlpha*((beatDetect->vol-presetOutputs->fModWaveAlphaStart)/(presetOutputs->fModWaveAlphaEnd-presetOutputs->fModWaveAlphaStart));} - else presetOutputs->wave_o=presetOutputs->fWaveAlpha; -} - -void Renderer::draw_motion_vectors(PresetOutputs *presetOutputs) -{ - - glEnableClientState(GL_VERTEX_ARRAY); - glDisableClientState(GL_TEXTURE_COORD_ARRAY); - glDisableClientState(GL_COLOR_ARRAY); - - float offsetx=presetOutputs->mv_dx, intervalx=1.0/(float)presetOutputs->mv_x; - float offsety=presetOutputs->mv_dy, intervaly=1.0/(float)presetOutputs->mv_y; - - - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - - glPointSize(presetOutputs->mv_l); - glColor4f(presetOutputs->mv_r, presetOutputs->mv_g, presetOutputs->mv_b, presetOutputs->mv_a); - - int numx = static_cast(presetOutputs->mv_x); - int numy = static_cast(presetOutputs->mv_y); - - if (numx + numy < 600) - { - int size = numx * numy; - - float points[size][2]; - - - - for (int x=0;xinitRenderToTexture(); } -void Renderer::draw_borders(PresetOutputs *presetOutputs) -{ - glEnableClientState(GL_VERTEX_ARRAY); - glDisableClientState(GL_COLOR_ARRAY); - glDisableClientState(GL_TEXTURE_COORD_ARRAY); - //Draw Borders - float of=presetOutputs->ob_size*.5; - float iff=presetOutputs->ib_size*.5; - float texof=1.0-of; - - //no additive drawing for borders - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - - glColor4f(presetOutputs->ob_r, presetOutputs->ob_g, presetOutputs->ob_b, presetOutputs->ob_a); - - - - float pointsA[4][2] = {{0,0},{0,1},{of,0},{of,1}}; - glVertexPointer(2,GL_FLOAT,0,pointsA); - glDrawArrays(GL_TRIANGLE_STRIP,0,4); - - float pointsB[4][2] = {{of,0},{of,of},{texof,0},{texof,of}}; - glVertexPointer(2,GL_FLOAT,0,pointsB); - glDrawArrays(GL_TRIANGLE_STRIP,0,4); - - float pointsC[4][2] = {{texof,0},{texof,1},{1,0},{1,1}}; - glVertexPointer(2,GL_FLOAT,0,pointsC); - glDrawArrays(GL_TRIANGLE_STRIP,0,4); - - float pointsD[4][2] = {{of,1},{of,texof},{texof,1},{texof,texof}}; - glVertexPointer(2,GL_FLOAT,0,pointsD); - glDrawArrays(GL_TRIANGLE_STRIP,0,4); - - glColor4f(presetOutputs->ib_r, presetOutputs->ib_g, presetOutputs->ib_b, presetOutputs->ib_a); - - glRectd(of, of, of+iff, texof); - glRectd(of+iff, of, texof-iff, of+iff); - glRectd(texof-iff, of, texof, texof); - glRectd(of+iff, texof, texof-iff, texof-iff); - - float pointsE[4][2] = {{of,of},{of,texof},{of+iff,of},{of+iff,texof}}; - glVertexPointer(2,GL_FLOAT,0,pointsE); - glDrawArrays(GL_TRIANGLE_STRIP,0,4); - - float pointsF[4][2] = {{of+iff,of},{of+iff,of+iff},{texof-iff,of},{texof-iff,of+iff}}; - glVertexPointer(2,GL_FLOAT,0,pointsF); - glDrawArrays(GL_TRIANGLE_STRIP,0,4); - - float pointsG[4][2] = {{texof-iff,of},{texof-iff,texof},{texof,of},{texof,texof}}; - glVertexPointer(2,GL_FLOAT,0,pointsG); - glDrawArrays(GL_TRIANGLE_STRIP,0,4); - - float pointsH[4][2] = {{of+iff,texof},{of+iff,texof-iff},{texof-iff,texof},{texof-iff,texof-iff}}; - glVertexPointer(2,GL_FLOAT,0,pointsH); - glDrawArrays(GL_TRIANGLE_STRIP,0,4); - - - -} - - void Renderer::draw_title_to_texture() { diff --git a/src/projectM-engine/Renderer.hpp b/src/projectM-engine/Renderer.hpp index 4080a1ab1..651a50ace 100644 --- a/src/projectM-engine/Renderer.hpp +++ b/src/projectM-engine/Renderer.hpp @@ -76,7 +76,7 @@ public: void reset(int w, int h); GLuint initRenderToTexture(); void PerPixelMath(PresetOutputs *presetOutputs, PresetInputs *presetInputs); - void WaveformMath(PresetOutputs *presetOutputs, PresetInputs *presetInputs, bool isSmoothing); + void setPresetName(const std::string& theValue) { @@ -88,7 +88,6 @@ public: return m_presetName; } - private: RenderTarget *renderTarget; @@ -128,7 +127,8 @@ private: void checkForCgError(const char *situation); -void SetupCg(); + void SetupCg(); + void SetupCgVariables(CGprogram program, const PipelineContext &context); #endif #ifdef USE_FTGL @@ -165,8 +165,7 @@ void SetupCg(); void draw_title_to_screen(bool flip); void maximize_colors(); void draw_title_to_texture(); - void draw_motion_vectors(PresetOutputs *presetOutputs); - void draw_borders(PresetOutputs *presetOutputs); + void draw_shapes(PresetOutputs *presetOutputs); void draw_custom_waves(PresetOutputs *presetOutputs); diff --git a/src/projectM-engine/TextureManager.cpp b/src/projectM-engine/TextureManager.cpp index c7ab9a964..8811fb218 100644 --- a/src/projectM-engine/TextureManager.cpp +++ b/src/projectM-engine/TextureManager.cpp @@ -1,3 +1,20 @@ +#ifdef LINUX +#include +#endif +#ifdef WIN32 +#include "glew.h" +#endif +#ifdef __APPLE__ +#include +#endif + +#ifdef USE_DEVIL +#include +#else +#include "SOIL.h" +#endif + + #include "TextureManager.hpp" #include "CustomShape.hpp" #include "Common.hpp" @@ -11,20 +28,20 @@ TextureManager::TextureManager(const std::string _presetURL): presetURL(_presetU ilInit(); iluInit(); ilutInit(); -ilutRenderer(ILUT_OPENGL); +ilutRenderer(ILUT_OPENGL); #endif Preload(); } TextureManager::~TextureManager() -{ +{ Clear(); } void TextureManager::Preload() { - + #ifdef USE_DEVIL ILuint image; ilGenImages(1, &image); @@ -32,20 +49,20 @@ void TextureManager::Preload() ilLoadL(IL_TYPE_UNKNOWN,(ILvoid*) M_data, M_bytes); GLuint tex = ilutGLBindTexImage(); #else - GLuint tex = SOIL_load_OGL_texture_from_memory( + uint tex = SOIL_load_OGL_texture_from_memory( M_data, M_bytes, SOIL_LOAD_AUTO, SOIL_CREATE_NEW_ID, - - SOIL_FLAG_POWER_OF_TWO + + SOIL_FLAG_POWER_OF_TWO | SOIL_FLAG_MULTIPLY_ALPHA - | SOIL_FLAG_COMPRESS_TO_DXT + | SOIL_FLAG_COMPRESS_TO_DXT ); #endif - + textures["M.tga"]=tex; - + #ifdef USE_DEVIL ilLoadL(IL_TYPE_UNKNOWN,(ILvoid*) project_data,project_bytes); tex = ilutGLBindTexImage(); @@ -55,15 +72,15 @@ void TextureManager::Preload() project_bytes, SOIL_LOAD_AUTO, SOIL_CREATE_NEW_ID, - - SOIL_FLAG_POWER_OF_TWO + + SOIL_FLAG_POWER_OF_TWO | SOIL_FLAG_MULTIPLY_ALPHA - | SOIL_FLAG_COMPRESS_TO_DXT + | SOIL_FLAG_COMPRESS_TO_DXT ); #endif - + textures["project.tga"]=tex; - + #ifdef USE_DEVIL ilLoadL(IL_TYPE_UNKNOWN,(ILvoid*) headphones_data, headphones_bytes); tex = ilutGLBindTexImage(); @@ -73,19 +90,19 @@ void TextureManager::Preload() headphones_bytes, SOIL_LOAD_AUTO, SOIL_CREATE_NEW_ID, - - SOIL_FLAG_POWER_OF_TWO + + SOIL_FLAG_POWER_OF_TWO | SOIL_FLAG_MULTIPLY_ALPHA - | SOIL_FLAG_COMPRESS_TO_DXT + | SOIL_FLAG_COMPRESS_TO_DXT ); #endif - + textures["headphones.tga"]=tex; } void TextureManager::Clear() { - + for(std::map::const_iterator iter = textures.begin(); iter != textures.end(); iter++) { @@ -95,34 +112,34 @@ void TextureManager::Clear() } -void TextureManager::unloadTextures(const PresetOutputs::cshape_container &shapes) -{ +//void TextureManager::unloadTextures(const PresetOutputs::cshape_container &shapes) +//{ /* for (PresetOutputs::cshape_container::const_iterator pos = shapes.begin(); - pos != shapes.end(); ++pos) + pos != shapes.end(); ++pos) { if( (*pos)->enabled==1) { - + if ( (*pos)->textured) { std::string imageUrl = (*pos)->getImageUrl(); if (imageUrl != "") { std::string fullUrl = presetURL + "/" + imageUrl; - ReleaseTexture(LoadTexture(fullUrl.c_str())); + ReleaseTexture(LoadTexture(fullUrl.c_str())); } } } } */ -} +//} GLuint TextureManager::getTexture(const std::string imageURL) { - + if (textures.find(imageURL)!= textures.end()) { return textures[imageURL]; @@ -133,11 +150,11 @@ GLuint TextureManager::getTexture(const std::string imageURL) #ifdef USE_DEVIL GLuint tex = ilutGLLoadImage((char *)fullURL.c_str()); #else - GLuint tex = SOIL_load_OGL_texture( + uint tex = SOIL_load_OGL_texture( fullURL.c_str(), SOIL_LOAD_AUTO, SOIL_CREATE_NEW_ID, - + SOIL_FLAG_POWER_OF_TWO // SOIL_FLAG_MIPMAPS | SOIL_FLAG_MULTIPLY_ALPHA @@ -147,9 +164,9 @@ GLuint TextureManager::getTexture(const std::string imageURL) #endif textures[imageURL]=tex; return tex; - - } + + } } unsigned int TextureManager::getTextureMemorySize() diff --git a/src/projectM-engine/TextureManager.hpp b/src/projectM-engine/TextureManager.hpp index e42a153cd..81f7caf1d 100644 --- a/src/projectM-engine/TextureManager.hpp +++ b/src/projectM-engine/TextureManager.hpp @@ -1,24 +1,6 @@ #ifndef TextureManager_HPP #define TextureManager_HPP -#include "PresetFrameIO.hpp" -#ifdef LINUX -#include -#endif -#ifdef WIN32 -#include "glew.h" -#endif - -#ifdef __APPLE__ -#include -#endif - -#ifdef USE_DEVIL -#include -#else -#include "SOIL.h" -#endif - #include #include #include @@ -26,14 +8,14 @@ class TextureManager { std::string presetURL; - std::map textures; + std::map textures; public: ~TextureManager(); TextureManager(std::string _presetURL); - void unloadTextures(const PresetOutputs::cshape_container &shapes); + //void unloadTextures(const PresetOutputs::cshape_container &shapes); void Clear(); void Preload(); - GLuint getTexture(std::string imageUrl); + unsigned int getTexture(std::string imageUrl); unsigned int getTextureMemorySize(); }; diff --git a/src/projectM-engine/TimeKeeper.cpp b/src/projectM-engine/TimeKeeper.cpp index 912703731..a701516df 100644 --- a/src/projectM-engine/TimeKeeper.cpp +++ b/src/projectM-engine/TimeKeeper.cpp @@ -3,11 +3,29 @@ #else #endif /** !WIN32 */ #include +#ifdef LINUX +#include +#endif +#ifdef WIN32 +#include "glew.h" +#endif + +#ifdef __APPLE__ +#include +#endif + +#ifdef USE_DEVIL +#include +#else +#include "SOIL.h" +#endif + + #include "TimeKeeper.hpp" #include "RandomNumberGenerators.hpp" TimeKeeper::TimeKeeper(double presetDuration, double smoothDuration, double easterEgg) - { + { _smoothDuration = smoothDuration; _presetDuration = presetDuration; _easterEgg = easterEgg; @@ -55,10 +73,10 @@ TimeKeeper::TimeKeeper(double presetDuration, double smoothDuration, double east _presetFrameA = _presetFrameB; _presetDurationA = _presetDurationB; } - + bool TimeKeeper::CanHardCut() { - return ((_currentTime - _presetTimeA) > HARD_CUT_DELAY); + return ((_currentTime - _presetTimeA) > HARD_CUT_DELAY); } double TimeKeeper::SmoothRatio() @@ -73,7 +91,7 @@ TimeKeeper::TimeKeeper(double presetDuration, double smoothDuration, double east double TimeKeeper::GetRunningTime() { return _currentTime; - } + } double TimeKeeper::PresetProgressA() { diff --git a/src/projectM-engine/Waveform.cpp b/src/projectM-engine/Waveform.cpp index 570823d9a..8b4c3a265 100644 --- a/src/projectM-engine/Waveform.cpp +++ b/src/projectM-engine/Waveform.cpp @@ -5,6 +5,16 @@ * Author: pete */ +#ifdef LINUX +#include +#endif +#ifdef WIN32 +#include "glew.h" +#endif +#ifdef __APPLE__ +#include +#endif + #include "Waveform.hpp" #include @@ -56,16 +66,20 @@ void Waveform::Draw(RenderContext &context) //value2[x]*=mult; //std::iota(&pointContext[0],&pointContext[samples],0); - for(int x=0;x< samples;x++) - pointContext[x]=((float)x); - - std::transform(&pointContext[0],&pointContext[samples],&pointContext[0],std::bind2nd(std::divides(),samples-1)); - // printf("mid inner loop\n"); //std::transform(points.begin(),points.end(),pointContext.begin(),points.begin(),std::mem_fun(&Waveform::PerPoint)); + WaveformContext waveContext(samples, context.beatDetect); + for(int x=0;x< samples;x++) - points[x] = PerPoint(points[x],pointContext[x],*context.beatDetect); + { + waveContext.sample = x/(float)(samples - 1); + waveContext.sample_int = x; + waveContext.left = value1[x]; + waveContext.right = value2[x]; + + points[x] = PerPoint(points[x],waveContext); + } float colors[samples][4]; float p[samples][2]; diff --git a/src/projectM-engine/Waveform.hpp b/src/projectM-engine/Waveform.hpp index 0b51e74ba..b6aa4680d 100644 --- a/src/projectM-engine/Waveform.hpp +++ b/src/projectM-engine/Waveform.hpp @@ -24,6 +24,20 @@ public: ColoredPoint():x(0.5),y(0.5),r(1),g(1),b(1),a(1){}; }; +class WaveformContext +{ +public: + float sample; + int samples; + int sample_int; + float left; + float right; + BeatDetect *music; + + WaveformContext(int samples, BeatDetect *music):samples(samples),music(music){}; +}; + + class Waveform : public RenderItem { public: @@ -42,7 +56,7 @@ public: void Draw(RenderContext &context); private: - virtual ColoredPoint PerPoint(ColoredPoint p, const float sample, const BeatDetect &music)=0; + virtual ColoredPoint PerPoint(ColoredPoint p, const WaveformContext context)=0; std::vector points; std::vector pointContext; diff --git a/src/projectM-engine/projectM.cpp b/src/projectM-engine/projectM.cpp index 4d5a14d60..a34bc4b02 100755 --- a/src/projectM-engine/projectM.cpp +++ b/src/projectM-engine/projectM.cpp @@ -106,7 +106,7 @@ projectM::~projectM() _pcm = 0; } - + } DLLEXPORT unsigned projectM::initRenderToTexture() @@ -123,7 +123,7 @@ DLLEXPORT void projectM::projectM_resetTextures() DLLEXPORT projectM::projectM ( std::string config_file, int flags) : beatDetect ( 0 ), renderer ( 0 ), _pcm(0), m_presetPos(0), m_flags(flags) { - readConfig ( config_file ); + readConfig ( config_file ); projectM_reset(); projectM_resetGL ( _settings.windowWidth, _settings.windowHeight); @@ -131,9 +131,9 @@ DLLEXPORT projectM::projectM ( std::string config_file, int flags) : bool projectM::writeConfig(const std::string & configFile, const Settings & settings) { - + ConfigFile config ( configFile ); - + config.add("Mesh X", settings.meshX); config.add("Mesh Y", settings.meshY); config.add("Texture Size", settings.textureSize); @@ -149,8 +149,8 @@ bool projectM::writeConfig(const std::string & configFile, const Settings & sett config.add("Aspect Correction", settings.aspectCorrection); config.add("Easter Egg Parameter", settings.easterEgg); config.add("Shuffle Enabled", settings.shuffleEnabled); - - std::fstream file(configFile.c_str()); + + std::fstream file(configFile.c_str()); if (file) { file << config; return true; @@ -163,7 +163,7 @@ bool projectM::writeConfig(const std::string & configFile, const Settings & sett void projectM::readConfig (const std::string & configFile ) { std::cout << "configFile: " << configFile << std::endl; - + ConfigFile config ( configFile ); _settings.meshX = config.read ( "Mesh X", 32 ); _settings.meshY = config.read ( "Mesh Y", 24 ); @@ -171,70 +171,70 @@ void projectM::readConfig (const std::string & configFile ) _settings.fps = config.read ( "FPS", 35 ); _settings.windowWidth = config.read ( "Window Width", 512 ); _settings.windowHeight = config.read ( "Window Height", 512 ); - _settings.smoothPresetDuration = config.read + _settings.smoothPresetDuration = config.read ( "Smooth Preset Duration", config.read("Smooth Transition Duration", 10)); _settings.presetDuration = config.read ( "Preset Duration", 15 ); - + #ifdef LINUX _settings.presetURL = config.read ( "Preset Path", CMAKE_INSTALL_PREFIX "/share/projectM/presets" ); #endif - + #ifdef __APPLE__ /// @bug awful hardcoded hack- need to add intelligence to cmake wrt bundling - carm _settings.presetURL = config.read ( "Preset Path", "../Resources/presets" ); #endif - + #ifdef WIN32 _settings.presetURL = config.read ( "Preset Path", CMAKE_INSTALL_PREFIX "/share/projectM/presets" ); #endif - + #ifdef __APPLE__ - _settings.titleFontURL = config.read + _settings.titleFontURL = config.read ( "Title Font", "../Resources/fonts/Vera.tff"); - _settings.menuFontURL = config.read + _settings.menuFontURL = config.read ( "Menu Font", "../Resources/fonts/VeraMono.ttf"); #endif - + #ifdef LINUX - _settings.titleFontURL = config.read + _settings.titleFontURL = config.read ( "Title Font", CMAKE_INSTALL_PREFIX "/share/projectM/fonts/Vera.ttf" ); - _settings.menuFontURL = config.read - ( "Menu Font", CMAKE_INSTALL_PREFIX "/share/projectM/fonts/VeraMono.ttf" ); + _settings.menuFontURL = config.read + ( "Menu Font", CMAKE_INSTALL_PREFIX "/share/projectM/fonts/VeraMono.ttf" ); #endif - + #ifdef WIN32 - _settings.titleFontURL = config.read + _settings.titleFontURL = config.read ( "Title Font", CMAKE_INSTALL_PREFIX "/share/projectM/fonts/Vera.ttf" ); - _settings.menuFontURL = config.read - ( "Menu Font", CMAKE_INSTALL_PREFIX "/share/projectM/fonts/VeraMono.ttf" ); + _settings.menuFontURL = config.read + ( "Menu Font", CMAKE_INSTALL_PREFIX "/share/projectM/fonts/VeraMono.ttf" ); #endif - - + + _settings.shuffleEnabled = config.read ( "Shuffle Enabled", true); - + _settings.easterEgg = config.read ( "Easter Egg Parameter", 0.0); - - + + projectM_init ( _settings.meshX, _settings.meshY, _settings.fps, _settings.textureSize, _settings.windowWidth,_settings.windowHeight); - + _settings.beatSensitivity = beatDetect->beat_sensitivity = config.read ( "Hard Cut Sensitivity", 10.0 ); - + if ( config.read ( "Aspect Correction", true ) ) _settings.aspectCorrection = renderer->correction = true; - else + else _settings.aspectCorrection = renderer->correction = false; - + } #ifdef USE_THREADS static void *thread_callback(void *prjm) { projectM *p = (projectM *)prjm; - p->thread_func(prjm); -return NULL;} + p->thread_func(prjm); +return NULL;} void *projectM::thread_func(void *vptr_args) @@ -250,20 +250,19 @@ void *projectM::thread_func(void *vptr_args) return NULL; } evaluateSecondPreset(); - } + } } #endif void projectM::evaluateSecondPreset() -{ +{ setupPresetInputs(&m_activePreset2->presetInputs()); m_activePreset2->presetInputs().frame = timeKeeper->PresetFrameB(); m_activePreset2->presetInputs().progress= timeKeeper->PresetProgressB(); - + assert ( m_activePreset2.get() ); m_activePreset2->evaluateFrame(); renderer->PerPixelMath ( &m_activePreset2->presetOutputs(), &presetInputs2 ); - renderer->WaveformMath ( &m_activePreset2->presetOutputs(), &presetInputs2, true ); } void projectM::setupPresetInputs(PresetInputs *inputs) @@ -298,7 +297,7 @@ DLLEXPORT void projectM::renderFrame() m_activePreset->presetInputs().frame = timeKeeper->PresetFrameA(); m_activePreset->presetInputs().progress= timeKeeper->PresetProgressA(); - beatDetect->detectFromSamples(); + beatDetect->detectFromSamples(); //m_activePreset->evaluateFrame(); @@ -306,17 +305,17 @@ DLLEXPORT void projectM::renderFrame() { if ( timeKeeper->PresetProgressA()>=1.0 && !timeKeeper->IsSmoothing()) { - - timeKeeper->StartSmoothing(); + + timeKeeper->StartSmoothing(); // printf("Start Smooth\n"); // if(timeKeeper->IsSmoothing())printf("Confirmed\n"); - switchPreset(m_activePreset2, - &m_activePreset->presetInputs() == &presetInputs ? presetInputs2 : presetInputs, + switchPreset(m_activePreset2, + &m_activePreset->presetInputs() == &presetInputs ? presetInputs2 : presetInputs, &m_activePreset->presetOutputs() == &presetOutputs ? presetOutputs2 : presetOutputs); - + presetSwitchedEvent(false, **m_presetPos); } - + else if ( ( beatDetect->vol-beatDetect->vol_old>beatDetect->beat_sensitivity ) && timeKeeper->CanHardCut() ) { // printf("Hard Cut\n"); @@ -324,34 +323,33 @@ DLLEXPORT void projectM::renderFrame() timeKeeper->StartPreset(); presetSwitchedEvent(true, **m_presetPos); - } + } } if ( timeKeeper->IsSmoothing() && timeKeeper->SmoothRatio() <= 1.0 && !m_presetChooser->empty() ) { - + // printf("start thread\n"); - + assert ( m_activePreset.get() ); - + #ifdef USE_THREADS pthread_cond_signal(&condition); pthread_mutex_unlock( &mutex ); #endif m_activePreset->evaluateFrame(); renderer->PerPixelMath ( &m_activePreset->presetOutputs(), &presetInputs ); - renderer->WaveformMath ( &m_activePreset->presetOutputs(), &presetInputs, true ); #ifdef USE_THREADS pthread_mutex_lock( &mutex ); -#else +#else evaluateSecondPreset(); #endif - - - PresetMerger::MergePresets ( m_activePreset->presetOutputs(),m_activePreset2->presetOutputs(),timeKeeper->SmoothRatio(),presetInputs.gx, presetInputs.gy ); + + + PresetMerger::MergePresets ( m_activePreset->presetOutputs(),m_activePreset2->presetOutputs(),timeKeeper->SmoothRatio(),presetInputs.gx, presetInputs.gy ); } else @@ -359,15 +357,15 @@ DLLEXPORT void projectM::renderFrame() if ( timeKeeper->IsSmoothing() && timeKeeper->SmoothRatio() > 1.0 ) { //printf("End Smooth\n"); - m_activePreset = m_activePreset2; + m_activePreset = m_activePreset2; timeKeeper->EndSmoothing(); } //printf("Normal\n"); - + m_activePreset->evaluateFrame(); renderer->PerPixelMath ( &m_activePreset->presetOutputs(), &presetInputs ); - renderer->WaveformMath ( &m_activePreset->presetOutputs(), &presetInputs, false ); + } @@ -409,12 +407,12 @@ void projectM::projectM_reset() /** Default variable settings */ // this->wvw = 512; - // this->wvh = 512; + // this->wvh = 512; /** More other stuff */ this->mspf = 0; this->timed = 0; - this->timestart = 0; + this->timestart = 0; this->count = 0; this->fpsstart = 0; @@ -456,22 +454,22 @@ void projectM::projectM_init ( int gx, int gy, int fps, int texsize, int width, if ( presetInputs.fps > 0 ) mspf= ( int ) ( 1000.0/ ( float ) presetInputs.fps ); else mspf = 0; - + this->presetInputs.gx = gx; this->presetInputs.gy = gy; this->presetInputs2.gx = gx; this->presetInputs2.gy = gy; this->renderer = new Renderer ( width, height, gx, gy, texsize, beatDetect, settings().presetURL, settings().titleFontURL, settings().menuFontURL ); - + running = true; #ifdef USE_THREADS pthread_mutex_init(&mutex, NULL); pthread_cond_init(&condition, NULL); if (pthread_create(&thread, NULL, thread_callback, this) != 0) - { - + { + std::cerr << "failed to allocate a thread! try building with option USE_THREADS turned off" << std::endl;; exit(1); } @@ -503,41 +501,13 @@ void projectM::projectM_initengine() this->presetOutputs.decay=.98; - this->presetOutputs.wave_r= 1.0; - this->presetOutputs.wave_g= 0.2; - this->presetOutputs.wave_b= 0.0; - this->presetOutputs.wave_x= 0.5; - this->presetOutputs.wave_y= 0.5; - this->presetOutputs.wave_mystery= 0.0; - - this->presetOutputs.ob_size= 0.0; - this->presetOutputs.ob_r= 0.0; - this->presetOutputs.ob_g= 0.0; - this->presetOutputs.ob_b= 0.0; - this->presetOutputs.ob_a= 0.0; - - this->presetOutputs.ib_size = 0.0; - this->presetOutputs.ib_r = 0.0; - this->presetOutputs.ib_g = 0.0; - this->presetOutputs.ib_b = 0.0; - this->presetOutputs.ib_a = 0.0; - - this->presetOutputs.mv_a = 0.0; - this->presetOutputs.mv_r = 0.0; - this->presetOutputs.mv_g = 0.0; - this->presetOutputs.mv_b = 0.0; - this->presetOutputs.mv_l = 1.0; - this->presetOutputs.mv_x = 16.0; - this->presetOutputs.mv_y = 12.0; - this->presetOutputs.mv_dy = 0.02; - this->presetOutputs.mv_dx = 0.02; //this->presetInputs.meshx = 0; //this->presetInputs.meshy = 0; this->presetInputs.progress = 0; - this->presetInputs.frame = 1; + this->presetInputs.frame = 1; this->presetInputs2.progress = 0; this->presetInputs2.frame = 1; //bass_thresh = 0; @@ -549,12 +519,6 @@ void projectM::projectM_initengine() this->presetOutputs.fVideoEchoAlpha = 0; this->presetOutputs.nVideoEchoOrientation = 0; - this->presetOutputs.nWaveMode = 7; - this->presetOutputs.bAdditiveWaves = 0; - this->presetOutputs.bWaveDots = 0; - this->presetOutputs.bWaveThick = 0; - this->presetOutputs.bModWaveAlphaByVolume = 0; - this->presetOutputs.bMaximizeWaveColor = 0; this->presetOutputs.bTexWrap = 0; this->presetOutputs.bDarkenCenter = 0; this->presetOutputs.bRedBlueStereo = 0; @@ -564,22 +528,14 @@ void projectM::projectM_initengine() this->presetOutputs.bInvert = 0; this->presetOutputs.bMotionVectorsOn = 1; - this->presetOutputs.fWaveAlpha =1.0; - this->presetOutputs.fWaveScale = 1.0; - this->presetOutputs.fWaveSmoothing = 0; - this->presetOutputs.fWaveParam = 0; - this->presetOutputs.fModWaveAlphaStart = 0; - this->presetOutputs.fModWaveAlphaEnd = 0; this->presetOutputs.fWarpAnimSpeed = 0; this->presetOutputs.fWarpScale = 0; this->presetOutputs.fShader = 0; - /* PER_PIXEL CONSTANTS BEGIN */ /* PER_PIXEL CONSTANT END */ - /* Q AND T VARIABLES START */ this->presetOutputs.q1 = 0; @@ -614,34 +570,34 @@ void projectM::projectM_resetengine() this->presetOutputs.decay=.98; - this->presetOutputs.wave_r= 1.0; - this->presetOutputs.wave_g= 0.2; - this->presetOutputs.wave_b= 0.0; - this->presetOutputs.wave_x= 0.5; - this->presetOutputs.wave_y= 0.5; - this->presetOutputs.wave_mystery= 0.0; + this->presetOutputs.wave.r= 1.0; + this->presetOutputs.wave.g= 0.2; + this->presetOutputs.wave.b= 0.0; + this->presetOutputs.wave.x= 0.5; + this->presetOutputs.wave.y= 0.5; + this->presetOutputs.wave.mystery= 0.0; - this->presetOutputs.ob_size= 0.0; - this->presetOutputs.ob_r= 0.0; - this->presetOutputs.ob_g= 0.0; - this->presetOutputs.ob_b= 0.0; - this->presetOutputs.ob_a= 0.0; + this->presetOutputs.border.outer_size= 0.0; + this->presetOutputs.border.outer_r= 0.0; + this->presetOutputs.border.outer_g= 0.0; + this->presetOutputs.border.outer_b= 0.0; + this->presetOutputs.border.outer_a= 0.0; - this->presetOutputs.ib_size = 0.0; - this->presetOutputs.ib_r = 0.0; - this->presetOutputs.ib_g = 0.0; - this->presetOutputs.ib_b = 0.0; - this->presetOutputs.ib_a = 0.0; + this->presetOutputs.border.inner_size = 0.0; + this->presetOutputs.border.inner_r = 0.0; + this->presetOutputs.border.inner_g = 0.0; + this->presetOutputs.border.inner_b = 0.0; + this->presetOutputs.border.inner_a = 0.0; - this->presetOutputs.mv_a = 0.0; - this->presetOutputs.mv_r = 0.0; - this->presetOutputs.mv_g = 0.0; - this->presetOutputs.mv_b = 0.0; - this->presetOutputs.mv_l = 1.0; - this->presetOutputs.mv_x = 16.0; - this->presetOutputs.mv_y = 12.0; - this->presetOutputs.mv_dy = 0.02; - this->presetOutputs.mv_dx = 0.02; + this->presetOutputs.mv.a = 0.0; + this->presetOutputs.mv.r = 0.0; + this->presetOutputs.mv.g = 0.0; + this->presetOutputs.mv.b = 0.0; + this->presetOutputs.mv.length = 1.0; + this->presetOutputs.mv.x_num = 16.0; + this->presetOutputs.mv.y_num = 12.0; + this->presetOutputs.mv.x_offset = 0.02; + this->presetOutputs.mv.y_offset = 0.02; if ( beatDetect != NULL ) @@ -661,12 +617,11 @@ void projectM::projectM_resetengine() this->presetOutputs.fVideoEchoAlpha = 0; this->presetOutputs.nVideoEchoOrientation = 0; - this->presetOutputs.nWaveMode = 7; - this->presetOutputs.bAdditiveWaves = 0; - this->presetOutputs.bWaveDots = 0; - this->presetOutputs.bWaveThick = 0; - this->presetOutputs.bModWaveAlphaByVolume = 0; - this->presetOutputs.bMaximizeWaveColor = 0; + this->presetOutputs.wave.additive = false; + this->presetOutputs.wave.dots = false; + this->presetOutputs.wave.thick = false; + this->presetOutputs.wave.modulateAlphaByVolume = 0; + this->presetOutputs.wave.maximizeColors = 0; this->presetOutputs.bTexWrap = 0; this->presetOutputs.bDarkenCenter = 0; this->presetOutputs.bRedBlueStereo = 0; @@ -676,12 +631,12 @@ void projectM::projectM_resetengine() this->presetOutputs.bInvert = 0; this->presetOutputs.bMotionVectorsOn = 1; - this->presetOutputs.fWaveAlpha =1.0; - this->presetOutputs.fWaveScale = 1.0; - this->presetOutputs.fWaveSmoothing = 0; - this->presetOutputs.fWaveParam = 0; - this->presetOutputs.fModWaveAlphaStart = 0; - this->presetOutputs.fModWaveAlphaEnd = 0; + this->presetOutputs.wave.a =1.0; + this->presetOutputs.wave.scale = 1.0; + this->presetOutputs.wave.smoothing = 0; + this->presetOutputs.wave.mystery = 0; + this->presetOutputs.wave.modOpacityEnd = 0; + this->presetOutputs.wave.modOpacityStart = 0; this->presetOutputs.fWarpAnimSpeed = 0; this->presetOutputs.fWarpScale = 0; this->presetOutputs.fShader = 0; @@ -748,7 +703,7 @@ int projectM::initPresetTools() srand ( time ( NULL ) ); std::string url = (m_flags & FLAG_DISABLE_PLAYLIST_LOAD) ? std::string() : settings().presetURL; - + if ( ( m_presetLoader = new PresetLoader ( url) ) == 0 ) { m_presetLoader = 0; @@ -781,7 +736,7 @@ int projectM::initPresetTools() //std::cerr << "[projectM] Allocating idle preset..." << std::endl; m_activePreset = IdlePreset::allocate ( presetInputs, presetOutputs ); - // Case where no valid presets exist in directory. Could also mean + // Case where no valid presets exist in directory. Could also mean // playlist initialization was deferred //if ( m_presetChooser->empty() ) //{ @@ -825,16 +780,16 @@ void projectM::destroyPresetTools() /// @bug queuePreset case isn't handled void projectM::removePreset(unsigned int index) { - + unsigned int chooserIndex = **m_presetPos; m_presetLoader->removePreset(index); // Case: no more presets, set iterator to end - if (m_presetChooser->empty()) + if (m_presetChooser->empty()) *m_presetPos = m_presetChooser->end(); - + // Case: chooser index has become one less due to removal of an index below it else if (chooserIndex > index) { chooserIndex--; @@ -843,28 +798,28 @@ void projectM::removePreset(unsigned int index) { // Case: we have deleted the active preset position // Set iterator to end of chooser - else if (chooserIndex == index) { + else if (chooserIndex == index) { //*m_presetPos = m_presetChooser->begin(chooserIndex); std::cerr << "deleted active preset!"; *m_presetPos = m_presetChooser->end(); } - + } unsigned int projectM::addPresetURL ( const std::string & presetURL, const std::string & presetName, int rating ) -{ +{ bool restorePosition = false; - - if (*m_presetPos == m_presetChooser->end()) + + if (*m_presetPos == m_presetChooser->end()) restorePosition = true; - + int index = m_presetLoader->addPresetURL ( presetURL, presetName, rating); - + if (restorePosition) *m_presetPos = m_presetChooser->end(); - + return index; } @@ -892,7 +847,7 @@ void projectM::switchPreset(std::auto_ptr & targetPreset, PresetInputs & *m_presetPos = m_presetChooser->weightedRandom(); else m_presetChooser->nextPreset(*m_presetPos); - + targetPreset = m_presetPos->allocate( inputs, outputs ); // Set preset name here- event is not done because at the moment this function is oblivious to smooth/hard switches @@ -926,12 +881,12 @@ std::string projectM::getPresetName ( unsigned int index ) const return m_presetLoader->getPresetName(index); } -void projectM::clearPlaylist ( ) +void projectM::clearPlaylist ( ) { - + m_presetLoader->clear(); *m_presetPos = m_presetChooser->end(); - + } /// Sets preset iterator position to the passed in index @@ -940,20 +895,20 @@ void projectM::selectPresetPosition(unsigned int index) { } bool projectM::selectedPresetIndex(unsigned int & index) const { - + if (*m_presetPos == m_presetChooser->end()) return false; - + index = **m_presetPos; return true; } bool projectM::presetPositionValid() const { - + return (*m_presetPos != m_presetChooser->end()); -} - +} + unsigned int projectM::getPlaylistSize() const { return m_presetLoader->getNumPresets(); @@ -966,40 +921,40 @@ void projectM:: changePresetRating (unsigned int index, int rating) { void projectM::insertPresetURL(unsigned int index, const std::string & presetURL, const std::string & presetName, int rating) { bool atEndPosition = false; - + int newSelectedIndex; - - + + if (*m_presetPos == m_presetChooser->end()) // Case: preset not selected { - atEndPosition = true; + atEndPosition = true; } - + else if (**m_presetPos < index) // Case: inserting before selected preset { - newSelectedIndex = **m_presetPos; - } - - else if (**m_presetPos > index) // Case: inserting after selected preset + newSelectedIndex = **m_presetPos; + } + + else if (**m_presetPos > index) // Case: inserting after selected preset { newSelectedIndex++; - } - + } + else // Case: inserting at selected preset { newSelectedIndex++; } - + m_presetLoader->insertPresetURL (index, presetURL, presetName, rating); - + if (atEndPosition) *m_presetPos = m_presetChooser->end(); else *m_presetPos = m_presetChooser->begin(newSelectedIndex); - - + + } - +