mirror of
https://github.com/projectM-visualizer/projectm.git
synced 2026-02-04 17:05:39 +00:00
PJS: smoothing of waveforms == much better
git-svn-id: https://projectm.svn.sourceforge.net/svnroot/projectm/personal/carm/dev-1.0@332 6778bc44-b910-0410-a7a0-be141de4315d
This commit is contained in:
@ -138,7 +138,10 @@ public:
|
||||
|
||||
double wavearray_x[2048];
|
||||
double wavearray_y[2048];
|
||||
double wavearray2_x[2048];
|
||||
double wavearray2_y[2048];
|
||||
int wave_samples;
|
||||
bool two_waves;
|
||||
double wave_rot;
|
||||
double wave_scale;
|
||||
|
||||
|
||||
@ -9,10 +9,44 @@ void PresetMerger::MergePresets(PresetOutputs & A, PresetOutputs & B, double rat
|
||||
A.wave_rot = A.wave_rot* invratio + B.wave_rot*ratio;
|
||||
A.wave_scale = A.wave_scale* invratio + B.wave_scale*ratio;
|
||||
|
||||
for (int x = 0; x<A.wave_samples;x++)
|
||||
if (A.two_waves && B.two_waves)
|
||||
{
|
||||
A.wavearray_x[x] = A.wavearray_x[x]* invratio + B.wavearray_x[x]*ratio;
|
||||
A.wavearray_y[x] = A.wavearray_y[x]* invratio + B.wavearray_y[x]*ratio;
|
||||
for (int x = 0; x<A.wave_samples;x++)
|
||||
{
|
||||
A.wavearray_x[x] = A.wavearray_x[x]* invratio + B.wavearray_x[x]*ratio;
|
||||
A.wavearray_y[x] = A.wavearray_y[x]* invratio + B.wavearray_y[x]*ratio;
|
||||
A.wavearray2_x[x] = A.wavearray2_x[x]* invratio + B.wavearray2_x[x]*ratio;
|
||||
A.wavearray2_y[x] = A.wavearray2_y[x]* invratio + B.wavearray2_y[x]*ratio;
|
||||
}
|
||||
}
|
||||
else if (A.two_waves)
|
||||
{
|
||||
for (int x = 0; x<A.wave_samples;x++)
|
||||
{
|
||||
A.wavearray_x[x] = A.wavearray_x[x]* invratio + B.wavearray_x[x]*ratio;
|
||||
A.wavearray_y[x] = A.wavearray_y[x]* invratio + B.wavearray_y[x]*ratio;
|
||||
A.wavearray2_x[x] = A.wavearray2_x[x]* invratio + B.wavearray_x[x]*ratio;
|
||||
A.wavearray2_y[x] = A.wavearray2_y[x]* invratio + B.wavearray_y[x]*ratio;
|
||||
}
|
||||
}
|
||||
else if (B.two_waves)
|
||||
{
|
||||
A.two_waves=true;
|
||||
for (int x = 0; x<A.wave_samples;x++)
|
||||
{
|
||||
A.wavearray_x[x] = A.wavearray_x[x]* invratio + B.wavearray_x[x]*ratio;
|
||||
A.wavearray_y[x] = A.wavearray_y[x]* invratio + B.wavearray_y[x]*ratio;
|
||||
A.wavearray2_x[x] = A.wavearray_x[x]* invratio + B.wavearray_x[x]*ratio;
|
||||
A.wavearray2_y[x] = A.wavearray_y[x]* invratio + B.wavearray_y[x]*ratio;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int x = 0; x<A.wave_samples;x++)
|
||||
{
|
||||
A.wavearray_x[x] = A.wavearray_x[x]* invratio + B.wavearray_x[x]*ratio;
|
||||
A.wavearray_y[x] = A.wavearray_y[x]* invratio + B.wavearray_y[x]*ratio;
|
||||
}
|
||||
}
|
||||
|
||||
for (PresetOutputs::cshape_container::iterator pos = A.customShapes.begin();
|
||||
|
||||
@ -791,7 +791,7 @@ void Renderer::draw_shapes(PresetOutputs *presetOutputs) {
|
||||
}
|
||||
|
||||
|
||||
void Renderer::WaveformMath(PresetOutputs *presetOutputs, PresetInputs *presetInputs) {
|
||||
void Renderer::WaveformMath(PresetOutputs *presetOutputs, PresetInputs *presetInputs, bool isSmoothing) {
|
||||
|
||||
int x;
|
||||
|
||||
@ -811,6 +811,8 @@ void Renderer::WaveformMath(PresetOutputs *presetOutputs, PresetInputs *presetIn
|
||||
offset=presetOutputs->wave_x-.5;
|
||||
scale=505.0/512.0;
|
||||
|
||||
presetOutputs->two_waves = false;
|
||||
|
||||
DWRITE( "WaveformMath: %d\n", presetOutputs->nWaveMode );
|
||||
|
||||
switch(presetOutputs->nWaveMode)
|
||||
@ -827,8 +829,8 @@ void Renderer::WaveformMath(PresetOutputs *presetOutputs, PresetInputs *presetIn
|
||||
|
||||
DWRITE( "nsamples: %d\n", beatDetect->pcm->numsamples );
|
||||
|
||||
presetOutputs->wave_samples = beatDetect->pcm->numsamples;
|
||||
presetOutputs->wave_samples= 512-32;
|
||||
presetOutputs->wave_samples = isSmoothing ? 512-32 : beatDetect->pcm->numsamples;
|
||||
// presetOutputs->wave_samples= 512-32;
|
||||
for ( x=0;x<presetOutputs->wave_samples-1;x++)
|
||||
{ float inv_nverts_minus_one = 1.0f/(float)( presetOutputs->wave_samples);
|
||||
|
||||
@ -996,9 +998,9 @@ void Renderer::WaveformMath(PresetOutputs *presetOutputs, PresetInputs *presetIn
|
||||
// glScalef(1.0+wave_x_temp,1.0,1.0);
|
||||
// glTranslatef(-.5,-.5, 0);
|
||||
wave_x_temp=-1*(presetOutputs->wave_x-1.0);
|
||||
presetOutputs->wave_samples = beatDetect->pcm->numsamples;
|
||||
presetOutputs->wave_samples= 512-32;
|
||||
|
||||
//presetOutputs->wave_samples = beatDetect->pcm->numsamples;
|
||||
//presetOutputs->wave_samples= 512-32;
|
||||
presetOutputs->wave_samples = isSmoothing ? 512-32 : beatDetect->pcm->numsamples;
|
||||
|
||||
for ( x=0;x< presetOutputs->wave_samples;x++)
|
||||
{
|
||||
@ -1015,35 +1017,34 @@ void Renderer::WaveformMath(PresetOutputs *presetOutputs, PresetInputs *presetIn
|
||||
|
||||
case 7://dual waveforms
|
||||
|
||||
presetOutputs->wave_samples = beatDetect->pcm->numsamples;
|
||||
presetOutputs->wave_samples= 512-32;
|
||||
// presetOutputs->wave_samples = beatDetect->pcm->numsamples;
|
||||
//presetOutputs->wave_samples= 512-32;
|
||||
wave_x_temp=-2*0.4142*(fabs(fabs(presetOutputs->wave_mystery)-.5)-.5);
|
||||
// glTranslatef(.5,.5, 0);
|
||||
presetOutputs->wave_rot = -presetOutputs->wave_mystery*90;
|
||||
presetOutputs->wave_scale =1.0+wave_x_temp;
|
||||
// glRotated(-presetOutputs->wave_mystery*90,0,0,1);
|
||||
|
||||
|
||||
presetOutputs->wave_samples = isSmoothing ? 512-32 : beatDetect->pcm->numsamples;
|
||||
presetOutputs->two_waves = true;
|
||||
//glScalef(1.0+wave_x_temp,1.0,1.0);
|
||||
// glTranslatef(-.5,-.5, -1);
|
||||
|
||||
|
||||
wave_y_temp=-1*(presetOutputs->wave_x-1);
|
||||
|
||||
|
||||
|
||||
for ( x=0;x< presetOutputs->wave_samples *0.5 ;x++)
|
||||
wave_y_temp=-1*(presetOutputs->wave_x-1);
|
||||
|
||||
for ( x=0;x< presetOutputs->wave_samples ;x++)
|
||||
{
|
||||
presetOutputs->wavearray_x[x]=x/((float) presetOutputs->wave_samples*0.5);
|
||||
presetOutputs->wavearray_x[x]=x/((float) presetOutputs->wave_samples);
|
||||
presetOutputs->wavearray_y[x]= beatDetect->pcm->pcmdataL[x]*.04*presetOutputs->fWaveScale+(wave_y_temp+(presetOutputs->wave_y*presetOutputs->wave_y*.5));
|
||||
// glVertex2f(x/(float)beatDetect->pcm->numsamples, beatDetect->pcm->pcmdataL[x]*.04*presetOutputs->fWaveScale+(wave_y_temp+(presetOutputs->wave_y*presetOutputs->wave_y*.5)));
|
||||
}
|
||||
|
||||
for ( x=0;x< presetOutputs->wave_samples *0.5;x++)
|
||||
for ( x=0;x< presetOutputs->wave_samples;x++)
|
||||
{
|
||||
int index = presetOutputs->wave_samples*0.5 + x;
|
||||
presetOutputs->wavearray_x[index]=x/((float) presetOutputs->wave_samples*0.5);
|
||||
presetOutputs->wavearray_y[index]=beatDetect->pcm->pcmdataR[x]*.04*presetOutputs->fWaveScale+(wave_y_temp-(presetOutputs->wave_y*presetOutputs->wave_y*.5));
|
||||
|
||||
presetOutputs->wavearray2_x[x]=x/((float) presetOutputs->wave_samples);
|
||||
presetOutputs->wavearray2_y[x]=beatDetect->pcm->pcmdataR[x]*.04*presetOutputs->fWaveScale+(wave_y_temp-(presetOutputs->wave_y*presetOutputs->wave_y*.5));
|
||||
// glVertex2f(x/(float)beatDetect->pcm->numsamples, beatDetect->pcm->pcmdataR[x]*.04*presetOutputs->fWaveScale+(wave_y_temp-(presetOutputs->wave_y*presetOutputs->wave_y*.5)));
|
||||
}
|
||||
|
||||
|
||||
@ -66,7 +66,7 @@ char *title;
|
||||
void RenderFrame(PresetOutputs *presetOutputs, PresetInputs *presetInputs);
|
||||
void reset(int w, int h);
|
||||
void PerPixelMath(PresetOutputs *presetOutputs, PresetInputs *presetInputs);
|
||||
void WaveformMath(PresetOutputs *presetOutputs, PresetInputs *presetInputs);
|
||||
void WaveformMath(PresetOutputs *presetOutputs, PresetInputs *presetInputs, bool isSmoothing);
|
||||
|
||||
private:
|
||||
void draw_waveform(PresetOutputs * presetOutputs);
|
||||
|
||||
@ -173,14 +173,14 @@ DLLEXPORT void projectM::renderFrame()
|
||||
assert(m_activePreset.get());
|
||||
m_activePreset->evaluateFrame();
|
||||
renderer->PerPixelMath(&m_activePreset->presetOutputs(), &presetInputs);
|
||||
renderer->WaveformMath(&m_activePreset->presetOutputs(), &presetInputs);
|
||||
renderer->WaveformMath(&m_activePreset->presetOutputs(), &presetInputs, true);
|
||||
|
||||
presetInputs.frame = frame;
|
||||
presetInputs.progress= frame /(float) avgtime;
|
||||
assert(m_activePreset2.get());
|
||||
m_activePreset2->evaluateFrame();
|
||||
renderer->PerPixelMath(&m_activePreset2->presetOutputs(), &presetInputs);
|
||||
renderer->WaveformMath(&m_activePreset2->presetOutputs(), &presetInputs);
|
||||
renderer->WaveformMath(&m_activePreset2->presetOutputs(), &presetInputs, true);
|
||||
|
||||
double ratio = smoothFrame / (presetInputs.fps * smoothTime);
|
||||
|
||||
@ -205,7 +205,7 @@ DLLEXPORT void projectM::renderFrame()
|
||||
m_activePreset->evaluateFrame();
|
||||
|
||||
renderer->PerPixelMath(&m_activePreset->presetOutputs(), &presetInputs);
|
||||
renderer->WaveformMath(&m_activePreset->presetOutputs(), &presetInputs);
|
||||
renderer->WaveformMath(&m_activePreset->presetOutputs(), &presetInputs, false);
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user